mirror of
https://github.com/ivellioscolin/pykd.git
synced 2025-04-21 21:03:23 +08:00
[0.1.x] added : reg routine
[0.1.x] removed : cpuReg class git-svn-id: https://pykd.svn.codeplex.com/svn@71752 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
parent
07f0d3a0fb
commit
2e787e1b57
@ -13,6 +13,7 @@
|
|||||||
#include "dbgcmd.h"
|
#include "dbgcmd.h"
|
||||||
#include "pyaux.h"
|
#include "pyaux.h"
|
||||||
#include "disasm.h"
|
#include "disasm.h"
|
||||||
|
#include "cpureg.h"
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
@ -149,6 +150,10 @@ public:
|
|||||||
|
|
||||||
void readMemory( ULONG64 address, PVOID buffer, ULONG length, bool phyAddr = FALSE );
|
void readMemory( ULONG64 address, PVOID buffer, ULONG length, bool phyAddr = FALSE );
|
||||||
|
|
||||||
|
python::object getRegByName( const std::wstring ®Name );
|
||||||
|
|
||||||
|
python::object getRegByIndex( ULONG index );
|
||||||
|
|
||||||
void setExecutionStatus( ULONG status );
|
void setExecutionStatus( ULONG status );
|
||||||
|
|
||||||
void waitForEvent();
|
void waitForEvent();
|
||||||
|
@ -57,7 +57,7 @@ std::string
|
|||||||
getDebuggerImage()
|
getDebuggerImage()
|
||||||
{
|
{
|
||||||
std::vector<char> buffer(MAX_PATH);
|
std::vector<char> buffer(MAX_PATH);
|
||||||
GetModuleFileNameExA( GetCurrentProcess(), NULL, &buffer[0], buffer.size() );
|
GetModuleFileNameExA( GetCurrentProcess(), NULL, &buffer[0], (DWORD)buffer.size() );
|
||||||
return std::string( &buffer[0] );
|
return std::string( &buffer[0] );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -213,6 +213,10 @@ 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 )" )
|
"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,
|
.def( "ptrSize", &DebugClient::ptrSize,
|
||||||
"Return effective pointer size" )
|
"Return effective pointer size" )
|
||||||
|
.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", &pykd::DebugClient::setExecutionStatus,
|
.def( "setExecutionStatus", &pykd::DebugClient::setExecutionStatus,
|
||||||
"Requests that the debugger engine enter an executable state" )
|
"Requests that the debugger engine enter an executable state" )
|
||||||
.def( "step", &pykd::DebugClient::changeDebuggerStatus<DEBUG_STATUS_STEP_OVER>,
|
.def( "step", &pykd::DebugClient::changeDebuggerStatus<DEBUG_STATUS_STEP_OVER>,
|
||||||
@ -252,6 +256,8 @@ BOOST_PYTHON_MODULE( pykd )
|
|||||||
"Check if it is a dump analyzing ( not living debuggee )" );
|
"Check if it is a dump analyzing ( not living debuggee )" );
|
||||||
python::def( "isKernelDebugging", &isKernelDebugging,
|
python::def( "isKernelDebugging", &isKernelDebugging,
|
||||||
"Check if kernel dubugging is running" );
|
"Check if kernel dubugging is running" );
|
||||||
|
python::def( "isWindbgExt", &WindbgGlobalSession::isInit,
|
||||||
|
"Check if script works in windbg context" );
|
||||||
python::def( "loadBytes", &loadBytes, loadBytes_( python::args( "offset", "count", "phyAddr" ),
|
python::def( "loadBytes", &loadBytes, loadBytes_( python::args( "offset", "count", "phyAddr" ),
|
||||||
"Read the block of the target's memory and return it as liat of unsigned bytes" ) );
|
"Read the block of the target's memory and return it as liat of unsigned bytes" ) );
|
||||||
python::def( "loadWords", &loadWords, loadWords_( python::args( "offset", "count", "phyAddr" ),
|
python::def( "loadWords", &loadWords, loadWords_( python::args( "offset", "count", "phyAddr" ),
|
||||||
@ -308,6 +314,10 @@ 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 )" ) );
|
"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,
|
python::def( "ptrSize", &ptrSize,
|
||||||
"Return effective pointer size" );
|
"Return effective pointer size" );
|
||||||
|
python::def( "reg", &getRegByName,
|
||||||
|
"Return a CPU regsiter value by the register's name" );
|
||||||
|
python::def( "reg", &getRegByIndex,
|
||||||
|
"Return a CPU regsiter value by the register's value" );
|
||||||
python::def( "setExecutionStatus", &pykd::setExecutionStatus,
|
python::def( "setExecutionStatus", &pykd::setExecutionStatus,
|
||||||
"Requests that the debugger engine enter an executable state" );
|
"Requests that the debugger engine enter an executable state" );
|
||||||
python::def( "step", &pykd::changeDebuggerStatus<DEBUG_STATUS_STEP_OVER>,
|
python::def( "step", &pykd::changeDebuggerStatus<DEBUG_STATUS_STEP_OVER>,
|
||||||
|
@ -36,7 +36,7 @@ protected:
|
|||||||
if ( FAILED( hres ) )
|
if ( FAILED( hres ) )
|
||||||
throw DbgException("QueryInterface IDebugDataSpaces failed");
|
throw DbgException("QueryInterface IDebugDataSpaces failed");
|
||||||
|
|
||||||
hres = client->QueryInterface( __uuidof(IDebugRegisters), (void**)&m_registers );
|
hres = client->QueryInterface( __uuidof(IDebugRegisters2), (void**)&m_registers );
|
||||||
if ( FAILED( hres ) )
|
if ( FAILED( hres ) )
|
||||||
throw DbgException("QueryInterface IDebugDataSpaces failed");
|
throw DbgException("QueryInterface IDebugDataSpaces failed");
|
||||||
}
|
}
|
||||||
@ -49,7 +49,7 @@ protected:
|
|||||||
CComPtr<IDebugSymbols3> m_symbols;
|
CComPtr<IDebugSymbols3> m_symbols;
|
||||||
CComPtr<IDebugAdvanced2> m_advanced;
|
CComPtr<IDebugAdvanced2> m_advanced;
|
||||||
CComPtr<IDebugDataSpaces> m_dataSpaces;
|
CComPtr<IDebugDataSpaces> m_dataSpaces;
|
||||||
CComPtr<IDebugRegisters> m_registers;
|
CComPtr<IDebugRegisters2> m_registers;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
184
pykd/module.h
184
pykd/module.h
@ -98,187 +98,3 @@ Module loadModuleByOffset( ULONG64 offset );
|
|||||||
}; // end pykd namespace
|
}; // end pykd namespace
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//#include <string>
|
|
||||||
//#include <map>
|
|
||||||
//
|
|
||||||
//#include "dbgext.h"
|
|
||||||
//#include "dbgmem.h"
|
|
||||||
//
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
//// global unique module data
|
|
||||||
//// WARNING: add only numeric field or change operator <
|
|
||||||
//struct ModuleInfo
|
|
||||||
//{
|
|
||||||
// ULONG64 m_base;
|
|
||||||
// ULONG m_timeDataStamp;
|
|
||||||
// ULONG m_checkSumm;
|
|
||||||
//
|
|
||||||
// ModuleInfo()
|
|
||||||
// : m_base(0)
|
|
||||||
// , m_timeDataStamp(0)
|
|
||||||
// , m_checkSumm(0)
|
|
||||||
// {
|
|
||||||
// }
|
|
||||||
// ModuleInfo(
|
|
||||||
// const ModuleInfo &rhs
|
|
||||||
// ) : m_base(rhs.m_base)
|
|
||||||
// , m_timeDataStamp(rhs.m_timeDataStamp)
|
|
||||||
// , m_checkSumm(rhs.m_checkSumm)
|
|
||||||
// {
|
|
||||||
// }
|
|
||||||
// ModuleInfo(
|
|
||||||
// const IMAGEHLP_MODULEW64 &dbgImageHelperInfo
|
|
||||||
// ) : m_base(addr64(dbgImageHelperInfo.BaseOfImage))
|
|
||||||
// , m_timeDataStamp(dbgImageHelperInfo.TimeDateStamp)
|
|
||||||
// , m_checkSumm(dbgImageHelperInfo.CheckSum)
|
|
||||||
// {
|
|
||||||
// }
|
|
||||||
// ModuleInfo(
|
|
||||||
// const DEBUG_MODULE_PARAMETERS &dbgModuleParameters
|
|
||||||
// ) : m_base(addr64(dbgModuleParameters.Base))
|
|
||||||
// , m_timeDataStamp(dbgModuleParameters.TimeDateStamp)
|
|
||||||
// , m_checkSumm(dbgModuleParameters.Checksum)
|
|
||||||
// {
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// bool operator ==(const ModuleInfo &rhs) const
|
|
||||||
// {
|
|
||||||
// return m_base == rhs.m_base
|
|
||||||
// && m_timeDataStamp == rhs.m_timeDataStamp
|
|
||||||
// && m_checkSumm == rhs.m_checkSumm;
|
|
||||||
// }
|
|
||||||
// bool operator < (const ModuleInfo &rhs) const
|
|
||||||
// {
|
|
||||||
// return memcmp(this, &rhs, sizeof(ModuleInfo)) < 0;
|
|
||||||
// }
|
|
||||||
//};
|
|
||||||
//
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
//class dbgModuleClass {
|
|
||||||
//
|
|
||||||
//public:
|
|
||||||
//
|
|
||||||
// dbgModuleClass() :
|
|
||||||
// m_base( 0 ),
|
|
||||||
// m_end( 0 )
|
|
||||||
// {}
|
|
||||||
//
|
|
||||||
// dbgModuleClass( const std::string &name, ULONG64 base, ULONG size );
|
|
||||||
//
|
|
||||||
// ULONG64
|
|
||||||
// getBegin() const {
|
|
||||||
// return m_base;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// ULONG64
|
|
||||||
// getEnd() const {
|
|
||||||
// return m_end;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// ULONG
|
|
||||||
// getSize() const {
|
|
||||||
// return (ULONG)( m_end - m_base );
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// bool
|
|
||||||
// contain( ULONG64 addr ) const {
|
|
||||||
// if ( *( (ULONG*)&addr + 1 ) == 0 )
|
|
||||||
// *( (ULONG*)&addr + 1 ) = 0xFFFFFFFF;
|
|
||||||
//
|
|
||||||
// return m_base <= addr && addr <= m_end;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// std::string
|
|
||||||
// getName() const {
|
|
||||||
// return m_name;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// void
|
|
||||||
// reloadSymbols();
|
|
||||||
//
|
|
||||||
// ULONG64
|
|
||||||
// getOffset( const std::string &symName );
|
|
||||||
//
|
|
||||||
// std::wstring
|
|
||||||
// getImageSymbolName() const {
|
|
||||||
// return m_imageFullName;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// std::wstring
|
|
||||||
// getPdbName() const {
|
|
||||||
// return std::wstring( m_debugInfo.LoadedPdbName );
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// ULONG
|
|
||||||
// getCheckSum() const {
|
|
||||||
// return m_debugInfo.CheckSum;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// ULONG
|
|
||||||
// getTimeStamp() const {
|
|
||||||
// return m_debugInfo.TimeDateStamp;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// bool
|
|
||||||
// addSyntheticSymbol( ULONG64 offset, ULONG size, const std::string &symName );
|
|
||||||
//
|
|
||||||
// void
|
|
||||||
// delAllSyntheticSymbols();
|
|
||||||
//
|
|
||||||
// ULONG
|
|
||||||
// delSyntheticSymbol( ULONG64 offset );
|
|
||||||
//
|
|
||||||
// ULONG
|
|
||||||
// delSyntheticSymbolsMask( const std::string &symName );
|
|
||||||
//
|
|
||||||
// std::string
|
|
||||||
// print() const;
|
|
||||||
//
|
|
||||||
//private:
|
|
||||||
//
|
|
||||||
// ULONG64 m_base;
|
|
||||||
//
|
|
||||||
// ULONG64 m_end;
|
|
||||||
//
|
|
||||||
// std::string m_name;
|
|
||||||
//
|
|
||||||
// std::wstring m_imageFullName;
|
|
||||||
//
|
|
||||||
// IMAGEHLP_MODULEW64 m_debugInfo;
|
|
||||||
//
|
|
||||||
// typedef std::map<std::string, ULONG64> OffsetMap;
|
|
||||||
// OffsetMap m_offsets;
|
|
||||||
//
|
|
||||||
// void
|
|
||||||
// getImagePath();
|
|
||||||
//};
|
|
||||||
//
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
//boost::python::object
|
|
||||||
//loadModule( const std::string &moduleName );
|
|
||||||
//
|
|
||||||
//// query module parameters (for construct dbgModuleClass) by virtual address
|
|
||||||
//// error : DbgException exception
|
|
||||||
//void queryModuleParams(
|
|
||||||
// __in ULONG64 addr,
|
|
||||||
// __out std::string &name,
|
|
||||||
// __out ULONG64 &base,
|
|
||||||
// __out ULONG &size
|
|
||||||
//);
|
|
||||||
//
|
|
||||||
//boost::python::object
|
|
||||||
//findModule( ULONG64 addr );
|
|
||||||
//
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
@ -349,6 +349,10 @@
|
|||||||
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||||
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
|
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
|
||||||
>
|
>
|
||||||
|
<File
|
||||||
|
RelativePath=".\cpureg.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\dbgclient.cpp"
|
RelativePath=".\dbgclient.cpp"
|
||||||
>
|
>
|
||||||
@ -455,6 +459,10 @@
|
|||||||
Filter="h;hpp;hxx;hm;inl;inc;xsd"
|
Filter="h;hpp;hxx;hm;inl;inc;xsd"
|
||||||
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
|
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
|
||||||
>
|
>
|
||||||
|
<File
|
||||||
|
RelativePath=".\cpureg.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\dbgclient.h"
|
RelativePath=".\dbgclient.h"
|
||||||
>
|
>
|
||||||
|
@ -95,7 +95,6 @@ class BaseTest( unittest.TestCase ):
|
|||||||
self.assertTrue( hasattr(pykd, 'TypeException') )
|
self.assertTrue( hasattr(pykd, 'TypeException') )
|
||||||
self.assertTrue( hasattr(pykd, 'WaitEventException') )
|
self.assertTrue( hasattr(pykd, 'WaitEventException') )
|
||||||
self.assertTrue( hasattr(pykd, 'bp') )
|
self.assertTrue( hasattr(pykd, 'bp') )
|
||||||
self.assertTrue( hasattr(pykd, 'cpuReg') )
|
|
||||||
self.assertTrue( hasattr(pykd, 'dbgStackFrameClass') )
|
self.assertTrue( hasattr(pykd, 'dbgStackFrameClass') )
|
||||||
self.assertTrue( hasattr(pykd, 'disasm') )
|
self.assertTrue( hasattr(pykd, 'disasm') )
|
||||||
self.assertTrue( hasattr(pykd, 'ext') )
|
self.assertTrue( hasattr(pykd, 'ext') )
|
||||||
@ -105,6 +104,7 @@ class BaseTest( unittest.TestCase ):
|
|||||||
|
|
||||||
def testOldRemovedApi( self ):
|
def testOldRemovedApi( self ):
|
||||||
""" Branch test: old API 0.0.x what should be removed """
|
""" Branch test: old API 0.0.x what should be removed """
|
||||||
|
self.assertFalse( hasattr(pykd, 'cpuReg') )
|
||||||
self.assertFalse( hasattr(pykd, 'dbgModuleClass') )
|
self.assertFalse( hasattr(pykd, 'dbgModuleClass') )
|
||||||
self.assertFalse( hasattr(pykd, 'debugEvent') )
|
self.assertFalse( hasattr(pykd, 'debugEvent') )
|
||||||
self.assertFalse( hasattr(pykd, 'findModule') )
|
self.assertFalse( hasattr(pykd, 'findModule') )
|
||||||
|
Loading…
Reference in New Issue
Block a user