An ARJ archive is a main header, then a local file header and the compressed data for
each file, then an end marker. Both kinds of header have the same frame and share most
of their first 34 bytes. This page follows the technical note
TECHNOTE.DOC
(“ARJ TECHNICAL INFORMATION”, November 1994, from the ARJ 2.42b package, read 2026-11-13); fields added by
later ARJ versions are marked as such and come from the
unarc-rs 0.6.1 sources
(local header),
which parse them; the note does not describe them. Numbers are little-endian.
Header frame
| Offset | Size | Name | Description |
|---|---|---|---|
0 | 2 | Header ID | 60 EA (the number EA60). |
2 | 2 | Basic header size | Bytes from first_hdr_size to the end of the comment’s NUL: first_hdr_size + name length + 1 + comment length + 1. At most 2,600. 0 marks the end of the archive. |
4 | … | Basic header | The fixed fields (main or local, below), any extra data, then the name and the comment, each ending with a NUL. |
| … | 4 | Basic header CRC | CRC-32 of the basic header (from offset 4, the size given at offset 2). |
| … | 2 | Extended header size | 0 when there is none (the usual case). |
| … | … | Extended header | Unused by ARJ 2.4x; the size and data repeat until a size of 0. |
| … | 4 | Extended header CRC | CRC-32 of that extended header. Absent when the size is 0. |
The technical note warns that older ARJ, AV.C and UNARJ.C
skip only 2 bytes for an extended header’s CRC instead of 4; it did not matter because
no ARJ version then wrote extended headers.
The CRC is the standard CRC-32 of ZIP (polynomial EDB88320, start
FFFFFFFF, final value inverted); the note gives no parameters and points
to UNARJ’s source, which uses this one.
Main header
Offsets are from the start of the header ID. first_hdr_size is 30 in
ARJ 2.4x archives; later versions write 34 and add the bytes at 34 to 37.
| Offset | Size | Name | Description |
|---|---|---|---|
4 | 1 | first_hdr_size | Size of the fixed part and extra data, counted from this byte. |
5 | 1 | Archiver version | Version of ARJ that made the archive. |
6 | 1 | Minimum version to extract | |
7 | 1 | Host OS | See host OS. |
8 | 1 | ARJ flags | See main header flags. |
9 | 1 | Security version | 2 is current. |
10 | 1 | File type | Always 2 in the main header. |
11 | 1 | Reserved | |
12 | 4 | Created | Date and time the archive was created, in DOS format. |
16 | 4 | Modified | Date and time the archive was last modified (added to the note in 1993). |
20 | 4 | Archive size | Used only by secured archives. |
24 | 4 | Security envelope position | File position of the ARJ-SECURITY envelope. |
28 | 2 | Filespec position | Where the file name part starts in the stored name. |
30 | 2 | Security envelope length | |
32 | 1 | Encryption version | “Not used” in ARJ 2.4x (the note’s two unused bytes at 32–33). unarc-rs reads it as the encryption version; its values are not documented in the sources read. |
33 | 1 | Last chapter | Later versions: the highest chapter number in a chapter archive. “Not used” in ARJ 2.4x. |
34 | 1 | Protection factor | Later versions, when first_hdr_size ≥ 34: the ARJ-PROTECT recovery data factor. |
35 | 1 | Flags 2 | Later versions: second flags byte, read by unarc-rs when first_hdr_size is 34 or more; its bits are not described in any source read. |
36 | 2 | Spare | Later versions: unused. |
4 + first_hdr_size | … | Archive name | The archive’s file name when it was made, NUL-terminated. |
| … | … | Comment | Archive comment, NUL-terminated. |
ARJ-SECURITY, the authenticity envelope sold as an add-on, uses the fields at 9 and 20 to 31; their layout was made public with ARJ 2.39. The contents of the envelope itself are not public.
Main header flags
| Bit | ARJ 2.4x name | Meaning |
|---|---|---|
01 | not used | Later versions: GARBLED_FLAG, the archive is password-protected. |
02 | OLD_SECURED_FLAG | Secured with the old method. Later versions reuse the bit as ANSIPAGE_FLAG: names are in the Windows ANSI code page. |
04 | VOLUME_FLAG | Another volume follows. |
08 | not used | Later versions: ARJPROT_FLAG, the archive carries ARJ-PROTECT recovery data. |
10 | PATHSYM_FLAG | The archive name was translated: \ became /. |
20 | BACKUP_FLAG | A backup-type archive. |
40 | SECURED_FLAG | The archive has an ARJ-SECURITY envelope. |
80 | – | Later versions: ALTNAME_FLAG. unarc-rs reads it as “altname” and gives no description; its meaning is not in the note. |
Local file header
first_hdr_size is 30, or 34 when EXTFILE_FLAG is set; later
versions write 46 to add the access and creation times.
| Offset | Size | Name | Description |
|---|---|---|---|
4 | 1 | first_hdr_size | As in the main header. |
5 | 1 | Archiver version | |
6 | 1 | Minimum version to extract | |
7 | 1 | Host OS | See host OS. |
8 | 1 | ARJ flags | See local header flags. |
9 | 1 | Method | See methods. |
10 | 1 | File type | See file types. |
11 | 1 | Reserved | Later versions: the password modifier, a value mixed into the garbling key. |
12 | 4 | Modified | Date and time the file was last modified, in DOS format. |
16 | 4 | Compressed size | Bytes of data after the header. |
20 | 4 | Original size | Size when extracted. For text-mode files this can differ from the size on disk, because line endings are converted. |
24 | 4 | Original CRC | CRC-32 of the extracted data. |
28 | 2 | Filespec position | Offset of the file name part in the stored path. |
30 | 2 | File access mode | File attributes or mode of the host system (DOS attributes on DOS, st_mode bits on Unix). |
32 | 1 | First chapter | “Host data, currently unused” in ARJ 2.4x. Later versions: the first chapter the file belongs to. |
33 | 1 | Last chapter | Later versions: the last chapter the file belongs to. |
34 | 4 | Extended file position | Only with EXTFILE_FLAG: where this part of a split file starts in the whole file. |
38 | 4 | Accessed | Later versions, when first_hdr_size ≥ 46: last access time, DOS format. |
42 | 4 | Created | As above: creation time. |
46 | 4 | Original size, all volumes | As above: the whole file’s size even when this part is one volume of it. |
4 + first_hdr_size | … | File name | Path and name, NUL-terminated. |
| … | … | Comment | File comment, NUL-terminated. |
The compressed data follows the frame’s last CRC (or the zero extended header size).
Local header flags
| Bit | Name | Meaning |
|---|---|---|
01 | GARBLED_FLAG | The file is password-protected (garbled). |
02 | not used | |
04 | VOLUME_FLAG | The file continues in the next volume. |
08 | EXTFILE_FLAG | This is a continued part: the extended file position field is present. |
10 | PATHSYM_FLAG | The name was translated: \ became /. |
20 | BACKUP_FLAG | The file is marked as a backup. |
40, 80 | – | Not defined in the note. |
Code values
Host OS
| Value | System |
|---|---|
0 | MS-DOS |
1 | PRIMOS |
2 | Unix |
3 | Amiga |
4 | Mac OS |
5 | OS/2 |
6 | Apple IIGS |
7 | Atari ST |
8 | NeXT |
9 | VAX VMS |
10 | Windows 95 (not in the note; named in the unarc-rs sources) |
11 | Win32 (as above) |
Methods
| Value | Method |
|---|---|
0 | Stored |
1 | Compressed, most (best compression) |
2 | Compressed |
3 | Compressed, faster |
4 | Compressed, fastest |
8 | No data, no CRC (later versions; used for entries such as chapter labels) |
9 | No data (later versions) |
The technical note describes no compression algorithm. The decoders below are from ClamAV’s
libclamav/unarj.c,
a decoder derived from UNARJ (read 2026-11-13). It decodes methods 1, 2 and 3 with one routine and method 4
with another, method 0 by copying, and rejects any other method value. Both keep a
26,624-byte window (DDICSIZ) and stop when the original size has been produced.
Bits are read most significant first from a 16-bit buffer. A match has a minimum length of 3
(THRESHOLD) and a maximum of 256 (MAXMATCH); its source starts at
output position − distance − 1, wrapping in the window.
Methods 1 to 3
LZ77 with Huffman coding. The data is in blocks; each block starts with a 16-bit number of symbols to
decode, then three tables (alphabet sizes: NT = 19 code-length symbols, NC =
510 character-and-length symbols, NP = 17 position symbols):
- The code-length code (
read_pt_lenwith 5 bits, special position 3): a 5-bit count n. If 0, one more 5-bit value gives the only symbol (all lengths 0). Otherwise n code lengths follow: 3 bits each, and a value of 7 is extended by reading 1 bits until a 0 (each 1 adds 1); after entry 3 a 2-bit count of extra zero lengths is read and inserted. The remaining lengths are 0. - The character-and-length code (
read_c_len): a 9-bit count n. If 0, one 9-bit value gives the only symbol. Otherwise symbols are read through the code-length code: 0 means one zero length, 1 means 4 bits + 3 zero lengths, 2 means 9 bits + 20 zero lengths, and any other value c sets a length of c − 2. The rest are 0. - The position code (
read_pt_lenwith 5 bits, no special position), like the first but for the position alphabet.
Each symbol is then decoded with the character table (a table lookup on 12 bits, then a tree walk for
longer codes; the position table uses 8 bits). A symbol of 255 or less is a literal. A larger symbol is a
match of length symbol − 253 (3 to 256); then a position symbol j is decoded, and
the distance is j if it is 0, otherwise (1 << (j − 1)) + the next
j − 1 bits. Canonical codes are built from the lengths with a standard table-building
routine (make_table): the codes of each length are consecutive, with the 16-bit
left-aligned code space required to be exactly filled. Methods 1, 2 and 3 use the same decoder; the
note says only that they differ in speed (“compressed most” to “faster”).
Method 4
No tables. A length code is read as: starting at width 0, read bits while they are 1 (at most 7 times),
adding 2width each time to a base; then read width bits and add them to the base.
A result of 0 means a literal: the next 8 bits are the byte. Otherwise the match length is the result + 2
(3 and up). The distance is read the same way but starts at width 9 and stops at 13, so the base grows
from 512 by 512, 1,024, 2,048 and 4,096, and then width bits are added; the source
position is again output position − distance − 1.
File types
| Value | Type |
|---|---|
0 | Binary |
1 | 7-bit text (stored with line endings converted) |
2 | Main header (later versions also: comment header) |
3 | Directory |
4 | Volume label |
5 | Chapter label (later versions) |
Date and time
A 32-bit MS-DOS date and time, local time, with 2-second resolution:
| Bits | Meaning |
|---|---|
| 31 to 25 | Year − 1980 |
| 24 to 21 | Month, 1 to 12 |
| 20 to 16 | Day, 1 to 31 |
| 15 to 11 | Hour, 0 to 23 |
| 10 to 5 | Minute, 0 to 59 |
| 4 to 0 | Second ÷ 2 |
Finding the archive
A self-extracting ARJ is an MS-DOS program with the archive after it, and the main
header need not follow the program directly. The note’s find_header()
routine searches for it:
- Find the bytes
60 EA. - Read the next 2 bytes as the basic header size. If it is over 2,600, move one byte past the ID and search again.
- Read that many bytes and their CRC-32. If the CRC does not match, move one byte past the ID and search again.
The archive ends with a header whose basic header size is 0: the four
bytes 60 EA 00 00. Split archives continue in .a01,
.a02 and so on, each with its own main header.