using System.Runtime.InteropServices; namespace SabreTools.Data.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, CharSet = CharSet.Ansi)] public sealed class ExecutableHeader { /// /// "NE" /// [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 2)] public string Magic = string.Empty; /// /// Version number of the linker. /// /// Also known as the major linker version public byte LinkerVersion; /// /// Revision number of the linker. /// /// Also known as the minor linker version public byte LinkerRevision; /// /// Entry Table file offset, relative to the beginning of the segmented EXE header. /// public ushort EntryTableOffset; /// /// Length of entry table in bytes /// 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 /// [MarshalAs(UnmanagedType.U2)] 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. /// /// CS:IP entry point, CS is index into segment table public uint InitialCSIPSetting; /// /// Segment number:offset of SS:SP. /// /// /// SS:SP initial stack pointer, SS is index into segment table /// /// 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; /// /// Size of non-resident names table in bytes /// 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. /// [MarshalAs(UnmanagedType.U1)] public OperatingSystem TargetOperatingSystem; #region OS/2 Specific /// /// Other OS/2 flags /// [MarshalAs(UnmanagedType.U1)] 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; #endregion } }