mirror of
https://github.com/ivellioscolin/pykd.git
synced 2025-04-21 04:13:22 +08:00
[0.2.x] + target system version
git-svn-id: https://pykd.svn.codeplex.com/svn@83540 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
parent
77bd01b21f
commit
ca4d73e776
@ -38,7 +38,20 @@ ULONG getPageSize();
|
||||
ULONG getSystemUptime();
|
||||
ULONG getCurrentTime();
|
||||
|
||||
//manage debug module
|
||||
struct SystemVersion {
|
||||
ULONG platformId;
|
||||
ULONG win32Major;
|
||||
ULONG win32Minor;
|
||||
ULONG buildNumber;
|
||||
std::string buildString;
|
||||
std::string servicePackString;
|
||||
bool isCheckedBuild;
|
||||
};
|
||||
typedef boost::shared_ptr< SystemVersion > SystemVersionPtr;
|
||||
|
||||
SystemVersionPtr getSystemVersion();
|
||||
|
||||
// manage debug module
|
||||
ULONG64 findModuleBase( const std::string &moduleName );
|
||||
ULONG64 findModuleBase( ULONG64 offset );
|
||||
ULONG64 findModuleBySymbol( const std::string &symbolName );
|
||||
@ -163,7 +176,6 @@ ULONG breakPointSet( ULONG64 offset, bool hardware = false, ULONG size = 0, ULON
|
||||
void breakPointRemove( ULONG id );
|
||||
void breakPointRemoveAll();
|
||||
|
||||
|
||||
// processes end threads
|
||||
ULONG64 getCurrentProcess();
|
||||
ULONG getCurrentProcessId();
|
||||
|
@ -145,6 +145,8 @@ BOOST_PYTHON_MODULE( pykd )
|
||||
"Return the number of seconds the computer has been running" );
|
||||
python::def( "currentTime", &getCurrentTime,
|
||||
"Return the number of seconds since the beginning of 1970" );
|
||||
python::def("getSystemVersion", &getSystemVersion,
|
||||
"Return systemVersion");
|
||||
|
||||
// Manage target memory access
|
||||
python::def( "addr64", &addr64,
|
||||
@ -531,6 +533,26 @@ BOOST_PYTHON_MODULE( pykd )
|
||||
.def( "__str__", &StackFrame::print,
|
||||
"Return stacks frame as a string");
|
||||
|
||||
python::class_< SystemVersion, SystemVersionPtr, boost::noncopyable >(
|
||||
"systemVersion", "Operation system version", python::no_init)
|
||||
.def_readonly( "platformId", &SystemVersion::platformId,
|
||||
"Platform ID: VER_PLATFORM_WIN32_NT for NT-based Windows")
|
||||
.def_readonly( "win32Major", &SystemVersion::win32Major,
|
||||
"Major version number of the target's operating system")
|
||||
.def_readonly( "win32Minor", &SystemVersion::win32Minor,
|
||||
"Minor version number of the target's operating system")
|
||||
.def_readonly( "buildNumber", &SystemVersion::buildNumber,
|
||||
"Build number for the target's operating system")
|
||||
.def_readonly( "buildString", &SystemVersion::buildString,
|
||||
"String that identifies the build of the system")
|
||||
.def_readonly( "servicePackString", &SystemVersion::servicePackString,
|
||||
"String for the service pack level of the target computer")
|
||||
.def_readonly( "isCheckedBuild", &SystemVersion::isCheckedBuild,
|
||||
"Checked build flag")
|
||||
.def("__str__", pysupport::printSystemVersion,
|
||||
"Return object as a string");
|
||||
|
||||
|
||||
python::class_< ExceptionInfo, ExceptionInfoPtr, boost::noncopyable >(
|
||||
"exceptionInfo", "Exception information", python::no_init )
|
||||
.def_readonly( "FirstChance", &ExceptionInfo::FirstChance,
|
||||
@ -548,6 +570,8 @@ BOOST_PYTHON_MODULE( pykd )
|
||||
.def( "__str__", &ExceptionInfo::print,
|
||||
"Return object as a string");
|
||||
|
||||
|
||||
|
||||
python::enum_<EVENT_TYPE>("eventType", "Type of debug event")
|
||||
.value("Breakpoint", EventTypeBreakpoint)
|
||||
.value("Exception", EventTypeException)
|
||||
|
@ -53,6 +53,21 @@ python::tuple moduleFindSymbolAndDisp( pykd::Module &module, ULONG64 offset )
|
||||
return python::make_tuple(symbolName,displacement);
|
||||
}
|
||||
|
||||
std::string printSystemVersion(SystemVersionPtr sysVer)
|
||||
{
|
||||
std::stringstream sstream;
|
||||
if (VER_PLATFORM_WIN32_NT == sysVer->platformId)
|
||||
sstream << "WIN32_NT";
|
||||
else
|
||||
sstream << "Platform ID: " << std::dec << sysVer->platformId;
|
||||
sstream << " " << std::dec << sysVer->win32Major << "." << sysVer->win32Minor;
|
||||
sstream << ", " << (sysVer->isCheckedBuild ? "checked" : "free") << " build: ";
|
||||
sstream << std::dec << sysVer->buildNumber << ", " << sysVer->buildString;
|
||||
if (!sysVer->servicePackString.empty())
|
||||
sstream << " (" << sysVer->servicePackString << ")";
|
||||
|
||||
return sstream.str();
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include <boost/python/list.hpp>
|
||||
|
||||
#include "module.h"
|
||||
#include "dbgengine.h"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ -17,6 +18,8 @@ python::tuple findSymbolAndDisp( ULONG64 offset );
|
||||
|
||||
python::tuple moduleFindSymbolAndDisp( pykd::Module &module, ULONG64 offset );
|
||||
|
||||
std::string printSystemVersion(SystemVersionPtr sysVer);
|
||||
|
||||
} } //pykd::support namespace end
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -339,6 +339,53 @@ ULONG getCurrentTime()
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
SystemVersionPtr getSystemVersion()
|
||||
{
|
||||
SystemVersionPtr sysVer( new SystemVersion );
|
||||
ULONG kdMajor;
|
||||
|
||||
boost::scoped_array< CHAR > arrSpString( new CHAR[MAX_PATH + 1] );
|
||||
memset(&arrSpString[0], 0, MAX_PATH + 1);
|
||||
|
||||
boost::scoped_array< CHAR > arrBuildString( new CHAR[MAX_PATH + 1] );
|
||||
memset(&arrBuildString[0], 0, MAX_PATH + 1);
|
||||
|
||||
ULONG tmp;
|
||||
|
||||
HRESULT hres =
|
||||
g_dbgEng->control->GetSystemVersion(
|
||||
&sysVer->platformId,
|
||||
&kdMajor,
|
||||
&sysVer->buildNumber,
|
||||
&arrSpString[0],
|
||||
MAX_PATH,
|
||||
&tmp,
|
||||
&tmp,
|
||||
&arrBuildString[0],
|
||||
MAX_PATH,
|
||||
&tmp);
|
||||
if (S_OK != hres)
|
||||
throw DbgException("IDebugControl::GetSystemVersion", hres);
|
||||
|
||||
sysVer->buildString = &arrBuildString[0];
|
||||
sysVer->servicePackString = &arrSpString[0];
|
||||
sysVer->isCheckedBuild = 0xC == kdMajor;
|
||||
|
||||
hres =
|
||||
g_dbgEng->control->GetSystemVersionValues(
|
||||
&sysVer->platformId,
|
||||
&sysVer->win32Major,
|
||||
&sysVer->win32Minor,
|
||||
NULL,
|
||||
NULL);
|
||||
if (S_OK != hres)
|
||||
throw DbgException("IDebugControl::GetSystemVersionValues", hres);
|
||||
|
||||
return sysVer;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
ULONG64 loadMSR( ULONG msr )
|
||||
{
|
||||
PyThread_StateRestore pyThreadRestore( g_dbgEng->pystate );
|
||||
|
@ -31,6 +31,7 @@ class StartProcessWithoutParamsTest(unittest.TestCase):
|
||||
target.processId = pykd.startProcess( target.appPath )
|
||||
target.module = pykd.module( target.moduleName )
|
||||
target.module.reload();
|
||||
print "\n" + str( pykd.getSystemVersion() )
|
||||
pykd.go()
|
||||
|
||||
class TerminateProcessTest(unittest.TestCase):
|
||||
|
Loading…
Reference in New Issue
Block a user