Professional Documents
Culture Documents
Tech Note
Tech Note
91 - Technical information
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
THE ARCHIVE FORMAT DESCRIBED BELOW IS ONLY VALID FOR VERSIONS SINCE 1.50
==========================================================================
RAR archive file format
==========================================================================
Archive file consists of variable length blocks. The order of these
blocks may vary, but the first block must be a marker block followed by
an archive header block.
Each block begins with the following fields:
HEAD_CRC
HEAD_TYPE
HEAD_FLAGS
HEAD_SIZE
ADD_SIZE
2
1
2
2
4
bytes
byte
bytes
bytes
bytes
marker block
archive header
file header
old style comment header
old style authenticity information
old style subblock
old style recovery record
old style authenticity information
subblock
Comment block is actually used only within other blocks and doesn't
exist separately.
Archive processing is made in the following manner:
1.
2.
3.
4.
HEAD_SIZE.
5. Check HEAD_TYPE.
if HEAD_TYPE==0x74
read file header ( first 7 bytes already read )
read or skip HEAD_SIZE-sizeof(FILE_HEAD) bytes
if (HEAD_FLAGS & 0x100)
read or skip HIGH_PACK_SIZE*0x100000000+PACK_SIZE bytes
else
read or skip PACK_SIZE bytes
else
read corresponding HEAD_TYPE block:
read HEAD_SIZE-7 bytes
if (HEAD_FLAGS & 0x8000)
read ADD_SIZE bytes
6. go to 4.
==========================================================================
Block Formats
==========================================================================
Marker block ( MARK_HEAD )
HEAD_CRC
2 bytes
Always 0x6152
HEAD_TYPE
1 byte
HEAD_FLAGS
2 bytes
Always 0x1a21
HEAD_SIZE
2 bytes
HEAD_TYPE
1 byte
HEAD_FLAGS
2 bytes
Bit flags:
0x0001 - Volume attribute (archive volume)
0x0002 - Archive comment present
RAR 3.x uses the separate comment block
and does not set this flag.
0x0004 - Archive lock attribute
0x0008 - Solid attribute (solid archive)
RESERVED1
2 bytes
Reserved
RESERVED2
4 bytes
Reserved
HEAD_TYPE
1 byte
HEAD_FLAGS
2 bytes
Bit flags:
0x01 - file continued from previous volume
0x02 - file continued in next volume
0x04 - file encrypted with password
0x08 - file comment present
RAR 3.x uses the separate comment block
and does not set this flag.
0x10 - information from previous files is used (solid flag)
(for RAR 2.0 and later)
bits 7 6 5 (for RAR 2.0 and later)
0
0
0
0
1
1
1
1
0
0
1
1
0
0
1
1
0
1
0
1
0
1
0
1
dictionary size 64
dictionary size 128
dictionary size 256
dictionary size 512
dictionary size 1024
dictionary size 2048
dictionary size 4096
file is directory
KB
KB
KB
KB
KB
KB
KB
PACK_SIZE
4 bytes
UNP_SIZE
4 bytes
HOST_OS
1 byte
FILE_CRC
4 bytes
File CRC
FTIME
4 bytes
UNP_VER
1 byte
METHOD
1 byte
Packing method
0x30
0x31
0x32
0x33
0x34
0x35
NAME_SIZE
storing
fastest compression
fast compression
normal compression
good compression
best compression
2 bytes
ATTR
4 bytes
File attributes
FILE_NAME
SALT
8 bytes
EXT_TIME
variable size