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/24 04:47] – prokushev | en:docs:tk:formats:newexe [2024/10/13 14:35] (current) – prokushev | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== New Executable file format ====== | ||
+ | |||
+ | 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. | ||
+ | |||
^ Offset ^ Size ^ Name ^ Description ^ | ^ Offset ^ Size ^ Name ^ Description ^ | ||
| 00h | WORD | ne_magic | Signature word NEMAGIC | | | 00h | WORD | ne_magic | Signature word NEMAGIC | | ||
- | union { | + | | On-disk |||| |
- | struct { | + | | 02h | BYTE | ne_ver |
- | BYTE | + | | 03h | BYTE| ne_rev |
- | BYTE | + | | In-memory |||| |
- | }; | + | | 02h | WORD | count | Usage count (ne_ver/ |
- | WORD count; | + | | 04h | WORD | ne_enttab |
- | }; | + | | On-disk |||| |
- | | + | | 06h | WORD | ne_cbenttab |
- | | + | | In-memory |||| |
- | union { | + | | 06h | WORD | next | Selector to next module |
- | WORD ne_cbenttab; | + | | On-disk |||| |
- | WORD next; | + | | 08h | DWORD | ne_crc |
- | }; | + | | In-memory |||| |
- | union { | + | | 08h | WORD | dgroup_entry |
- | DWORD ne_crc; /* 32-bit CRC of entire contents of file. | + | | 0Ah | WORD | fileinfo |
- | | + | | 0Ch | WORD | ne_flags |
- | struct { | + | | 0Eh | WORD | ne_autodata |
- | WORD dgroup_entry; /* Near ptr to segment entry for DGROUP | + | | 10h | WORD | ne_heap |
- | WORD fileinfo; /* Near ptr to file info (OFSTRUCT)*/ | + | | 12h | WORD | ne_stack |
- | }; | + | | 14h | DWORD | ne_csip |
- | }; | + | | 18h | DWORD | ne_sssp |
- | | + | | 1Ch | WORD | ne_cseg |
- | WORD ne_autodata; | + | | 1Eh | WORD | ne_cmod |
- | | + | | 20h | WORD | ne_cbnrestab |
- | | + | | 22h | WORD | ne_segtab |
- | | + | | 24h | WORD | ne_rsrctab |
- | + | | 26h | WORD | ne_restab | |
- | | + | | 28h | WORD | ne_modtab |
- | | + | | 2Ah | WORD | ne_imptab |
- | | + | | 2Ch | DWORD | ne_nrestab |
- | WORD ne_heap; | + | | 30h | WORD | ne_cmovent |
- | | + | | 32h | WORD | ne_align |
- | | + | | 34h | WORD | ne_cres |
- | WORD ne_stack; | + | | 36h | BYTE | ne_exetyp |
- | | + | | 37h | BYTE | ne_flagsothers |
- | | + | | 38h | WORD | ??? | offset to return thunks or start of gangload area | |
- | DWORD ne_csip; /* Segment number: | + | | 3Ah | WORD | ??? | offset to segment reference thunks or length of gangload area | |
- | DWORD | + | | 3Ch | WORD | ??? | minimum code swap area size | |
- | | + | | 3Eh | 2 BYTEs | ??? | expected Windows version (minor version first) | |
- | | + | |
- | | + | |
- | | + | |
- | + | ||
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | 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; | + | |
- | | + | |
- | }; | + | |
On-disk segment entry | On-disk segment entry | ||
Line 107: | Line 76: | ||
}; | }; | ||
- | struct new_rlcinfo { | + | Relocation table header |
- | WORD nr_nreloc; | + | |
- | }; | + | |
- | struct new_rlc { | + | ^ Offset ^ Size ^ Name ^ Description ^ |
- | | + | | 00h | WORD | nr_nreloc | Number of relocation table entries | |
- | 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) | + | |
- | # | + | ^ Offset ^ Size ^ Name ^ Description ^ |
- | #define NRSBYT | + | | 00h | char | nr_stype | Source type (0Fh = NRSTYP |
- | #define NRSSEG | + | | 01h | char | nr_flags | Flags byte (03h = TARGET_MASK): |
- | #define NRSPTR | + | | 02h | WORD | nr_soff | Offset within this segment of the source chain. If the ADDITIVE flag is set, then target value is added to the source contents, instead of replacing the source and following the chain. The source chain is an 0FFFFh terminated linked list within this segment of all references to the target | |
- | #define NRSOFF | + | | Internal fixup |||| |
- | #define NRPTR48 | + | | 04h | char | nr_segno | Segment number (for fixed segment) or 0FFh (for movable segment) | |
- | #define NROFF32 | + | | 05h | char | nr_res | Reserved (usually zero) | |
- | #define NRSOFF32 | + | | 06h | WORD | nr_entry | Entry table number (for movable segment) offset segment | |
+ | | Import |||| | ||
+ | | 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 | rs_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_id; | ||
- | 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 rs_align; | ||
- | struct rsrc_typeinfo | ||
- | }; | ||