[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:
SND\EreTIk_cp 2013-05-01 11:27:29 +00:00 committed by Mikhail I. Izmestev
parent 77bd01b21f
commit ca4d73e776
6 changed files with 104 additions and 2 deletions

View File

@ -38,6 +38,19 @@ ULONG getPageSize();
ULONG getSystemUptime(); ULONG getSystemUptime();
ULONG getCurrentTime(); ULONG getCurrentTime();
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 // manage debug module
ULONG64 findModuleBase( const std::string &moduleName ); ULONG64 findModuleBase( const std::string &moduleName );
ULONG64 findModuleBase( ULONG64 offset ); ULONG64 findModuleBase( ULONG64 offset );
@ -163,7 +176,6 @@ ULONG breakPointSet( ULONG64 offset, bool hardware = false, ULONG size = 0, ULON
void breakPointRemove( ULONG id ); void breakPointRemove( ULONG id );
void breakPointRemoveAll(); void breakPointRemoveAll();
// processes end threads // processes end threads
ULONG64 getCurrentProcess(); ULONG64 getCurrentProcess();
ULONG getCurrentProcessId(); ULONG getCurrentProcessId();

View File

@ -145,6 +145,8 @@ BOOST_PYTHON_MODULE( pykd )
"Return the number of seconds the computer has been running" ); "Return the number of seconds the computer has been running" );
python::def( "currentTime", &getCurrentTime, python::def( "currentTime", &getCurrentTime,
"Return the number of seconds since the beginning of 1970" ); "Return the number of seconds since the beginning of 1970" );
python::def("getSystemVersion", &getSystemVersion,
"Return systemVersion");
// Manage target memory access // Manage target memory access
python::def( "addr64", &addr64, python::def( "addr64", &addr64,
@ -531,6 +533,26 @@ BOOST_PYTHON_MODULE( pykd )
.def( "__str__", &StackFrame::print, .def( "__str__", &StackFrame::print,
"Return stacks frame as a string"); "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 >( python::class_< ExceptionInfo, ExceptionInfoPtr, boost::noncopyable >(
"exceptionInfo", "Exception information", python::no_init ) "exceptionInfo", "Exception information", python::no_init )
.def_readonly( "FirstChance", &ExceptionInfo::FirstChance, .def_readonly( "FirstChance", &ExceptionInfo::FirstChance,
@ -548,6 +570,8 @@ BOOST_PYTHON_MODULE( pykd )
.def( "__str__", &ExceptionInfo::print, .def( "__str__", &ExceptionInfo::print,
"Return object as a string"); "Return object as a string");
python::enum_<EVENT_TYPE>("eventType", "Type of debug event") python::enum_<EVENT_TYPE>("eventType", "Type of debug event")
.value("Breakpoint", EventTypeBreakpoint) .value("Breakpoint", EventTypeBreakpoint)
.value("Exception", EventTypeException) .value("Exception", EventTypeException)

View File

@ -53,6 +53,21 @@ python::tuple moduleFindSymbolAndDisp( pykd::Module &module, ULONG64 offset )
return python::make_tuple(symbolName,displacement); 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();
}
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////

View File

@ -3,6 +3,7 @@
#include <boost/python/list.hpp> #include <boost/python/list.hpp>
#include "module.h" #include "module.h"
#include "dbgengine.h"
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
@ -17,6 +18,8 @@ python::tuple findSymbolAndDisp( ULONG64 offset );
python::tuple moduleFindSymbolAndDisp( pykd::Module &module, ULONG64 offset ); python::tuple moduleFindSymbolAndDisp( pykd::Module &module, ULONG64 offset );
std::string printSystemVersion(SystemVersionPtr sysVer);
} } //pykd::support namespace end } } //pykd::support namespace end
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////

View File

@ -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 ) ULONG64 loadMSR( ULONG msr )
{ {
PyThread_StateRestore pyThreadRestore( g_dbgEng->pystate ); PyThread_StateRestore pyThreadRestore( g_dbgEng->pystate );

View File

@ -31,6 +31,7 @@ class StartProcessWithoutParamsTest(unittest.TestCase):
target.processId = pykd.startProcess( target.appPath ) target.processId = pykd.startProcess( target.appPath )
target.module = pykd.module( target.moduleName ) target.module = pykd.module( target.moduleName )
target.module.reload(); target.module.reload();
print "\n" + str( pykd.getSystemVersion() )
pykd.go() pykd.go()
class TerminateProcessTest(unittest.TestCase): class TerminateProcessTest(unittest.TestCase):