mirror of
https://github.com/ivellioscolin/pykd.git
synced 2025-04-20 19:53:22 +08:00
[0.1.x] added : loadUnicodeStr routine
[0.1.x] added : loadAnsiStr routine git-svn-id: https://pykd.svn.codeplex.com/svn@72369 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
parent
1e2374d73b
commit
789b00119a
@ -152,6 +152,10 @@ public:
|
||||
|
||||
std::wstring loadWStr( ULONG64 offset );
|
||||
|
||||
std::string loadAnsiStr( ULONG64 address );
|
||||
|
||||
std::wstring loadUnicodeStr( ULONG64 address );
|
||||
|
||||
ULONG ptrSize();
|
||||
|
||||
ULONG64 ptrByte( ULONG64 offset );
|
||||
|
@ -207,6 +207,10 @@ BOOST_PYTHON_MODULE( pykd )
|
||||
"Load string from the target buffer containing 0-terminated ansi-string" )
|
||||
.def( "loadWStr", &DebugClient::loadWStr,
|
||||
"Load string from the target buffer containing 0-terminated unicode-string" )
|
||||
.def( "loadUnicodeString", &DebugClient::loadUnicodeStr,
|
||||
"Return string represention of windows UNICODE_STRING type" )
|
||||
.def( "loadAnsiString", &DebugClient::loadAnsiStr,
|
||||
"Return string represention of windows ANSU_STRING type" )
|
||||
.def( "ptrByte", &DebugClient::ptrByte,
|
||||
"Read an unsigned 1-byte integer from the target memory" )
|
||||
.def( "ptrWord", &DebugClient::ptrWord,
|
||||
@ -342,6 +346,10 @@ BOOST_PYTHON_MODULE( pykd )
|
||||
"Load string from the target buffer containing 0-terminated ansi-string" );
|
||||
python::def( "loadWStr", &loadWStr,
|
||||
"Load string from the target buffer containing 0-terminated unicode-string" );
|
||||
python::def( "loadUnicodeString", &loadUnicodeStr,
|
||||
"Return string represention of windows UNICODE_STRING type" );
|
||||
python::def( "loadAnsiString", &loadAnsiStr,
|
||||
"Return string represention of windows ANSU_STRING type" );
|
||||
python::def( "ptrByte", &ptrByte,
|
||||
"Read an unsigned 1-byte integer from the target memory" );
|
||||
python::def( "ptrWord", &ptrWord,
|
||||
|
@ -526,5 +526,102 @@ bool compareMemory( ULONG64 addr1, ULONG64 addr2, ULONG length, bool phyAddr )
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
std::wstring DebugClient::loadUnicodeStr( ULONG64 address )
|
||||
{
|
||||
USHORT length;
|
||||
USHORT maximumLength;
|
||||
ULONG64 buffer = 0;
|
||||
|
||||
readMemory( m_dataSpaces, address, &length, sizeof( length ) );
|
||||
|
||||
if ( length == 0 )
|
||||
return L"";
|
||||
|
||||
address += sizeof( length );
|
||||
|
||||
readMemory( m_dataSpaces, address, &maximumLength, sizeof( maximumLength ) );
|
||||
|
||||
address += sizeof( maximumLength );
|
||||
|
||||
if ( is64bitSystem() )
|
||||
{
|
||||
address += address % 8 ? ( 8 - address % 8 ) : 0 ; // âûðàâíèâàíèå íà 8 áàéò
|
||||
|
||||
buffer = ptrPtr( address );
|
||||
|
||||
address += 8;
|
||||
}
|
||||
else
|
||||
{
|
||||
address += address % 4 ? ( 4 - address % 4 ) : 0 ; // âûðàâíèâàíèå íà 8 áàéò
|
||||
|
||||
buffer = addr64( ptrPtr( address ) );
|
||||
|
||||
address += 4;
|
||||
}
|
||||
|
||||
std::vector<wchar_t> str(length / 2);
|
||||
|
||||
readMemory( m_dataSpaces, buffer, &str[0], length );
|
||||
|
||||
return std::wstring (&str[0], length/2);
|
||||
}
|
||||
|
||||
std::wstring loadUnicodeStr( ULONG64 address )
|
||||
{
|
||||
return g_dbgClient->loadUnicodeStr( address );
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
std::string DebugClient::loadAnsiStr( ULONG64 address )
|
||||
{
|
||||
USHORT length;
|
||||
USHORT maximumLength;
|
||||
ULONG64 buffer = 0;
|
||||
|
||||
readMemory( m_dataSpaces, address, &length, sizeof( length ) );
|
||||
|
||||
if ( length == 0 )
|
||||
return "";
|
||||
|
||||
address += sizeof( length );
|
||||
|
||||
readMemory( m_dataSpaces, address, &maximumLength, sizeof( maximumLength ) );
|
||||
|
||||
address += sizeof( maximumLength );
|
||||
|
||||
if ( is64bitSystem() )
|
||||
{
|
||||
address += address % 8 ? ( 8 - address % 8 ) : 0 ; // âûðàâíèâàíèå íà 8 áàéò
|
||||
|
||||
buffer = ptrPtr( address );
|
||||
|
||||
address += 8;
|
||||
}
|
||||
else
|
||||
{
|
||||
address += address % 4 ? ( 4 - address % 4 ) : 0 ; // âûðàâíèâàíèå íà 8 áàéò
|
||||
|
||||
buffer = addr64( ptrPtr( address ) );
|
||||
|
||||
address += 4;
|
||||
}
|
||||
|
||||
std::vector<char> str(length);
|
||||
|
||||
readMemory( m_dataSpaces, buffer, &str[0], length );
|
||||
|
||||
return std::string (&str[0], length);
|
||||
}
|
||||
|
||||
|
||||
std::string loadAnsiStr( ULONG64 address )
|
||||
{
|
||||
return g_dbgClient->loadAnsiStr( address );
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
}; // end of pykd
|
||||
|
||||
|
@ -82,6 +82,10 @@ ULONG64 ptrPtr( ULONG64 offset, IDebugDataSpaces4* dbgDataSpace );
|
||||
bool
|
||||
compareMemory( ULONG64 addr1, ULONG64 addr2, ULONG length, bool phyAddr = FALSE );
|
||||
|
||||
std::wstring loadUnicodeStr( ULONG64 address );
|
||||
|
||||
std::string loadAnsiStr( ULONG64 address );
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
};
|
||||
|
@ -53,8 +53,8 @@ END
|
||||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 0,1,0,0
|
||||
PRODUCTVERSION 0,1,0,0
|
||||
FILEVERSION 0,1,0,1
|
||||
PRODUCTVERSION 0,1,0,1
|
||||
FILEFLAGSMASK 0x17L
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
@ -70,11 +70,11 @@ BEGIN
|
||||
BLOCK "041904b0"
|
||||
BEGIN
|
||||
VALUE "FileDescription", "pykd - python extension for windbg"
|
||||
VALUE "FileVersion", "0, 1, 0, 0"
|
||||
VALUE "FileVersion", "0, 1, 0, 1"
|
||||
VALUE "InternalName", "pykd"
|
||||
VALUE "OriginalFilename", "pykd.dll"
|
||||
VALUE "ProductName", "pykd - python extension for windbg"
|
||||
VALUE "ProductVersion", "0, 1, 0, 0"
|
||||
VALUE "ProductVersion", "0, 1, 0, 1"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
|
@ -149,7 +149,6 @@ listStruct1 g_listItem13 = { 300 };
|
||||
_EX_ListHead->Blink = (Entry);\
|
||||
}
|
||||
|
||||
|
||||
void FuncWithName0()
|
||||
{
|
||||
classChild _classChild;
|
||||
@ -180,6 +179,11 @@ void FuncWithName0()
|
||||
std::cout << strArray[0];
|
||||
std::cout << (*ptrIntMatrix)[0][1];
|
||||
std::cout << g_struct3.m_noArrayField;
|
||||
std::cout << g_structWithBits.m_bit5;
|
||||
std::cout << ptrStrArray;
|
||||
std::cout << g_structTest1.m_field2;
|
||||
std::cout << ptrIntMatrix1;
|
||||
std::cout << g_bigValue;
|
||||
}
|
||||
|
||||
void FuncWithName1(int a)
|
||||
|
Loading…
Reference in New Issue
Block a user