[+] 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,15 +10,25 @@ using namespace std;
///////////////////////////////////////////////////////////////////////////////////
bool
loadMemory( ULONG64 address, PVOID dest, ULONG length )
loadMemory( ULONG64 address, PVOID dest, ULONG length, BOOLEAN phyAddr )
{
address = addr64( address );
try {
HRESULT hres = dbgExt->dataSpaces->ReadVirtual( address, dest, length, NULL );
if ( FAILED( hres ) )
throw DbgException( "IDebugDataSpace::ReadVirtual failed" );
if ( phyAddr == FALSE )
{
HRESULT hres = dbgExt->dataSpaces->ReadVirtual( address, dest, length, NULL );
if ( FAILED( hres ) )
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;
@ -49,7 +59,7 @@ addr64( ULONG64 addr )
///////////////////////////////////////////////////////////////////////////////////
bool
compareMemory( ULONG64 addr1, ULONG64 addr2, ULONG length )
compareMemory( ULONG64 addr1, ULONG64 addr2, ULONG length, BOOLEAN phyAddr )
{
HRESULT hres;
bool result = false;
@ -62,13 +72,27 @@ compareMemory( ULONG64 addr1, ULONG64 addr2, ULONG length )
try {
hres = dbgExt->dataSpaces->ReadVirtual( addr1, m1, length, NULL );
if ( FAILED( hres ) )
throw DbgException( "IDebugDataSpace::ReadVirtual failed" );
if ( phyAddr == FALSE )
{
hres = dbgExt->dataSpaces->ReadVirtual( addr1, m1, length, NULL );
if ( FAILED( hres ) )
throw DbgException( "IDebugDataSpace::ReadVirtual failed" );
hres = dbgExt->dataSpaces->ReadVirtual( addr2, m2, length, NULL );
if ( FAILED( hres ) )
throw DbgException( "IDebugDataSpace::ReadVirtual failed" );
hres = dbgExt->dataSpaces->ReadVirtual( addr2, m2, length, NULL );
if ( FAILED( hres ) )
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;

View File

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