mirror of
https://github.com/ivellioscolin/pykd.git
synced 2025-04-20 03:23:23 +08:00
[0.2.x] added : getOffset routine
git-svn-id: https://pykd.svn.codeplex.com/svn@78888 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
parent
be7d58a4e8
commit
2decf9abc7
@ -162,6 +162,8 @@ BOOST_PYTHON_MODULE( pykd )
|
||||
"Read the block of the target's memory and return it as a list of pointers" );
|
||||
|
||||
// types and vaiables
|
||||
python::def( "getOffset", &TypeInfo::getOffset,
|
||||
"Return traget virtual address for specified symbol" );
|
||||
python::def( "findSymbol", &TypeInfo::findSymbol,
|
||||
"Find symbol by the target virtual memory offset" );
|
||||
python::def( "sizeof", &TypeInfo::getSymbolSize,
|
||||
|
@ -83,6 +83,20 @@ std::string TypeInfo::findSymbol( ULONG64 offset )
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
ULONG64 TypeInfo::getOffset( const std::string &fullName )
|
||||
{
|
||||
std::string moduleName;
|
||||
std::string symName;
|
||||
|
||||
splitSymName( fullName, moduleName, symName );
|
||||
|
||||
ModulePtr module = Module::loadModuleByName( moduleName );
|
||||
|
||||
return module->getSymbolOffset( symName );
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
TypeInfoPtr TypeInfo::getTypeInfo( SymbolPtr &typeSym )
|
||||
{
|
||||
ULONG symTag = typeSym->getSymTag();
|
||||
|
@ -31,6 +31,9 @@ public:
|
||||
static
|
||||
std::string findSymbol( ULONG64 offset );
|
||||
|
||||
static
|
||||
ULONG64 getOffset( const std::string &symbolName );
|
||||
|
||||
static
|
||||
TypeInfoPtr getTypeInfo( SymbolPtr &symScope, const std::string &symName );
|
||||
|
||||
|
@ -46,6 +46,7 @@ class ModuleTest( unittest.TestCase ):
|
||||
def testSymbol( self ):
|
||||
self.assertEqual( target.module.rva("FuncWithName0"), target.module.offset("FuncWithName0") - target.module.begin() )
|
||||
self.assertEqual( target.module.rva("FuncWithName0"), target.module.FuncWithName0 - target.module.begin() )
|
||||
self.assertEqual( target.module.rva("FuncWithName0"), pykd.getOffset( target.module.name() + "!FuncWithName0") - target.module.begin() )
|
||||
|
||||
def testType( self ):
|
||||
self.assertEqual( "structTest", target.module.type("structTest").name() );
|
||||
|
Loading…
Reference in New Issue
Block a user