diff --git a/changelist.txt b/changelist.txt index 5f306be..0967689 100644 --- a/changelist.txt +++ b/changelist.txt @@ -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 diff --git a/pykd/dbgmem.cpp b/pykd/dbgmem.cpp index f375a2a..fc49961 100644 --- a/pykd/dbgmem.cpp +++ b/pykd/dbgmem.cpp @@ -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 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 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 dbgControl(dbgDataSpace); + addr1 = addr64( addr1 ); addr2 = addr64( addr2 ); std::vector m1(length); std::vector 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() ); } diff --git a/pykd/dbgmem.h b/pykd/dbgmem.h index 1458e7f..413d416 100644 --- a/pykd/dbgmem.h +++ b/pykd/dbgmem.h @@ -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 ); diff --git a/pykd/typedvar.cpp b/pykd/typedvar.cpp index ddf717e..e3da50f 100644 --- a/pykd/typedvar.cpp +++ b/pykd/typedvar.cpp @@ -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; };