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

@@ -294,6 +294,27 @@ namespace Il2CppInspector
return Binary.MethodInvokerIndices[module][methodInModule - 1];
}
public MetadataUsage[] GetVTable(Il2CppTypeDefinition definition) {
MetadataUsage[] res = new MetadataUsage[definition.vtable_count];
for (int i = 0; i < definition.vtable_count; i++) {
var encodedIndex = VTableMethodIndices[definition.vtableStart + i];
uint index;
MetadataUsageType usageType;
if (Version < 19) {
var flag = encodedIndex & 0x80000000;
index = Binary.VTableMethodReferences[encodedIndex & 0x7FFFFFFF];
usageType = (flag != 0) ? MetadataUsageType.MethodRef : MetadataUsageType.MethodDef;
} else {
var encodedType = encodedIndex & 0xE0000000;
usageType = (MetadataUsageType)(encodedType >> 29);
index = encodedIndex & 0x1FFFFFFF;
}
if (index != 0)
res[i] = new MetadataUsage(usageType, (int)index, i);
}
return res;
}
public static List<Il2CppInspector> LoadFromFile(string codeFile, string metadataFile) {
// Load the metadata file
Metadata metadata;