mirror of
https://github.com/ivellioscolin/pykd.git
synced 2025-04-20 03:23:23 +08:00
[+] added: sizeof routine ( returns size of type )
[+] added: sizeof method for typedVarClass ( return size of var in memory ) git-svn-id: https://pykd.svn.codeplex.com/svn@55065 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
parent
51f2adb195
commit
eba80f2426
@ -71,6 +71,7 @@ BOOST_PYTHON_MODULE( pykd )
|
||||
boost::python::def( "typedVar", &loadTypedVar );
|
||||
boost::python::def( "typedVarList", &loadTypedVarList );
|
||||
boost::python::def( "containingRecord", &containingRecord );
|
||||
boost::python::def( "sizeof", &sizeofType );
|
||||
boost::python::def( "loadModule", &loadModule );
|
||||
boost::python::def( "findSymbol", &findSymbolForAddress );
|
||||
boost::python::def( "getOffset", &findAddressForSymbol );
|
||||
@ -104,7 +105,8 @@ BOOST_PYTHON_MODULE( pykd )
|
||||
boost::python::def( "getImplicitThread", &getImplicitThread );
|
||||
boost::python::def( "setImplicitThread", &setImplicitThread );
|
||||
boost::python::class_<typedVarClass>( "typedVarClass" )
|
||||
.def("getAddress", &typedVarClass::getAddress );
|
||||
.def("getAddress", &typedVarClass::getAddress )
|
||||
.def("sizeof", &typedVarClass::size );
|
||||
boost::python::class_<dbgModuleClass>( "dbgModuleClass" )
|
||||
.def("begin", &dbgModuleClass::getBegin )
|
||||
.def("end", &dbgModuleClass::getEnd )
|
||||
|
@ -94,8 +94,13 @@ loadTypedVar( const std::string &moduleName, const std::string &typeName, ULONG6
|
||||
hres = dbgExt->symbols->GetTypeId( moduleBase, typeName.c_str(), &typeId );
|
||||
if ( FAILED( hres ) )
|
||||
throw DbgException( "IDebugSymbol::GetTypeId failed" );
|
||||
|
||||
ULONG typeSize;
|
||||
hres = dbgExt->symbols->GetTypeSize( moduleBase, typeId, &typeSize );
|
||||
if ( FAILED( hres ) )
|
||||
throw DbgException( "IDebugSymbol::GetTypeSize failed" );
|
||||
|
||||
typedVarClass temp( address );
|
||||
typedVarClass temp( address, typeSize );
|
||||
boost::python::object var( temp );
|
||||
|
||||
for ( ULONG i = 0; ; ++i )
|
||||
@ -201,6 +206,44 @@ containingRecord( ULONG64 address, const std::string &moduleName, const std::str
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
ULONG
|
||||
sizeofType( const std::string &moduleName, const std::string &typeName )
|
||||
{
|
||||
HRESULT hres;
|
||||
ULONG typeSize = ~0;
|
||||
|
||||
try {
|
||||
|
||||
ULONG64 moduleBase;
|
||||
|
||||
hres = dbgExt->symbols->GetModuleByModuleName( moduleName.c_str(), 0, NULL, &moduleBase );
|
||||
if ( FAILED( hres ) )
|
||||
throw DbgException( "IDebugSymbol::GetModuleByModuleName failed" );
|
||||
|
||||
ULONG typeId;
|
||||
hres = dbgExt->symbols->GetTypeId( moduleBase, typeName.c_str(), &typeId );
|
||||
if ( FAILED( hres ) )
|
||||
throw DbgException( "IDebugSymbol::GetTypeId failed" );
|
||||
|
||||
hres = dbgExt->symbols->GetTypeSize( moduleBase, typeId, &typeSize );
|
||||
if ( FAILED( hres ) )
|
||||
throw DbgException( "IDebugSymbol::GetTypeSize failed" );
|
||||
}
|
||||
|
||||
catch( std::exception &e )
|
||||
{
|
||||
dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "pykd error: %s\n", e.what() );
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "pykd unexpected error\n" );
|
||||
}
|
||||
|
||||
return typeSize;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
boost::python::object
|
||||
loadTypedVarList( ULONG64 address, const std::string &moduleName, const std::string &typeName, const std::string &listEntryName )
|
||||
{
|
||||
|
@ -14,8 +14,9 @@ public:
|
||||
typedVarClass()
|
||||
{}
|
||||
|
||||
typedVarClass( ULONG64 addr ) :
|
||||
m_addr( addr )
|
||||
typedVarClass( ULONG64 addr, ULONG size ) :
|
||||
m_addr( addr ),
|
||||
m_size( size )
|
||||
{}
|
||||
|
||||
ULONG64
|
||||
@ -23,9 +24,16 @@ public:
|
||||
return m_addr;
|
||||
}
|
||||
|
||||
ULONG
|
||||
size() const {
|
||||
return m_size;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
ULONG64 m_addr;
|
||||
|
||||
ULONG m_size;
|
||||
|
||||
};
|
||||
|
||||
@ -40,5 +48,8 @@ loadTypedVarList( ULONG64 address, const std::string &moduleName, const std::str
|
||||
boost::python::object
|
||||
containingRecord( ULONG64 address, const std::string &moduleName, const std::string &typeName, const std::string &fieldName );
|
||||
|
||||
ULONG
|
||||
sizeofType( const std::string &moduleName, const std::string &typeName );
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
Loading…
Reference in New Issue
Block a user