From 5b6f4d65bfda6de1c5bbe61019f99ed31ea6fa24 Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Fri, 4 Nov 2022 14:51:57 -0700 Subject: [PATCH] Add LE/LX resource table --- .../LinearExecutable/Executable.cs | 9 +++- .../LinearExecutable/ResourceTableEntry.cs | 52 +++++++++++++++++++ 2 files changed, 59 insertions(+), 2 deletions(-) create mode 100644 BurnOutSharp.Models/LinearExecutable/ResourceTableEntry.cs diff --git a/BurnOutSharp.Models/LinearExecutable/Executable.cs b/BurnOutSharp.Models/LinearExecutable/Executable.cs index 643c6a1c..a3ff1327 100644 --- a/BurnOutSharp.Models/LinearExecutable/Executable.cs +++ b/BurnOutSharp.Models/LinearExecutable/Executable.cs @@ -30,8 +30,13 @@ namespace BurnOutSharp.Models.LinearExecutable /// public ObjectPageTableEntry[] ObjectPageTable { get; set; } - // TODO: Object iterate data map table - // TODO: Resource table + // TODO: Object iterate data map table [Does this exist?] + + /// + /// Resource table + /// + public ResourceTableEntry[] ResourceTable { get; set; } + // TODO: Resident-names table // TODO: Entry table // TODO: Module directives table diff --git a/BurnOutSharp.Models/LinearExecutable/ResourceTableEntry.cs b/BurnOutSharp.Models/LinearExecutable/ResourceTableEntry.cs new file mode 100644 index 00000000..2d11eb2d --- /dev/null +++ b/BurnOutSharp.Models/LinearExecutable/ResourceTableEntry.cs @@ -0,0 +1,52 @@ +using System.Runtime.InteropServices; + +namespace BurnOutSharp.Models.LinearExecutable +{ + /// + /// The resource table is an array of resource table entries. Each resource table + /// entry contains a type ID and name ID. These entries are used to locate resource + /// objects contained in the Object table. The number of entries in the resource + /// table is defined by the Resource Table Count located in the linear EXE header. + /// More than one resource may be contained within a single object. Resource table + /// entries are in a sorted order, (ascending, by Resource Name ID within the + /// Resource Type ID). This allows the DosGetResource API function to use a binary + /// search when looking up a resource in a 32-bit module instead of the linear search + /// being used in the current 16-bit module. + /// + /// + /// + [StructLayout(LayoutKind.Sequential)] + public class ResourceTableEntry + { + /// + /// Resource type ID. + /// + /// + /// The type of resources are: + /// - BTMP = Bitmap + /// - EMSG = Error message string + /// - FONT = Fonts + /// + public ushort TypeID; + + /// + /// An ID used as a name for the resource when referred to. + /// + public ushort NameID; + + /// + /// The number of bytes the resource consists of. + /// + public uint ResourceSize; + + /// + /// The number of the object which contains the resource. + /// + public ushort ObjectNumber; + + /// + /// The offset within the specified object where the resource begins. + /// + public uint Offset; + } +}