From ebf8275a948ab0b02dfc379c2d6716c7e07e3bcb Mon Sep 17 00:00:00 2001 From: "SND\\kernelnet_cp" Date: Wed, 28 Jul 2010 10:07:43 +0000 Subject: [PATCH] [+] 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 --- pykd/dbgext.cpp | 9 +++++++++ pykd/dbgmem.cpp | 25 +++++++++++++++++++++++++ pykd/dbgmem.h | 18 ++++++++++++++++++ pykd/dbgtype.cpp | 20 ++++++++++++-------- 4 files changed, 64 insertions(+), 8 deletions(-) diff --git a/pykd/dbgext.cpp b/pykd/dbgext.cpp index b3822d0..5b5a354 100644 --- a/pykd/dbgext.cpp +++ b/pykd/dbgext.cpp @@ -53,6 +53,15 @@ BOOST_PYTHON_MODULE( pykd ) boost::python::def( "loadSignDWords", &loadArray ); boost::python::def( "loadSignQWords", &loadArray<__int64> ); boost::python::def( "loadPtrs", &loadPtrArray ); + boost::python::def( "PtrByte", &loadByPtr ); + boost::python::def( "PtrSignByte", &loadByPtr ); + boost::python::def( "PtrWord", &loadByPtr ); + boost::python::def( "PtrSignWord", &loadByPtr ); + boost::python::def( "PtrDWord", &loadByPtr ); + boost::python::def( "PtrSignDWord", &loadByPtr ); + boost::python::def( "PtrQWord", &loadByPtr ); + boost::python::def( "PtrSignQWord", &loadByPtr<__int64> ); + boost::python::def( "PtrPtr", &loadPtrByPtr ); boost::python::def( "compareMemory", &compareMemory ); boost::python::class_( "typedVarClass" ) .def("getAddress", &typedVarClass::getAddress ); diff --git a/pykd/dbgmem.cpp b/pykd/dbgmem.cpp index aa74b02..9269ee8 100644 --- a/pykd/dbgmem.cpp +++ b/pykd/dbgmem.cpp @@ -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(); + } +} + /////////////////////////////////////////////////////////////////////////////////// \ No newline at end of file diff --git a/pykd/dbgmem.h b/pykd/dbgmem.h index 6c42a58..b1c6c56 100644 --- a/pykd/dbgmem.h +++ b/pykd/dbgmem.h @@ -32,6 +32,24 @@ loadArray( ULONG64 address, ULONG number ) return boost::python::object(); } +template +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 ); diff --git a/pykd/dbgtype.cpp b/pykd/dbgtype.cpp index 31a0679..be8bc94 100644 --- a/pykd/dbgtype.cpp +++ b/pykd/dbgtype.cpp @@ -69,12 +69,7 @@ loadTypedVar( const std::string &moduleName, const std::string &typeName, ULONG6 try { ULONG64 moduleBase; - - if ( typeName.find("*") < typeName.size() ) - { - return valueLoader( 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( address + fieldOffset, fieldSize ); + } + else + { + var.attr( fieldName ) = loadTypedVar( moduleName, fieldTypeName, address + fieldOffset ); + } } }