mirror of
https://github.com/ivellioscolin/pykd.git
synced 2025-04-29 11:53:23 +08:00
[0.2.x] fixed : print typedVar with invalid address will not raise MemoryException ( ???? printed instead )
git-svn-id: https://pykd.svn.codeplex.com/svn@80770 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
parent
d0c15a75a1
commit
ba2a699ce4
@ -6,6 +6,7 @@ namespace pykd {
|
|||||||
|
|
||||||
ULONG64 addr64( ULONG64 offset );
|
ULONG64 addr64( ULONG64 offset );
|
||||||
void readMemory( ULONG64 offset, PVOID buffer, ULONG length, bool phyAddr = FALSE, ULONG *readed = NULL );
|
void readMemory( ULONG64 offset, PVOID buffer, ULONG length, bool phyAddr = FALSE, ULONG *readed = NULL );
|
||||||
|
bool readMemoryUnsafe( ULONG64 offset, PVOID buffer, ULONG length, bool phyAddr = FALSE, ULONG *readed = NULL );
|
||||||
bool isVaValid( ULONG64 addr );
|
bool isVaValid( ULONG64 addr );
|
||||||
bool compareMemory( ULONG64 addr1, ULONG64 addr2, ULONG length, bool phyAddr = FALSE );
|
bool compareMemory( ULONG64 addr1, ULONG64 addr2, ULONG length, bool phyAddr = FALSE );
|
||||||
|
|
||||||
|
@ -166,10 +166,18 @@ std::string BasicTypedVar::print()
|
|||||||
|
|
||||||
std::string BasicTypedVar::printValue()
|
std::string BasicTypedVar::printValue()
|
||||||
{
|
{
|
||||||
std::stringstream sstr;
|
std::stringstream sstr;
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
sstr << "0x" << boost::apply_visitor( VariantToHex(), getValue() );
|
sstr << "0x" << boost::apply_visitor( VariantToHex(), getValue() );
|
||||||
sstr << " (" << boost::apply_visitor( VariantToStr(), getValue() ) << ")";
|
sstr << " (" << boost::apply_visitor( VariantToStr(), getValue() ) << ")";
|
||||||
|
|
||||||
|
}
|
||||||
|
catch( MemoryException& )
|
||||||
|
{
|
||||||
|
sstr << "????";
|
||||||
|
}
|
||||||
|
|
||||||
return sstr.str();
|
return sstr.str();
|
||||||
}
|
}
|
||||||
@ -205,9 +213,17 @@ std::string PtrTypedVar::print()
|
|||||||
|
|
||||||
std::string PtrTypedVar::printValue()
|
std::string PtrTypedVar::printValue()
|
||||||
{
|
{
|
||||||
std::stringstream sstr;
|
std::stringstream sstr;
|
||||||
|
|
||||||
sstr << "0x" << boost::apply_visitor( VariantToHex(), getValue() );
|
try {
|
||||||
|
|
||||||
|
sstr << "0x" << boost::apply_visitor( VariantToHex(), getValue() );
|
||||||
|
|
||||||
|
}
|
||||||
|
catch( MemoryException& )
|
||||||
|
{
|
||||||
|
sstr << "????";
|
||||||
|
}
|
||||||
|
|
||||||
return sstr.str();
|
return sstr.str();
|
||||||
}
|
}
|
||||||
@ -406,9 +422,16 @@ BaseTypeVariant BitFieldVar::getValue()
|
|||||||
std::string BitFieldVar::printValue()
|
std::string BitFieldVar::printValue()
|
||||||
{
|
{
|
||||||
std::stringstream sstr;
|
std::stringstream sstr;
|
||||||
|
|
||||||
sstr << "0x" << boost::apply_visitor( VariantToHex(), getValue() );
|
try
|
||||||
sstr << " (" << boost::apply_visitor( VariantToStr(), getValue() ) << ")";
|
{
|
||||||
|
sstr << "0x" << boost::apply_visitor( VariantToHex(), getValue() );
|
||||||
|
sstr << " (" << boost::apply_visitor( VariantToStr(), getValue() ) << ")";
|
||||||
|
}
|
||||||
|
catch( MemoryException& )
|
||||||
|
{
|
||||||
|
sstr << "????";
|
||||||
|
}
|
||||||
|
|
||||||
return sstr.str();
|
return sstr.str();
|
||||||
}
|
}
|
||||||
@ -442,23 +465,31 @@ std::string EnumTypedVar::printValue()
|
|||||||
{
|
{
|
||||||
std::stringstream sstr;
|
std::stringstream sstr;
|
||||||
|
|
||||||
ULONG val = boost::apply_visitor( VariantToULong(), getValue() );
|
try {
|
||||||
|
|
||||||
for ( ULONG i = 0; i < m_typeInfo->getFieldCount(); ++i )
|
ULONG val = boost::apply_visitor( VariantToULong(), getValue() );
|
||||||
{
|
|
||||||
ULONG val1 = boost::apply_visitor( VariantToULong(), m_typeInfo->getFieldByIndex(i)->getValue() );
|
|
||||||
|
|
||||||
if ( val == val1 )
|
for ( ULONG i = 0; i < m_typeInfo->getFieldCount(); ++i )
|
||||||
{
|
{
|
||||||
sstr << m_typeInfo->getFieldNameByIndex(i);
|
ULONG val1 = boost::apply_visitor( VariantToULong(), m_typeInfo->getFieldByIndex(i)->getValue() );
|
||||||
sstr << "(0x" << std::hex << val << ")";
|
|
||||||
|
if ( val == val1 )
|
||||||
|
{
|
||||||
|
sstr << m_typeInfo->getFieldNameByIndex(i);
|
||||||
|
sstr << "(0x" << std::hex << val << ")";
|
||||||
|
|
||||||
|
return sstr.str();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sstr << "0x" << std::hex << val;
|
||||||
|
sstr << " ( No matching name )";
|
||||||
|
|
||||||
return sstr.str();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
catch( MemoryException& )
|
||||||
sstr << "0x" << std::hex << val;
|
{
|
||||||
sstr << " ( No matching name )";
|
sstr << "????";
|
||||||
|
}
|
||||||
|
|
||||||
return sstr.str();
|
return sstr.str();
|
||||||
}
|
}
|
||||||
|
@ -92,6 +92,33 @@ void readMemory( ULONG64 offset, PVOID buffer, ULONG length, bool phyAddr, ULONG
|
|||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
bool readMemoryUnsafe( ULONG64 offset, PVOID buffer, ULONG length, bool phyAddr, ULONG *readed )
|
||||||
|
{
|
||||||
|
PyThread_StateRestore pyThreadRestore( g_dbgEng->pystate );
|
||||||
|
|
||||||
|
HRESULT hres;
|
||||||
|
if ( phyAddr == false )
|
||||||
|
{
|
||||||
|
offset = addr64NoSafe( offset );
|
||||||
|
|
||||||
|
// workitem/10473 workaround
|
||||||
|
ULONG64 nextAddress;
|
||||||
|
hres = g_dbgEng->dataspace->GetNextDifferentlyValidOffsetVirtual( offset, &nextAddress );
|
||||||
|
|
||||||
|
DBG_UNREFERENCED_LOCAL_VARIABLE(nextAddress);
|
||||||
|
|
||||||
|
hres = g_dbgEng->dataspace->ReadVirtual( offset, buffer, length, readed );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
hres = g_dbgEng->dataspace->ReadPhysical( offset, buffer, length, readed );
|
||||||
|
}
|
||||||
|
|
||||||
|
return hres == S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
std::string loadCStr( ULONG64 offset )
|
std::string loadCStr( ULONG64 offset )
|
||||||
{
|
{
|
||||||
PyThread_StateRestore pyThreadRestore( g_dbgEng->pystate );
|
PyThread_StateRestore pyThreadRestore( g_dbgEng->pystate );
|
||||||
|
@ -238,7 +238,12 @@ class TypedVarTest( unittest.TestCase ):
|
|||||||
self.assertTrue( str(target.module.typedVar( "g_voidPtr" ) ) )
|
self.assertTrue( str(target.module.typedVar( "g_voidPtr" ) ) )
|
||||||
self.assertTrue( str(target.module.typedVar( "g_arrOfPtrToFunc" ) ) )
|
self.assertTrue( str(target.module.typedVar( "g_arrOfPtrToFunc" ) ) )
|
||||||
self.assertTrue( str(target.module.typedVar( "g_unTypedPtrToFunction" ) ) )
|
self.assertTrue( str(target.module.typedVar( "g_unTypedPtrToFunction" ) ) )
|
||||||
|
|
||||||
|
def testNotValidPrint(self):
|
||||||
|
types = ("structTest", ) #, "ULong[100]", "Ulong*" )
|
||||||
|
for ti in types:
|
||||||
|
self.assertTrue( str(pykd.typedVar( target.module.type(ti), 0 ) ) )
|
||||||
|
|
||||||
def testStaticField(self):
|
def testStaticField(self):
|
||||||
tv = pykd.typedVar( "g_classChild" )
|
tv = pykd.typedVar( "g_classChild" )
|
||||||
self.assertEqual( 200, tv.m_staticField )
|
self.assertEqual( 200, tv.m_staticField )
|
||||||
|
Loading…
Reference in New Issue
Block a user