mirror of
https://github.com/ivellioscolin/pykd.git
synced 2025-04-21 12:53:23 +08:00
[0.2.x] fixed: pykd may crash by calling API routines with typeInfo = None
git-svn-id: https://pykd.svn.codeplex.com/svn@82314 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
parent
23244e1eb8
commit
45cc9ea644
@ -12,6 +12,9 @@ namespace pykd {
|
||||
|
||||
TypedVarPtr TypedVar::getTypedVar( const TypeInfoPtr& typeInfo, VarDataPtr varData )
|
||||
{
|
||||
if ( !typeInfo )
|
||||
throw DbgException( "typeInfo can not be None" );
|
||||
|
||||
TypedVarPtr tv;
|
||||
|
||||
if ( typeInfo->isBasicType() )
|
||||
@ -546,6 +549,9 @@ TypedVarPtr containingRecordByName( ULONG64 offset, const std::string &typeName,
|
||||
|
||||
TypedVarPtr containingRecordByType( ULONG64 addr, const TypeInfoPtr &typeInfo, const std::string &fieldName )
|
||||
{
|
||||
if ( !typeInfo )
|
||||
throw DbgException( "typeInfo can not be None" );
|
||||
|
||||
addr = addr64(addr);
|
||||
|
||||
VarDataPtr varData = VarDataMemory::factory( addr - typeInfo->getFieldOffsetByNameRecursive(fieldName) );
|
||||
@ -571,6 +577,9 @@ python::list getTypedVarListByTypeName( ULONG64 listHeadAddress, const std::stri
|
||||
|
||||
python::list getTypedVarListByType( ULONG64 listHeadAddress, const TypeInfoPtr &typeInfo, const std::string &listEntryName )
|
||||
{
|
||||
if ( !typeInfo )
|
||||
throw DbgException( "typeInfo can not be None" );
|
||||
|
||||
python::list lst;
|
||||
|
||||
listHeadAddress = addr64( listHeadAddress );
|
||||
@ -613,6 +622,9 @@ python::list getTypedVarArrayByTypeName( ULONG64 addr, const std::string &typeN
|
||||
|
||||
python::list getTypedVarArrayByType( ULONG64 offset, const TypeInfoPtr &typeInfo, ULONG number )
|
||||
{
|
||||
if ( !typeInfo )
|
||||
throw DbgException( "typeInfo can not be None" );
|
||||
|
||||
offset = addr64(offset);
|
||||
|
||||
python::list lst;
|
||||
|
@ -119,6 +119,5 @@ class MemoryTest( unittest.TestCase ):
|
||||
def testLoadDoubles(self):
|
||||
testArray = [ 1.0, 2.0000001, -3.0000004 ];
|
||||
readArray = pykd.loadDoubles( target.module.doubleArray, 3 );
|
||||
print readArray
|
||||
for i in range(0,3):
|
||||
self.assertTrue( math.fabs( testArray[i] - readArray[i] ) < 0.0000001 )
|
||||
|
@ -45,13 +45,13 @@ def getTestSuite( singleName = "" ):
|
||||
unittest.TestLoader().loadTestsFromTestCase( moduletest.ModuleTest ),
|
||||
unittest.TestLoader().loadTestsFromTestCase( memtest.MemoryTest ),
|
||||
unittest.TestLoader().loadTestsFromTestCase( typeinfo.TypeInfoTest ),
|
||||
#unittest.TestLoader().loadTestsFromTestCase( typedvar.TypedVarTest ),
|
||||
unittest.TestLoader().loadTestsFromTestCase( typedvar.TypedVarTest ),
|
||||
unittest.TestLoader().loadTestsFromTestCase( regtest.CpuRegTest ),
|
||||
unittest.TestLoader().loadTestsFromTestCase( customtypestest.CustomTypesTest ),
|
||||
# ^^^
|
||||
unittest.TestLoader().loadTestsFromTestCase( TerminateProcessTest ),
|
||||
|
||||
#unittest.TestLoader().loadTestsFromTestCase( localstest.LocalVarsTest ),
|
||||
unittest.TestLoader().loadTestsFromTestCase( localstest.LocalVarsTest ),
|
||||
unittest.TestLoader().loadTestsFromTestCase( ehexcepttest.EhExceptionTest ),
|
||||
] )
|
||||
else:
|
||||
@ -71,3 +71,7 @@ if __name__ == "__main__":
|
||||
#print "Test module: %s" % target.appPath
|
||||
|
||||
unittest.TextTestRunner(stream=sys.stdout, verbosity=2).run( getTestSuite() )
|
||||
#unittest.TextTestRunner(stream=sys.stdout, verbosity=2).run( getTestSuite("typedvar.TypedVarTest.testAmbiguousFieldAccess") )
|
||||
|
||||
raw_input(">")
|
||||
#
|
@ -311,5 +311,8 @@ class TypedVarTest( unittest.TestCase ):
|
||||
lst.append(entry)
|
||||
entry = entry.deref().Flink
|
||||
|
||||
|
||||
|
||||
def testWrongArgs(self):
|
||||
self.assertRaises( pykd.BaseException, pykd.typedVar, None, 0 )
|
||||
self.assertRaises( pykd.BaseException, pykd.typedVarList, target.module.g_listHead1, None, "next" )
|
||||
self.assertRaises( pykd.BaseException, pykd.typedVarArray, target.module.g_testArray, None, 2 )
|
||||
self.assertRaises( pykd.BaseException, pykd.containingRecord, target.module.offset( "g_structTest" ), None, "m_field2" )
|
||||
|
Loading…
Reference in New Issue
Block a user