[+] added: physical memory read support ( for loadBytes, loadWords etc)

git-svn-id: https://pykd.svn.codeplex.com/svn@56418 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
SND\kernelnet_cp 2010-10-26 13:44:19 +00:00
parent 477da2e29f
commit 7831603e21
2 changed files with 39 additions and 15 deletions

View File

@ -10,16 +10,26 @@ using namespace std;
/////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////
bool bool
loadMemory( ULONG64 address, PVOID dest, ULONG length ) loadMemory( ULONG64 address, PVOID dest, ULONG length, BOOLEAN phyAddr )
{ {
address = addr64( address ); address = addr64( address );
try { try {
if ( phyAddr == FALSE )
{
HRESULT hres = dbgExt->dataSpaces->ReadVirtual( address, dest, length, NULL ); HRESULT hres = dbgExt->dataSpaces->ReadVirtual( address, dest, length, NULL );
if ( FAILED( hres ) ) if ( FAILED( hres ) )
throw DbgException( "IDebugDataSpace::ReadVirtual failed" ); throw DbgException( "IDebugDataSpace::ReadVirtual failed" );
}
else
{
HRESULT hres = dbgExt->dataSpaces->ReadPhysical( address, dest, length, NULL );
if ( FAILED( hres ) )
throw DbgException( "IDebugDataSpace::ReadPhysical failed" );
}
return true; return true;
} }
@ -49,7 +59,7 @@ addr64( ULONG64 addr )
/////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////
bool bool
compareMemory( ULONG64 addr1, ULONG64 addr2, ULONG length ) compareMemory( ULONG64 addr1, ULONG64 addr2, ULONG length, BOOLEAN phyAddr )
{ {
HRESULT hres; HRESULT hres;
bool result = false; bool result = false;
@ -62,6 +72,9 @@ compareMemory( ULONG64 addr1, ULONG64 addr2, ULONG length )
try { try {
if ( phyAddr == FALSE )
{
hres = dbgExt->dataSpaces->ReadVirtual( addr1, m1, length, NULL ); hres = dbgExt->dataSpaces->ReadVirtual( addr1, m1, length, NULL );
if ( FAILED( hres ) ) if ( FAILED( hres ) )
throw DbgException( "IDebugDataSpace::ReadVirtual failed" ); throw DbgException( "IDebugDataSpace::ReadVirtual failed" );
@ -69,6 +82,17 @@ compareMemory( ULONG64 addr1, ULONG64 addr2, ULONG length )
hres = dbgExt->dataSpaces->ReadVirtual( addr2, m2, length, NULL ); hres = dbgExt->dataSpaces->ReadVirtual( addr2, m2, length, NULL );
if ( FAILED( hres ) ) if ( FAILED( hres ) )
throw DbgException( "IDebugDataSpace::ReadVirtual failed" ); throw DbgException( "IDebugDataSpace::ReadVirtual failed" );
}
else
{
hres = dbgExt->dataSpaces->ReadPhysical( addr1, m1, length, NULL );
if ( FAILED( hres ) )
throw DbgException( "IDebugDataSpace::ReadPhysical failed" );
hres = dbgExt->dataSpaces->ReadPhysical( addr2, m2, length, NULL );
if ( FAILED( hres ) )
throw DbgException( "IDebugDataSpace::ReadPhysical failed" );
}
result = memcmp( m1, m2, length ) == 0; result = memcmp( m1, m2, length ) == 0;

View File

@ -7,7 +7,7 @@
///////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////
bool bool
loadMemory( ULONG64 address, PVOID dest, ULONG length ); loadMemory( ULONG64 address, PVOID dest, ULONG length, BOOLEAN phyAddr = FALSE );
ULONG64 ULONG64
loadPtrByPtr( ULONG64 address ); loadPtrByPtr( ULONG64 address );
@ -15,11 +15,11 @@ loadPtrByPtr( ULONG64 address );
template<typename T> template<typename T>
boost::python::object boost::python::object
loadArray( ULONG64 address, ULONG number ) loadArray( ULONG64 address, ULONG number, BOOLEAN phyAddr = FALSE )
{ {
T *buffer = new T[ number ]; T *buffer = new T[ number ];
if ( loadMemory( address, buffer, number*sizeof(T) ) ) if ( loadMemory( address, buffer, number*sizeof(T), phyAddr ) )
{ {
boost::python::dict arr; boost::python::dict arr;
@ -60,7 +60,7 @@ boost::python::object
loadAnsiStr( ULONG64 address ); loadAnsiStr( ULONG64 address );
bool bool
compareMemory( ULONG64 addr1, ULONG64 addr2, ULONG length ); compareMemory( ULONG64 addr1, ULONG64 addr2, ULONG length, BOOLEAN phyAddr = FALSE );
ULONG64 ULONG64
addr64( ULONG64 addr ); addr64( ULONG64 addr );