diff --git a/BurnOutSharp.Models/NewExecutable/Enums.cs b/BurnOutSharp.Models/NewExecutable/Enums.cs index 72dfd141..eb39acce 100644 --- a/BurnOutSharp.Models/NewExecutable/Enums.cs +++ b/BurnOutSharp.Models/NewExecutable/Enums.cs @@ -48,4 +48,43 @@ namespace BurnOutSharp.Models.NewExecutable { WINDOWS = 0x02, } + + [Flags] + public enum SegmentTableEntryFlag : ushort + { + /// + /// Segment-type field. + /// + TYPE_MASK = 0x0007, + + /// + /// Code-segment type. + /// + CODE = 0x0000, + + /// + /// Data-segment type. + /// + DATA = 0x0001, + + /// + /// Segment is not fixed. + /// + MOVEABLE = 0x0010, + + /// + /// Segment will be preloaded; read-only if this is a data segment. + /// + PRELOAD = 0x0040, + + /// + /// Set if segment has relocation records. + /// + RELOCINFO = 0x0100, + + /// + /// Discard priority. + /// + DISCARD = 0xF000, + } } diff --git a/BurnOutSharp.Models/NewExecutable/Executable.cs b/BurnOutSharp.Models/NewExecutable/Executable.cs index d75268b4..96026779 100644 --- a/BurnOutSharp.Models/NewExecutable/Executable.cs +++ b/BurnOutSharp.Models/NewExecutable/Executable.cs @@ -21,7 +21,11 @@ namespace BurnOutSharp.Models.NewExecutable /// public ExecutableHeader Header { get; set; } - // TODO: Segment Table + /// + /// Segment table + /// + public SegmentTableEntry[] SegmentTable { get; set; } + // TODO: Resource Table // TODO: Resident-Name Table // TODO: Module-Reference Table diff --git a/BurnOutSharp.Models/NewExecutable/ExecutableHeader.cs b/BurnOutSharp.Models/NewExecutable/ExecutableHeader.cs index 19680dc8..84ad631d 100644 --- a/BurnOutSharp.Models/NewExecutable/ExecutableHeader.cs +++ b/BurnOutSharp.Models/NewExecutable/ExecutableHeader.cs @@ -1,4 +1,3 @@ -using System.IO; using System.Runtime.InteropServices; namespace BurnOutSharp.Models.NewExecutable diff --git a/BurnOutSharp.Models/NewExecutable/SegmentTableEntry.cs b/BurnOutSharp.Models/NewExecutable/SegmentTableEntry.cs new file mode 100644 index 00000000..3b22a096 --- /dev/null +++ b/BurnOutSharp.Models/NewExecutable/SegmentTableEntry.cs @@ -0,0 +1,38 @@ +using System.Runtime.InteropServices; + +namespace BurnOutSharp.Models.NewExecutable +{ + /// + /// The segment table contains an entry for each segment in the executable + /// file. The number of segment table entries are defined in the segmented + /// EXE header. The first entry in the segment table is segment number 1. + /// The following is the structure of a segment table entry. + /// + /// + [StructLayout(LayoutKind.Sequential)] + public class SegmentTableEntry + { + /// + /// Logical-sector offset (n byte) to the contents of the segment + /// data, relative to the beginning of the file. Zero means no + /// file data. + /// + public ushort Offset; + + /// + /// Length of the segment in the file, in bytes. Zero means 64K. + /// + public ushort Length; + + /// + /// Flag word. + /// + public SegmentTableEntryFlag FlagWord; + + /// + /// Minimum allocation size of the segment, in bytes. Total size + /// of the segment. Zero means 64K. + /// + public ushort MinimumAllocationSize; + } +}