Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
en:docs:tk:formats:newexe [2024/09/22 09:40] – prokushev | en:docs:tk:formats:newexe [2024/09/26 12:59] (current) – prokushev | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ^ Offset ^ Size ^ Name ^ Description ^ | + | ====== New Executable |
- | | 00h | WORD | e_magic | 0x4d, 0x5a. This is the "magic number" | + | |
- | | 02h | WORD | e_cblp | + | |
- | | 04h | WORD | e_cp | Number of blocks in the file that are part of the EXE file. If [02-03] is non-zero, only that much of the last block is used. | | + | |
- | | 06h | WORD | e_crlc | Number of relocation entries stored after the header. May be zero. | | + | |
- | | 08h | WORD | e_cparhdr | Number of paragraphs in the header. The program' | + | |
- | | 0Ah | WORD | e_minalloc | Number of paragraphs of additional memory that the program will need. This is the equivalent of the BSS size in a Unix program. The program can't be loaded if there isn't at least this much memory available to it. | | + | |
- | | 0Ch | WORD | e_maxalloc | Maximum number of paragraphs of additional memory. Normally, the OS reserves all the remaining conventional memory for your program, but you can limit it with this field. | | + | |
- | | 0EH | WORD | e_ss | Relative value of the stack segment. This value is added to the segment the program was loaded at, and the result is used to initialize the SS register. | | + | |
- | | 10h | WORD | e_sp | Initial value of the SP register. | | + | |
- | | 12h | WORD | e_csum | Word checksum. If set properly, the 16-bit sum of all words in the file should be zero. Usually, this isn't filled in. | | + | |
- | | 14h | WORD | e_ip | Initial value of the IP register. | | + | |
- | | 16h | WORD | e_cs | Initial value of the CS register, relative to the segment the program was loaded at. | | + | |
- | | 18h | WORD | e_lfarlc | Offset of the first relocation item in the file. | | + | |
- | | 1Ah | WORD | e_ovno | Overlay number. Normally zero, meaning that it's the main program. | | + | |
- | | 1Ch | WORD | e_res[ERES1WDS] | | | + | |
- | WORD e_oemid; | + | |
- | WORD e_oeminfo; | + | |
- | WORD e_res2[ERES2WDS]; | + | |
- | DWORD e_lfanew; | + | |
+ | New Executable (NE) file format used by set of operating system including OS/2, Windows, Multitasking MS-DOS 4 and set of DOS Extenders. It is designed to be store on disk and in-memory usage. In-disk format is same for all OSes, but In-memory usage is mostly specific for Windows systems. | ||
- | /* In-disk | + | ^ Offset ^ Size ^ Name ^ Description ^ |
+ | | 00h | WORD | ne_magic | Signature word NEMAGIC | | ||
+ | | On-disk |||| | ||
+ | | 02h | BYTE | ne_ver | Version number of the linker | | ||
+ | | 03h | BYTE| ne_rev | Revision number of the linker | | ||
+ | | In-memory |||| | ||
+ | | 02h | WORD | count | Usage count (ne_ver/ | ||
+ | | 04h | WORD | ne_enttab | Entry Table file offset, relative to the beginning of the segmented EXE header | | ||
+ | | On-disk |||| | ||
+ | | 06h | WORD | ne_cbenttab | Number of bytes in the entry table | | ||
+ | | In-memory | ||
+ | | 06h | WORD | next | Selector to next module | ||
+ | | On-disk |||| | ||
+ | | 08h | DWORD | ne_crc | 32-bit CRC of entire contents of file. These words are taken as 00 during the calculation | | ||
+ | | In-memory |||| | ||
+ | | 08h | WORD | dgroup_entry | Near ptr to segment entry for DGROUP | | ||
+ | | 0Ah | WORD | fileinfo | Near ptr to file info (OFSTRUCT) | | ||
+ | | 0Ch | WORD | ne_flags | Flag word | | ||
+ | | 0Eh | WORD | ne_autodata | 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 | | ||
+ | | 10h | WORD | ne_heap | Initial size, in bytes, of dynamic heap added to the data segment. This value is zero if no initial local heap is allocated | | ||
+ | | 12h | WORD | ne_stack | 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 | | ||
+ | | 14h | DWORD | ne_csip | Segment number: | ||
+ | | 18h | DWORD | ne_sssp | Segment number: | ||
+ | | 1Ch | WORD | ne_cseg | Number of entries in the Segment Table | | ||
+ | | 1Eh | WORD | ne_cmod | Number of entries in the Module Reference Table | | ||
+ | | 20h | WORD | ne_cbnrestab | Number of bytes in the Non-Resident Name Table | | ||
+ | | 22h | WORD | ne_segtab | Segment Table file offset, relative to the beginning of the segmented EXE header | | ||
+ | | 24h | WORD | ne_rsrctab | Resource Table file offset, relative to the beginning of the segmented EXE header | | ||
+ | | 26h | WORD | ne_restab | Resident Name Table file offset, relative to the beginning of the segmented EXE header | | ||
+ | | 28h | WORD | ne_modtab | Module Reference Table file offset, relative to the beginning of the segmented EXE header | | ||
+ | | 2Ah | WORD | ne_imptab | Imported Names Table file offset, relative to the beginning of the segmented EXE header | | ||
+ | | 2Ch | DWORD | ne_nrestab | Non-Resident Name Table offset, relative to the beginning of the file | | ||
+ | | 30h | WORD | ne_cmovent | Number of movable entries in the Entry Table | | ||
+ | | 32h | WORD | ne_align | Logical sector alignment shift count, log(base 2) of the segment sector size (default 9) | | ||
+ | | 34h | WORD | ne_cres | Number of resource entries | | ||
+ | | 36h | BYTE | ne_exetyp | Executable type, used by loader. 02h = WINDOWS | | ||
+ | | 37h | BYTE | ne_flagsothers | Operating system flags | | ||
+ | | 38h | WORD | ??? | offset to return thunks or start of gangload area | | ||
+ | | 3Ah | WORD | ??? | offset to segment reference thunks or length of gangload area | | ||
+ | | 3Ch | WORD | ??? | minimum code swap area size | | ||
+ | | 3Eh | 2 BYTEs | ??? | expected Windows version (minor version first) | | ||
- | struct new_exe { | + | On-disk segment entry |
- | WORD ne_magic; | + | |
- | union { | + | |
- | struct { | + | |
- | BYTE | + | |
- | BYTE | + | |
- | }; | + | |
- | WORD | + | |
- | }; | + | |
- | WORD ne_enttab; | + | |
- | | + | |
- | union { | + | |
- | WORD | + | |
- | WORD | + | |
- | }; | + | |
- | union { | + | |
- | DWORD | + | |
- | | + | |
- | struct { | + | |
- | WORD dgroup_entry; | + | |
- | WORD fileinfo; | + | |
- | }; | + | |
- | }; | + | |
- | WORD ne_flags; | + | |
- | WORD ne_autodata; | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | ^ Offset ^ Size ^ Name ^ Description ^ |
- | | + | | 00h | WORD | ns_sector | Logical-sector offset (n byte) to the contents of the segment |
- | | + | | 02h | WORD | ns_cbseg | Length of the segment in the file, in bytes. |
- | WORD ne_heap; | + | | 04h | WORD | ns_flags | Flag word | |
- | | + | | 06h | WORD | ns_minalloc | Minimum |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | DWORD ne_csip; | + | |
- | DWORD | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | In-memory |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | WORD ne_cseg; | + | |
- | WORD ne_cmod; | + | |
- | WORD ne_cbnrestab; | + | |
- | WORD ne_segtab; | + | |
- | | + | |
- | WORD ne_rsrctab; | + | |
- | | + | |
- | WORD ne_restab; | + | |
- | | + | |
- | WORD ne_modtab; | + | |
- | | + | |
- | WORD ne_imptab; | + | |
- | | + | |
- | DWORD ne_nrestab; | + | |
- | | + | |
- | WORD ne_cmovent; | + | |
- | WORD ne_align; | + | |
- | | + | |
- | WORD ne_cres; | + | |
- | BYTE ne_exetyp; | + | |
- | | + | |
- | BYTE ne_flagsothers; | + | |
- | char ne_res[NERESBYTES]; | + | |
- | }; | + | |
- | // On-disk segment entry | + | ^ Offset ^ Size ^ Name ^ Description ^ |
- | struct new_seg { | + | | 00h | WORD | ns1_sector | Logical-sector offset (n byte) to the contents of the segment data, relative to the beginning of the file. Zero means no file data | |
- | WORD | + | | 02h | WORD | ns1_cbseg | Length of the segment in the file, in bytes. Zero means 64K | |
- | | + | | 04h | WORD | ns1_flags | Flag word | |
- | | + | | 06h | WORD | ns1_minalloc | Minimum allocation size of the segment, in bytes. Total size of the segment. Zero means 64K | |
- | WORD | + | | 08h | WORD | ns1_handle | Selector or handle (selector - 1) of segment in memory | |
- | WORD | + | |
- | WORD | + | |
- | | + | |
- | }; | + | |
- | // In-memory segment entry | ||
- | struct new_seg1 { | ||
- | WORD ns1_sector; | ||
- | | ||
- | | ||
- | WORD ns1_cbseg; | ||
- | WORD ns1_flags; | ||
- | WORD ns1_minalloc; | ||
- | | ||
- | WORD ns1_handle; | ||
- | }; | ||
struct new_segdata { | struct new_segdata { | ||
Line 136: | Line 76: | ||
}; | }; | ||
- | struct new_rlcinfo { | + | Relocation table header |
- | WORD nr_nreloc; | + | |
- | }; | + | |
- | struct new_rlc { | + | ^ Offset ^ Size ^ Name ^ Description ^ |
- | | + | | 00h | WORD | nr_nreloc | ??? | |
- | char nr_flags; | + | |
- | | + | |
- | union { | + | |
- | struct { | + | |
- | char nr_segno; | + | |
- | char nr_res; | + | |
- | WORD nr_entry; | + | |
- | } nr_intref; | + | |
- | struct { | + | |
- | WORD nr_mod; | + | |
- | WORD nr_proc; | + | |
- | } nr_import; | + | |
- | struct { | + | |
- | WORD nr_ostype; | + | |
- | WORD nr_osres; | + | |
- | } nr_osfix; | + | |
- | } nr_union; | + | |
- | }; | + | |
- | #define NR_STYPE(x) | + | Relocation table entry |
- | #define NR_FLAGS(x) | + | |
- | #define NR_SOFF(x) | + | |
- | #define NR_SEGNO(x) | + | |
- | #define NR_RES(x) | + | |
- | #define NR_ENTRY(x) | + | |
- | #define NR_MOD(x) | + | |
- | #define NR_PROC(x) | + | |
- | #define NR_OSTYPE(x) | + | |
- | #define NR_OSRES(x) | + | |
- | #define NRSTYP | + | ^ Offset ^ Size ^ Name ^ Description ^ |
- | #define NRSBYT | + | | 00h | char | nr_stype | ??? | |
- | #define NRSSEG | + | | 01h | char | nr_flags | ??? | |
- | #define NRSPTR | + | | 02h | WORD | nr_soff | ??? | |
- | #define NRSOFF | + | | Internal fixup |||| |
- | #define NRPTR48 | + | | 04h | char | nr_segno | ??? | |
- | #define NROFF32 | + | | 05h | char | nr_res | ??? | |
- | #define NRSOFF32 | + | | 06h | WORD | nr_entry | ??? | |
+ | | ??? |||| | ||
+ | | 04h | WORD | nr_mod | ??? | | ||
+ | | 06h | WORD | nr_proc | ??? | | ||
+ | | OS Fixup |||| | ||
+ | | 04h | WORD | nr_ostype | ??? | | ||
+ | | 06h | WORD | nr_osres | ??? | | ||
- | #define NRADD 0x04 | ||
- | #define NRRTYP | ||
- | #define NRRINT | ||
- | #define NRRORD | ||
- | #define NRRNAM | ||
- | #define NRROSF | ||
- | #define NRICHAIN | ||
- | #if (EXE386 == 0) | + | ^ Offset ^ Size ^ Name ^ Description ^ |
+ | | 00h | char | rs_len | ??? | | ||
+ | | 01h | char | rs_string[1] | ??? | | ||
- | #define RS_LEN(x) | + | ^ Offset ^ Size ^ Name ^ Description ^ |
- | #define RS_STRING(x) | + | | 00h | WORD | rt_id | ??? | |
- | #define RS_ALIGN(x) | + | | 02h | WORD | rt_nres | ??? | |
+ | | 04h | DWORD | rt_proc | ??? | | ||
- | #define RT_ID(x) | + | ^ Offset ^ Size ^ Name ^ Description ^ |
- | #define RT_NRES(x) | + | | 00h | WORD | rn_offset | ??? | |
- | #define RT_PROC(x) | + | | 02h | WORD | rn_length | ??? | |
+ | | 04h | WORD | rn_flags | ??? | | ||
+ | | 06h | WORD | rn_id | ??? | | ||
+ | | 08h | WORD | rn_handle | ??? | | ||
+ | | 0Ah | WORD | rn_usage | ??? | | ||
- | #define RN_OFFSET(x) | + | ^ Offset ^ Size ^ Name ^ Description ^ |
- | #define RN_LENGTH(x) | + | | 00h | WORD | rs_align |
- | #define RN_FLAGS(x) | + | | 02h | struct rsrc_typeinfo |
- | #define RN_ID(x) | + | |
- | #define RN_HANDLE(x) | + | |
- | #define RN_USAGE(x) | + | |
- | + | ||
- | #define RSORDID | + | |
- | + | ||
- | #define RNMOVE | + | |
- | #define RNPURE | + | |
- | #define RNPRELOAD | + | |
- | #define RNDISCARD | + | |
- | + | ||
- | #define NE_FFLAGS_LIBMODULE 0x8000 | + | |
- | + | ||
- | struct rsrc_string { | + | |
- | char rs_len; | + | |
- | char rs_string[1]; | + | |
- | }; | + | |
- | + | ||
- | struct rsrc_typeinfo { | + | |
- | | + | |
- | WORD rt_nres; | + | |
- | DWORD rt_proc; | + | |
- | }; | + | |
- | + | ||
- | struct rsrc_nameinfo { | + | |
- | WORD rn_offset; | + | |
- | WORD rn_length; | + | |
- | WORD rn_flags; | + | |
- | WORD rn_id; | + | |
- | WORD rn_handle; | + | |
- | WORD rn_usage; | + | |
- | }; | + | |
- | + | ||
- | struct new_rsrc { | + | |
- | WORD | + | |
- | struct rsrc_typeinfo | + | |
- | }; | + | |
- | + | ||
- | #endif | + | |
- | #pragma pack(pop) | ||
- | #ifdef __cplusplus | ||
- | } /* extern " | ||
- | #endif | ||
- | #endif | ||