[+] added: loadLinkedList routine

[+] added: getPdbFile routine
[+] added: reloadSymbols

git-svn-id: https://pykd.svn.codeplex.com/svn@54138 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
SND\kernelnet_cp 2010-08-16 15:04:22 +00:00
parent f5286ff2e8
commit d2e5dacb50
6 changed files with 104 additions and 1 deletions

View File

@ -86,7 +86,8 @@ BOOST_PYTHON_MODULE( pykd )
boost::python::def( "loadSignQWords", &loadArray<__int64> ); boost::python::def( "loadSignQWords", &loadArray<__int64> );
boost::python::def( "loadPtrs", &loadPtrArray ); boost::python::def( "loadPtrs", &loadPtrArray );
boost::python::def( "loadUnicodeString", &loadUnicodeStr ); boost::python::def( "loadUnicodeString", &loadUnicodeStr );
boost::python::def( "loadAnsiString", &loadAnsiStr ); boost::python::def( "loadAnsiString", &loadAnsiStr );
boost::python::def( "loadLinkedList", &loadLinkedList );
boost::python::def( "ptrByte", &loadByPtr<unsigned char> ); boost::python::def( "ptrByte", &loadByPtr<unsigned char> );
boost::python::def( "ptrSignByte", &loadByPtr<char> ); boost::python::def( "ptrSignByte", &loadByPtr<char> );
boost::python::def( "ptrWord", &loadByPtr<unsigned short> ); boost::python::def( "ptrWord", &loadByPtr<unsigned short> );
@ -98,6 +99,8 @@ BOOST_PYTHON_MODULE( pykd )
boost::python::def( "ptrPtr", &loadPtrByPtr ); boost::python::def( "ptrPtr", &loadPtrByPtr );
boost::python::def( "compareMemory", &compareMemory ); boost::python::def( "compareMemory", &compareMemory );
boost::python::def( "getStack", &getStack ); boost::python::def( "getStack", &getStack );
boost::python::def( "reloadSymbols", &reloadSymbols );
boost::python::def( "getPdbFile", &getPdbFile );
boost::python::class_<typedVarClass>( "typedVarClass" ) boost::python::class_<typedVarClass>( "typedVarClass" )
.def("getAddress", &typedVarClass::getAddress ); .def("getAddress", &typedVarClass::getAddress );
boost::python::class_<dbgModuleClass>( "dbgModuleClass" ) boost::python::class_<dbgModuleClass>( "dbgModuleClass" )
@ -163,6 +166,7 @@ SetupDebugEngine( IDebugClient4 *client, DbgExt *dbgExt )
client->QueryInterface( __uuidof(IDebugDataSpaces), (void **)&dbgExt->dataSpaces ); client->QueryInterface( __uuidof(IDebugDataSpaces), (void **)&dbgExt->dataSpaces );
client->QueryInterface( __uuidof(IDebugAdvanced2), (void **)&dbgExt->advanced2 );
} }
///////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////

View File

@ -1,6 +1,7 @@
#pragma once #pragma once
#include <dbgeng.h> #include <dbgeng.h>
#include <dbghelp.h>
struct DbgExt { struct DbgExt {
@ -16,6 +17,8 @@ struct DbgExt {
IDebugSymbols3 *symbols3; IDebugSymbols3 *symbols3;
IDebugDataSpaces *dataSpaces; IDebugDataSpaces *dataSpaces;
IDebugAdvanced2 *advanced2;
}; };
extern DbgExt *dbgExt; extern DbgExt *dbgExt;

View File

@ -296,4 +296,19 @@ loadAnsiStr( ULONG64 address )
return boost::python::object( "" ); return boost::python::object( "" );
} }
///////////////////////////////////////////////////////////////////////////////////
boost::python::object
loadLinkedList( ULONG64 address )
{
ULONG64 entryAddress = 0;
boost::python::list objList;
for( entryAddress = loadPtrByPtr( address ); entryAddress != address; entryAddress = loadPtrByPtr( entryAddress ) )
objList.append( entryAddress );
return objList;
}
/////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////

View File

@ -65,4 +65,7 @@ compareMemory( ULONG64 addr1, ULONG64 addr2, ULONG length );
ULONG64 ULONG64
addr64( ULONG64 addr ); addr64( ULONG64 addr );
boost::python::object
loadLinkedList( ULONG64 address );
///////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////

View File

@ -70,3 +70,73 @@ dbgSymPath()
/////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////
std::string
getPdbFile( ULONG64 moduleBase )
{
HRESULT hres;
try {
IMAGEHLP_MODULEW64 imageHelpInfo = { 0 };
hres =
dbgExt->advanced2->GetSymbolInformation(
DEBUG_SYMINFO_IMAGEHLP_MODULEW64,
moduleBase,
0,
&imageHelpInfo,
sizeof( imageHelpInfo ),
NULL,
NULL,
0,
NULL );
char fileName[ 256 ];
WideCharToMultiByte( CP_ACP, 0, imageHelpInfo.LoadedPdbName, 256, fileName, 256, NULL, NULL );
return std::string( fileName );
}
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 std::string();
}
///////////////////////////////////////////////////////////////////////////////////
void
reloadSymbols( const char * moduleName )
{
HRESULT hres;
try {
std::string reloadParam( "/f " );
reloadParam += moduleName;
hres = dbgExt->symbols->Reload( reloadParam.c_str() );
if ( FAILED( hres ) )
throw DbgException( "IDebugSymbol::Reload 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" );
}
}
///////////////////////////////////////////////////////////////////////////////////

View File

@ -16,5 +16,13 @@ ptrSize() {
std::string std::string
dbgSymPath(); dbgSymPath();
std::string
getPdbFile( ULONG64 moduleBase );
std::string
getImageFile( ULONG64 moduleBase );
void
reloadSymbols( const char * moduleName );
///////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////