mirror of
https://github.com/ivellioscolin/pykd.git
synced 2025-04-29 11:53:23 +08:00
[0.1.x] + pointer to unknown/unsupported type (f.e. pointer to function)
git-svn-id: https://pykd.svn.codeplex.com/svn@73298 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
parent
7532741252
commit
eceba31ad4
@ -10,7 +10,8 @@ TypeInfoPtr TypeInfo::getTypeInfo( pyDia::SymbolPtr &typeSym )
|
||||
{
|
||||
ULONG tag = typeSym->getSymTag();
|
||||
|
||||
switch( typeSym->getSymTag() )
|
||||
const ULONG symTag = typeSym->getSymTag();
|
||||
switch( symTag )
|
||||
{
|
||||
case SymTagBaseType:
|
||||
return getBaseTypeInfo( typeSym );
|
||||
@ -219,7 +220,14 @@ BitFieldTypeInfo::BitFieldTypeInfo( pyDia::SymbolPtr &symbol )
|
||||
|
||||
PointerTypeInfo::PointerTypeInfo( pyDia::SymbolPtr &symbol )
|
||||
{
|
||||
m_derefType = TypeInfo::getTypeInfo( symbol->getType() );
|
||||
try
|
||||
{
|
||||
m_derefType = TypeInfo::getTypeInfo( symbol->getType() );
|
||||
}
|
||||
catch (const SymbolException &)
|
||||
{
|
||||
m_derefType.swap( TypeInfoPtr() );
|
||||
}
|
||||
m_size = (ULONG)symbol->getSize();
|
||||
}
|
||||
|
||||
@ -227,7 +235,14 @@ PointerTypeInfo::PointerTypeInfo( pyDia::SymbolPtr &symbol )
|
||||
|
||||
PointerTypeInfo::PointerTypeInfo( pyDia::SymbolPtr &symScope, const std::string &symName )
|
||||
{
|
||||
m_derefType = TypeInfo::getTypeInfo( symScope, symName );
|
||||
try
|
||||
{
|
||||
m_derefType = TypeInfo::getTypeInfo( symScope, symName );
|
||||
}
|
||||
catch (const SymbolException &)
|
||||
{
|
||||
m_derefType.swap( TypeInfoPtr() );
|
||||
}
|
||||
m_size = (symScope->getMachineType() == IMAGE_FILE_MACHINE_AMD64) ? 8 : 4;
|
||||
}
|
||||
|
||||
|
@ -285,10 +285,14 @@ public:
|
||||
}
|
||||
|
||||
virtual TypeInfoPtr deref() {
|
||||
if (!m_derefType)
|
||||
throw TypeException("<ptr>", "this pointer can not be dereferenced");
|
||||
return m_derefType;
|
||||
}
|
||||
|
||||
TypeInfoPtr getDerefType() {
|
||||
if (!m_derefType)
|
||||
throw TypeException("<ptr>", "this pointer can not be dereferenced");
|
||||
return m_derefType;
|
||||
}
|
||||
|
||||
|
@ -168,3 +168,13 @@ class TypedVarTest( unittest.TestCase ):
|
||||
tv = target.module.typedVar( "g_unNamedStruct" )
|
||||
self.assertEqual( 4, tv.m_fieldNestedStruct )
|
||||
self.assertEqual( 5, tv.m_fieldOfUnNamed )
|
||||
|
||||
def testPointerToFunction( self ):
|
||||
tv1 = target.module.typedVar( "g_unTypedPtrToFunction" )
|
||||
self.assertEqual( target.module.offset("EnumWindowsProc2"), tv1 )
|
||||
|
||||
tv2 = target.module.typedVar( "g_unTypedPtrToFunction" )
|
||||
self.assertEqual( tv1, tv2 )
|
||||
|
||||
self.assertRaises( pykd.TypeException, tv1.deref )
|
||||
self.assertRaises( pykd.TypeException, tv2.deref )
|
||||
|
@ -214,6 +214,8 @@ struct StructWithNested {
|
||||
StructWithNested g_structWithNested;
|
||||
StructWithNested::Nested g_structNested;
|
||||
|
||||
WNDENUMPROC g_ptrToFunction;
|
||||
void *g_unTypedPtrToFunction;
|
||||
#pragma pack( pop )
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@ -276,6 +278,7 @@ void FuncWithName0()
|
||||
std::cout << g_classChild.m_enumField;
|
||||
std::cout << g_unNamedStruct.m_fieldNestedStruct;
|
||||
std::cout << g_structNested.m_nestedFiled;
|
||||
std::cout << g_unTypedPtrToFunction;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@ -295,6 +298,7 @@ void FuncWithName1(int a)
|
||||
std::cout << g_string;
|
||||
std::cout << g_unNamedStruct.m_fieldOfUnNamed;
|
||||
std::cout << g_structWithNested.m_field;
|
||||
std::cout << g_ptrToFunction;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@ -392,6 +396,9 @@ int _tmain(int argc, _TCHAR* argv[])
|
||||
g_structWithNested.m_field = 34;
|
||||
g_structNested.m_nestedFiled = 46;
|
||||
|
||||
g_ptrToFunction = &EnumWindowsProc2;
|
||||
g_unTypedPtrToFunction = &EnumWindowsProc2;
|
||||
|
||||
// Let test scripts to execute
|
||||
__debugbreak();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user