From 4bdc5dc90f9438fb69fc5134d08952a3c313465e Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Fri, 4 Nov 2022 09:40:29 -0700 Subject: [PATCH] Add simple NE tables --- .../NewExecutable/Executable.cs | 28 ++++++++++++--- .../NewExecutable/ImportedNameTableEntry.cs | 28 +++++++++++++++ .../ModuleReferenceTableEntry.cs | 19 +++++++++++ .../NonResidentNameTableEntry.cs | 34 +++++++++++++++++++ .../NewExecutable/ResidentNameTableEntry.cs | 33 ++++++++++++++++++ 5 files changed, 137 insertions(+), 5 deletions(-) create mode 100644 BurnOutSharp.Models/NewExecutable/ImportedNameTableEntry.cs create mode 100644 BurnOutSharp.Models/NewExecutable/ModuleReferenceTableEntry.cs create mode 100644 BurnOutSharp.Models/NewExecutable/NonResidentNameTableEntry.cs create mode 100644 BurnOutSharp.Models/NewExecutable/ResidentNameTableEntry.cs diff --git a/BurnOutSharp.Models/NewExecutable/Executable.cs b/BurnOutSharp.Models/NewExecutable/Executable.cs index 96026779..52001660 100644 --- a/BurnOutSharp.Models/NewExecutable/Executable.cs +++ b/BurnOutSharp.Models/NewExecutable/Executable.cs @@ -26,12 +26,30 @@ namespace BurnOutSharp.Models.NewExecutable /// public SegmentTableEntry[] SegmentTable { get; set; } - // TODO: Resource Table - // TODO: Resident-Name Table - // TODO: Module-Reference Table - // TODO: Imported-Name Table + // TODO: NE Resource Table + + /// + /// Resident-Name table + /// + public ResidentNameTableEntry[] ResidentNameTable { get; set; } + + /// + /// Module-Reference table + /// + public ModuleReferenceTableEntry[] ModuleReferenceTable { get; set; } + + /// + /// Imported-Name table + /// + public ImportedNameTableEntry[] ImportedNameTable { get; set; } + // TODO: Entry Table - // TODO: Nonresident-Name Table + + /// + /// Nonresident-Name table + /// + public NonResidentNameTableEntry[] NonResidentNameTable { get; set; } + // TODO: Per Segment Data } } diff --git a/BurnOutSharp.Models/NewExecutable/ImportedNameTableEntry.cs b/BurnOutSharp.Models/NewExecutable/ImportedNameTableEntry.cs new file mode 100644 index 00000000..9000a017 --- /dev/null +++ b/BurnOutSharp.Models/NewExecutable/ImportedNameTableEntry.cs @@ -0,0 +1,28 @@ +using System.Runtime.InteropServices; + +namespace BurnOutSharp.Models.NewExecutable +{ + /// + /// The imported-name table follows the module-reference table. This table + /// contains the names of modules and procedures that are imported by the + /// executable file. Each entry is composed of a 1-byte field that + /// contains the length of the string, followed by any number of + /// characters. The strings are not null-terminated and are case + /// sensitive. + /// + /// + [StructLayout(LayoutKind.Sequential)] + public class ImportedNameTableEntry + { + /// + /// Length of the name string that follows. A zero value indicates + /// the end of the name table. + /// + public byte Length; + + /// + /// ASCII text of the name string. + /// + public byte[] NameString; + } +} diff --git a/BurnOutSharp.Models/NewExecutable/ModuleReferenceTableEntry.cs b/BurnOutSharp.Models/NewExecutable/ModuleReferenceTableEntry.cs new file mode 100644 index 00000000..98403473 --- /dev/null +++ b/BurnOutSharp.Models/NewExecutable/ModuleReferenceTableEntry.cs @@ -0,0 +1,19 @@ +using System.Runtime.InteropServices; + +namespace BurnOutSharp.Models.NewExecutable +{ + /// + /// The module-reference table follows the resident-name table. Each entry + /// contains an offset for the module-name string within the imported- + /// names table; each entry is 2 bytes long. + /// + /// + [StructLayout(LayoutKind.Sequential)] + public class ModuleReferenceTableEntry + { + /// + /// Offset within Imported Names Table to referenced module name string. + /// + public ushort Offset; + } +} diff --git a/BurnOutSharp.Models/NewExecutable/NonResidentNameTableEntry.cs b/BurnOutSharp.Models/NewExecutable/NonResidentNameTableEntry.cs new file mode 100644 index 00000000..e6643828 --- /dev/null +++ b/BurnOutSharp.Models/NewExecutable/NonResidentNameTableEntry.cs @@ -0,0 +1,34 @@ +using System.Runtime.InteropServices; + +namespace BurnOutSharp.Models.NewExecutable +{ + /// + /// The nonresident-name table follows the entry table, and contains a + /// module description and nonresident exported procedure name strings. + /// The first string in this table is a module description. These name + /// strings are case-sensitive and are not null-terminated. The name + /// strings follow the same format as those defined in the resident name + /// table. + /// + /// + [StructLayout(LayoutKind.Sequential)] + public class NonResidentNameTableEntry + { + /// + /// Length of the name string that follows. A zero value indicates + /// the end of the name table. + /// + public byte Length; + + /// + /// ASCII text of the name string. + /// + public byte[] NameString; + + /// + /// Ordinal number (index into entry table). This value is ignored + /// for the module name. + /// + public ushort OrdinalNumber; + } +} diff --git a/BurnOutSharp.Models/NewExecutable/ResidentNameTableEntry.cs b/BurnOutSharp.Models/NewExecutable/ResidentNameTableEntry.cs new file mode 100644 index 00000000..3b08a7af --- /dev/null +++ b/BurnOutSharp.Models/NewExecutable/ResidentNameTableEntry.cs @@ -0,0 +1,33 @@ +using System.Runtime.InteropServices; + +namespace BurnOutSharp.Models.NewExecutable +{ + /// + /// The resident-name table follows the resource table, and contains this + /// module's name string and resident exported procedure name strings. The + /// first string in this table is this module's name. These name strings + /// are case-sensitive and are not null-terminated. The following + /// describes the format of the name strings: + /// + /// + [StructLayout(LayoutKind.Sequential)] + public class ResidentNameTableEntry + { + /// + /// Length of the name string that follows. A zero value indicates + /// the end of the name table. + /// + public byte Length; + + /// + /// ASCII text of the name string. + /// + public byte[] NameString; + + /// + /// Ordinal number (index into entry table). This value is ignored + /// for the module name. + /// + public ushort OrdinalNumber; + } +}