Add support for parsing and interpreting VTables

This prepares for a future PR where we add types to the IDA script
output.
This commit is contained in:
Robert Xiao
2020-04-07 05:05:21 -07:00
committed by Katy
parent 5224429b0a
commit d426dad820
3 changed files with 40 additions and 0 deletions

View File

@@ -133,6 +133,18 @@ namespace Il2CppInspector.Reflection {
// Get a property by its name
public PropertyInfo GetProperty(string name) => DeclaredProperties.FirstOrDefault(p => p.Name == name);
public MethodBase[] GetVTable() {
var definition = Definition;
MetadataUsage[] vt = Assembly.Model.Package.GetVTable(definition);
MethodBase[] res = new MethodBase[vt.Length];
for (int i = 0; i < vt.Length; i++) {
if (vt[i] != null)
res[i] = Assembly.Model.GetMetadataUsageMethod(vt[i]);
}
return res;
}
// Method that the type is declared in if this is a type parameter of a generic method
// TODO: Make a unit test from this: https://docs.microsoft.com/en-us/dotnet/api/system.type.declaringmethod?view=netframework-4.8
public MethodBase DeclaringMethod;