mirror of
https://github.com/ivellioscolin/pykd.git
synced 2025-04-20 03:23:23 +08:00
[+] routines for loading integer value by pointer ( PtrByte, PtrSignByte, PtrWord ... )
[!] bugfix: typedVar git-svn-id: https://pykd.svn.codeplex.com/svn@53137 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
parent
4547274ef0
commit
ebf8275a94
@ -53,6 +53,15 @@ BOOST_PYTHON_MODULE( pykd )
|
||||
boost::python::def( "loadSignDWords", &loadArray<long> );
|
||||
boost::python::def( "loadSignQWords", &loadArray<__int64> );
|
||||
boost::python::def( "loadPtrs", &loadPtrArray );
|
||||
boost::python::def( "PtrByte", &loadByPtr<unsigned char> );
|
||||
boost::python::def( "PtrSignByte", &loadByPtr<char> );
|
||||
boost::python::def( "PtrWord", &loadByPtr<unsigned short> );
|
||||
boost::python::def( "PtrSignWord", &loadByPtr<short> );
|
||||
boost::python::def( "PtrDWord", &loadByPtr<unsigned long> );
|
||||
boost::python::def( "PtrSignDWord", &loadByPtr<long> );
|
||||
boost::python::def( "PtrQWord", &loadByPtr<unsigned __int64> );
|
||||
boost::python::def( "PtrSignQWord", &loadByPtr<__int64> );
|
||||
boost::python::def( "PtrPtr", &loadPtrByPtr );
|
||||
boost::python::def( "compareMemory", &compareMemory );
|
||||
boost::python::class_<typedVarClass>( "typedVarClass" )
|
||||
.def("getAddress", &typedVarClass::getAddress );
|
||||
|
@ -135,4 +135,29 @@ loadPtrArray( ULONG64 address, ULONG number )
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
boost::python::object
|
||||
loadPtrByPtr( ULONG64 address )
|
||||
{
|
||||
if ( is64bitSystem() )
|
||||
{
|
||||
ULONG64 value;
|
||||
|
||||
if ( loadMemory( address, &value, sizeof(ULONG64) ) )
|
||||
return boost::python::object( value );
|
||||
|
||||
return boost::python::object();
|
||||
}
|
||||
else
|
||||
{
|
||||
ULONG value;
|
||||
|
||||
if ( loadMemory( address, &value, sizeof(ULONG) ) )
|
||||
return boost::python::object( addr64( value ) );
|
||||
|
||||
return boost::python::object();
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
@ -32,6 +32,24 @@ loadArray( ULONG64 address, ULONG number )
|
||||
return boost::python::object();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
boost::python::object
|
||||
loadByPtr( ULONG64 address )
|
||||
{
|
||||
T value;
|
||||
|
||||
if ( loadMemory( address, &value, sizeof(T) ) )
|
||||
{
|
||||
return boost::python::object( value );
|
||||
}
|
||||
|
||||
return boost::python::object();
|
||||
}
|
||||
|
||||
boost::python::object
|
||||
loadPtrByPtr( ULONG64 address );
|
||||
|
||||
|
||||
boost::python::object
|
||||
loadPtrArray( ULONG64 address, ULONG number );
|
||||
|
||||
|
@ -69,12 +69,7 @@ loadTypedVar( const std::string &moduleName, const std::string &typeName, ULONG6
|
||||
try {
|
||||
|
||||
ULONG64 moduleBase;
|
||||
|
||||
if ( typeName.find("*") < typeName.size() )
|
||||
{
|
||||
return valueLoader<void*>( address, ptrSize() );
|
||||
}
|
||||
|
||||
|
||||
hres = dbgExt->symbols->GetModuleByModuleName( moduleName.c_str(), 0, NULL, &moduleBase );
|
||||
if ( FAILED( hres ) )
|
||||
throw DbgException( "IDebugSymbol::GetModuleByModuleName failed" );
|
||||
@ -83,7 +78,7 @@ 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" );
|
||||
|
||||
|
||||
typedVarClass temp( address );
|
||||
boost::python::object var( temp );
|
||||
|
||||
@ -117,7 +112,16 @@ loadTypedVar( const std::string &moduleName, const std::string &typeName, ULONG6
|
||||
}
|
||||
else
|
||||
{
|
||||
var.attr( fieldName ) = loadTypedVar( moduleName, fieldTypeName, address + fieldOffset );
|
||||
std::string fieldTypeNameStr( fieldTypeName );
|
||||
|
||||
if ( fieldTypeNameStr.find("*") < fieldTypeNameStr.size() )
|
||||
{
|
||||
var.attr( fieldName ) = valueLoader<void*>( address + fieldOffset, fieldSize );
|
||||
}
|
||||
else
|
||||
{
|
||||
var.attr( fieldName ) = loadTypedVar( moduleName, fieldTypeName, address + fieldOffset );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user