namespace SabreTools.Models.MSDOS { /// /// MZ executables only consists of 2 structures: the header and the relocation table. /// The header, which is followed by the program image, looks like this. /// /// /// public sealed class ExecutableHeader { #region Standard Fields /// /// 0x5A4D (ASCII for 'M' and 'Z') /// #if NET48 public string Magic { get; set; } #else public string? Magic { get; set; } #endif /// /// Number of bytes in the last page. /// public ushort LastPageBytes { get; set; } /// /// Number of whole/partial pages. /// /// A page (or block) is 512 bytes long. public ushort Pages { get; set; } /// /// Number of entries in the relocation table. /// public ushort RelocationItems { get; set; } /// /// The number of paragraphs taken up by the header. It can be any value, as the loader /// just uses it to find where the actual executable data starts. It may be larger than /// what the "standard" fields take up, and you may use it if you want to include your /// own header metadata, or put the relocation table there, or use it for any other purpose. [08] /// /// A paragraph is 16 bytes in size public ushort HeaderParagraphSize { get; set; } /// /// The number of paragraphs required by the program, excluding the PSP and program image. /// If no free block is big enough, the loading stops. /// /// A paragraph is 16 bytes in size public ushort MinimumExtraParagraphs { get; set; } /// /// The number of paragraphs requested by the program. /// If no free block is big enough, the biggest one possible is allocated. /// /// A paragraph is 16 bytes in size public ushort MaximumExtraParagraphs { get; set; } /// /// Relocatable segment address for SS. /// public ushort InitialSSValue { get; set; } /// /// Initial value for SP. /// public ushort InitialSPValue { get; set; } /// /// When added to the sum of all other words in the file, the result should be zero. /// public ushort Checksum { get; set; } /// /// Initial value for IP. [14] /// public ushort InitialIPValue { get; set; } /// /// Relocatable segment address for CS. /// public ushort InitialCSValue { get; set; } /// /// The (absolute) offset to the relocation table. /// public ushort RelocationTableAddr { get; set; } /// /// Value used for overlay management. /// If zero, this is the main executable. /// public ushort OverlayNumber { get; set; } #endregion #region PE Extensions /// /// Reserved words /// #if NET48 public ushort[] Reserved1 { get; set; } = new ushort[4]; #else public ushort[]? Reserved1 { get; set; } = new ushort[4]; #endif /// /// Defined by name but no other information is given; typically zeroes /// public ushort OEMIdentifier { get; set; } /// /// Defined by name but no other information is given; typically zeroes /// public ushort OEMInformation { get; set; } /// /// Reserved words /// #if NET48 public ushort[] Reserved2 { get; set; } = new ushort[10]; #else public ushort[]? Reserved2 { get; set; } = new ushort[10]; #endif /// /// Starting address of the PE header /// public uint NewExeHeaderAddr { get; set; } #endregion } }