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
Offset
Size
Type
Field
Notes
0x0
2
u16 LE
Header Size
0x0
1
u8
Header Size
0x7
4
u32 LE
Compressed Size
Other fields read
Read in
Offset
Size
Type
Field
Notes
LhaExtractor.ParseExtHeaders
(int)cursor
2
u16 LE
Size
Constants
General Lha
Name
Value
Type
Notes
Threshold
3
int
Nc
510
int
literal (0..255) + length codes
Nt
19
int
pre-tree code count
CBit
9
int
bits for the c-table code count
TBit
5
int
bits for the pre-tree code count
Implementation limits reader
Class
Name
Value
Notes
LhaExtractor
MaxEntries
2_000_000
LzhCarver
MaxEntries
2_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.