diff --git a/BurnOutSharp.Models/NewExecutable/EntryTableBundle.cs b/BurnOutSharp.Models/NewExecutable/EntryTableBundle.cs new file mode 100644 index 00000000..85422c37 --- /dev/null +++ b/BurnOutSharp.Models/NewExecutable/EntryTableBundle.cs @@ -0,0 +1,58 @@ +namespace BurnOutSharp.Models.NewExecutable +{ + /// + /// The entry table follows the imported-name table. This table contains + /// bundles of entry-point definitions. Bundling is done to save space in + /// the entry table. The entry table is accessed by an ordinal value. + /// Ordinal number one is defined to index the first entry in the entry + /// table. To find an entry point, the bundles are scanned searching for a + /// specific entry point using an ordinal number. The ordinal number is + /// adjusted as each bundle is checked. When the bundle that contains the + /// entry point is found, the ordinal number is multiplied by the size of + /// the bundle's entries to index the proper entry. + /// + /// + /// The linker forms bundles in the most dense manner it can, under the + /// restriction that it cannot reorder entry points to improve bundling. + /// The reason for this restriction is that other .EXE files may refer to + /// entry points within this bundle by their ordinal number. The following + /// describes the format of the entry table bundles. + /// + /// + public class EntryTableBundle + { + /// + /// Number of entries in this bundle. All records in one bundle + /// are either moveable or refer to the same fixed segment. A zero + /// value in this field indicates the end of the entry table. + /// + public byte EntryCount; + + /// + /// Segment indicator for this bundle. This defines the type of + /// entry table entry data within the bundle. There are three + /// types of entries that are defined. + /// - 000h = Unused entries. There is no entry data in an unused + /// bundle. The next bundle follows this field. This is + /// used by the linker to skip ordinal numbers. + /// - 001h-0FEh = Segment number for fixed segment entries. A fixed + /// segment entry is 3 bytes long. + /// - 0FFH = Moveable segment entries. The entry data contains the + /// segment number for the entry points. A moveable segment + /// entry is 6 bytes long. + /// + public byte SegmentIndicator; + + /// + /// Fixed segment entry + /// + /// Must be NULL if is used. + public FixedSegmentEntry FixedSegmentEntry; + + /// + /// Moveable segment entry + /// + /// Must be NULL if is used. + public MoveableSegmentEntry MoveableSegmentEntry; + } +} diff --git a/BurnOutSharp.Models/NewExecutable/Enums.cs b/BurnOutSharp.Models/NewExecutable/Enums.cs index 2b406925..97d99426 100644 --- a/BurnOutSharp.Models/NewExecutable/Enums.cs +++ b/BurnOutSharp.Models/NewExecutable/Enums.cs @@ -2,6 +2,26 @@ namespace BurnOutSharp.Models.NewExecutable { + [Flags] + public enum FixedSegmentEntryFlag : byte + { + /// + /// Set if the entry is exported. + /// + Exported = 0x01, + + /// + /// Set if the entry uses a global (shared) data segments. + /// + /// + /// The first assembly-language instruction in the + /// entry point prologue must be "MOV AX,data + /// segment number". This may be set only for + /// SINGLEDATA library modules. + /// + Global = 0x02, + } + [Flags] public enum HeaderFlag : ushort { @@ -112,6 +132,20 @@ namespace BurnOutSharp.Models.NewExecutable #endregion } + [Flags] + public enum MoveableSegmentEntryFlag : byte + { + /// + /// Set if the entry is exported. + /// + Exported = 0x01, + + /// + /// Set if the entry uses a global (shared) data segments. + /// + Global = 0x02, + } + public enum OperatingSystem : byte { OS2 = 0x01, diff --git a/BurnOutSharp.Models/NewExecutable/Executable.cs b/BurnOutSharp.Models/NewExecutable/Executable.cs index adcb60ee..f5c49de6 100644 --- a/BurnOutSharp.Models/NewExecutable/Executable.cs +++ b/BurnOutSharp.Models/NewExecutable/Executable.cs @@ -46,7 +46,10 @@ namespace BurnOutSharp.Models.NewExecutable /// public ImportedNameTableEntry[] ImportedNameTable { get; set; } - // TODO: Entry Table + /// + /// Entry table + /// + public EntryTableBundle[] EntryTable { get; set; } /// /// Nonresident-Name table diff --git a/BurnOutSharp.Models/NewExecutable/FixedSegmentEntry.cs b/BurnOutSharp.Models/NewExecutable/FixedSegmentEntry.cs new file mode 100644 index 00000000..3190e91a --- /dev/null +++ b/BurnOutSharp.Models/NewExecutable/FixedSegmentEntry.cs @@ -0,0 +1,25 @@ +using System.Runtime.InteropServices; + +namespace BurnOutSharp.Models.NewExecutable +{ + /// + /// Segment number for fixed segment entries. A fixed + /// segment entry is 3 bytes long and has the following + /// format. + /// + /// 001h-0FEh + /// + [StructLayout(LayoutKind.Sequential)] + public class FixedSegmentEntry + { + /// + /// Flag word. + /// + public FixedSegmentEntryFlag FlagWord; + + /// + /// Offset within segment to entry point. + /// + public ushort Offset; + } +} diff --git a/BurnOutSharp.Models/NewExecutable/MoveableSegmentEntry.cs b/BurnOutSharp.Models/NewExecutable/MoveableSegmentEntry.cs new file mode 100644 index 00000000..eba61614 --- /dev/null +++ b/BurnOutSharp.Models/NewExecutable/MoveableSegmentEntry.cs @@ -0,0 +1,35 @@ +using System.Runtime.InteropServices; + +namespace BurnOutSharp.Models.NewExecutable +{ + /// + /// Moveable segment entries. The entry data contains the + /// segment number for the entry points. A moveable segment + /// entry is 6 bytes long and has the following format. + /// + /// 0FFH + /// + [StructLayout(LayoutKind.Sequential)] + public class MoveableSegmentEntry + { + /// + /// Flag word. + /// + public MoveableSegmentEntryFlag FlagWord; + + /// + /// INT 3FH. + /// + public ushort Reserved; + + /// + /// Segment number. + /// + public byte SegmentNumber; + + /// + /// Offset within segment to entry point. + /// + public ushort Offset; + } +}