using System.Runtime.InteropServices;
namespace BurnOutSharp.Models.NewExecutable
{
///
/// The NE header is a relatively large structure with multiple characteristics.
/// Because of the age of the format some items are unclear in meaning.
///
///
///
[StructLayout(LayoutKind.Sequential)]
public class ExecutableHeader
{
///
/// Signature word.
/// "N" is low-order byte.
/// "E" is high-order byte.
///
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)]
public char[] Magic;
///
/// Version number of the linker.
///
public byte LinkerVersion;
///
/// Revision number of the linker.
///
public byte LinkerRevision;
///
/// Entry Table file offset, relative to the beginning of the segmented EXE header.
///
public ushort EntryTableOffset;
///
/// Number of bytes in the entry table.
///
public ushort EntryTableSize;
///
/// 32-bit CRC of entire contents of file.
///
/// These words are taken as 00 during the calculation.
public uint CrcChecksum;
///
/// Flag word
///
public HeaderFlag FlagWord;
///
/// 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.
///
///
/// A Segment number is an index into the module's segment
/// table. The first entry in the segment table is segment
/// number 1.
///
public ushort AutomaticDataSegmentNumber;
///
/// Initial size, in bytes, of dynamic heap added to the
/// data segment. This value is zero if no initial local
/// heap is allocated.
///
public ushort InitialHeapAlloc;
///
/// 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.
///
public ushort InitialStackAlloc;
///
/// Segment number:offset of CS:IP.
///
public uint InitialCSIPSetting;
///
/// Segment number:offset of SS:SP.
///
///
/// 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.
///
public uint InitialSSSPSetting;
///
/// Number of entries in the Segment Table.
///
public ushort FileSegmentCount;
///
/// Number of entries in the Module Reference Table.
///
public ushort ModuleReferenceTableSize;
///
/// Number of bytes in the Non-Resident Name Table.
///
public ushort NonResidentNameTableSize;
///
/// Segment Table file offset, relative to the beginning
/// of the segmented EXE header.
///
public ushort SegmentTableOffset;
///
/// Resource Table file offset, relative to the beginning
/// of the segmented EXE header.
///
public ushort ResourceTableOffset;
///
/// Resident Name Table file offset, relative to the
/// beginning of the segmented EXE header.
///
public ushort ResidentNameTableOffset;
///
/// Module Reference Table file offset, relative to the
/// beginning of the segmented EXE header.
///
public ushort ModuleReferenceTableOffset;
///
/// Imported Names Table file offset, relative to the
/// beginning of the segmented EXE header.
///
public ushort ImportedNamesTableOffset;
///
/// Non-Resident Name Table offset, relative to the
/// beginning of the file.
///
public uint NonResidentNamesTableOffset;
///
/// Number of movable entries in the Entry Table.
///
public ushort MovableEntriesCount;
///
/// Logical sector alignment shift count, log(base 2) of
/// the segment sector size (default 9).
///
public ushort SegmentAlignmentShiftCount;
///
/// Number of resource entries.
///
public ushort ResourceEntriesCount;
///
/// Executable type, used by loader.
///
public OperatingSystem TargetOperatingSystem;
///
/// Other OS/2 flags
///
public OS2Flag AdditionalFlags;
///
/// Offset to return thunks or start of gangload area
///
public ushort ReturnThunkOffset;
///
/// Offset to segment reference thunks or size of gangload area
///
public ushort SegmentReferenceThunkOffset;
///
/// Minimum code swap area size
///
public ushort MinCodeSwapAreaSize;
///
/// Windows SDK revison number
///
public byte WindowsSDKRevision;
///
/// Windows SDK version number
///
public byte WindowsSDKVersion;
}
}