From 996fb1ff360a6907272522457c1f6a8895114477 Mon Sep 17 00:00:00 2001 From: Robert Xiao Date: Fri, 10 Apr 2020 20:18:35 -0700 Subject: [PATCH] Avoid recreating ref'd types that already exist Because TypesByReferenceIndex can be populated in two places (Il2CppModel constructor and GetTypeFromVirtualAddress), we need to avoid generating the same type multiple times. --- Il2CppInspector.Common/Reflection/Il2CppModel.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Il2CppInspector.Common/Reflection/Il2CppModel.cs b/Il2CppInspector.Common/Reflection/Il2CppModel.cs index c1e6e7d..e83764f 100644 --- a/Il2CppInspector.Common/Reflection/Il2CppModel.cs +++ b/Il2CppInspector.Common/Reflection/Il2CppModel.cs @@ -73,6 +73,11 @@ namespace Il2CppInspector.Reflection // Create and reference types from TypeRefs // Note that you can't resolve any TypeRefs until all the TypeDefs have been processed for (int typeRefIndex = 0; typeRefIndex < package.TypeReferences.Count; typeRefIndex++) { + if(TypesByReferenceIndex[typeRefIndex] != null) { + /* type already generated - probably by forward reference through GetTypeFromVirtualAddress */ + continue; + } + var typeRef = Package.TypeReferences[typeRefIndex]; var referencedType = TypeInfo.FromTypeReference(this, typeRef);