I'm trying to implement managed debugger looking at MDBG sample. Currently I'm stuck trying to get base class hierarchy methods using IMetaDataImport.
EnumMethods, that I'm using, enumerates MethodDef tokens representing methods of the specified type. But I want to enumerate all the methods in class hierarchy. To do that I'm using GetTypeDefProps, that returns ptkExtends, which is token representing the base class. The problem is that base class could be represented by TypeDef, TypeRef or TypeSpec.
How can I get base class TypeDef from relative TypeSpec?
I've read ECMA part II specifications, but it didn't help me a lot...
Here is what I got so far:
int size;
TypeAttributes pdwTypeDefFlags;
m_importer.GetTypeDefProps(m_typeToken,
null,
0,
out size,
out pdwTypeDefFlags,
out ptkExtends
);
//ptkExtends is correct TypeSpec token
IntPtr ppvSig;
uint pcbSig;
m_importer.GetTypeSpecFromToken(ptkExtends, out ppvSig, out pcbSig);
//I'm getting the TypeSpec Blob signature in ppvSig, how to use it to get TypeDef?!