2020-06-15 07:18:57 -07:00
|
|
|
#ifndef COSMOPOLITAN_LIBC_NT_STRUCT_IMAGEOPTIONALHEADER_H_
|
|
|
|
#define COSMOPOLITAN_LIBC_NT_STRUCT_IMAGEOPTIONALHEADER_H_
|
2020-11-25 08:19:00 -08:00
|
|
|
#include "libc/nt/pedef.internal.h"
|
|
|
|
#include "libc/nt/struct/imagedatadirectory.internal.h"
|
2020-06-15 07:18:57 -07:00
|
|
|
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
|
|
|
|
2023-07-25 05:43:04 -07:00
|
|
|
/**
|
|
|
|
* Portable Executable Optional Header.
|
|
|
|
*
|
|
|
|
* @see NtImageNtHeaders which encloses this
|
|
|
|
* @see NtImageFileHeader which precedes this
|
|
|
|
* @see NtImageSectionHeader which follows this
|
|
|
|
*/
|
2020-06-15 07:18:57 -07:00
|
|
|
struct NtImageOptionalHeader {
|
2023-07-25 05:43:04 -07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Must be kNtPe64bit.
|
|
|
|
*/
|
2020-06-15 07:18:57 -07:00
|
|
|
uint16_t Magic;
|
2023-07-25 05:43:04 -07:00
|
|
|
|
2020-06-15 07:18:57 -07:00
|
|
|
uint8_t MajorLinkerVersion;
|
|
|
|
uint8_t MinorLinkerVersion;
|
|
|
|
uint32_t SizeOfCode;
|
|
|
|
uint32_t SizeOfInitializedData;
|
|
|
|
uint32_t SizeOfUninitializedData;
|
2023-07-24 00:49:06 -07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* The address of the entry point relative to the image base when the
|
|
|
|
* executable file is loaded into memory. For program images, this is
|
|
|
|
* the starting address. For device drivers, this is the address of
|
|
|
|
* the initialization function. An entry point is optional for DLLs.
|
|
|
|
* When no entry point is present, this field must be zero.
|
|
|
|
*/
|
2020-06-15 07:18:57 -07:00
|
|
|
uint32_t AddressOfEntryPoint;
|
2023-07-24 00:49:06 -07:00
|
|
|
|
2020-06-15 07:18:57 -07:00
|
|
|
uint32_t BaseOfCode;
|
2023-07-24 00:49:06 -07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* The preferred address of the first byte of image when loaded into
|
|
|
|
* memory; must be a multiple of 64 K. The default for DLLs is
|
|
|
|
* 0x10000000. The default for Windows CE EXEs is 0x00010000. The
|
|
|
|
* default for Windows NT, Windows 2000, Windows XP, Windows 95,
|
|
|
|
* Windows 98, and Windows Me is 0x00400000.
|
|
|
|
*/
|
2020-06-15 07:18:57 -07:00
|
|
|
uint64_t ImageBase;
|
2023-07-24 00:49:06 -07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* The alignment (in bytes) of sections when they are loaded into
|
|
|
|
* memory. It must be greater than or equal to FileAlignment. The
|
|
|
|
* default is the page size for the architecture.
|
|
|
|
*/
|
2020-06-15 07:18:57 -07:00
|
|
|
uint32_t SectionAlignment;
|
2023-07-24 00:49:06 -07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* The alignment factor (in bytes) that is used to align the raw data
|
|
|
|
* of sections in the image file. The value should be a power of 2
|
|
|
|
* between 512 and 64 K, inclusive. The default is 512. If the
|
|
|
|
* SectionAlignment is less than the architecture's page size, then
|
|
|
|
* FileAlignment must match SectionAlignment.
|
|
|
|
*/
|
2020-06-15 07:18:57 -07:00
|
|
|
uint32_t FileAlignment;
|
2023-07-24 00:49:06 -07:00
|
|
|
|
2020-06-15 07:18:57 -07:00
|
|
|
uint16_t MajorOperatingSystemVersion;
|
|
|
|
uint16_t MinorOperatingSystemVersion;
|
|
|
|
uint16_t MajorImageVersion;
|
|
|
|
uint16_t MinorImageVersion;
|
|
|
|
uint16_t MajorSubsystemVersion;
|
|
|
|
uint16_t MinorSubsystemVersion;
|
|
|
|
uint32_t Win32VersionValue;
|
2023-07-25 05:43:04 -07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* The size (in bytes) of the image, including all headers, as the
|
|
|
|
* image is loaded in memory. It must be a multiple of
|
|
|
|
* SectionAlignment.
|
|
|
|
*/
|
2020-06-15 07:18:57 -07:00
|
|
|
uint32_t SizeOfImage;
|
2023-07-25 05:43:04 -07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* The combined size of an MS-DOS stub, PE header, and section headers
|
|
|
|
* rounded up to a multiple of FileAlignment.
|
|
|
|
*/
|
2020-06-15 07:18:57 -07:00
|
|
|
uint32_t SizeOfHeaders;
|
2023-07-25 05:43:04 -07:00
|
|
|
|
2020-06-15 07:18:57 -07:00
|
|
|
uint32_t CheckSum;
|
|
|
|
uint16_t Subsystem;
|
|
|
|
uint16_t DllCharacteristics;
|
|
|
|
uint64_t SizeOfStackReserve;
|
|
|
|
uint64_t SizeOfStackCommit;
|
|
|
|
uint64_t SizeOfHeapReserve;
|
|
|
|
uint64_t SizeOfHeapCommit;
|
|
|
|
uint32_t LoaderFlags;
|
|
|
|
uint32_t NumberOfRvaAndSizes;
|
2023-07-24 00:49:06 -07:00
|
|
|
struct NtImageDataDirectory DataDirectory[];
|
2020-06-15 07:18:57 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
|
|
|
#endif /* COSMOPOLITAN_LIBC_NT_STRUCT_IMAGEOPTIONALHEADER_H_ */
|