From 185278310e5b673c13e861b1e191c94d0bbdb845 Mon Sep 17 00:00:00 2001 From: Perfare Date: Thu, 24 Jun 2021 01:55:01 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96v27=E4=BB=A5=E4=B8=8AMetadata?= =?UTF-8?q?=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Il2CppDumper/ExecutableFormats/Elf.cs | 66 +++++----- Il2CppDumper/ExecutableFormats/Elf64.cs | 66 +++++----- Il2CppDumper/ExecutableFormats/Macho.cs | 25 ++-- Il2CppDumper/ExecutableFormats/Macho64.cs | 25 ++-- Il2CppDumper/ExecutableFormats/NSO.cs | 18 ++- Il2CppDumper/ExecutableFormats/PE.cs | 40 +++--- .../ExecutableFormats/WebAssemblyMemory.cs | 40 +++--- Il2CppDumper/Il2Cpp/Il2Cpp.cs | 1 + Il2CppDumper/Outputs/StructGenerator.cs | 121 +++++++++--------- Il2CppDumper/Utils/Il2CppExecutor.cs | 5 + .../Utils/{PlusSearch.cs => SectionHelper.cs} | 14 +- 11 files changed, 235 insertions(+), 186 deletions(-) rename Il2CppDumper/Utils/{PlusSearch.cs => SectionHelper.cs} (96%) diff --git a/Il2CppDumper/ExecutableFormats/Elf.cs b/Il2CppDumper/ExecutableFormats/Elf.cs index 5ef962f8..ce7d63b2 100644 --- a/Il2CppDumper/ExecutableFormats/Elf.cs +++ b/Il2CppDumper/ExecutableFormats/Elf.cs @@ -150,36 +150,9 @@ public override bool Search() public override bool PlusSearch(int methodCount, int typeDefinitionsCount, int imageCount) { - var dataList = new List(); - var execList = new List(); - foreach (var phdr in programSegment) - { - if (phdr.p_memsz != 0ul) - { - switch (phdr.p_flags) - { - case 1u: //PF_X - case 3u: - case 5u: - case 7u: - execList.Add(phdr); - break; - case 2u: //PF_W && PF_R - case 4u: - case 6u: - dataList.Add(phdr); - break; - } - } - } - var data = dataList.ToArray(); - var exec = execList.ToArray(); - var plusSearch = new PlusSearch(this, methodCount, typeDefinitionsCount, maxMetadataUsages, imageCount); - plusSearch.SetSection(SearchSectionType.Exec, exec); - plusSearch.SetSection(SearchSectionType.Data, data); - plusSearch.SetSection(SearchSectionType.Bss, data); - var codeRegistration = plusSearch.FindCodeRegistration(); - var metadataRegistration = plusSearch.FindMetadataRegistration(); + var sectionHelper = GetSectionHelper(methodCount, typeDefinitionsCount, imageCount); + var codeRegistration = sectionHelper.FindCodeRegistration(); + var metadataRegistration = sectionHelper.FindMetadataRegistration(); return AutoPlusInit(codeRegistration, metadataRegistration); } @@ -338,5 +311,38 @@ private void FixedDynamicSection() } } } + + public override SectionHelper GetSectionHelper(int methodCount, int typeDefinitionsCount, int imageCount) + { + var dataList = new List(); + var execList = new List(); + foreach (var phdr in programSegment) + { + if (phdr.p_memsz != 0ul) + { + switch (phdr.p_flags) + { + case 1u: //PF_X + case 3u: + case 5u: + case 7u: + execList.Add(phdr); + break; + case 2u: //PF_W && PF_R + case 4u: + case 6u: + dataList.Add(phdr); + break; + } + } + } + var data = dataList.ToArray(); + var exec = execList.ToArray(); + var sectionHelper = new SectionHelper(this, methodCount, typeDefinitionsCount, maxMetadataUsages, imageCount); + sectionHelper.SetSection(SearchSectionType.Exec, exec); + sectionHelper.SetSection(SearchSectionType.Data, data); + sectionHelper.SetSection(SearchSectionType.Bss, data); + return sectionHelper; + } } } \ No newline at end of file diff --git a/Il2CppDumper/ExecutableFormats/Elf64.cs b/Il2CppDumper/ExecutableFormats/Elf64.cs index d4b15f40..0bf38502 100644 --- a/Il2CppDumper/ExecutableFormats/Elf64.cs +++ b/Il2CppDumper/ExecutableFormats/Elf64.cs @@ -90,36 +90,9 @@ public override bool Search() public override bool PlusSearch(int methodCount, int typeDefinitionsCount, int imageCount) { - var dataList = new List(); - var execList = new List(); - foreach (var phdr in programSegment) - { - if (phdr.p_memsz != 0ul) - { - switch (phdr.p_flags) - { - case 1u: //PF_X - case 3u: - case 5u: - case 7u: - execList.Add(phdr); - break; - case 2u: //PF_W && PF_R - case 4u: - case 6u: - dataList.Add(phdr); - break; - } - } - } - var data = dataList.ToArray(); - var exec = execList.ToArray(); - var plusSearch = new PlusSearch(this, methodCount, typeDefinitionsCount, maxMetadataUsages, imageCount); - plusSearch.SetSection(SearchSectionType.Exec, exec); - plusSearch.SetSection(SearchSectionType.Data, data); - plusSearch.SetSection(SearchSectionType.Bss, data); - var codeRegistration = plusSearch.FindCodeRegistration(); - var metadataRegistration = plusSearch.FindMetadataRegistration(); + var sectionHelper = GetSectionHelper(methodCount, typeDefinitionsCount, imageCount); + var codeRegistration = sectionHelper.FindCodeRegistration(); + var metadataRegistration = sectionHelper.FindMetadataRegistration(); return AutoPlusInit(codeRegistration, metadataRegistration); } @@ -282,5 +255,38 @@ private void FixedDynamicSection() } } } + + public override SectionHelper GetSectionHelper(int methodCount, int typeDefinitionsCount, int imageCount) + { + var dataList = new List(); + var execList = new List(); + foreach (var phdr in programSegment) + { + if (phdr.p_memsz != 0ul) + { + switch (phdr.p_flags) + { + case 1u: //PF_X + case 3u: + case 5u: + case 7u: + execList.Add(phdr); + break; + case 2u: //PF_W && PF_R + case 4u: + case 6u: + dataList.Add(phdr); + break; + } + } + } + var data = dataList.ToArray(); + var exec = execList.ToArray(); + var sectionHelper = new SectionHelper(this, methodCount, typeDefinitionsCount, maxMetadataUsages, imageCount); + sectionHelper.SetSection(SearchSectionType.Exec, exec); + sectionHelper.SetSection(SearchSectionType.Data, data); + sectionHelper.SetSection(SearchSectionType.Bss, data); + return sectionHelper; + } } } diff --git a/Il2CppDumper/ExecutableFormats/Macho.cs b/Il2CppDumper/ExecutableFormats/Macho.cs index c98fc893..bd0a7c7b 100644 --- a/Il2CppDumper/ExecutableFormats/Macho.cs +++ b/Il2CppDumper/ExecutableFormats/Macho.cs @@ -176,16 +176,9 @@ public override bool Search() public override bool PlusSearch(int methodCount, int typeDefinitionsCount, int imageCount) { - var data = sections.Where(x => x.sectname == "__const").ToArray(); - var code = sections.Where(x => x.flags == 0x80000400).ToArray(); - var bss = sections.Where(x => x.flags == 1u).ToArray(); - - var plusSearch = new PlusSearch(this, methodCount, typeDefinitionsCount, maxMetadataUsages, imageCount); - plusSearch.SetSection(SearchSectionType.Exec, code); - plusSearch.SetSection(SearchSectionType.Data, data); - plusSearch.SetSection(SearchSectionType.Bss, bss); - var codeRegistration = plusSearch.FindCodeRegistration(); - var metadataRegistration = plusSearch.FindMetadataRegistration(); + var sectionHelper = GetSectionHelper(methodCount, typeDefinitionsCount, imageCount); + var codeRegistration = sectionHelper.FindCodeRegistration(); + var metadataRegistration = sectionHelper.FindMetadataRegistration(); return AutoPlusInit(codeRegistration, metadataRegistration); } @@ -198,5 +191,17 @@ public override ulong GetRVA(ulong pointer) { return pointer - vmaddr; } + + public override SectionHelper GetSectionHelper(int methodCount, int typeDefinitionsCount, int imageCount) + { + var data = sections.Where(x => x.sectname == "__const").ToArray(); + var code = sections.Where(x => x.flags == 0x80000400).ToArray(); + var bss = sections.Where(x => x.flags == 1u).ToArray(); + var sectionHelper = new SectionHelper(this, methodCount, typeDefinitionsCount, maxMetadataUsages, imageCount); + sectionHelper.SetSection(SearchSectionType.Exec, code); + sectionHelper.SetSection(SearchSectionType.Data, data); + sectionHelper.SetSection(SearchSectionType.Bss, bss); + return sectionHelper; + } } } diff --git a/Il2CppDumper/ExecutableFormats/Macho64.cs b/Il2CppDumper/ExecutableFormats/Macho64.cs index 516534fd..a9059ae2 100644 --- a/Il2CppDumper/ExecutableFormats/Macho64.cs +++ b/Il2CppDumper/ExecutableFormats/Macho64.cs @@ -238,16 +238,9 @@ public override bool Search() public override bool PlusSearch(int methodCount, int typeDefinitionsCount, int imageCount) { - var data = sections.Where(x => x.sectname == "__const" || x.sectname == "__cstring" || x.sectname == "__data").ToArray(); - var code = sections.Where(x => x.flags == 0x80000400).ToArray(); - var bss = sections.Where(x => x.flags == 1u).ToArray(); - - var plusSearch = new PlusSearch(this, methodCount, typeDefinitionsCount, maxMetadataUsages, imageCount); - plusSearch.SetSection(SearchSectionType.Exec, code); - plusSearch.SetSection(SearchSectionType.Data, data); - plusSearch.SetSection(SearchSectionType.Bss, bss); - var codeRegistration = plusSearch.FindCodeRegistration(); - var metadataRegistration = plusSearch.FindMetadataRegistration(); + var sectionHelper = GetSectionHelper(methodCount, typeDefinitionsCount, imageCount); + var codeRegistration = sectionHelper.FindCodeRegistration(); + var metadataRegistration = sectionHelper.FindMetadataRegistration(); return AutoPlusInit(codeRegistration, metadataRegistration); } @@ -260,5 +253,17 @@ public override ulong GetRVA(ulong pointer) { return pointer - vmaddr; } + + public override SectionHelper GetSectionHelper(int methodCount, int typeDefinitionsCount, int imageCount) + { + var data = sections.Where(x => x.sectname == "__const" || x.sectname == "__cstring" || x.sectname == "__data").ToArray(); + var code = sections.Where(x => x.flags == 0x80000400).ToArray(); + var bss = sections.Where(x => x.flags == 1u).ToArray(); + var sectionHelper = new SectionHelper(this, methodCount, typeDefinitionsCount, maxMetadataUsages, imageCount); + sectionHelper.SetSection(SearchSectionType.Exec, code); + sectionHelper.SetSection(SearchSectionType.Data, data); + sectionHelper.SetSection(SearchSectionType.Bss, bss); + return sectionHelper; + } } } diff --git a/Il2CppDumper/ExecutableFormats/NSO.cs b/Il2CppDumper/ExecutableFormats/NSO.cs index 93800fdb..0a05a811 100644 --- a/Il2CppDumper/ExecutableFormats/NSO.cs +++ b/Il2CppDumper/ExecutableFormats/NSO.cs @@ -113,12 +113,9 @@ public override bool Search() public override bool PlusSearch(int methodCount, int typeDefinitionsCount, int imageCount) { - var plusSearch = new PlusSearch(this, methodCount, typeDefinitionsCount, maxMetadataUsages, imageCount); - plusSearch.SetSection(SearchSectionType.Exec, header.TextSegment); - plusSearch.SetSection(SearchSectionType.Data, header.DataSegment, header.RoDataSegment); - plusSearch.SetSection(SearchSectionType.Bss, header.BssSegment); - var codeRegistration = plusSearch.FindCodeRegistration(); - var metadataRegistration = plusSearch.FindMetadataRegistration(); + var sectionHelper = GetSectionHelper(methodCount, typeDefinitionsCount, imageCount); + var codeRegistration = sectionHelper.FindCodeRegistration(); + var metadataRegistration = sectionHelper.FindMetadataRegistration(); return AutoPlusInit(codeRegistration, metadataRegistration); } @@ -214,5 +211,14 @@ public NSO UnCompress() } return this; } + + public override SectionHelper GetSectionHelper(int methodCount, int typeDefinitionsCount, int imageCount) + { + var sectionHelper = new SectionHelper(this, methodCount, typeDefinitionsCount, maxMetadataUsages, imageCount); + sectionHelper.SetSection(SearchSectionType.Exec, header.TextSegment); + sectionHelper.SetSection(SearchSectionType.Data, header.DataSegment, header.RoDataSegment); + sectionHelper.SetSection(SearchSectionType.Bss, header.BssSegment); + return sectionHelper; + } } } diff --git a/Il2CppDumper/ExecutableFormats/PE.cs b/Il2CppDumper/ExecutableFormats/PE.cs index 62cff674..2226b063 100644 --- a/Il2CppDumper/ExecutableFormats/PE.cs +++ b/Il2CppDumper/ExecutableFormats/PE.cs @@ -83,6 +83,24 @@ public override bool Search() } public override bool PlusSearch(int methodCount, int typeDefinitionsCount, int imageCount) + { + var sectionHelper = GetSectionHelper(methodCount, typeDefinitionsCount, imageCount); + var codeRegistration = sectionHelper.FindCodeRegistration(); + var metadataRegistration = sectionHelper.FindMetadataRegistration(); + return AutoPlusInit(codeRegistration, metadataRegistration); + } + + public override bool SymbolSearch() + { + return false; + } + + public override ulong GetRVA(ulong pointer) + { + return pointer - imageBase; + } + + public override SectionHelper GetSectionHelper(int methodCount, int typeDefinitionsCount, int imageCount) { var execList = new List(); var dataList = new List(); @@ -99,25 +117,13 @@ public override bool PlusSearch(int methodCount, int typeDefinitionsCount, int i break; } } - var plusSearch = new PlusSearch(this, methodCount, typeDefinitionsCount, maxMetadataUsages, imageCount); + var sectionHelper = new SectionHelper(this, methodCount, typeDefinitionsCount, maxMetadataUsages, imageCount); var data = dataList.ToArray(); var exec = execList.ToArray(); - plusSearch.SetSection(SearchSectionType.Exec, imageBase, exec); - plusSearch.SetSection(SearchSectionType.Data, imageBase, data); - plusSearch.SetSection(SearchSectionType.Bss, imageBase, data); - var codeRegistration = plusSearch.FindCodeRegistration(); - var metadataRegistration = plusSearch.FindMetadataRegistration(); - return AutoPlusInit(codeRegistration, metadataRegistration); - } - - public override bool SymbolSearch() - { - return false; - } - - public override ulong GetRVA(ulong pointer) - { - return pointer - imageBase; + sectionHelper.SetSection(SearchSectionType.Exec, imageBase, exec); + sectionHelper.SetSection(SearchSectionType.Data, imageBase, data); + sectionHelper.SetSection(SearchSectionType.Bss, imageBase, data); + return sectionHelper; } } } diff --git a/Il2CppDumper/ExecutableFormats/WebAssemblyMemory.cs b/Il2CppDumper/ExecutableFormats/WebAssemblyMemory.cs index c6243bfd..5247f74a 100644 --- a/Il2CppDumper/ExecutableFormats/WebAssemblyMemory.cs +++ b/Il2CppDumper/ExecutableFormats/WebAssemblyMemory.cs @@ -20,6 +20,24 @@ public override ulong MapRTVA(ulong addr) } public override bool PlusSearch(int methodCount, int typeDefinitionsCount, int imageCount) + { + var sectionHelper = GetSectionHelper(methodCount, typeDefinitionsCount, imageCount); + var codeRegistration = sectionHelper.FindCodeRegistration(); + var metadataRegistration = sectionHelper.FindMetadataRegistration(); + return AutoPlusInit(codeRegistration, metadataRegistration); + } + + public override bool Search() + { + return false; + } + + public override bool SymbolSearch() + { + return false; + } + + public override SectionHelper GetSectionHelper(int methodCount, int typeDefinitionsCount, int imageCount) { var exec = new SearchSection { @@ -42,23 +60,11 @@ public override bool PlusSearch(int methodCount, int typeDefinitionsCount, int i address = Length, addressEnd = long.MaxValue //hack }; - var plusSearch = new PlusSearch(this, methodCount, typeDefinitionsCount, maxMetadataUsages, imageCount); - plusSearch.SetSection(SearchSectionType.Exec, exec); - plusSearch.SetSection(SearchSectionType.Data, data); - plusSearch.SetSection(SearchSectionType.Bss, bss); - var codeRegistration = plusSearch.FindCodeRegistration(); - var metadataRegistration = plusSearch.FindMetadataRegistration(); - return AutoPlusInit(codeRegistration, metadataRegistration); - } - - public override bool Search() - { - return false; - } - - public override bool SymbolSearch() - { - return false; + var sectionHelper = new SectionHelper(this, methodCount, typeDefinitionsCount, maxMetadataUsages, imageCount); + sectionHelper.SetSection(SearchSectionType.Exec, exec); + sectionHelper.SetSection(SearchSectionType.Data, data); + sectionHelper.SetSection(SearchSectionType.Bss, bss); + return sectionHelper; } } } diff --git a/Il2CppDumper/Il2Cpp/Il2Cpp.cs b/Il2CppDumper/Il2Cpp/Il2Cpp.cs index 75799e7b..9922ae5b 100644 --- a/Il2CppDumper/Il2Cpp/Il2Cpp.cs +++ b/Il2CppDumper/Il2Cpp/Il2Cpp.cs @@ -36,6 +36,7 @@ public abstract class Il2Cpp : BinaryStream public abstract bool Search(); public abstract bool PlusSearch(int methodCount, int typeDefinitionsCount, int imageCount); public abstract bool SymbolSearch(); + public abstract SectionHelper GetSectionHelper(int methodCount, int typeDefinitionsCount, int imageCount); protected Il2Cpp(Stream stream) : base(stream) { } diff --git a/Il2CppDumper/Outputs/StructGenerator.cs b/Il2CppDumper/Outputs/StructGenerator.cs index 5cc4e9b0..003f96cd 100644 --- a/Il2CppDumper/Outputs/StructGenerator.cs +++ b/Il2CppDumper/Outputs/StructGenerator.cs @@ -236,77 +236,80 @@ public void WriteScript(string outputDir) //TODO interopData内也包含函数 orderedPointers = orderedPointers.Distinct().OrderBy(x => x).ToList(); orderedPointers.Remove(0); - var orderedRVAPointers = new ulong[orderedPointers.Count]; + json.Addresses = new ulong[orderedPointers.Count]; for (int i = 0; i < orderedPointers.Count; i++) { - orderedRVAPointers[i] = il2Cpp.GetRVA(orderedPointers[i]); + json.Addresses[i] = il2Cpp.GetRVA(orderedPointers[i]); } - json.Addresses = orderedRVAPointers; // 处理MetadataUsage if (il2Cpp.Version >= 27) { - il2Cpp.Position = il2Cpp.MapVATR(orderedPointers.Last()); - while (il2Cpp.Position < il2Cpp.Length - il2Cpp.PointerSize) + var sectionHelper = executor.GetSectionHelper(); + foreach (var sec in sectionHelper.data) { - var addr = il2Cpp.Position; - var metadataValue = il2Cpp.ReadUIntPtr(); - var position = il2Cpp.Position; - if (metadataValue < uint.MaxValue) + il2Cpp.Position = sec.offset; + while (il2Cpp.Position < sec.offsetEnd - il2Cpp.PointerSize) { - var encodedToken = (uint)metadataValue; - var usage = metadata.GetEncodedIndexType(encodedToken); - if (usage > 0 && usage <= 6) + var addr = il2Cpp.Position; + var metadataValue = il2Cpp.ReadUIntPtr(); + var position = il2Cpp.Position; + if (metadataValue < uint.MaxValue) { - var decodedIndex = metadata.GetDecodedMethodIndex(encodedToken); - if (metadataValue == ((usage << 29) | (decodedIndex << 1)) + 1) + var encodedToken = (uint)metadataValue; + var usage = metadata.GetEncodedIndexType(encodedToken); + if (usage > 0 && usage <= 6) { - var va = il2Cpp.MapRTVA(addr); - if (va > 0) + var decodedIndex = metadata.GetDecodedMethodIndex(encodedToken); + if (metadataValue == ((usage << 29) | (decodedIndex << 1)) + 1) { - switch ((Il2CppMetadataUsage)usage) + var va = il2Cpp.MapRTVA(addr); + if (va > 0) { - case Il2CppMetadataUsage.kIl2CppMetadataUsageInvalid: - break; - case Il2CppMetadataUsage.kIl2CppMetadataUsageTypeInfo: - if (decodedIndex < il2Cpp.types.Length) - { - AddMetadataUsageTypeInfo(json, decodedIndex, va); - } - break; - case Il2CppMetadataUsage.kIl2CppMetadataUsageIl2CppType: - if (decodedIndex < il2Cpp.types.Length) - { - AddMetadataUsageIl2CppType(json, decodedIndex, va); - } - break; - case Il2CppMetadataUsage.kIl2CppMetadataUsageMethodDef: - if (decodedIndex < metadata.methodDefs.Length) - { - AddMetadataUsageMethodDef(json, decodedIndex, va); - } - break; - case Il2CppMetadataUsage.kIl2CppMetadataUsageFieldInfo: - if (decodedIndex < metadata.fieldRefs.Length) - { - AddMetadataUsageFieldInfo(json, decodedIndex, va); - } - break; - case Il2CppMetadataUsage.kIl2CppMetadataUsageStringLiteral: - if (decodedIndex < metadata.stringLiterals.Length) - { - AddMetadataUsageStringLiteral(json, decodedIndex, va); - } - break; - case Il2CppMetadataUsage.kIl2CppMetadataUsageMethodRef: - if (decodedIndex < il2Cpp.methodSpecs.Length) - { - AddMetadataUsageMethodRef(json, decodedIndex, va); - } - break; - } - if (il2Cpp.Position != position) - { - il2Cpp.Position = position; + switch ((Il2CppMetadataUsage)usage) + { + case Il2CppMetadataUsage.kIl2CppMetadataUsageInvalid: + break; + case Il2CppMetadataUsage.kIl2CppMetadataUsageTypeInfo: + if (decodedIndex < il2Cpp.types.Length) + { + AddMetadataUsageTypeInfo(json, decodedIndex, va); + } + break; + case Il2CppMetadataUsage.kIl2CppMetadataUsageIl2CppType: + if (decodedIndex < il2Cpp.types.Length) + { + AddMetadataUsageIl2CppType(json, decodedIndex, va); + } + break; + case Il2CppMetadataUsage.kIl2CppMetadataUsageMethodDef: + if (decodedIndex < metadata.methodDefs.Length) + { + AddMetadataUsageMethodDef(json, decodedIndex, va); + } + break; + case Il2CppMetadataUsage.kIl2CppMetadataUsageFieldInfo: + if (decodedIndex < metadata.fieldRefs.Length) + { + AddMetadataUsageFieldInfo(json, decodedIndex, va); + } + break; + case Il2CppMetadataUsage.kIl2CppMetadataUsageStringLiteral: + if (decodedIndex < metadata.stringLiterals.Length) + { + AddMetadataUsageStringLiteral(json, decodedIndex, va); + } + break; + case Il2CppMetadataUsage.kIl2CppMetadataUsageMethodRef: + if (decodedIndex < il2Cpp.methodSpecs.Length) + { + AddMetadataUsageMethodRef(json, decodedIndex, va); + } + break; + } + if (il2Cpp.Position != position) + { + il2Cpp.Position = position; + } } } } diff --git a/Il2CppDumper/Utils/Il2CppExecutor.cs b/Il2CppDumper/Utils/Il2CppExecutor.cs index 47c366c4..86ad718f 100644 --- a/Il2CppDumper/Utils/Il2CppExecutor.cs +++ b/Il2CppDumper/Utils/Il2CppExecutor.cs @@ -311,5 +311,10 @@ public Il2CppGenericParameter GetGenericParameteFromIl2CppType(Il2CppType il2Cpp return metadata.genericParameters[il2CppType.data.genericParameterIndex]; } } + + public SectionHelper GetSectionHelper() + { + return il2Cpp.GetSectionHelper(metadata.methodDefs.Count(x => x.methodIndex >= 0), metadata.typeDefs.Length, metadata.imageDefs.Length); + } } } diff --git a/Il2CppDumper/Utils/PlusSearch.cs b/Il2CppDumper/Utils/SectionHelper.cs similarity index 96% rename from Il2CppDumper/Utils/PlusSearch.cs rename to Il2CppDumper/Utils/SectionHelper.cs index 43be2b26..114abae2 100644 --- a/Il2CppDumper/Utils/PlusSearch.cs +++ b/Il2CppDumper/Utils/SectionHelper.cs @@ -4,18 +4,18 @@ namespace Il2CppDumper { - public class PlusSearch + public class SectionHelper { private Il2Cpp il2Cpp; private int methodCount; private int typeDefinitionsCount; private long maxMetadataUsages; private int imageCount; - private List exec; - private List data; - private List bss; + public List exec; + public List data; + public List bss; - public PlusSearch(Il2Cpp il2Cpp, int methodCount, int typeDefinitionsCount, long maxMetadataUsages, int imageCount) + public SectionHelper(Il2Cpp il2Cpp, int methodCount, int typeDefinitionsCount, long maxMetadataUsages, int imageCount) { this.il2Cpp = il2Cpp; this.methodCount = methodCount; @@ -255,7 +255,7 @@ private ulong FindMetadataRegistrationV21() foreach (var section in data) { il2Cpp.Position = section.offset; - while (il2Cpp.Position < section.offsetEnd) + while (il2Cpp.Position < section.offsetEnd - il2Cpp.PointerSize) { var addr = il2Cpp.Position; if (il2Cpp.ReadIntPtr() == typeDefinitionsCount) @@ -353,7 +353,7 @@ private ulong FindReference(ulong addr) foreach (var dataSec in data) { il2Cpp.Position = dataSec.offset; - while (il2Cpp.Position < dataSec.offsetEnd) + while (il2Cpp.Position < dataSec.offsetEnd - il2Cpp.PointerSize) { var offset = il2Cpp.Position; if (il2Cpp.ReadUIntPtr() == addr)