LHA – LZH Archive (.lzh)

Japanese archiver widely used on Amiga and DOS.

Overview

LHA entries begin with a header whose method field is a string such as -lh5-. The header contains the compressed and original size, timestamp, attributes and CRC-16. Methods use LZ77 and Huffman coding with different window sizes.

Where it is used

  • Amiga and Japanese PC software distribution.

History

  • Created by Haruyasu Yoshizaki in 1988.

Status today

  • Legacy; still used by Amiga and retro users.

Structures read by the implementation

Offsets are in bytes from the start of the buffer named in each heading. Field names are taken from the implementation and are not an official specification. Fixed-width integers are shown as u/i (unsigned/signed) followed by bit width and byte order.

LzhCarver.Carve buffer e · LzhCarver.cs

OffsetSizeTypeFieldNotes
0x02u16 LEHeader Size
0x01u8Header Size
0x74u32 LECompressed Size

Other fields read

Read inOffsetSizeTypeFieldNotes
LhaExtractor.ParseExtHeaders(int)cursor2u16 LESize

Constants

General Lha

NameValueTypeNotes
Threshold3int
Nc510intliteral (0..255) + length codes
Nt19intpre-tree code count
CBit9intbits for the c-table code count
TBit5intbits for the pre-tree code count

Implementation limits reader

ClassNameValueNotes
LhaExtractorMaxEntries2_000_000
LzhCarverMaxEntries2_000_000
Structures and constants were extracted from: Carving/Plugins/Lzh/Lha.cs, Carving/Plugins/Lzh/LhaExtractor.cs, Carving/Plugins/Lzh/LzhCarver.cs, Modules/FileSystems/LhaArchiveModule.cs. Prose sections are a summary from public sources; verify details before relying on them.