IL2CPP: Allow metadataUsages to be found in dumped images

This commit is contained in:
Katy Coe
2020-12-11 10:28:04 +01:00
parent 2c2608ce50
commit 5fb5a03adf

View File

@@ -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;