From f93df74624b9b8bdd378dac274d6eded288a129f Mon Sep 17 00:00:00 2001 From: "SND\\kernelnet_cp" Date: Fri, 23 Dec 2011 13:07:25 +0000 Subject: [PATCH] [0.1.x] added : rdmsr routine [0.1.x] added : wrmsr routine git-svn-id: https://pykd.svn.codeplex.com/svn@72655 9b283d60-5439-405e-af05-b73fd8c4d996 --- pykd/dbgclient.cpp | 35 +++++++++++++++++++++++++++++++++++ pykd/dbgclient.h | 8 ++++++++ pykd/dbgext.cpp | 8 ++++++++ test/scripts/basetest.py | 4 ++-- 4 files changed, 53 insertions(+), 2 deletions(-) diff --git a/pykd/dbgclient.cpp b/pykd/dbgclient.cpp index fad59df..dc5cfdb 100644 --- a/pykd/dbgclient.cpp +++ b/pykd/dbgclient.cpp @@ -179,6 +179,25 @@ void loadDump( const std::wstring &fileName ) { /////////////////////////////////////////////////////////////////////////////////// +ULONG64 DebugClient::loadMSR( ULONG msr ) +{ + HRESULT hres; + ULONG64 value; + + hres = m_dataSpaces->ReadMsr( msr, &value ); + if ( FAILED( hres ) ) + throw DbgException( "IDebugDataSpaces::ReadMsr failed" ); + + return value; +} + +ULONG64 loadMSR( ULONG msr ) +{ + return g_dbgClient->loadMSR( msr ); +} + +/////////////////////////////////////////////////////////////////////////////////// + void DebugClient::startProcess( const std::wstring &processName ) { HRESULT hres; @@ -351,6 +370,22 @@ void setExecutionStatus( ULONG status ) /////////////////////////////////////////////////////////////////////////////////// +void DebugClient::setMSR( ULONG msr, ULONG64 value) +{ + HRESULT hres; + + hres = m_dataSpaces->WriteMsr(msr, value); + if ( FAILED( hres ) ) + throw DbgException( "IDebugDataSpaces::WriteMsr failed" ); +} + +void setMSR( ULONG msr, ULONG64 value) +{ + g_dbgClient->setMSR( msr, value ); +} + +/////////////////////////////////////////////////////////////////////////////////// + void DebugClient::waitForEvent() { HRESULT hres; diff --git a/pykd/dbgclient.h b/pykd/dbgclient.h index cdd08d3..16ca1c0 100644 --- a/pykd/dbgclient.h +++ b/pykd/dbgclient.h @@ -162,6 +162,8 @@ public: python::list loadPtrArray( ULONG64 address, ULONG number ); + ULONG64 loadMSR( ULONG msr ); + ULONG ptrSize(); ULONG64 ptrByte( ULONG64 offset ); @@ -185,6 +187,8 @@ public: LONG64 ptrSignMWord( ULONG64 offset ); ULONG64 ptrPtr( ULONG64 offset ); + + void setMSR( ULONG msr, ULONG64 value); python::object getRegByName( const std::wstring ®Name ); @@ -300,10 +304,14 @@ bool isKernelDebugging(); bool isDumpAnalyzing(); +ULONG64 loadMSR( ULONG msr ); + ULONG ptrSize(); void setExecutionStatus( ULONG status ); +void setMSR( ULONG msr, ULONG64 value); + void terminateProcess(); void waitForEvent(); diff --git a/pykd/dbgext.cpp b/pykd/dbgext.cpp index 47298a5..a3dfaa8 100644 --- a/pykd/dbgext.cpp +++ b/pykd/dbgext.cpp @@ -255,12 +255,16 @@ BOOST_PYTHON_MODULE( pykd ) "Print out string and insert end of line symbol. If dml = True string is printed with dml highlighting ( only for windbg )" ) .def( "ptrSize", &DebugClient::ptrSize, "Return effective pointer size" ) + .def ( "rdmsr", &DebugClient::loadMSR, + "Return MSR value" ) .def( "reg", &DebugClient::getRegByName, "Return a CPU regsiter value by the register's name" ) .def( "reg", &DebugClient::getRegByIndex, "Return a CPU regsiter value by the register's value" ) .def( "setExecutionStatus", &DebugClient::setExecutionStatus, "Requests that the debugger engine enter an executable state" ) + .def( "wrmsr", &DebugClient::setMSR, + "Set MSR value" ) .def( "step", &DebugClient::changeDebuggerStatus, "Change debugger status to DEBUG_STATUS_STEP_OVER" ) .def( "trace", &DebugClient::changeDebuggerStatus, @@ -410,6 +414,8 @@ BOOST_PYTHON_MODULE( pykd ) "Print out string and insert end of line symbol. If dml = True string is printed with dml highlighting ( only for windbg )" ) ); python::def( "ptrSize", &ptrSize, "Return effective pointer size" ); + python::def ( "rdmsr", &DebugClient::loadMSR, + "Return MSR value" ); python::def( "reg", &getRegByName, "Return a CPU regsiter value by the register's name" ); python::def( "reg", &getRegByIndex, @@ -418,6 +424,8 @@ BOOST_PYTHON_MODULE( pykd ) "Requests that the debugger engine enter an executable state" ); python::def( "step", &pykd::changeDebuggerStatus, "Change debugger status to DEBUG_STATUS_STEP_OVER" ); + python::def( "wrmsr", &setMSR, + "Set MSR value" ); python::def( "trace", &pykd::changeDebuggerStatus, "Change debugger status to DEBUG_STATUS_STEP_INTO" ); python::def( "waitForEvent", &pykd::waitForEvent, diff --git a/test/scripts/basetest.py b/test/scripts/basetest.py index 0788fac..ebd75e9 100644 --- a/test/scripts/basetest.py +++ b/test/scripts/basetest.py @@ -114,11 +114,11 @@ class BaseTest( unittest.TestCase ): def testNewAddededApi( self ): """ Branch test: new API 0.1.x what must be available """ self.assertTrue( hasattr(pykd, 'createDbgClient') ) - self.asseerTrue( hasattr(pykd, 'detachProcess') ) + self.assertTrue( hasattr(pykd, 'detachProcess') ) self.assertTrue( hasattr(pykd, 'diaLoadPdb') ) self.assertTrue( hasattr(pykd, 'getDebuggeeType' ) ) self.assertTrue( hasattr(pykd, 'getExecutionStatus' ) ) - self.asseerTrue( hasattr(pykd, 'killProcess') ) + self.assertTrue( hasattr(pykd, 'killProcess') ) self.assertTrue( hasattr(pykd, 'loadExt') ) self.assertTrue( hasattr(pykd, 'loadPtrList') ) self.assertTrue( hasattr(pykd, 'loadPtrArray') )