diff --git a/Il2CppInspector.Common/IL2CPP/Il2CppBinaryClasses.cs b/Il2CppInspector.Common/IL2CPP/Il2CppBinaryClasses.cs index 59ea30b..f6148d0 100644 --- a/Il2CppInspector.Common/IL2CPP/Il2CppBinaryClasses.cs +++ b/Il2CppInspector.Common/IL2CPP/Il2CppBinaryClasses.cs @@ -202,7 +202,7 @@ namespace Il2CppInspector [Version(Max = 24.3)] public long typeDefinitionIndex; /* the generic type definition */ [Version(Min = 27)] - public long type; // Il2CppType* /* the generic type definition */ + public ulong type; // Il2CppType* /* the generic type definition */ public Il2CppGenericContext context; /* a context that contains the type instantiation doesn't contain any method instantiation */ public ulong cached_class; /* if present, the Il2CppClass corresponding to the instantiation. */ diff --git a/Il2CppInspector.Common/Reflection/TypeModel.cs b/Il2CppInspector.Common/Reflection/TypeModel.cs index 007224b..6d990f5 100644 --- a/Il2CppInspector.Common/Reflection/TypeModel.cs +++ b/Il2CppInspector.Common/Reflection/TypeModel.cs @@ -195,15 +195,19 @@ namespace Il2CppInspector.Reflection // TODO: Replace with array load from Il2CppMetadataRegistration.genericClasses var generic = image.ReadMappedObject(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