From cd6f8f3db37619d2fe95bc9a44a3a10bd37a5f15 Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Fri, 4 Nov 2022 13:48:30 -0700 Subject: [PATCH] Add LE/LX object page table --- BurnOutSharp.Models/LinearExecutable/Enums.cs | 29 +++++++++ .../LinearExecutable/Executable.cs | 6 +- .../LinearExecutable/ObjectPageTableEntry.cs | 60 +++++++++++++++++++ 3 files changed, 94 insertions(+), 1 deletion(-) create mode 100644 BurnOutSharp.Models/LinearExecutable/ObjectPageTableEntry.cs diff --git a/BurnOutSharp.Models/LinearExecutable/Enums.cs b/BurnOutSharp.Models/LinearExecutable/Enums.cs index 0b9a4c4d..e83194d8 100644 --- a/BurnOutSharp.Models/LinearExecutable/Enums.cs +++ b/BurnOutSharp.Models/LinearExecutable/Enums.cs @@ -313,6 +313,35 @@ namespace BurnOutSharp.Models.LinearExecutable PrivilegeLevel = 0x8000, } + [Flags] + public enum ObjectPageFlags : ushort + { + /// + /// Legal Physical Page in the module (Offset from Preload Page Section). + /// + LegalPhysicalPage = 0x0000, + + /// + /// Iterated Data Page (Offset from Iterated Data Pages Section). + /// + IteratedDataPage = 0x0001, + + /// + /// Invalid Page (zero). + /// + InvalidPage = 0x0002, + + /// + /// Zero Filled Page (zero). + /// + ZeroFilledPage = 0x0003, + + /// + /// Range of Pages. + /// + RangeOfPages = 0x0004, + } + public enum OperatingSystem : ushort { /// diff --git a/BurnOutSharp.Models/LinearExecutable/Executable.cs b/BurnOutSharp.Models/LinearExecutable/Executable.cs index 0ca8b39c..643c6a1c 100644 --- a/BurnOutSharp.Models/LinearExecutable/Executable.cs +++ b/BurnOutSharp.Models/LinearExecutable/Executable.cs @@ -25,7 +25,11 @@ namespace BurnOutSharp.Models.LinearExecutable /// public ObjectTableEntry[] ObjectTable { get; set; } - // TODO: Object page map table + /// + /// Object page table + /// + public ObjectPageTableEntry[] ObjectPageTable { get; set; } + // TODO: Object iterate data map table // TODO: Resource table // TODO: Resident-names table diff --git a/BurnOutSharp.Models/LinearExecutable/ObjectPageTableEntry.cs b/BurnOutSharp.Models/LinearExecutable/ObjectPageTableEntry.cs new file mode 100644 index 00000000..6681a173 --- /dev/null +++ b/BurnOutSharp.Models/LinearExecutable/ObjectPageTableEntry.cs @@ -0,0 +1,60 @@ +using System.Runtime.InteropServices; + +namespace BurnOutSharp.Models.LinearExecutable +{ + /// + /// The Object page table provides information about a logical page in an object. + /// A logical page may be an enumerated page, a pseudo page or an iterated page. + /// The structure of the object page table in conjunction with the structure of + /// the object table allows for efficient access of a page when a page fault occurs, + /// while still allowing the physical page data to be located in the preload page, + /// demand load page or iterated data page sections in the linear EXE module. The + /// logical page entries in the Object Page Table are numbered starting from one. + /// The Object Page Table is parallel to the Fixup Page Table as they are both + /// indexed by the logical page number. + /// + /// + /// + [StructLayout(LayoutKind.Sequential)] + public class ObjectPageTableEntry + { + /// + /// Offset to the page data in the EXE file. + /// + /// + /// This field, when bit shifted left by the PAGE OFFSET SHIFT from the module + /// header, specifies the offset from the beginning of the Preload Page section + /// of the physical page data in the EXE file that corresponds to this logical + /// page entry. The page data may reside in the Preload Pages, Demand Load Pages + /// or the Iterated Data Pages sections. + /// + /// If the FLAGS field specifies that this is a zero-Filled page then the PAGE + /// DATA OFFSET field will contain a 0. + /// + /// If the logical page is specified as an iterated data page, as indicated by + /// the FLAGS field, then this field specifies the offset into the Iterated Data + /// Pages section. + /// + /// The logical page number (Object Page Table index), is used to index the Fixup + /// Page Table to find any fixups associated with the logical page. + /// + public uint PageDataOffset; + + /// + /// Number of bytes of data for this page. + /// + /// + /// This field specifies the actual number of bytes that represent the page in the + /// file. If the PAGE SIZE field from the module header is greater than the value + /// of this field and the FLAGS field indicates a Legal Physical Page, the remaining + /// bytes are to be filled with zeros. If the FLAGS field indicates an Iterated Data + /// Page, the iterated data records will completely fill out the remainder. + /// + public ushort DataSize; + + /// + /// Attributes specifying characteristics of this logical page. + /// + public ObjectPageFlags Flags; + } +}