diff --git a/pykd/typedvar.cpp b/pykd/typedvar.cpp index d4a77fb..9cf0cd7 100644 --- a/pykd/typedvar.cpp +++ b/pykd/typedvar.cpp @@ -149,7 +149,10 @@ BaseTypeVariant BasicTypedVar::getValue() if ( m_typeInfo->getName() == "Bool" ) return *(bool*)&val; - + + if ( m_typeInfo->getName() == "Hresult" ) + return *(PULONG)&val; + throw DbgException( "failed get value " ); } diff --git a/pykd/typeinfo.cpp b/pykd/typeinfo.cpp index 3b387b6..a47827c 100644 --- a/pykd/typeinfo.cpp +++ b/pykd/typeinfo.cpp @@ -252,7 +252,7 @@ TypeInfoPtr TypeInfo::getTypeInfo( SymbolPtr &symScope, const std::string &symN ///////////////////////////////////////////////////////////////////////////////////// -static const boost::regex baseMatch("^(Char)|(WChar)|(Int1B)|(UInt1B)|(Int2B)|(UInt2B)|(Int4B)|(UInt4B)|(Int8B)|(UInt8B)|(Long)|(ULong)|(Float)|(Bool)|(Double)$" ); +static const boost::regex baseMatch("^(Char)|(WChar)|(Int1B)|(UInt1B)|(Int2B)|(UInt2B)|(Int4B)|(UInt4B)|(Int8B)|(UInt8B)|(Long)|(ULong)|(Float)|(Bool)|(Double)|(Hresult)$" ); bool TypeInfo::isBaseType( const std::string &symName ) @@ -313,6 +313,9 @@ TypeInfo::getBaseTypeInfo( const std::string &symName, ULONG pointerSize ) if ( baseMatchResult[15].matched ) return TypeInfoPtr( new TypeInfoWrapper<double>("Double", pointerSize) ); + + if ( baseMatchResult[16].matched ) + return TypeInfoPtr( new TypeInfoWrapper<unsigned long>("Hresult", pointerSize) ); } return TypeInfoPtr(); diff --git a/test/scripts/typedvar.py b/test/scripts/typedvar.py index a11edeb..d3234b0 100644 --- a/test/scripts/typedvar.py +++ b/test/scripts/typedvar.py @@ -323,3 +323,7 @@ class TypedVarTest( unittest.TestCase ): 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" ) + + def testHresult(self): + tv = pykd.typedVar( "g_atlException" ) + self.assertEqual( tv.m_hr, 0x8000FFFF ) diff --git a/test/scripts/typeinfo.py b/test/scripts/typeinfo.py index 67bd6f4..a03fabb 100644 --- a/test/scripts/typeinfo.py +++ b/test/scripts/typeinfo.py @@ -192,7 +192,7 @@ class TypeInfoTest( unittest.TestCase ): self.assertTrue( str(target.module.type( "g_voidPtr" ) ) ) self.assertTrue( str(target.module.type( "g_arrOfPtrToFunc" ) ) ) self.assertTrue( str(target.module.type( "g_unTypedPtrToFunction" ) ) ) - + def testTypedef(self): self.assertEqual( "structTest", pykd.typeInfo( "g_structTypeDef" ).name() ) self.assertEqual( "structTest", pykd.typeInfo( "structTestTypeDef" ).name() ) @@ -213,21 +213,20 @@ class TypeInfoTest( unittest.TestCase ): self.assertEqual( 5, len(ti) ) for field in ti: str( field ) - + def testStructNullSize(self): ti = target.module.type("structNullSize") self.assertEqual( 0, len(ti) ) - + def testDerefName(self): entry = pykd.typedVar("entry1").Flink self.assertEqual( "_LIST_ENTRY*", entry.type().name() ) - - def testPtrTo(self): + + def testPtrTo(self): ti = pykd.typeInfo("UInt8B").ptrTo() self.assertTrue( "UInt8B*", ti.name() ) self.assertNotEqual( 0, ti.size() ) - + def testArrayOf(self): ti = pykd.typeInfo("UInt8B").arrayOf(10) - self.assertTrue( "UInt8B[10]", ti.name() ) - + self.assertTrue( "UInt8B[10]", ti.name() ) diff --git a/test/targetapp/targetapp.cpp b/test/targetapp/targetapp.cpp index 043cbd2..92f4688 100644 --- a/test/targetapp/targetapp.cpp +++ b/test/targetapp/targetapp.cpp @@ -1,7 +1,7 @@ #include "stdafx.h" #include <intrin.h> - +#include <atlexcept.h> #include <iostream> #include <string> @@ -206,7 +206,7 @@ struct struct3 { struct3 g_struct3 = { { 0, 2 }, 3 }; __int64 g_bigValue = 0x8080808080808080; - +volatile ATL::CAtlException g_atlException(E_UNEXPECTED); static LIST_ENTRY g_listHead; @@ -437,7 +437,7 @@ void FuncWithName0() std::cout << g_charValue; std::cout << g_shortValue; std::cout << g_longValue; - std::cout << g_longlongValue; + std::cout << g_longlongValue << g_atlException.m_hr; std::cout << g_structTest.m_field0; std::cout << g_testArray[1].m_field3;