Fill out LE/LX builder

This commit is contained in:
Matt Nadareski
2023-01-11 11:44:13 -08:00
parent 4ccf80189e
commit af7ff05ecf
11 changed files with 875 additions and 119 deletions

View File

@@ -2,55 +2,11 @@
namespace BurnOutSharp.Models.LinearExecutable
{
/// <summary>
/// The entry table contains object and offset information that is used to resolve
/// fixup references to the entry points within this module. Not all entry points
/// in the entry table will be exported, some entry points will only be used
/// within the module. An ordinal number is used to index into the entry table.
/// The entry table entries are numbered starting from one.
///
/// The list of entries are compressed into 'bundles', where possible. The entries
/// within each bundle are all the same size. A bundle starts with a count field
/// which indicates the number of entries in the bundle. The count is followed by
/// a type field which identifies the bundle format. This provides both a means
/// for saving space as well as a mechanism for extending the bundle types.
/// </summary>
/// <see href="https://faydoc.tripod.com/formats/exe-LE.htm"/>
/// <see href="http://www.edm2.com/index.php/LX_-_Linear_eXecutable_Module_Format_Description"/>
[StructLayout(LayoutKind.Explicit)]
public sealed class EntryTableEntry
{
/// <summary>
/// Number of entries.
/// </summary>
/// <remarks>
/// This is the number of entries in this bundle.
///
/// A zero value for the number of entries identifies the end of the
/// entry table. There is no further bundle information when the number
/// of entries is zero. In other words the entry table is terminated by
/// a single zero byte.
///
/// For <see cref="BundleType.UnusedEntry"/>, this is the number of unused
/// entries to skip.
/// For <see cref="BundleType.SixteenBitEntry"/>, this is the number of 16-bit
/// entries in this bundle. The flags and offset value are repeated this
/// number of times.
/// For <see cref="BundleType.TwoEightySixCallGateEntry"/>, this is the number
/// of 286 call gate entries in this bundle. The flags, callgate, and offset
/// value are repeated this number of times.
/// For <see cref="BundleType.ThirtyTwoBitEntry"/>, this is the number
/// of 32-bit entries in this bundle. The flags and offset value are repeated
/// this number of times.
/// For <see cref="BundleType.ForwarderEntry"/>, this field is reserved for future use.
/// </remarks>
[FieldOffset(0)] public byte Entries;
/// <summary>
/// This defines the bundle type which determines the contents of the BUNDLE INFO.
/// </summary>
[FieldOffset(1)] public BundleType BundleType;
#region 16-bit Entry
/// <summary>
@@ -59,7 +15,7 @@ namespace BurnOutSharp.Models.LinearExecutable
/// <remarks>
/// This is the object number for the entries in this bundle.
/// </remarks>
[FieldOffset(2)] public ushort SixteenBitObjectNumber;
[FieldOffset(0)] public ushort SixteenBitObjectNumber;
/// <summary>
/// Entry flags.
@@ -67,7 +23,7 @@ namespace BurnOutSharp.Models.LinearExecutable
/// <remarks>
/// These are the flags for this entry point.
/// </remarks>
[FieldOffset(4)] public EntryFlags SixteenBitEntryFlags;
[FieldOffset(2)] public EntryFlags SixteenBitEntryFlags;
/// <summary>
/// Offset in object.
@@ -75,7 +31,7 @@ namespace BurnOutSharp.Models.LinearExecutable
/// <remarks>
/// This is the offset in the object for the entry point defined at this ordinal number.
/// </remarks>
[FieldOffset(5)] public ushort SixteenBitOffset;
[FieldOffset(3)] public ushort SixteenBitOffset;
#endregion
@@ -87,7 +43,7 @@ namespace BurnOutSharp.Models.LinearExecutable
/// <remarks>
/// This is the object number for the entries in this bundle.
/// </remarks>
[FieldOffset(2)] public ushort TwoEightySixObjectNumber;
[FieldOffset(0)] public ushort TwoEightySixObjectNumber;
/// <summary>
/// Entry flags.
@@ -95,7 +51,7 @@ namespace BurnOutSharp.Models.LinearExecutable
/// <remarks>
/// These are the flags for this entry point.
/// </remarks>
[FieldOffset(4)] public EntryFlags TwoEightySixEntryFlags;
[FieldOffset(2)] public EntryFlags TwoEightySixEntryFlags;
/// <summary>
/// Offset in object.
@@ -103,7 +59,7 @@ namespace BurnOutSharp.Models.LinearExecutable
/// <remarks>
/// This is the offset in the object for the entry point defined at this ordinal number.
/// </remarks>
[FieldOffset(5)] public ushort TwoEightySixOffset;
[FieldOffset(3)] public ushort TwoEightySixOffset;
/// <summary>
/// Callgate selector.
@@ -115,7 +71,7 @@ namespace BurnOutSharp.Models.LinearExecutable
/// offset is place in the relocation fixup address. The segment number and offset
/// in segment is placed in the LDT callgate.
/// </remarks>
[FieldOffset(7)] public ushort TwoEightySixCallgate;
[FieldOffset(5)] public ushort TwoEightySixCallgate;
#endregion
@@ -127,7 +83,7 @@ namespace BurnOutSharp.Models.LinearExecutable
/// <remarks>
/// This is the object number for the entries in this bundle.
/// </remarks>
[FieldOffset(2)] public ushort ThirtyTwoBitObjectNumber;
[FieldOffset(0)] public ushort ThirtyTwoBitObjectNumber;
/// <summary>
/// Entry flags.
@@ -135,7 +91,7 @@ namespace BurnOutSharp.Models.LinearExecutable
/// <remarks>
/// These are the flags for this entry point.
/// </remarks>
[FieldOffset(4)] public EntryFlags ThirtyTwoBitEntryFlags;
[FieldOffset(2)] public EntryFlags ThirtyTwoBitEntryFlags;
/// <summary>
/// Offset in object.
@@ -143,7 +99,7 @@ namespace BurnOutSharp.Models.LinearExecutable
/// <remarks>
/// This is the offset in the object for the entry point defined at this ordinal number.
/// </remarks>
[FieldOffset(5)] public uint ThirtyTwoBitOffset;
[FieldOffset(3)] public uint ThirtyTwoBitOffset;
#endregion
@@ -155,7 +111,7 @@ namespace BurnOutSharp.Models.LinearExecutable
/// <remarks>
/// This field is reserved for future use.
/// </remarks>
[FieldOffset(2)] public ushort ForwarderReserved;
[FieldOffset(0)] public ushort ForwarderReserved;
/// <summary>
/// Forwarder flags.
@@ -163,7 +119,7 @@ namespace BurnOutSharp.Models.LinearExecutable
/// <remarks>
/// These are the flags for this entry point.
/// </remarks>
[FieldOffset(4)] public ForwarderFlags ForwarderFlags;
[FieldOffset(2)] public ForwarderFlags ForwarderFlags;
/// <summary>
/// Module Ordinal Number
@@ -171,7 +127,7 @@ namespace BurnOutSharp.Models.LinearExecutable
/// <remarks>
/// This is the index into the Import Module Name Table for this forwarder.
/// </remarks>
[FieldOffset(5)] public ushort ForwarderModuleOrdinalNumber;
[FieldOffset(3)] public ushort ForwarderModuleOrdinalNumber;
/// <summary>
/// Procedure Name Offset
@@ -199,7 +155,7 @@ namespace BurnOutSharp.Models.LinearExecutable
/// single libraries, one could provide entry points for the three libraries
/// that are forwarders pointing to the common implementation.
/// </remarks>
[FieldOffset(7)] public uint ProcedureNameOffset;
[FieldOffset(5)] public uint ProcedureNameOffset;
/// <summary>
/// Import Ordinal Number
@@ -227,8 +183,8 @@ namespace BurnOutSharp.Models.LinearExecutable
/// single libraries, one could provide entry points for the three libraries
/// that are forwarders pointing to the common implementation.
/// </remarks>
[FieldOffset(7)] public uint ImportOrdinalNumber;
[FieldOffset(5)] public uint ImportOrdinalNumber;
#endregion
}
}
}