diff --git a/Il2CppInspector.Common/FileFormatReaders/FormatLayouts/PE.cs b/Il2CppInspector.Common/FileFormatReaders/FormatLayouts/PE.cs index dfa40dc..48132bb 100644 --- a/Il2CppInspector.Common/FileFormatReaders/FormatLayouts/PE.cs +++ b/Il2CppInspector.Common/FileFormatReaders/FormatLayouts/PE.cs @@ -13,7 +13,11 @@ namespace Il2CppInspector public enum PE : uint { IMAGE_NT_OPTIONAL_HDR32_MAGIC = 0x10b, - IMAGE_NT_OPTIONAL_HDR64_MAGIC = 0x20b + IMAGE_NT_OPTIONAL_HDR64_MAGIC = 0x20b, + + IMAGE_SCN_CNT_CODE = 0x00000020, + IMAGE_SCN_CNT_INITIALIZED_DATA = 0x00000040, + IMAGE_SCN_CNT_UNINITIALIZED_DATA = 0x00000080 } #pragma warning disable CS0649 @@ -132,6 +136,8 @@ namespace Il2CppInspector // _IMAGE_SECTION_HEADER internal class PESection { + public PE Characteristics => (PE) f_Characteristics; + [String(FixedSize=8)] public string Name; public uint VirtualSize; // Size in memory @@ -142,7 +148,7 @@ namespace Il2CppInspector public uint PointerToLinenumbers; public ushort NumberOfRelocations; public ushort NumberOfLinenumbers; - public uint Characteristics; + public uint f_Characteristics; } // _IMAGE_EXPORT_DIRECTORY diff --git a/Il2CppInspector.Common/FileFormatReaders/PEReader.cs b/Il2CppInspector.Common/FileFormatReaders/PEReader.cs index dc3f473..6595056 100644 --- a/Il2CppInspector.Common/FileFormatReaders/PEReader.cs +++ b/Il2CppInspector.Common/FileFormatReaders/PEReader.cs @@ -168,6 +168,19 @@ namespace Il2CppInspector return pe.ImageBase + section.VirtualAddress + offset - section.PointerToRawData; } - // TODO: PEReader.GetSections() + public override IEnumerable
GetSections() { + return sections.Select(s => new Section { + VirtualStart = pe.ImageBase + s.VirtualAddress, + VirtualEnd = pe.ImageBase + s.VirtualAddress + s.VirtualSize - 1, + ImageStart = s.PointerToRawData, + ImageEnd = s.PointerToRawData + s.SizeOfRawData - 1, + + IsData = (s.Characteristics & PE.IMAGE_SCN_CNT_INITIALIZED_DATA) != 0, + IsExec = (s.Characteristics & PE.IMAGE_SCN_CNT_CODE) != 0, + IsBSS = (s.Characteristics & PE.IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 || s.PointerToRawData == 0u, + + Name = s.Name + }); + } } }