Format:LZMS
| On this wiki | Facts · Code · Notes · Topics |
|---|
Microsoft's LZMS compression (Windows 8 Compression API COMPRESS_ALGORITHM_LZMS, solid WIM resources / .esd): LZ77 plus delta matches coded with an adaptive binary range coder and five Huffman codes, read from both ends of a block in 16-bit units.
LZMS is an undocumented Microsoft format (no public specification); wimlib's decompressor is the reference most readers follow. It is the compression of solid-resource WIM files (version 0xE00, flag 0x80000) and one of the Windows 8+ Compression API algorithms.
Structure (from wimlib src/lzms_decompress.c)
- A block is read in 16-bit little-endian units from both directions: a forward bitstream carries binary range-coded decisions, a backward bitstream (starting at the end of the block) carries Huffman symbols and verbatim bits; within a unit the first bit is the high-order bit (header comment, lines 26-47).
- The range decoder starts with range 0xFFFFFFFF and a code value of the first 32 bits; when the range falls below 0x10000 it is renormalised from the next 16 bits (lines 133-139, 448, 480).
- Items are literals, LZ77 matches, or delta matches; a match offset is either explicit or a reference into a queue of 3 recent LZ offsets (or 3 recent (power, raw offset) pairs for delta matches).
- Probabilities are 6-bit numerators over 64, initially 48, with recent-bit history initialised to 0x55555555; the decision classes have 16 (main), 32 (match), 64 (lz, lz rep, delta, delta rep) probability entries (
include/wimlib/lzms_constants.h). - Five Huffman codes: literal (256 symbols, rebuilt every 1024 symbols), LZ offset (up to 799 symbols, 1024), length (54 symbols, 512), delta offset (799, 1024), delta power (8 symbols, 512); maximum codeword length 15.
- Match length 1 to 1073809578, offset 1 to 1180427428 (format limits); wimlib limits buffers to 2^30 and notes that Microsoft's implementation seems to use 2^26 bytes. Up to 30 extra bits for both length and offset slots.
- After decoding, an x86 postprocess translates absolute call targets back to relative ones (window 65535 bytes, maximum translation offset 1023).
This is the 'raw' form (what the Windows 8 API does with COMPRESS_RAW); wimlib says the non-raw API output is presumably a container of blocks. Inside a WIM the blocks are chunked by the resource header, see Format:WIM.
Identification
No magic. In a WIM the header flag 0x80000 and version 0xE00 say LZMS is used. In a binary, look for the constants 799, 54, 48/64 probabilities and the 0x55555555 initial history. Unverified: Windows 10 .esd files are WIMs with this compression.
Related
Format:Xpress, Format:LZX, Format:LZNT1.
Code & repositories
- https://github.com/ebiggers/wimlib @
cd5e231c348c255ae5088873b5a66ee0eb96fa07· license: LGPL-3.0-or-later OR GPL-3.0-or-later (declared by the contributor; GitHub's detector did not recognize COPYING)
wimlib: WIM header (include/wimlib/header.h) and the LZMS decoder (src/lzms_decompress.c, include/wimlib/lzms_constants.h) with long explanatory comments.
Tested on: source read, not run · checked 2026-10-19; last activity 2026-01-30