From 858c5f2492afce44365d8f00f6bfdbc4c8b39e4a Mon Sep 17 00:00:00 2001 From: "SND\\EreTIk_cp" Date: Wed, 18 Jan 2012 19:14:46 +0000 Subject: [PATCH] [0.1.x] +unnamed struct test git-svn-id: https://pykd.svn.codeplex.com/svn@73285 9b283d60-5439-405e-af05-b73fd8c4d996 --- test/scripts/typedvar.py | 17 +++++++++++------ test/targetapp/targetapp.cpp | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 6 deletions(-) diff --git a/test/scripts/typedvar.py b/test/scripts/typedvar.py index 4aa6929..015342b 100644 --- a/test/scripts/typedvar.py +++ b/test/scripts/typedvar.py @@ -11,7 +11,7 @@ class TypedVarTest( unittest.TestCase ): def testCtor( self ): tv = target.module.typedVar( "structTest", target.module.g_structTest ) tv = target.module.typedVar( "g_structTest" ) - + def testBaseTypes(self): self.assertEqual( 1, target.module.typedVar( "g_ucharValue" ) ) self.assertEqual( 2, target.module.typedVar( "g_ushortValue" ) ) @@ -21,8 +21,8 @@ class TypedVarTest( unittest.TestCase ): self.assertEqual( -2, target.module.typedVar( "g_shortValue" ) ) self.assertEqual( -4, target.module.typedVar( "g_longValue" ) ) self.assertEqual( -8, target.module.typedVar( "g_longlongValue" ) ) - - def testConst(self): + + def testConst(self): try: self.assertEqual( True, target.module.typedVar( "g_constBoolValue" ) ) except pykd.BaseException: @@ -150,16 +150,21 @@ class TypedVarTest( unittest.TestCase ): self.assertEqual( 4, ind ) self.assertTrue( ind in { 1 : "1", 4 : "2" } ) self.assertEqual( "2", { 1 : "1", 4 : "2" }[ind] ) - + def testDeref(self): tv = target.module.typedVar( "g_structTest1" ) self.assertEqual( target.module.g_structTest, tv.m_field4.deref().getAddress() ) - + tv = target.module.typedVar( "g_structTest" ) self.assertEqual( 0, tv.m_field4.deref().getAddress() ) - + try: tv.m_field1.deref() self.assertTrue(False) except pykd.BaseException: pass + + def testUnNamedStruct(self): + tv = target.module.typedVar( "g_unNamedStruct" ) + self.assertEqual( 4, tv.m_fieldNestedStruct ) + self.assertEqual( 5, tv.m_fieldOfUnNamed ) diff --git a/test/targetapp/targetapp.cpp b/test/targetapp/targetapp.cpp index de111e2..4e46ca5 100644 --- a/test/targetapp/targetapp.cpp +++ b/test/targetapp/targetapp.cpp @@ -197,6 +197,13 @@ listStruct1 g_listItem11 = { 100 }; listStruct1 g_listItem12 = { 200 }; listStruct1 g_listItem13 = { 300 }; +struct { + struct { + int m_fieldNestedStruct; + }; + int m_fieldOfUnNamed; +}g_unNamedStruct; + #pragma pack( pop ) //////////////////////////////////////////////////////////////////////////////// @@ -257,6 +264,7 @@ void FuncWithName0() std::cout << ptrIntMatrix1; std::cout << g_bigValue; std::cout << g_classChild.m_enumField; + std::cout << g_unNamedStruct.m_fieldNestedStruct; } //////////////////////////////////////////////////////////////////////////////// @@ -274,6 +282,7 @@ void FuncWithName1(int a) std::cout << _structTest.m_field1; std::cout << _struct2.m_struct.m_field1; std::cout << g_string; + std::cout << g_unNamedStruct.m_fieldOfUnNamed; } //////////////////////////////////////////////////////////////////////////////// @@ -318,6 +327,23 @@ int doLoadUnload() return 0; } +//////////////////////////////////////////////////////////////////////////////// + +int doExeptions() +{ + __debugbreak(); + + PUCHAR _ptr = reinterpret_cast(2); + __try { + *_ptr = 5; + } __except(EXCEPTION_EXECUTE_HANDLER) { + } + + ++_ptr; + *_ptr = 6; + + return 0; +} //////////////////////////////////////////////////////////////////////////////// @@ -348,6 +374,9 @@ int _tmain(int argc, _TCHAR* argv[]) g_childListEntry2.m_next = &g_childListEntry3; g_childListEntry3.m_next = NULL; + g_unNamedStruct.m_fieldNestedStruct = 4; + g_unNamedStruct.m_fieldOfUnNamed = 5; + // Let test scripts to execute __debugbreak(); @@ -363,6 +392,9 @@ int _tmain(int argc, _TCHAR* argv[]) ::EnumWindows(&EnumWindowsProc2, 7); return ERROR_SUCCESS; } + + if ( !_tcsicmp(argv[1], _T("-testExceptions")) ) + return doExeptions(); } __debugbreak();