From 32497364e5d5a344d17da7ec9fb0598411a32d26 Mon Sep 17 00:00:00 2001 From: Katy Coe Date: Fri, 7 Aug 2020 19:08:27 +0200 Subject: [PATCH] AppModel: Don't crash on MetadataUsage MethodDef/Ref without prior method definition --- Il2CppInspector.Common/Model/AppModel.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Il2CppInspector.Common/Model/AppModel.cs b/Il2CppInspector.Common/Model/AppModel.cs index d078f27..8229066 100644 --- a/Il2CppInspector.Common/Model/AppModel.cs +++ b/Il2CppInspector.Common/Model/AppModel.cs @@ -210,7 +210,13 @@ namespace Il2CppInspector.Model var method = ILModel.GetMetadataUsageMethod(usage); declarationGenerator.IncludeMethod(method); AddTypes(declarationGenerator.GenerateRemainingTypeDeclarations()); - + + // Any method here SHOULD already be in the Methods list + // but we have seen one example where this is not the case for a MethodDef + if (!Methods.ContainsKey(method)) { + var fnPtr = declarationGenerator.GenerateMethodDeclaration(method); + Methods.Add(method, fnPtr, new AppMethod(method, fnPtr) {Group = Group}); + } Methods[method].MethodInfoPtrAddress = address; break; }