Add NE resource table

This commit is contained in:
Matt Nadareski
2022-11-04 09:56:06 -07:00
parent 4bdc5dc90f
commit dcef3115b8
6 changed files with 165 additions and 1 deletions

View File

@@ -150,6 +150,25 @@ namespace BurnOutSharp.Models.NewExecutable
Unknown = 0xF0,
}
[Flags]
public enum ResourceTypeResourceFlag : ushort
{
/// <summary>
/// Resource is not fixed.
/// </summary>
MOVEABLE = 0x0010,
/// <summary>
/// Resource can be shared.
/// </summary>
PURE = 0x0020,
/// <summary>
/// Resource is preloaded.
/// </summary>
PRELOAD = 0x0040,
}
[Flags]
public enum SegmentTableEntryFlag : ushort
{

View File

@@ -26,7 +26,10 @@ namespace BurnOutSharp.Models.NewExecutable
/// </summary>
public SegmentTableEntry[] SegmentTable { get; set; }
// TODO: NE Resource Table
/// <summary>
/// Resource table
/// </summary>
public ResourceTable ResourceTable { get; set; }
/// <summary>
/// Resident-Name table

View File

@@ -0,0 +1,35 @@
using System.Runtime.InteropServices;
namespace BurnOutSharp.Models.NewExecutable
{
/// <summary>
/// The resource table follows the segment table and contains entries for
/// each resource in the executable file. The resource table consists of
/// an alignment shift count, followed by a table of resource records. The
/// resource records define the type ID for a set of resources. Each
/// resource record contains a table of resource entries of the defined
/// type. The resource entry defines the resource ID or name ID for the
/// resource. It also defines the location and size of the resource. The
/// following describes the contents of each of these structures:
/// </summary>
/// <see href="http://bytepointer.com/resources/win16_ne_exe_format_win3.0.htm"/>
[StructLayout(LayoutKind.Sequential)]
public class ResourceTable
{
/// <summary>
/// Alignment shift count for resource data.
/// </summary>
public ushort AlignmentShiftCount;
/// <summary>
/// A table of resource type information blocks follows.
/// </summary>
public ResourceTypeInformationEntry[] ResourceTypes;
/// <summary>
/// Resource type and name strings are stored at the end of the
/// resource table.
/// </summary>
public ResourceTypeAndNameString[] TypeAndNameStrings;
}
}

View File

@@ -0,0 +1,26 @@
using System.Runtime.InteropServices;
namespace BurnOutSharp.Models.NewExecutable
{
/// <summary>
/// Resource type and name strings are stored at the end of the
/// resource table. Note that these strings are NOT null terminated and
/// are case sensitive.
/// </summary>
/// <see href="http://bytepointer.com/resources/win16_ne_exe_format_win3.0.htm"/>
[StructLayout(LayoutKind.Sequential)]
public class ResourceTypeAndNameString
{
/// <summary>
/// Length of the type or name string that follows. A zero value
/// indicates the end of the resource type and name string, also
/// the end of the resource table.
/// </summary>
public byte Length;
/// <summary>
/// ASCII text of the type or name string.
/// </summary>
public byte[] Text;
}
}

View File

@@ -0,0 +1,37 @@
using System.Runtime.InteropServices;
namespace BurnOutSharp.Models.NewExecutable
{
/// <summary>
/// A table of resource type information blocks follows. The following
/// is the format of each type information block:
/// </summary>
/// <see href="http://bytepointer.com/resources/win16_ne_exe_format_win3.0.htm"/>
[StructLayout(LayoutKind.Sequential)]
public class ResourceTypeInformationEntry
{
/// <summary>
/// Type ID. This is an integer type if the high-order bit is
/// set (8000h); otherwise, it is an offset to the type string,
/// the offset is relative to the beginning of the resource
/// table. A zero type ID marks the end of the resource type
/// information blocks.
/// </summary>
public ushort TypeID;
/// <summary>
/// Number of resources for this type.
/// </summary>
public ushort ResourceCount;
/// <summary>
/// Reserved.
/// </summary>
public uint Reserved;
/// <summary>
/// A table of resources for this type follows.
/// </summary>
public ResourceTypeResourceEntry[] Resources;
}
}

View File

@@ -0,0 +1,44 @@
using System.Runtime.InteropServices;
namespace BurnOutSharp.Models.NewExecutable
{
/// <summary>
/// A table of resources for this type follows. The following is
/// the format of each resource (8 bytes each):
/// </summary>
/// <see href="http://bytepointer.com/resources/win16_ne_exe_format_win3.0.htm"/>
[StructLayout(LayoutKind.Sequential)]
public class ResourceTypeResourceEntry
{
/// <summary>
/// File offset to the contents of the resource data,
/// relative to beginning of file. The offset is in terms
/// of the alignment shift count value specified at
/// beginning of the resource table.
/// </summary>
public ushort Offset;
/// <summary>
/// Length of the resource in the file (in bytes).
/// </summary>
public ushort Length;
/// <summary>
/// Flag word.
/// </summary>
public ResourceTypeResourceFlag FlagWord;
/// <summary>
/// Resource ID. This is an integer type if the high-order
/// bit is set (8000h), otherwise it is the offset to the
/// resource string, the offset is relative to the
/// beginning of the resource table.
/// </summary>
public ushort ResourceID;
/// <summary>
/// Reserved.
/// </summary>
public uint Reserved;
}
}