diff --git a/Il2CppInspector.Common/FileFormatReaders/FileFormatReader.cs b/Il2CppInspector.Common/FileFormatReaders/FileFormatReader.cs index 975bc34..3078a29 100644 --- a/Il2CppInspector.Common/FileFormatReaders/FileFormatReader.cs +++ b/Il2CppInspector.Common/FileFormatReaders/FileFormatReader.cs @@ -31,6 +31,8 @@ namespace Il2CppInspector Dictionary GetSymbolTable(); uint[] GetFunctionTable(); IEnumerable GetExports(); + IEnumerable
GetSections(); + bool TryGetSections(out IEnumerable
sections); uint MapVATR(ulong uiAddr); bool TryMapVATR(ulong uiAddr, out uint fileOffset); @@ -183,6 +185,19 @@ namespace Il2CppInspector // Find all symbol exports for the image public virtual IEnumerable GetExports() => null; + // Get all sections for the image in a universal format + public virtual IEnumerable
GetSections() => throw new NotImplementedException(); + + public bool TryGetSections(out IEnumerable
sections) { + try { + sections = GetSections(); + return true; + } catch (NotImplementedException) { + sections = null; + return false; + } + } + // Map an RVA to an offset into the file image // No mapping by default public virtual uint MapVATR(ulong uiAddr) => (uint) uiAddr; diff --git a/Il2CppInspector.Common/FileFormatReaders/SElfReader.cs b/Il2CppInspector.Common/FileFormatReaders/SElfReader.cs index 63442f6..f8930a4 100644 --- a/Il2CppInspector.Common/FileFormatReaders/SElfReader.cs +++ b/Il2CppInspector.Common/FileFormatReaders/SElfReader.cs @@ -98,7 +98,7 @@ namespace Il2CppInspector foreach (var entry in dataEntries) { pht[entry.SegmentIndex].f_p_filesz = entry.EncryptedCompressedSize; pht[entry.SegmentIndex].f_p_offset = entry.FileOffset; - pht[entry.SegmentIndex].p_memsz = entry.MemorySize; + pht[entry.SegmentIndex].f_p_memsz = entry.MemorySize; } // Filter out unused phdr entries diff --git a/Il2CppInspector.Common/FileFormatReaders/Section.cs b/Il2CppInspector.Common/FileFormatReaders/Section.cs new file mode 100644 index 0000000..822702d --- /dev/null +++ b/Il2CppInspector.Common/FileFormatReaders/Section.cs @@ -0,0 +1,21 @@ +/* + Copyright 2020 Katy Coe - http://www.djkaty.com - https://github.com/djkaty + + All rights reserved. +*/ + +namespace Il2CppInspector +{ + // A code file function export + public class Section + { + public ulong VirtualStart; + public ulong VirtualEnd; + public uint ImageStart; + public uint ImageEnd; + public bool IsExec; + public bool IsData; + public bool IsBSS; + public string Name; + } +}