diff --git a/BurnOutSharp.Models/NewExecutable/Enums.cs b/BurnOutSharp.Models/NewExecutable/Enums.cs index 97d99426..8ff4ea93 100644 --- a/BurnOutSharp.Models/NewExecutable/Enums.cs +++ b/BurnOutSharp.Models/NewExecutable/Enums.cs @@ -184,6 +184,65 @@ namespace BurnOutSharp.Models.NewExecutable Unknown = 0xF0, } + public enum OSFixupType : ushort + { + /// + /// FIARQQ, FJARQQ + /// + FIARQQ = 0x0001, + + /// + /// FISRQQ, FJSRQQ + /// + FISRQQ = 0x0002, + + /// + /// FICRQQ, FJCRQQ + /// + FICRQQ = 0x0003, + + FIERQQ = 0x0004, + + FIDRQQ = 0x0005, + + FIWRQQ = 0x0006, + } + + [Flags] + public enum RelocationRecordFlag : byte + { + TARGET_MASK = 0x03, + + INTERNALREF = 0x00, + + IMPORTORDINAL = 0x01, + + IMPORTNAME = 0x02, + + OSFIXUP = 0x03, + + ADDITIVE = 0x04, + } + + public enum RelocationRecordSourceType : byte + { + SOURCE_MASK = 0x0F, + + LOBYTE = 0x00, + + SEGMENT = 0x02, + + /// + /// 32-bit pointer + /// + FAR_ADDR = 0x03, + + /// + /// 16-bit offset + /// + OFFSET = 0x05, + } + [Flags] public enum ResourceTypeResourceFlag : ushort { diff --git a/BurnOutSharp.Models/NewExecutable/Executable.cs b/BurnOutSharp.Models/NewExecutable/Executable.cs index f5c49de6..88e6f178 100644 --- a/BurnOutSharp.Models/NewExecutable/Executable.cs +++ b/BurnOutSharp.Models/NewExecutable/Executable.cs @@ -55,7 +55,5 @@ namespace BurnOutSharp.Models.NewExecutable /// Nonresident-Name table /// public NonResidentNameTableEntry[] NonResidentNameTable { get; set; } - - // TODO: Per Segment Data } } diff --git a/BurnOutSharp.Models/NewExecutable/ImportNameRelocationRecord.cs b/BurnOutSharp.Models/NewExecutable/ImportNameRelocationRecord.cs new file mode 100644 index 00000000..05c83eaa --- /dev/null +++ b/BurnOutSharp.Models/NewExecutable/ImportNameRelocationRecord.cs @@ -0,0 +1,19 @@ +using System.Runtime.InteropServices; + +namespace BurnOutSharp.Models.NewExecutable +{ + /// + [StructLayout(LayoutKind.Sequential)] + public class ImportNameRelocationRecord + { + /// + /// Index into module reference table for the imported module. + /// + public ushort Index; + + /// + /// Offset within Imported Names Table to procedure name string. + /// + public ushort Offset; + } +} diff --git a/BurnOutSharp.Models/NewExecutable/ImportOrdinalRelocationRecord.cs b/BurnOutSharp.Models/NewExecutable/ImportOrdinalRelocationRecord.cs new file mode 100644 index 00000000..9d8f1930 --- /dev/null +++ b/BurnOutSharp.Models/NewExecutable/ImportOrdinalRelocationRecord.cs @@ -0,0 +1,19 @@ +using System.Runtime.InteropServices; + +namespace BurnOutSharp.Models.NewExecutable +{ + /// + [StructLayout(LayoutKind.Sequential)] + public class ImportOrdinalRelocationRecord + { + /// + /// Index into module reference table for the imported module. + /// + public ushort Index; + + /// + /// Procedure ordinal number. + /// + public ushort Ordinal; + } +} diff --git a/BurnOutSharp.Models/NewExecutable/InternalRefRelocationRecord.cs b/BurnOutSharp.Models/NewExecutable/InternalRefRelocationRecord.cs new file mode 100644 index 00000000..180e1975 --- /dev/null +++ b/BurnOutSharp.Models/NewExecutable/InternalRefRelocationRecord.cs @@ -0,0 +1,26 @@ +using System.Runtime.InteropServices; + +namespace BurnOutSharp.Models.NewExecutable +{ + /// + [StructLayout(LayoutKind.Sequential)] + public class InternalRefRelocationRecord + { + /// + /// Segment number for a fixed segment, or 0FFh for a + /// movable segment. + /// + public byte SegmentNumber; + + /// + /// 0 + /// + public byte Reserved; + + /// + /// Offset into segment if fixed segment, or ordinal + /// number index into Entry Table if movable segment. + /// + public ushort Offset; + } +} diff --git a/BurnOutSharp.Models/NewExecutable/OSFixupRelocationRecord.cs b/BurnOutSharp.Models/NewExecutable/OSFixupRelocationRecord.cs new file mode 100644 index 00000000..bd8c63ed --- /dev/null +++ b/BurnOutSharp.Models/NewExecutable/OSFixupRelocationRecord.cs @@ -0,0 +1,20 @@ +using System.Runtime.InteropServices; + +namespace BurnOutSharp.Models.NewExecutable +{ + /// + [StructLayout(LayoutKind.Sequential)] + public class OSFixupRelocationRecord + { + /// + /// Operating system fixup type. + /// Floating-point fixups. + /// + public OSFixupType FixupType; + + /// + /// 0 + /// + public ushort Reserved; + } +} diff --git a/BurnOutSharp.Models/NewExecutable/PerSegmentData.cs b/BurnOutSharp.Models/NewExecutable/PerSegmentData.cs new file mode 100644 index 00000000..bd45517a --- /dev/null +++ b/BurnOutSharp.Models/NewExecutable/PerSegmentData.cs @@ -0,0 +1,23 @@ +namespace BurnOutSharp.Models.NewExecutable +{ + /// + /// The location and size of the per-segment data is defined in the + /// segment table entry for the segment. If the segment has relocation + /// fixups, as defined in the segment table entry flags, they directly + /// follow the segment data in the file. The relocation fixup information + /// is defined as follows: + /// + /// + public class PerSegmentData + { + /// + /// Number of relocation records that follow. + /// + public ushort RelocationRecordCount; + + /// + /// A table of relocation records follows. + /// + public RelocationRecord[] RelocationRecords; + } +} diff --git a/BurnOutSharp.Models/NewExecutable/RelocationRecord.cs b/BurnOutSharp.Models/NewExecutable/RelocationRecord.cs new file mode 100644 index 00000000..71f00b57 --- /dev/null +++ b/BurnOutSharp.Models/NewExecutable/RelocationRecord.cs @@ -0,0 +1,60 @@ +using System.Runtime.InteropServices; + +namespace BurnOutSharp.Models.NewExecutable +{ + /// + /// A table of relocation records follows. The following is the format + /// of each relocation record. + /// + /// + [StructLayout(LayoutKind.Sequential)] + public class RelocationRecord + { + /// + /// Source type. + /// + public RelocationRecordSourceType SourceType; + + /// + /// Flags byte. + /// + /// The target value has four types that are defined in the flag + /// byte field. + /// + public RelocationRecordFlag Flags; + + /// + /// Offset within this segment of the source chain. + /// If the ADDITIVE flag is set, then target value is added to + /// the source contents, instead of replacing the source and + /// following the chain. The source chain is an 0FFFFh + /// terminated linked list within this segment of all + /// references to the target. + /// + public ushort Offset; + + /// + /// INTERNALREF + /// + /// Must be NULL if is not set to + public InternalRefRelocationRecord InternalRefRelocationRecord; + + /// + /// IMPORTNAME + /// + /// Must be NULL if is not set to + public ImportNameRelocationRecord ImportNameRelocationRecord; + + /// + /// IMPORTORDINAL + /// + /// Must be NULL if is not set to + public ImportOrdinalRelocationRecord ImportOrdinalRelocationRecord; + + /// + /// IMPORTORDINAL + /// + /// Must be NULL if is not set to + public OSFixupRelocationRecord OSFixupRelocationRecord; + } +}