[~] updated : __str__ method for typedVar class

git-svn-id: https://pykd.svn.codeplex.com/svn@60649 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
SND\kernelnet_cp 2011-01-24 14:13:02 +00:00
parent afb977d03b
commit b61ac0b10a
4 changed files with 112 additions and 3 deletions

View File

@ -339,6 +339,76 @@ loadAnsiStr( ULONG64 address )
return boost::python::object( "" );
}
///////////////////////////////////////////////////////////////////////////////////
bool
loadCStrToBuffer( ULONG64 address, PCHAR buffer, ULONG bufferLen )
{
address = addr64( address );
try {
HRESULT hres =
dbgExt->dataSpaces4->ReadMultiByteStringVirtual(
address,
bufferLen,
buffer,
bufferLen/sizeof(CHAR),
NULL );
if ( FAILED( hres ) )
return false;
return true;
}
catch( std::exception &e )
{
dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "pykd error: %s\n", e.what() );
}
catch(...)
{
dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "pykd unexpected error\n" );
}
return false;
}
///////////////////////////////////////////////////////////////////////////////////
bool
loadWStrToBuffer( ULONG64 address, PWCHAR buffer, ULONG bufferLen )
{
address = addr64( address );
try {
HRESULT hres =
dbgExt->dataSpaces4->ReadUnicodeStringVirtualWide(
address,
bufferLen,
buffer,
bufferLen/sizeof(WCHAR),
NULL );
if ( FAILED( hres ) )
return false;
return true;
}
catch( std::exception &e )
{
dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "pykd error: %s\n", e.what() );
}
catch(...)
{
dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "pykd unexpected error\n" );
}
return false;
}
///////////////////////////////////////////////////////////////////////////////////
boost::python::object
@ -423,6 +493,7 @@ loadWStr( ULONG64 address )
return strObj;
}
///////////////////////////////////////////////////////////////////////////////////
boost::python::object

View File

@ -68,9 +68,15 @@ loadAnsiStr( ULONG64 address );
boost::python::object
loadCStr( ULONG64 address );
bool
loadCStrToBuffer( ULONG64 address, PCHAR buffer, ULONG bufferLen );
boost::python::object
loadWStr( ULONG64 address );
bool
loadWStrToBuffer( ULONG64 address, PWCHAR buffer, ULONG bufferLen );
bool
compareMemory( ULONG64 addr1, ULONG64 addr2, ULONG length, BOOLEAN phyAddr = FALSE );

View File

@ -431,7 +431,7 @@ typedVarClass::print() const
{
sstr << "\t" << hex << "+" << field->offset << " " << field->name << " ";
if ( field->type.isComplex() )
if ( field->type.isComplex() && !field->type.isPtr())
sstr << field->type.name();
else
{
@ -447,8 +447,35 @@ typedVarClass::print() const
{
unsigned __int64 val = boost::python::extract<unsigned __int64>( attr );
sstr << hex << "0x" << val << dec << " ( " << val << " )";
}
sstr << hex << "0x" << val;
if ( field->type.name() == "char*" )
{
char buf[0x100];
if ( loadCStrToBuffer( val, buf, sizeof(buf) ) )
sstr << " (" << buf << " )";
else
sstr << " ( read string error )";
}
else if ( field->type.name() == "unsigned short*" )
{
wchar_t wbuf[0x100];
if ( loadWStrToBuffer( val, wbuf, sizeof(wbuf) ) )
{
char mbBuf[0x100] = { 0 };
WideCharToMultiByte( CP_ACP, 0, wbuf, wcslen(wbuf)+1, mbBuf, sizeof(mbBuf), NULL, NULL );
sstr << " (" << mbBuf << " )";
}
else
sstr << " ( read string error )";
}
else
{
sstr << dec << " ( " << val << " )";
}
}
}
else
{

View File

@ -106,6 +106,11 @@ public:
return !m_baseType;
}
bool
isPtr() const {
return m_pointer;
}
private:
static TypeInfoMap g_typeInfoCache;