From a3a06d807a345f8a9a32c59e42ea1ef42629aa5e Mon Sep 17 00:00:00 2001 From: Katy Coe Date: Tue, 15 Dec 2020 16:13:24 +0100 Subject: [PATCH] IL2CPP: Fix edge case where max metadata dest index can be greater than usagesCount (#110) --- Il2CppInspector.Common/IL2CPP/Il2CppInspector.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Il2CppInspector.Common/IL2CPP/Il2CppInspector.cs b/Il2CppInspector.Common/IL2CPP/Il2CppInspector.cs index feec8ed..cb0be38 100644 --- a/Il2CppInspector.Common/IL2CPP/Il2CppInspector.cs +++ b/Il2CppInspector.Common/IL2CPP/Il2CppInspector.cs @@ -151,7 +151,8 @@ namespace Il2CppInspector // Metadata usages (addresses) // Unfortunately the value supplied in MetadataRegistration.matadataUsagesCount seems to be incorrect, // so we have to calculate the correct number of usages above before reading the usage address list from the binary - var addresses = Binary.Image.ReadMappedArray(Binary.MetadataRegistration.metadataUsages, usages.Count); + var count = usages.Keys.Max() + 1; + var addresses = Binary.Image.ReadMappedArray(Binary.MetadataRegistration.metadataUsages, (int) count); foreach (var usage in usages) usage.Value.SetAddress(addresses[usage.Key]);