[+] added: loadCStr, loadWStr routine added ( loading c-style string )

git-svn-id: https://pykd.svn.codeplex.com/svn@57285 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
SND\kernelnet_cp 2010-11-09 09:33:19 +00:00
parent d389e26054
commit 69e93336d9
4 changed files with 94 additions and 0 deletions

View File

@ -102,6 +102,8 @@ BOOST_PYTHON_MODULE( pykd )
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( "loadCStr", &loadCStr );
boost::python::def( "loadWStr", &loadWStr );
boost::python::def( "loadLinkedList", &loadLinkedList ); 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> );
@ -189,6 +191,7 @@ SetupDebugEngine( IDebugClient4 *client, DbgExt *dbgExt )
client->QueryInterface( __uuidof(IDebugSymbols3), (void ** )&dbgExt->symbols3 ); client->QueryInterface( __uuidof(IDebugSymbols3), (void ** )&dbgExt->symbols3 );
client->QueryInterface( __uuidof(IDebugDataSpaces), (void **)&dbgExt->dataSpaces ); client->QueryInterface( __uuidof(IDebugDataSpaces), (void **)&dbgExt->dataSpaces );
client->QueryInterface( __uuidof(IDebugDataSpaces4), (void **)&dbgExt->dataSpaces4 );
client->QueryInterface( __uuidof(IDebugAdvanced2), (void **)&dbgExt->advanced2 ); client->QueryInterface( __uuidof(IDebugAdvanced2), (void **)&dbgExt->advanced2 );

View File

@ -17,6 +17,7 @@ struct DbgExt {
IDebugSymbols3 *symbols3; IDebugSymbols3 *symbols3;
IDebugDataSpaces *dataSpaces; IDebugDataSpaces *dataSpaces;
IDebugDataSpaces4 *dataSpaces4;
IDebugAdvanced2 *advanced2; IDebugAdvanced2 *advanced2;

View File

@ -322,6 +322,90 @@ loadAnsiStr( ULONG64 address )
/////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////
boost::python::object
loadCStr( ULONG64 address )
{
const size_t maxLength = 0x1000;
boost::python::object strObj( std::string("") );
address = addr64( address );
char* buffer = new char[maxLength];
try {
HRESULT hres =
dbgExt->dataSpaces4->ReadMultiByteStringVirtual(
address,
maxLength,
buffer,
maxLength,
NULL );
if ( FAILED( hres ) )
throw DbgException( "IDebugDataSpace4::ReadMultiByteStringVirtual failed" );
strObj = boost::python::object( std::string( buffer ) );
}
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" );
}
delete[] buffer;
return strObj;
}
///////////////////////////////////////////////////////////////////////////////////
boost::python::object
loadWStr( ULONG64 address )
{
const size_t maxLength = 0x1000;
boost::python::object strObj( std::wstring(L"") );
address = addr64( address );
wchar_t* buffer = new wchar_t[maxLength];
try {
HRESULT hres =
dbgExt->dataSpaces4->ReadUnicodeStringVirtualWide(
address,
maxLength*sizeof(wchar_t),
buffer,
maxLength,
NULL );
if ( FAILED( hres ) )
throw DbgException( "IDebugDataSpace4::ReadUnicodeStringVirtualWide failed" );
strObj = boost::python::object( std::wstring(buffer) );
}
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" );
}
delete[] buffer;
return strObj;
}
///////////////////////////////////////////////////////////////////////////////////
boost::python::object boost::python::object
loadLinkedList( ULONG64 address ) loadLinkedList( ULONG64 address )
{ {

View File

@ -59,6 +59,12 @@ loadUnicodeStr( ULONG64 address );
boost::python::object boost::python::object
loadAnsiStr( ULONG64 address ); loadAnsiStr( ULONG64 address );
boost::python::object
loadCStr( ULONG64 address );
boost::python::object
loadWStr( ULONG64 address );
bool bool
compareMemory( ULONG64 addr1, ULONG64 addr2, ULONG length, BOOLEAN phyAddr = FALSE ); compareMemory( ULONG64 addr1, ULONG64 addr2, ULONG length, BOOLEAN phyAddr = FALSE );