diff --git a/BurnOutSharp.Models/LinearExecutable/Enums.cs b/BurnOutSharp.Models/LinearExecutable/Enums.cs new file mode 100644 index 00000000..56940955 --- /dev/null +++ b/BurnOutSharp.Models/LinearExecutable/Enums.cs @@ -0,0 +1,143 @@ +using System; + +namespace BurnOutSharp.Models.LinearExecutable +{ + public enum ByteOrder : byte + { + /// + /// little-endian + /// + LE = 0x00, + + /// + /// big-endian + /// + /// non-zero + BE = 0x01, + } + + public enum CPUType : ushort + { + /// + /// Intel 80286 or upwardly compatible + /// + Intel80286 = 0x01, + + /// + /// Intel 80386 or upwardly compatible + /// + Intel80386 = 0x02, + + /// + /// Intel 80486 or upwardly compatible + /// + Intel80486 = 0x03, + + /// + /// Intel 80586 or upwardly compatible + /// + Intel80586 = 0x04, + + /// + /// Intel i860 (N10) or compatible + /// + Inteli860 = 0x20, + + /// + /// Intel "N11" or compatible + /// + IntelN11 = 0x21, + + /// + /// MIPS Mark I (R2000, R3000) or compatible + /// + MIPSMarkI = 0x40, + + /// + /// MIPS Mark II ( R6000 ) or compatible + /// + MIPSMarkII = 0x41, + + /// + /// MIPS Mark III ( R4000 ) or compatible + /// + MIPSMarkIII = 0x42, + } + + [Flags] + public enum InformationBlockFlag : uint + { + /// + /// Initialization (Only for DLL): + /// 0 Global + /// 1 Per-Process + /// + Initialization = 1 << 2, + + /// + /// No internal fixup in exe image + /// + NoInternalFixup = 1 << 4, + + /// + /// No internal fixup in exe image + /// + NoExternalFixup = 1 << 5, + + // TODO: Figure out this block of flags + // 8, 9, 10 all have the same note: + // 0 Unknown + // 1 Incompatible with PM windowing + // 2 Compatible with PM windowing + // 3 Uses PM windowing API + + /// + /// Module not loadable + /// + ModuleNotLoadable = 1 << 13, + + /// + /// Module is DLL rather then program + /// + IsDLL = 1 << 15, + + // Bits 16-31 are all reserved + } + + public enum OperatingSystem : ushort + { + /// + /// OS/2 + /// + OS2 = 0x01, + + /// + /// Windows + /// + Windows = 0x02, + + /// + /// DOS 4.x + /// + DOS4x = 0x03, + + /// + /// Windows 386 + /// + Windows386 = 0x04, + } + + public enum WordOrder : byte + { + /// + /// little-endian + /// + LE = 0x00, + + /// + /// big-endian + /// + /// non-zero + BE = 0x01, + } +} diff --git a/BurnOutSharp.Models/LinearExecutable/Executable.cs b/BurnOutSharp.Models/LinearExecutable/Executable.cs index bc596c3a..6f7b510b 100644 --- a/BurnOutSharp.Models/LinearExecutable/Executable.cs +++ b/BurnOutSharp.Models/LinearExecutable/Executable.cs @@ -14,5 +14,27 @@ namespace BurnOutSharp.Models.LinearExecutable /// MS-DOS executable header /// public MSDOS.ExecutableHeader Stub { get; set; } + + /// + /// Information block + /// + public InformationBlock InformationBlock { get; set; } + + // TODO: Object table + // TODO: Object page map table + // TODO: Object iterate data map table + // TODO: Resource table + // TODO: Resident-names table + // TODO: Entry table + // TODO: Module directives table + // TODO: Fix-up page table + // TODO: Fix-up record table + // TODO: Imported modules name table + // TODO: Imported procedures name table + // TODO: Per-page checksum table + + // TODO: Code or Data Segment X + + // TODO: Non-resident table } } diff --git a/BurnOutSharp.Models/LinearExecutable/InformationBlock.cs b/BurnOutSharp.Models/LinearExecutable/InformationBlock.cs new file mode 100644 index 00000000..88e41ebf --- /dev/null +++ b/BurnOutSharp.Models/LinearExecutable/InformationBlock.cs @@ -0,0 +1,252 @@ +using System.Runtime.InteropServices; + +namespace BurnOutSharp.Models.LinearExecutable +{ + /// + /// The `information block` in the LE header contains the linker version number, + /// length of various tables that further describe the executable file, the + /// offsets from the beginning of the header to the beginning of these tables, + /// the heap and stack sizes, and so on. The following list summarizes the + /// contents of the header `information block` (the locations are relative to + /// the beginning of the block): + /// + /// + [StructLayout(LayoutKind.Sequential)] + public class InformationBlock + { + /// + /// Specifies the signature word 'LE' (4Ch 45H) + /// + public char[] Signature; + + /// + /// Byte order + /// + public ByteOrder ByteOrder; + + /// + /// Word order + /// + public WordOrder WordOrder; + + /// + /// Executable format level + /// + public uint ExecutableFormatLevel; + + /// + /// CPU type + /// + public CPUType CPUType; + + /// + /// Target operating system + /// + public OperatingSystem TargetOperatingSystem; + + /// + /// Module version + /// + public uint ModuleVersion; + + /// + /// Module type flags + /// + public InformationBlockFlag ModuleTypeFlags; + + /// + /// Number of memory pages + /// + public uint MemoryPageCount; + + /// + /// Initial object CS number + /// + public uint InitialObjectCS; + + /// + /// Initial EIP + /// + public uint InitialEIP; + + /// + /// Initial object SS number + /// + public uint InitialObjectSS; + + /// + /// Initial ESP + /// + public uint InitialESP; + + /// + /// Memory page size + /// + public uint MemoryPageSize; + + /// + /// Bytes on last page + /// + public uint BytesOnLastPage; + + /// + /// Fix-up section size + /// + public uint FixupSectionSize; + + /// + /// Fix-up section checksum + /// + public uint FixupSectionChecksum; + + /// + /// Loader section size + /// + public uint LoaderSectionSize; + + /// + /// Loader section checksum + /// + public uint LoaderSectionChecksum; + + /// + /// Offset of object table + /// + public uint ObjectTableOffset; + + /// + /// Object table entries + /// + public uint ObjectTableCount; + + /// + /// Object page map offset + /// + public uint ObjectPageMapOffset; + + /// + /// Object iterate data map offset + /// + public uint ObjectIterateDataMapOffset; + + /// + /// Resource table offset + /// + public uint ResourceTableOffset; + + /// + /// Resource table entries + /// + public uint ResourceTableCount; + + /// + /// Resident names table offset + /// + public uint ResidentNamesTableOffset; + + /// + /// Entry table offset + /// + public uint EntryTableOffset; + + /// + /// Module directives table offset + /// + public uint ModuleDirectivesTableOffset; + + /// + /// Module directives entries + /// + public uint ModuleDirectivesCount; + + /// + /// Fix-up page table offset + /// + public uint FixupPageTableOffset; + + /// + /// Fix-up record table offset + /// + public uint FixupRecordTableOffset; + + /// + /// Imported modules name table offset + /// + public uint ImportedModulesNameTableOffset; + + /// + /// Imported modules count + /// + public uint ImportedModulesCount; + + /// + /// Imported procedure name table offset + /// + public uint ImportedProcedureNameTableOffset; + + /// + /// Per-page checksum table offset + /// + public uint PerPageChecksumTableOffset; + + /// + /// Data pages offset from top of file + /// + public uint DataPagesOffset; + + /// + /// Preload page count + /// + public uint PreloadPageCount; + + /// + /// Non-resident names table offset from top of file + /// + public uint NonresidentNamesTableOffset; + + /// + /// Non-resident names table length + /// + public uint NonresidentNamesTableLength; + + /// + /// Non-resident names table checksum + /// + public uint NonresidentNamesTableChecksum; + + /// + /// Automatic data object + /// + public uint AutomaticDataObject; + + /// + /// Debug information offset + /// + public uint DebugInformationOffset; + + /// + /// Debug information length + /// + public uint DebugInformationLength; + + /// + /// Preload instance pages number + /// + public uint PreloadInstancePagesNumber; + + /// + /// Demand instance pages number + /// + public uint DemandInstancePagesNumber; + + /// + /// Extra heap allocation + /// + public uint ExtraHeapAllocation; + + /// + /// ??? + /// + public uint Reserved; + } +}