Model: Handle generic type definition fetch for metadata v27

This commit is contained in:
Katy Coe
2020-08-16 01:13:27 +02:00
parent 86dd475a56
commit ec6066aa1d
2 changed files with 13 additions and 9 deletions

View File

@@ -195,15 +195,19 @@ namespace Il2CppInspector.Reflection
// TODO: Replace with array load from Il2CppMetadataRegistration.genericClasses
var generic = image.ReadMappedObject<Il2CppGenericClass>(typeRef.datapoint); // Il2CppGenericClass *
// It appears that TypeRef can be -1 if the generic depth recursion limit
// (--maximum-recursive-generic-depth=) is reached in Il2Cpp. In this case,
// no generic instance type is generated, so we just produce a null TypeInfo here.
// Get generic type definition
TypeInfo genericTypeDef;
if (Package.Version < 27) {
// It appears that TypeRef can be -1 if the generic depth recursion limit
// (--maximum-recursive-generic-depth=) is reached in Il2Cpp. In this case,
// no generic instance type is generated, so we just produce a null TypeInfo here.
if ((generic.typeDefinitionIndex & 0xffff_ffff) == 0x0000_0000_ffff_ffff)
return null;
// TODO: Generic type definition index resolution is broken in metadata v27 (replaced with Il2CppType *type)
if ((generic.typeDefinitionIndex & 0xffff_ffff) == 0x0000_0000_ffff_ffff)
return null;
var genericTypeDef = TypesByDefinitionIndex[generic.typeDefinitionIndex];
genericTypeDef = TypesByDefinitionIndex[generic.typeDefinitionIndex];
} else {
genericTypeDef = GetTypeFromVirtualAddress(generic.type);
}
// Get the instantiation
// TODO: Replace with array load from Il2CppMetadataRegistration.genericInsts