mirror of
https://github.com/SabreTools/SabreTools.Models.git
synced 2026-09-24 07:37:10 +00:00
Migrate many models to StructLayout
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace SabreTools.Models.NewExecutable
|
||||
{
|
||||
/// <summary>
|
||||
@@ -6,6 +8,7 @@ namespace SabreTools.Models.NewExecutable
|
||||
/// </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"/>
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
|
||||
public sealed class ExecutableHeader
|
||||
{
|
||||
/// <summary>
|
||||
@@ -13,38 +16,40 @@ namespace SabreTools.Models.NewExecutable
|
||||
/// "N" is low-order byte.
|
||||
/// "E" is high-order byte.
|
||||
/// </summary>
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 2)]
|
||||
public string? Magic;
|
||||
|
||||
/// <summary>
|
||||
/// Version number of the linker.
|
||||
/// </summary>
|
||||
public byte LinkerVersion { get; set; }
|
||||
public byte LinkerVersion;
|
||||
|
||||
/// <summary>
|
||||
/// Revision number of the linker.
|
||||
/// </summary>
|
||||
public byte LinkerRevision { get; set; }
|
||||
public byte LinkerRevision;
|
||||
|
||||
/// <summary>
|
||||
/// Entry Table file offset, relative to the beginning of the segmented EXE header.
|
||||
/// </summary>
|
||||
public ushort EntryTableOffset { get; set; }
|
||||
public ushort EntryTableOffset;
|
||||
|
||||
/// <summary>
|
||||
/// Number of bytes in the entry table.
|
||||
/// </summary>
|
||||
public ushort EntryTableSize { get; set; }
|
||||
public ushort EntryTableSize;
|
||||
|
||||
/// <summary>
|
||||
/// 32-bit CRC of entire contents of file.
|
||||
/// </summary>
|
||||
/// <remarks>These words are taken as 00 during the calculation.</remarks>
|
||||
public uint CrcChecksum { get; set; }
|
||||
public uint CrcChecksum;
|
||||
|
||||
/// <summary>
|
||||
/// Flag word
|
||||
/// </summary>
|
||||
public HeaderFlag FlagWord { get; set; }
|
||||
[MarshalAs(UnmanagedType.U2)]
|
||||
public HeaderFlag FlagWord;
|
||||
|
||||
/// <summary>
|
||||
/// Segment number of automatic data segment.
|
||||
@@ -57,26 +62,26 @@ namespace SabreTools.Models.NewExecutable
|
||||
/// table. The first entry in the segment table is segment
|
||||
/// number 1.
|
||||
/// </remarks>
|
||||
public ushort AutomaticDataSegmentNumber { get; set; }
|
||||
public ushort AutomaticDataSegmentNumber;
|
||||
|
||||
/// <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>
|
||||
public ushort InitialHeapAlloc { get; set; }
|
||||
public ushort InitialHeapAlloc;
|
||||
|
||||
/// <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>
|
||||
public ushort InitialStackAlloc { get; set; }
|
||||
public ushort InitialStackAlloc;
|
||||
|
||||
/// <summary>
|
||||
/// Segment number:offset of CS:IP.
|
||||
/// </summary>
|
||||
public uint InitialCSIPSetting { get; set; }
|
||||
public uint InitialCSIPSetting;
|
||||
|
||||
/// <summary>
|
||||
/// Segment number:offset of SS:SP.
|
||||
@@ -87,108 +92,110 @@ namespace SabreTools.Models.NewExecutable
|
||||
/// automatic data segment just below the additional heap
|
||||
/// area.
|
||||
/// </remarks>
|
||||
public uint InitialSSSPSetting { get; set; }
|
||||
public uint InitialSSSPSetting;
|
||||
|
||||
/// <summary>
|
||||
/// Number of entries in the Segment Table.
|
||||
/// </summary>
|
||||
public ushort FileSegmentCount { get; set; }
|
||||
public ushort FileSegmentCount;
|
||||
|
||||
/// <summary>
|
||||
/// Number of entries in the Module Reference Table.
|
||||
/// </summary>
|
||||
public ushort ModuleReferenceTableSize { get; set; }
|
||||
public ushort ModuleReferenceTableSize;
|
||||
|
||||
/// <summary>
|
||||
/// Number of bytes in the Non-Resident Name Table.
|
||||
/// </summary>
|
||||
public ushort NonResidentNameTableSize { get; set; }
|
||||
public ushort NonResidentNameTableSize;
|
||||
|
||||
/// <summary>
|
||||
/// Segment Table file offset, relative to the beginning
|
||||
/// of the segmented EXE header.
|
||||
/// </summary>
|
||||
public ushort SegmentTableOffset { get; set; }
|
||||
public ushort SegmentTableOffset;
|
||||
|
||||
/// <summary>
|
||||
/// Resource Table file offset, relative to the beginning
|
||||
/// of the segmented EXE header.
|
||||
/// </summary>
|
||||
public ushort ResourceTableOffset { get; set; }
|
||||
public ushort ResourceTableOffset;
|
||||
|
||||
/// <summary>
|
||||
/// Resident Name Table file offset, relative to the
|
||||
/// beginning of the segmented EXE header.
|
||||
/// </summary>
|
||||
public ushort ResidentNameTableOffset { get; set; }
|
||||
public ushort ResidentNameTableOffset;
|
||||
|
||||
/// <summary>
|
||||
/// Module Reference Table file offset, relative to the
|
||||
/// beginning of the segmented EXE header.
|
||||
/// </summary>
|
||||
public ushort ModuleReferenceTableOffset { get; set; }
|
||||
public ushort ModuleReferenceTableOffset;
|
||||
|
||||
/// <summary>
|
||||
/// Imported Names Table file offset, relative to the
|
||||
/// beginning of the segmented EXE header.
|
||||
/// </summary>
|
||||
public ushort ImportedNamesTableOffset { get; set; }
|
||||
public ushort ImportedNamesTableOffset;
|
||||
|
||||
/// <summary>
|
||||
/// Non-Resident Name Table offset, relative to the
|
||||
/// beginning of the file.
|
||||
/// </summary>
|
||||
public uint NonResidentNamesTableOffset { get; set; }
|
||||
public uint NonResidentNamesTableOffset;
|
||||
|
||||
/// <summary>
|
||||
/// Number of movable entries in the Entry Table.
|
||||
/// </summary>
|
||||
public ushort MovableEntriesCount { get; set; }
|
||||
public ushort MovableEntriesCount;
|
||||
|
||||
/// <summary>
|
||||
/// Logical sector alignment shift count, log(base 2) of
|
||||
/// the segment sector size (default 9).
|
||||
/// </summary>
|
||||
public ushort SegmentAlignmentShiftCount { get; set; }
|
||||
public ushort SegmentAlignmentShiftCount;
|
||||
|
||||
/// <summary>
|
||||
/// Number of resource entries.
|
||||
/// </summary>
|
||||
public ushort ResourceEntriesCount { get; set; }
|
||||
public ushort ResourceEntriesCount;
|
||||
|
||||
/// <summary>
|
||||
/// Executable type, used by loader.
|
||||
/// </summary>
|
||||
public OperatingSystem TargetOperatingSystem { get; set; }
|
||||
[MarshalAs(UnmanagedType.U1)]
|
||||
public OperatingSystem TargetOperatingSystem;
|
||||
|
||||
/// <summary>
|
||||
/// Other OS/2 flags
|
||||
/// </summary>
|
||||
public OS2Flag AdditionalFlags { get; set; }
|
||||
[MarshalAs(UnmanagedType.U1)]
|
||||
public OS2Flag AdditionalFlags;
|
||||
|
||||
/// <summary>
|
||||
/// Offset to return thunks or start of gangload area
|
||||
/// </summary>
|
||||
public ushort ReturnThunkOffset { get; set; }
|
||||
public ushort ReturnThunkOffset;
|
||||
|
||||
/// <summary>
|
||||
/// Offset to segment reference thunks or size of gangload area
|
||||
/// </summary>
|
||||
public ushort SegmentReferenceThunkOffset { get; set; }
|
||||
public ushort SegmentReferenceThunkOffset;
|
||||
|
||||
/// <summary>
|
||||
/// Minimum code swap area size
|
||||
/// </summary>
|
||||
public ushort MinCodeSwapAreaSize { get; set; }
|
||||
public ushort MinCodeSwapAreaSize;
|
||||
|
||||
/// <summary>
|
||||
/// Windows SDK revison number
|
||||
/// </summary>
|
||||
public byte WindowsSDKRevision { get; set; }
|
||||
public byte WindowsSDKRevision;
|
||||
|
||||
/// <summary>
|
||||
/// Windows SDK version number
|
||||
/// </summary>
|
||||
public byte WindowsSDKVersion { get; set; }
|
||||
public byte WindowsSDKVersion;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user