[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:
SND\kernelnet_cp 2012-08-16 15:54:06 +00:00 committed by Mikhail I. Izmestev
parent be7d58a4e8
commit 2decf9abc7
4 changed files with 20 additions and 0 deletions

View File

@ -162,6 +162,8 @@ BOOST_PYTHON_MODULE( pykd )
"Read the block of the target's memory and return it as a list of pointers" ); "Read the block of the target's memory and return it as a list of pointers" );
// types and vaiables // types and vaiables
python::def( "getOffset", &TypeInfo::getOffset,
"Return traget virtual address for specified symbol" );
python::def( "findSymbol", &TypeInfo::findSymbol, python::def( "findSymbol", &TypeInfo::findSymbol,
"Find symbol by the target virtual memory offset" ); "Find symbol by the target virtual memory offset" );
python::def( "sizeof", &TypeInfo::getSymbolSize, python::def( "sizeof", &TypeInfo::getSymbolSize,

View File

@ -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 ) TypeInfoPtr TypeInfo::getTypeInfo( SymbolPtr &typeSym )
{ {
ULONG symTag = typeSym->getSymTag(); ULONG symTag = typeSym->getSymTag();

View File

@ -31,6 +31,9 @@ public:
static static
std::string findSymbol( ULONG64 offset ); std::string findSymbol( ULONG64 offset );
static
ULONG64 getOffset( const std::string &symbolName );
static static
TypeInfoPtr getTypeInfo( SymbolPtr &symScope, const std::string &symName ); TypeInfoPtr getTypeInfo( SymbolPtr &symScope, const std::string &symName );

View File

@ -46,6 +46,7 @@ class ModuleTest( unittest.TestCase ):
def testSymbol( self ): def testSymbol( self ):
self.assertEqual( target.module.rva("FuncWithName0"), target.module.offset("FuncWithName0") - target.module.begin() ) 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"), target.module.FuncWithName0 - target.module.begin() )
self.assertEqual( target.module.rva("FuncWithName0"), pykd.getOffset( target.module.name() + "!FuncWithName0") - target.module.begin() )
def testType( self ): def testType( self ):
self.assertEqual( "structTest", target.module.type("structTest").name() ); self.assertEqual( "structTest", target.module.type("structTest").name() );