764N/A RAR version 3.00 - Technical information
764N/A ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
764N/A THE ARCHIVE FORMAT DESCRIBED BELOW IS ONLY VALID FOR VERSIONS SINCE 1.50
764N/A ==========================================================================
764N/A RAR archive file format
764N/A ==========================================================================
764N/A Archive file consists of variable length blocks. The order of these
764N/Ablocks may vary, but the first block must be a marker block followed by
764N/Aan archive header block.
764N/A Each block begins with the following fields:
764N/AHEAD_CRC 2 bytes CRC of total block or block part
764N/AHEAD_TYPE 1 byte Block type
764N/AHEAD_FLAGS 2 bytes Block flags
764N/AHEAD_SIZE 2 bytes Block size
764N/AADD_SIZE 4 bytes Optional field - added block size
764N/A Field ADD_SIZE present only if (HEAD_FLAGS & 0x8000) != 0
764N/A Total block size is HEAD_SIZE if (HEAD_FLAGS & 0x8000) == 0
764N/Aand HEAD_SIZE+ADD_SIZE if the field ADD_SIZE is present - when
764N/A(HEAD_FLAGS & 0x8000) != 0.
764N/A In each block the followings bits in HEAD_FLAGS have the same meaning:
764N/A 0x4000 - if set, older RAR versions will ignore the block
764N/A and remove it when the archive is updated.
764N/A if clear, the block is copied to the new archive
764N/A file when the archive is updated;
764N/A 0x8000 - if set, ADD_SIZE field is present and the full block
764N/A size is HEAD_SIZE+ADD_SIZE.
764N/AHEAD_TYPE=0x72 marker block
764N/AHEAD_TYPE=0x73 archive header
764N/AHEAD_TYPE=0x74 file header
764N/AHEAD_TYPE=0x75 comment header
764N/AHEAD_TYPE=0x76 old style authenticity information
764N/AHEAD_TYPE=0x78 recovery record
764N/AHEAD_TYPE=0x79 authenticity information
764N/A Comment block is actually used only within other blocks and doesn't
764N/A Archive processing is made in the following manner:
764N/A1. Read and check marker block
764N/A3. Read or skip HEAD_SIZE-sizeof(MAIN_HEAD) bytes
764N/A4. If end of archive encountered then terminate archive processing,
else read 7 bytes into fields HEAD_CRC, HEAD_TYPE, HEAD_FLAGS,
read file header ( first 7 bytes already read )
read or skip HEAD_SIZE-sizeof(FILE_HEAD) bytes
read or skip HIGH_PACK_SIZE*0x100000000+PACK_SIZE bytes
read or skip PACK_SIZE bytes
read corresponding HEAD_TYPE block:
==========================================================================
==========================================================================
Marker block ( MARK_HEAD )
HEAD_TYPE Header type: 0x72
HEAD_SIZE Block size = 0x0007
The marker block is actually considered as a fixed byte
sequence: 0x52 0x61 0x72 0x21 0x1a 0x07 0x00
Archive header ( MAIN_HEAD )
HEAD_CRC CRC of fields HEAD_TYPE to RESERVED2
HEAD_TYPE Header type: 0x73
0x01 - Volume attribute (archive volume)
0x02 - Archive comment present
0x04 - Archive lock attribute
0x08 - Solid attribute (solid archive)
0x20 - Authenticity information present
0x40 - Recovery record present
0x80 - Block headers are encrypted
other bits in HEAD_FLAGS are reserved for
HEAD_SIZE Archive header total size including archive comments
Comment block present if (HEAD_FLAGS & 0x02) != 0
File header (File in archive)
HEAD_CRC CRC of fields from HEAD_TYPE to FILEATTR
HEAD_TYPE Header type: 0x74
0x01 - file continued from previous volume
0x02 - file continued in next volume
0x04 - file encrypted with password
0x08 - file comment present
0x10 - information from previous files is used (solid flag)
bits 7 6 5 (for RAR 2.0 and later)
0 0 0 - dictionary size 64 KB
0 0 1 - dictionary size 128 KB
0 1 0 - dictionary size 256 KB
0 1 1 - dictionary size 512 KB
1 0 0 - dictionary size 1024 KB
1 0 1 - dictionary size 2048 KB
1 1 0 - dictionary size 4096 KB
1 1 1 - file is directory
0x100 - HIGH_PACK_SIZE and HIGH_UNP_SIZE fields
are present. These fields are used to archive
only very large files (larger than 2Gb),
for smaller files these fields are absent.
0x200 - FILE_NAME contains both usual and encoded
Unicode name separated by zero. In this case
NAME_SIZE field is equal to the length
of usual name plus encoded Unicode name plus 1.
0x400 - the header contains additional 8 bytes
after the file name, which are required to
increase encryption security (so called 'salt').
0x800 - Version flag. It is an old file version,
a version number is appended to file name as ';n'.
0x8000 - this bit always is set, so the complete
block size is HEAD_SIZE + PACK_SIZE
(and plus HIGH_PACK_SIZE, if bit 0x100 is set)
HEAD_SIZE File header full size including file name and comments
PACK_SIZE Compressed file size
UNP_SIZE Uncompressed file size
HOST_OS Operating system used for archiving
FTIME Date and time in standard MS DOS format
UNP_VER RAR version needed to extract file
HIGH_PACK_SIZE High 4 bytes of 64 bit value of compressed file size.
4 bytes Optional value, presents only if bit 0x100 in HEAD_FLAGS
HIGH_UNP_SIZE High 4 bytes of 64 bit value of uncompressed file size.
4 bytes Optional value, presents only if bit 0x100 in HEAD_FLAGS
FILE_NAME File name - string of NAME_SIZE bytes size
Comment block present if (HEAD_FLAGS & 0x08) != 0
HEAD_CRC CRC of fields from HEAD_TYPE to COMM_CRC
HEAD_TYPE Header type: 0x75
HEAD_SIZE Comment header size + comment size
UNP_SIZE Uncompressed comment size
UNP_VER RAR version needed to extract comment
HEAD_TYPE Header type: 0x76
HEAD_SIZE Total block size
An object in the archive (the block or header) can be followed
by a subblock. The subblock is dependent upon the main object.
Subblock can be erased or moved to a new version of the archive
The subblock contains the following fields:
HEAD_TYPE Header type: 0x77
(HEAD_FLAGS & 0x8000) == 1, because full
block size is HEAD_SIZE + DATA_SIZE
HEAD_SIZE Total block size
DATA_SIZE Total data size
Other Other fields depending on the subblock type
OS/2 extended attributes subblock
HEAD_TYPE Header type: 0x77
(HEAD_FLAGS & 0x8000) == 1, because full
block size is HEAD_SIZE + DATA_SIZE
HEAD_SIZE Total block size
DATA_SIZE Total data size (packed extended attributes size)
UNP_SIZE Uncompressed extended attributes size
UNP_VER RAR version needed to extract extended attributes
EA_CRC Extended attributes CRC
==========================================================================
==========================================================================
1. To process an SFX archive you need to skip the SFX module searching
for the marker block in the archive. There is no marker block sequence (0x52
0x61 0x72 0x21 0x1a 0x07 0x00) in the SFX module itself.
2. The CRC is calculated using the standard polynomial 0xEDB88320. In
case the size of the CRC is less than 4 bytes, only the low order bytes
3. Packing method encoding:
0x31 - fastest compression
0x33 - normal compression
4. The RAR extraction version number is encoded as 10 * Major version