MDBG サンプルを見てマネージド デバッガーを実装しようとしています。
MDBG は、指定されたスコープ内で関数名を解決できますが、基本クラスを考慮していません。
MDBG はこれを行っています:
/// <summary>
/// Resolves a Function from a Module, Class Name, and Function Name.
/// </summary>
/// <param name="mdbgModule">The Module that has the Function.</param>
/// <param name="className">The name of the Class that has the Function.</param>
/// <param name="functionName">The name of the Function.</param>
/// <returns>The MDbgFunction that matches the given parameters.</returns>
public MDbgFunction ResolveFunctionName(MDbgModule mdbgModule, string className, string functionName) {
...
foreach (MethodInfo mi in t.GetMethods()) {
if (mi.Name.Equals(functionName)) {
func = mdbgModule.GetFunction((mi as MetadataMethodInfo).MetadataToken);
break;
}
}
return func;
}
Type.GetMethods() はオーバーライドされ、この実装があり、IMetaDataImport.EnumMethods を使用します。
public override MethodInfo[] GetMethods(BindingFlags bindingAttr) {
ArrayList al = new ArrayList();
IntPtr hEnum = new IntPtr();
int methodToken;
try {
while (true) {
int size;
m_importer.EnumMethods(ref hEnum, (int) m_typeToken, out methodToken, 1, out size);
if (size == 0) {
break;
}
al.Add(new MetadataMethodInfo(m_importer, methodToken));
}
}
finally {
m_importer.CloseEnum(hEnum);
}
return (MethodInfo[]) al.ToArray(typeof (MethodInfo));
}
問題は、m_importer.EnumMethods()が指定された型のメソッドを表す MethodDef トークンを列挙することですが、クラス階層のすべてのメソッドに興味があります。
クラス階層で定義されているすべてのメソッドを取得するにはどうすればよいですか? (もちろん、リフレクションなどの一般的な方法は使用できません。他のプロセスで定義された型を分析しているためです)
相互運用性と深い CLR/CIL 構造に関する私の限られた知識は、ここに進む正しい方法を見つけるための障害を生み出します。
アドバイス/提案は大歓迎です!
よろしく、