2023-09-04 00:12:49 -04:00
|
|
|
namespace SabreTools.Models.NewExecutable
|
2023-09-04 00:11:04 -04:00
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The NE header is a relatively large structure with multiple characteristics.
|
|
|
|
|
/// Because of the age of the format some items are unclear in meaning.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <see href="http://bytepointer.com/resources/win16_ne_exe_format_win3.0.htm"/>
|
|
|
|
|
/// <see href="https://github.com/libyal/libexe/blob/main/documentation/Executable%20(EXE)%20file%20format.asciidoc#24-ne-extended-header"/>
|
|
|
|
|
public sealed class ExecutableHeader
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Signature word.
|
|
|
|
|
/// "N" is low-order byte.
|
|
|
|
|
/// "E" is high-order byte.
|
|
|
|
|
/// </summary>
|
2023-09-04 21:14:41 -04:00
|
|
|
#if NET48
|
2023-09-04 00:11:04 -04:00
|
|
|
public string Magic;
|
2023-09-04 21:14:41 -04:00
|
|
|
#else
|
|
|
|
|
public string? Magic;
|
|
|
|
|
#endif
|
2023-09-04 00:11:04 -04:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Version number of the linker.
|
|
|
|
|
/// </summary>
|
2023-09-10 21:24:10 -04:00
|
|
|
public byte LinkerVersion { get; set; }
|
2023-09-04 00:11:04 -04:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Revision number of the linker.
|
|
|
|
|
/// </summary>
|
2023-09-10 21:24:10 -04:00
|
|
|
public byte LinkerRevision { get; set; }
|
2023-09-04 00:11:04 -04:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Entry Table file offset, relative to the beginning of the segmented EXE header.
|
|
|
|
|
/// </summary>
|
2023-09-10 21:24:10 -04:00
|
|
|
public ushort EntryTableOffset { get; set; }
|
2023-09-04 00:11:04 -04:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Number of bytes in the entry table.
|
|
|
|
|
/// </summary>
|
2023-09-10 21:24:10 -04:00
|
|
|
public ushort EntryTableSize { get; set; }
|
2023-09-04 00:11:04 -04:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 32-bit CRC of entire contents of file.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <remarks>These words are taken as 00 during the calculation.</remarks>
|
2023-09-10 21:24:10 -04:00
|
|
|
public uint CrcChecksum { get; set; }
|
2023-09-04 00:11:04 -04:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Flag word
|
|
|
|
|
/// </summary>
|
2023-09-10 21:24:10 -04:00
|
|
|
public HeaderFlag FlagWord { get; set; }
|
2023-09-04 00:11:04 -04:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Segment number of automatic data segment.
|
|
|
|
|
/// This value is set to zero if SINGLEDATA and
|
|
|
|
|
/// MULTIPLEDATA flag bits are clear, NOAUTODATA is
|
|
|
|
|
/// indicated in the flags word.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <remarks>
|
|
|
|
|
/// A Segment number is an index into the module's segment
|
|
|
|
|
/// table. The first entry in the segment table is segment
|
|
|
|
|
/// number 1.
|
|
|
|
|
/// </remarks>
|
2023-09-10 21:24:10 -04:00
|
|
|
public ushort AutomaticDataSegmentNumber { get; set; }
|
2023-09-04 00:11:04 -04:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Initial size, in bytes, of dynamic heap added to the
|
|
|
|
|
/// data segment. This value is zero if no initial local
|
|
|
|
|
/// heap is allocated.
|
|
|
|
|
/// </summary>
|
2023-09-10 21:24:10 -04:00
|
|
|
public ushort InitialHeapAlloc { get; set; }
|
2023-09-04 00:11:04 -04:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Initial size, in bytes, of stack added to the data
|
|
|
|
|
/// segment. This value is zero to indicate no initial
|
|
|
|
|
/// stack allocation, or when SS is not equal to DS.
|
|
|
|
|
/// </summary>
|
2023-09-10 21:24:10 -04:00
|
|
|
public ushort InitialStackAlloc { get; set; }
|
2023-09-04 00:11:04 -04:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Segment number:offset of CS:IP.
|
|
|
|
|
/// </summary>
|
2023-09-10 21:24:10 -04:00
|
|
|
public uint InitialCSIPSetting { get; set; }
|
2023-09-04 00:11:04 -04:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Segment number:offset of SS:SP.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <remarks>
|
|
|
|
|
/// If SS equals the automatic data segment and SP equals
|
|
|
|
|
/// zero, the stack pointer is set to the top of the
|
|
|
|
|
/// automatic data segment just below the additional heap
|
|
|
|
|
/// area.
|
|
|
|
|
/// </remarks>
|
2023-09-10 21:24:10 -04:00
|
|
|
public uint InitialSSSPSetting { get; set; }
|
2023-09-04 00:11:04 -04:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Number of entries in the Segment Table.
|
|
|
|
|
/// </summary>
|
2023-09-10 21:24:10 -04:00
|
|
|
public ushort FileSegmentCount { get; set; }
|
2023-09-04 00:11:04 -04:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Number of entries in the Module Reference Table.
|
|
|
|
|
/// </summary>
|
2023-09-10 21:24:10 -04:00
|
|
|
public ushort ModuleReferenceTableSize { get; set; }
|
2023-09-04 00:11:04 -04:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Number of bytes in the Non-Resident Name Table.
|
|
|
|
|
/// </summary>
|
2023-09-10 21:24:10 -04:00
|
|
|
public ushort NonResidentNameTableSize { get; set; }
|
2023-09-04 00:11:04 -04:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Segment Table file offset, relative to the beginning
|
|
|
|
|
/// of the segmented EXE header.
|
|
|
|
|
/// </summary>
|
2023-09-10 21:24:10 -04:00
|
|
|
public ushort SegmentTableOffset { get; set; }
|
2023-09-04 00:11:04 -04:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Resource Table file offset, relative to the beginning
|
|
|
|
|
/// of the segmented EXE header.
|
|
|
|
|
/// </summary>
|
2023-09-10 21:24:10 -04:00
|
|
|
public ushort ResourceTableOffset { get; set; }
|
2023-09-04 00:11:04 -04:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Resident Name Table file offset, relative to the
|
|
|
|
|
/// beginning of the segmented EXE header.
|
|
|
|
|
/// </summary>
|
2023-09-10 21:24:10 -04:00
|
|
|
public ushort ResidentNameTableOffset { get; set; }
|
2023-09-04 00:11:04 -04:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Module Reference Table file offset, relative to the
|
|
|
|
|
/// beginning of the segmented EXE header.
|
|
|
|
|
/// </summary>
|
2023-09-10 21:24:10 -04:00
|
|
|
public ushort ModuleReferenceTableOffset { get; set; }
|
2023-09-04 00:11:04 -04:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Imported Names Table file offset, relative to the
|
|
|
|
|
/// beginning of the segmented EXE header.
|
|
|
|
|
/// </summary>
|
2023-09-10 21:24:10 -04:00
|
|
|
public ushort ImportedNamesTableOffset { get; set; }
|
2023-09-04 00:11:04 -04:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Non-Resident Name Table offset, relative to the
|
|
|
|
|
/// beginning of the file.
|
|
|
|
|
/// </summary>
|
2023-09-10 21:24:10 -04:00
|
|
|
public uint NonResidentNamesTableOffset { get; set; }
|
2023-09-04 00:11:04 -04:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Number of movable entries in the Entry Table.
|
|
|
|
|
/// </summary>
|
2023-09-10 21:24:10 -04:00
|
|
|
public ushort MovableEntriesCount { get; set; }
|
2023-09-04 00:11:04 -04:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Logical sector alignment shift count, log(base 2) of
|
|
|
|
|
/// the segment sector size (default 9).
|
|
|
|
|
/// </summary>
|
2023-09-10 21:24:10 -04:00
|
|
|
public ushort SegmentAlignmentShiftCount { get; set; }
|
2023-09-04 00:11:04 -04:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Number of resource entries.
|
|
|
|
|
/// </summary>
|
2023-09-10 21:24:10 -04:00
|
|
|
public ushort ResourceEntriesCount { get; set; }
|
2023-09-04 00:11:04 -04:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Executable type, used by loader.
|
|
|
|
|
/// </summary>
|
2023-09-10 21:24:10 -04:00
|
|
|
public OperatingSystem TargetOperatingSystem { get; set; }
|
2023-09-04 00:11:04 -04:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Other OS/2 flags
|
|
|
|
|
/// </summary>
|
2023-09-10 21:24:10 -04:00
|
|
|
public OS2Flag AdditionalFlags { get; set; }
|
2023-09-04 00:11:04 -04:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Offset to return thunks or start of gangload area
|
|
|
|
|
/// </summary>
|
2023-09-10 21:24:10 -04:00
|
|
|
public ushort ReturnThunkOffset { get; set; }
|
2023-09-04 00:11:04 -04:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Offset to segment reference thunks or size of gangload area
|
|
|
|
|
/// </summary>
|
2023-09-10 21:24:10 -04:00
|
|
|
public ushort SegmentReferenceThunkOffset { get; set; }
|
2023-09-04 00:11:04 -04:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Minimum code swap area size
|
|
|
|
|
/// </summary>
|
2023-09-10 21:24:10 -04:00
|
|
|
public ushort MinCodeSwapAreaSize { get; set; }
|
2023-09-04 00:11:04 -04:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Windows SDK revison number
|
|
|
|
|
/// </summary>
|
2023-09-10 21:24:10 -04:00
|
|
|
public byte WindowsSDKRevision { get; set; }
|
2023-09-04 00:11:04 -04:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Windows SDK version number
|
|
|
|
|
/// </summary>
|
2023-09-10 21:24:10 -04:00
|
|
|
public byte WindowsSDKVersion { get; set; }
|
2023-09-04 00:11:04 -04:00
|
|
|
}
|
|
|
|
|
}
|