mirror of
https://github.com/ivellioscolin/pykd.git
synced 2025-04-21 04:13:22 +08:00
[0.2.x] ~getSymbolName->findSymbolAndDisp
git-svn-id: https://pykd.svn.codeplex.com/svn@82757 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
parent
3e5acdaaf4
commit
f03c94608e
@ -299,19 +299,14 @@ std::string Module::getSymbolNameByVa( ULONG64 offset, bool showDisplacement )
|
|||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
std::string Module::getStrictSymbolNameByVa( ULONG64 offset )
|
python::tuple Module::getSymbolAndDispByVa( ULONG64 offset )
|
||||||
{
|
{
|
||||||
offset = prepareVa(offset);
|
offset = prepareVa(offset);
|
||||||
|
|
||||||
LONG displacement = 0;
|
LONG displacement = 0;
|
||||||
|
SymbolPtr sym = getSymSession()->findByRva( (ULONG)(offset - m_base ), SymTagNull, &displacement );
|
||||||
|
|
||||||
const ULONG rva = (ULONG)(offset - m_base );
|
return python::make_tuple(sym->getName(), displacement);
|
||||||
SymbolPtr sym = getSymSession()->findByRva( rva , SymTagNull, &displacement );
|
|
||||||
|
|
||||||
if (displacement || rva != sym->getRva())
|
|
||||||
throw SymbolException( "Not exact address of symbol" );
|
|
||||||
|
|
||||||
return sym->getName();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -133,7 +133,7 @@ public:
|
|||||||
|
|
||||||
std::string getSymbolNameByVa( ULONG64 offset, bool showDisplacement = true );
|
std::string getSymbolNameByVa( ULONG64 offset, bool showDisplacement = true );
|
||||||
|
|
||||||
std::string getStrictSymbolNameByVa( ULONG64 offset );
|
python::tuple getSymbolAndDispByVa( ULONG64 offset );
|
||||||
|
|
||||||
void getSourceLine( ULONG64 offset, std::string &fileName, ULONG &lineNo, LONG &displacement );
|
void getSourceLine( ULONG64 offset, std::string &fileName, ULONG &lineNo, LONG &displacement );
|
||||||
|
|
||||||
|
@ -370,8 +370,8 @@ BOOST_PYTHON_MODULE( pykd )
|
|||||||
"Return offset of the symbol" )
|
"Return offset of the symbol" )
|
||||||
.def("findSymbol", &Module::getSymbolNameByVa, Module_findSymbol( python::args("offset", "showDisplacement"),
|
.def("findSymbol", &Module::getSymbolNameByVa, Module_findSymbol( python::args("offset", "showDisplacement"),
|
||||||
"Return symbol name by virtual address" ) )
|
"Return symbol name by virtual address" ) )
|
||||||
.def("getSymbolName", &Module::getStrictSymbolNameByVa,
|
.def("findSymbolAndDisp", &Module::getSymbolAndDispByVa,
|
||||||
"Return symbol name by virtual address (without displacement)" )
|
"Return tuple(symbol_name, displacement) by virtual address" )
|
||||||
.def("rva", &Module::getSymbolRva,
|
.def("rva", &Module::getSymbolRva,
|
||||||
"Return rva of the symbol" )
|
"Return rva of the symbol" )
|
||||||
.def("sizeof", &Module::getSymbolSize,
|
.def("sizeof", &Module::getSymbolSize,
|
||||||
|
@ -56,11 +56,10 @@ class ModuleTest( unittest.TestCase ):
|
|||||||
self.assertEqual( "_FuncWithName2+10", target.module.findSymbol( target.module.offset("_FuncWithName2") + 0x10 ) )
|
self.assertEqual( "_FuncWithName2+10", target.module.findSymbol( target.module.offset("_FuncWithName2") + 0x10 ) )
|
||||||
self.assertEqual( "_FuncWithName2", target.module.findSymbol( target.module.offset("_FuncWithName2") + 0x10, showDisplacement = False ) )
|
self.assertEqual( "_FuncWithName2", target.module.findSymbol( target.module.offset("_FuncWithName2") + 0x10, showDisplacement = False ) )
|
||||||
|
|
||||||
def testGetSymbolName( self ):
|
def testFindSymbolAndDisp( self ):
|
||||||
vaFuncWithName0 = target.module.offset("FuncWithName0")
|
vaFuncWithName0 = target.module.offset("FuncWithName0")
|
||||||
self.assertEqual( "FuncWithName0", target.module.getSymbolName(vaFuncWithName0) )
|
self.assertEqual( ("FuncWithName0", 0), target.module.findSymbolAndDisp(vaFuncWithName0) )
|
||||||
self.assertRaises( pykd.SymbolException, target.module.getSymbolName, vaFuncWithName0 + 1 )
|
self.assertEqual( ("FuncWithName0", 2), target.module.findSymbolAndDisp(vaFuncWithName0+2) )
|
||||||
self.assertRaises( pykd.SymbolException, target.module.getSymbolName, vaFuncWithName0 - 1 )
|
|
||||||
|
|
||||||
def testType( self ):
|
def testType( self ):
|
||||||
self.assertEqual( "structTest", target.module.type("structTest").name() );
|
self.assertEqual( "structTest", target.module.type("structTest").name() );
|
||||||
|
Loading…
Reference in New Issue
Block a user