[0.1.x] added : loadPtrList routine ( instead of loadLinkedList )

[0.1.x] added : loadPtrArray routine ( intead of loadPtrs )

git-svn-id: https://pykd.svn.codeplex.com/svn@72618 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
SND\kernelnet_cp 2011-12-22 08:17:27 +00:00 committed by Mikhail I. Izmestev
parent 8c1103f19b
commit 5b45c22301
6 changed files with 64 additions and 7 deletions

View File

@ -156,6 +156,10 @@ public:
std::wstring loadUnicodeStr( ULONG64 address );
python::list loadPtrList( ULONG64 address );
python::list loadPtrArray( ULONG64 address, ULONG number );
ULONG ptrSize();
ULONG64 ptrByte( ULONG64 offset );

View File

@ -210,7 +210,11 @@ BOOST_PYTHON_MODULE( pykd )
.def( "loadUnicodeString", &DebugClient::loadUnicodeStr,
"Return string represention of windows UNICODE_STRING type" )
.def( "loadAnsiString", &DebugClient::loadAnsiStr,
"Return string represention of windows ANSU_STRING type" )
"Return string represention of windows ANSI_STRING type" )
.def( "loadPtrList", &DebugClient::loadPtrList,
"Return list of pointers, each points to next" )
.def( "loadPtrArray", &DebugClient::loadPtrArray,
"Read the block of the target's memory and return it as a list of pointers" )
.def( "ptrByte", &DebugClient::ptrByte,
"Read an unsigned 1-byte integer from the target memory" )
.def( "ptrWord", &DebugClient::ptrWord,
@ -350,6 +354,10 @@ BOOST_PYTHON_MODULE( pykd )
"Return string represention of windows UNICODE_STRING type" );
python::def( "loadAnsiString", &loadAnsiStr,
"Return string represention of windows ANSU_STRING type" );
python::def( "loadPtrList", &loadPtrList,
"Return list of pointers, each points to next" );
python::def( "loadPtrArray", &loadPtrArray,
"Read the block of the target's memory and return it as a list of pointers" );
python::def( "ptrByte", &ptrByte,
"Read an unsigned 1-byte integer from the target memory" );
python::def( "ptrWord", &ptrWord,

View File

@ -623,5 +623,36 @@ std::string loadAnsiStr( ULONG64 address )
/////////////////////////////////////////////////////////////////////////////////////
python::list DebugClient::loadPtrList( ULONG64 address )
{
ULONG64 entryAddress = 0;
python::list lst;
for( entryAddress = ptrPtr( address ); entryAddress != address && entryAddress != 0; entryAddress = ptrPtr( entryAddress ) )
lst.append( entryAddress );
return lst;
}
python::list loadPtrList( ULONG64 address )
{
return g_dbgClient->loadPtrList( address );
}
/////////////////////////////////////////////////////////////////////////////////////
python::list DebugClient::loadPtrArray( ULONG64 address, ULONG number )
{
return ptrSize() == 8 ? loadQWords( address, number ) : loadDWords( address, number );
}
python::list loadPtrArray( ULONG64 address, ULONG number )
{
return g_dbgClient->loadPtrArray( address, number );
}
/////////////////////////////////////////////////////////////////////////////////////
}; // end of pykd

View File

@ -86,6 +86,10 @@ std::wstring loadUnicodeStr( ULONG64 address );
std::string loadAnsiStr( ULONG64 address );
python::list loadPtrList( ULONG64 address );
python::list loadPtrArray( ULONG64 address, ULONG number );
///////////////////////////////////////////////////////////////////////////////////
};

View File

@ -46,9 +46,7 @@ class BaseTest( unittest.TestCase ):
self.assertTrue( hasattr(pykd, 'loadChars') )
self.assertTrue( hasattr(pykd, 'loadDWords') )
self.assertTrue( hasattr(pykd, 'loadDump') )
self.assertTrue( hasattr(pykd, 'loadLinkedList') )
self.assertTrue( hasattr(pykd, 'loadModule') )
self.assertTrue( hasattr(pykd, 'loadPtrs') )
self.assertTrue( hasattr(pykd, 'loadQWords') )
self.assertTrue( hasattr(pykd, 'loadSignBytes') )
self.assertTrue( hasattr(pykd, 'loadSignDWords') )
@ -106,10 +104,12 @@ class BaseTest( unittest.TestCase ):
self.assertFalse( hasattr(pykd, 'cpuReg') )
self.assertFalse( hasattr(pykd, 'dbgModuleClass') )
self.assertFalse( hasattr(pykd, 'dbgStackFrameClass') )
self.assertFalse( hasattr(pykd, 'debugEvent') )
self.assertFalse( hasattr(pykd, 'findModule') )
self.assertFalse( hasattr(pykd, 'debugEvent') )
self.assertFalse( hasattr(pykd, 'findModule') )
self.assertFalse( hasattr(pykd, 'loadLinkedList') )
self.assertFalse( hasattr(pykd, 'loadPtrs') )
self.assertFalse( hasattr(pykd, 'windbgIn') )
self.assertFalse( hasattr(pykd, 'windbgOut') )
self.assertFalse( hasattr(pykd, 'windbgOut') )
def testNewAddededApi( self ):
""" Branch test: new API 0.1.x what must be available """
@ -118,6 +118,8 @@ class BaseTest( unittest.TestCase ):
self.assertTrue( hasattr(pykd, 'getDebuggeeType' ) )
self.assertTrue( hasattr(pykd, 'getExecutionStatus' ) )
self.assertTrue( hasattr(pykd, 'loadExt') )
self.assertTrue( hasattr(pykd, 'loadPtrList') )
self.assertTrue( hasattr(pykd, 'loadPtrArray') )
self.assertTrue( hasattr(pykd, 'setExecutionStatus') )
self.assertTrue( hasattr(pykd, 'waitForEvent') )

View File

@ -86,4 +86,12 @@ class MemoryTest( unittest.TestCase ):
self.assertTrue( pykd.isValid( target.module.begin() ) )
self.assertFalse( pykd.isValid( 0 ) )
self.assertFalse( pykd.isValid( 0xDEADBEAF ) )
def testPtrList( self ):
lst = pykd.loadPtrList( target.module.g_listHead )
self.assertEqual( 3, len( lst ) )
def testPtrArray( self ):
lst = pykd.loadPtrArray( target.module.arrIntMatrixPtrs, 3 )
self.assertEqual( 3, len( lst ) )