From 5fb5a03adfa16e59bd13710a55c7db544ab45074 Mon Sep 17 00:00:00 2001 From: Katy Coe Date: Fri, 11 Dec 2020 10:28:04 +0100 Subject: [PATCH] IL2CPP: Allow metadataUsages to be found in dumped images --- Il2CppInspector.Common/IL2CPP/ReconstructMetadata.cs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Il2CppInspector.Common/IL2CPP/ReconstructMetadata.cs b/Il2CppInspector.Common/IL2CPP/ReconstructMetadata.cs index d541933..7673808 100644 --- a/Il2CppInspector.Common/IL2CPP/ReconstructMetadata.cs +++ b/Il2CppInspector.Common/IL2CPP/ReconstructMetadata.cs @@ -559,15 +559,17 @@ namespace Il2CppInspector break; } - // Metadata usages always map to BSS sections - // TODO: For images dumped from memory, metadata usages must always map to data sections - if (dataPtrsCount == 0 && limit / (Image.Bits / 8) >= usages.Count) { + // Metadata usages always map to BSS sections (dataPtrsCount == 0) + // For images dumped from memory, metadata usages must always map to data sections + if ((dataPtrsCount == 0 && limit / (Image.Bits / 8) >= usages.Count) + || dataPtrsCount >= usages.Count) { - // No null pointers allowed + // No null pointers allowed (this test only applies to non-dumped images) if (ptrs.Take(usages.Count).All(p => p != 0ul)) { - // All the pointers must map to a BSS section + // For normal images, all the pointers must map to a BSS section // For PE files this relies on our section modding above + // For dumped images, BSS sections are also data sections so we can use the same test var bssMappableCount = ptrs.Take(usages.Count).Count(p => bssSections.Any(s => p >= s.VirtualStart && p <= s.VirtualEnd)); foundData.count = bssMappableCount;