[0.1.x] fixed : issue ( VirtualToOffset: not properly sign extended )

git-svn-id: https://pykd.svn.codeplex.com/svn@74119 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
SND\kernelnet_cp 2012-02-10 15:14:52 +00:00 committed by Mikhail I. Izmestev
parent 30795b3ef9
commit 15251a4c27
4 changed files with 41 additions and 26 deletions

View File

@ -1,4 +1,5 @@
[!] fixed : issue #10335 ( VirtualToOffset: not properly sign extended )
[!] fixed : issue #10336 ( pykd routines can not convert parameters to long )
version 0.1.0.7 30/01/2012

View File

@ -39,12 +39,12 @@ DebugClient::loadArray( ULONG64 offset, ULONG count, bool phyAddr )
/////////////////////////////////////////////////////////////////////////////////////
ULONG64
DebugClient::addr64( ULONG64 addr)
addr64( IDebugControl4* dbgControl, ULONG64 addr)
{
HRESULT hres;
ULONG processorMode;
hres = m_control->GetActualProcessorType( &processorMode );
hres = dbgControl->GetActualProcessorType( &processorMode );
if ( FAILED( hres ) )
throw DbgException( "IDebugControl::GetEffectiveProcessorType failed" );
@ -65,6 +65,13 @@ DebugClient::addr64( ULONG64 addr)
return addr;
}
ULONG64
DebugClient::addr64( ULONG64 addr )
{
return pykd::addr64( m_control, addr );
}
ULONG64
addr64( ULONG64 addr)
{
@ -105,9 +112,11 @@ readMemory( IDebugDataSpaces4* dbgDataSpace, ULONG64 address, PVOID buffer, ULO
{
HRESULT hres;
CComQIPtr<IDebugControl4> dbgControl(dbgDataSpace);
if ( phyAddr == false )
{
hres = dbgDataSpace->ReadVirtual( address, buffer, length, NULL );
hres = dbgDataSpace->ReadVirtual( addr64( dbgControl, address), buffer, length, NULL );
}
else
{
@ -120,18 +129,35 @@ readMemory( IDebugDataSpaces4* dbgDataSpace, ULONG64 address, PVOID buffer, ULO
/////////////////////////////////////////////////////////////////////////////////////
void
readMemoryPtr( IDebugDataSpaces4* dbgDataSpace, ULONG64 address, PULONG64 ptrValue )
{
HRESULT hres;
CComQIPtr<IDebugControl4> dbgControl(dbgDataSpace);
hres = dbgDataSpace->ReadPointersVirtual( 1, addr64( dbgControl, address), ptrValue );
if ( FAILED( hres ) )
throw MemoryException( address, false );
}
/////////////////////////////////////////////////////////////////////////////////////
bool compareMemoryRange( IDebugDataSpaces4* dbgDataSpace, ULONG64 addr1, ULONG64 addr2, ULONG length, bool phyAddr )
{
bool result = false;
CComQIPtr<IDebugControl4> dbgControl(dbgDataSpace);
addr1 = addr64( addr1 );
addr2 = addr64( addr2 );
std::vector<char> m1(length);
std::vector<char> m2(length);
readMemory( dbgDataSpace, addr1, &m1[0], length, phyAddr );
readMemory( dbgDataSpace, addr2, &m2[0], length, phyAddr );
readMemory( dbgDataSpace, addr64( dbgControl, addr1), &m1[0], length, phyAddr );
readMemory( dbgDataSpace, addr64( dbgControl, addr2), &m2[0], length, phyAddr );
return std::equal( m1.begin(), m1.end(), m2.begin() );
}

View File

@ -17,6 +17,9 @@ isVaValid( ULONG64 addr );
void
readMemory( IDebugDataSpaces4* dbgDataSpace, ULONG64 address, PVOID buffer, ULONG length, bool phyAddr = FALSE );
void
readMemoryPtr( IDebugDataSpaces4* dbgDataSpace, ULONG64 address, PULONG64 ptrValue );
void
writeMemory( IDebugDataSpaces4* dbgDataSpace, ULONG64 address, PVOID buffer, ULONG length, bool phyAddr = FALSE );

View File

@ -2,6 +2,7 @@
#include "typedvar.h"
#include "dbgclient.h"
#include "dbgmem.h"
namespace pykd {
@ -67,12 +68,8 @@ TypedVar::TypedVar ( IDebugClient4 *client, const TypeInfoPtr& typeInfo, ULONG64
BaseTypeVariant BasicTypedVar::getValue()
{
ULONG64 val = 0;
HRESULT hres;
hres = m_dataSpaces->ReadVirtual( m_offset, &val, getSize(), NULL );
if ( FAILED( hres ) )
throw MemoryException( m_offset, false );
readMemory( m_dataSpaces, m_offset, &val, getSize(), false );
if ( m_typeInfo->getName() == "Char" )
return (LONG)*(PCHAR)&val;
@ -120,12 +117,9 @@ BaseTypeVariant BasicTypedVar::getValue()
BaseTypeVariant PtrTypedVar::getValue()
{
HRESULT hres;
ULONG64 val = 0;
hres = m_dataSpaces->ReadPointersVirtual( 1, m_offset, &val );
if ( FAILED( hres ) )
throw MemoryException( m_offset, false );
readMemoryPtr( m_dataSpaces, m_offset, &val );
return val;
}
@ -134,12 +128,9 @@ BaseTypeVariant PtrTypedVar::getValue()
TypedVarPtr PtrTypedVar::deref()
{
HRESULT hres;
ULONG64 val = 0;
hres = m_dataSpaces->ReadPointersVirtual( 1, m_offset, &val );
if ( FAILED( hres ) )
throw MemoryException( m_offset, false );
readMemoryPtr( m_dataSpaces, m_offset, &val );
return TypedVar::getTypedVar( m_client, m_typeInfo->deref(), val );
}
@ -159,11 +150,8 @@ UdtTypedVar::getField( const std::string &fieldName )
BaseTypeVariant BitFieldVar::getValue()
{
ULONG64 val = 0;
HRESULT hres;
hres = m_dataSpaces->ReadVirtual( m_offset, &val, m_typeInfo->getSize(), NULL );
if ( FAILED( hres ) )
throw MemoryException( m_offset, false );
readMemory( m_dataSpaces, m_offset, &val, getSize(), false );
val >>= m_typeInfo->getBitOffset();
val &= m_typeInfo->getBitWidth();
@ -191,11 +179,8 @@ BaseTypeVariant BitFieldVar::getValue()
BaseTypeVariant EnumTypedVar::getValue()
{
ULONG val = 0;
HRESULT hres;
hres = m_dataSpaces->ReadVirtual( m_offset, &val, m_typeInfo->getSize(), NULL );
if ( FAILED( hres ) )
throw MemoryException( m_offset, false );
readMemory( m_dataSpaces, m_offset, &val, getSize(), false );
return val;
};