Format:LE and LX (Linear Executable)
| Magic | 'LE' (4C 45) or 'LX' (4C 58) at the offset in the MZ header at 0x3C |
|---|---|
| Extensions | .exe, .dll, .vxd, .drv |
| Endianness | little (byte_order and word_order 0) |
| On this wiki | Facts · Code · Notes · Topics |
32-bit protected-mode executable formats behind an MZ stub: LX (OS/2 2.x and later, some DOS extenders) and LE (DOS/4GW and DOS32 games, Windows 3.x VxDs), with a 196-byte header found through the dword at 0x3C of the MZ header, objects (segments), a page map and a fixup table.
Identification
A normal MZ file (Format:DOS MZ executable) with a dword at 0x3C pointing to LE or LX. DOS/4GW games (Doom, many Watcom-built 1990s titles) are usually an MZ stub that contains the DOS/4GW extender with the real program bound behind it as an LE or LX image; in such files the MZ header's e_lfanew is not necessarily the linear header, so also scan for the signature. Old 16-bit executables use NE (Format:NE (New Executable)); PE is Format:PE (Portable Executable).
Other DOS extenders use different images behind the MZ stub: DJGPP programs carry a COFF image after the MZ image (Tool:DJGPP), Phar Lap programs use MP/P3 images (Format:Phar Lap executables) and Rational's DOS16M uses the signature BW. A quick triage of all of them is in Technique:DOS executable packers and extenders.
Header
The 196-byte header (Open Watcom exeflat.h os2_flat_header) in field order: u16 signature, u8 byte_order, u8 word_order, u32 level, u16 cpu_type (1 286, 2 386, 3 486), u16 os_type (1 OS/2, 4 Windows 386), u32 version, u32 flags, u32 num_pages, start_obj, eip, stack_obj, esp, page_size (usually 4096), then LE: bytes on last page / LX: page_shift, fixup_size, fixup_cksum, loader_size, loader_cksum, objtab_off, num_objects, objmap_off, idmap_off, rsrc_off, num_rsrcs, resname_off, entry_off, moddir_off, num_moddirs, fixpage_off, fixrec_off, impmod_off, num_impmods, impproc_off, cksum_off, page_off (data pages), num_preload, nonres_off, nonres_size, nonres_cksum, autodata_obj, debug_off, debug_len, num_inst_preload, num_inst_demand, heapsize, stacksize, 20 reserved bytes (VxD: device id and DDK version). Table offsets are relative to the linear header; page_off and nonres_off are relative to the start of the file.
Objects and pages
Object table entry (24 bytes): size, relocation base address, flags, page map index (1-based), page count, reserved. Flags: 0x1 readable, 0x2 writable, 0x4 executable, 0x8 resource, 0x10 discardable, 0x20 shared, 0x40 preload, 0x2000 BIG (32-bit). The object page map has 4-byte entries in LE (24-bit page number plus a flags byte) and 8-byte entries in LX (u32 page data offset, u16 data size, u16 flags: 0 valid, 1 iterated, 2 invalid, 3 zero-filled, 4 range). Unverified: in LX the page offset is shifted left by page_shift and added to page_off; in LE page n is at page_off + (n - 1) * page_size. Iterated pages (flag 1) are run-length encoded.
Fixups
Relocations are not applied in the pages: the fixup page table (one offset per page + 1) points into the fixup record table, giving per-page records (source type, flags, source offset, target object and offset, or imported module and ordinal/name). Pages in the file are unrelocated.
Unverified
The DOS/4GW bound-executable layout above was not checked against a real file in this session; test by scanning a DOS/4GW game EXE for LE or LX and the DOS/4GW banner.
Code & repositories
- https://github.com/open-watcom/open-watcom-v2 @
96b007f094bb21c6108b2793706fa298da59fc5e· license: Watcom-1.0 (declared by the contributor; GitHub's detector did not recognize license.txt)
Open Watcom v2: bld/watcom/h/exeflat.h defines the LE/LX header, object and page map structures
Tested on: source read, not run: source reading only (one header) · checked 2026-10-18; last activity 2026-10-18