README
1
2 RAR version 3.00 - Technical information
3 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4
5 THE ARCHIVE FORMAT DESCRIBED BELOW IS ONLY VALID FOR VERSIONS SINCE 1.50
6
7 ==========================================================================
8 RAR archive file format
9 ==========================================================================
10
11 Archive file consists of variable length blocks. The order of these
12blocks may vary, but the first block must be a marker block followed by
13an archive header block.
14
15 Each block begins with the following fields:
16
17HEAD_CRC 2 bytes CRC of total block or block part
18HEAD_TYPE 1 byte Block type
19HEAD_FLAGS 2 bytes Block flags
20HEAD_SIZE 2 bytes Block size
21ADD_SIZE 4 bytes Optional field - added block size
22
23 Field ADD_SIZE present only if (HEAD_FLAGS & 0x8000) != 0
24
25 Total block size is HEAD_SIZE if (HEAD_FLAGS & 0x8000) == 0
26and HEAD_SIZE+ADD_SIZE if the field ADD_SIZE is present - when
27(HEAD_FLAGS & 0x8000) != 0.
28
29 In each block the followings bits in HEAD_FLAGS have the same meaning:
30
31 0x4000 - if set, older RAR versions will ignore the block
32 and remove it when the archive is updated.
33 if clear, the block is copied to the new archive
34 file when the archive is updated;
35
36 0x8000 - if set, ADD_SIZE field is present and the full block
37 size is HEAD_SIZE+ADD_SIZE.
38
39 Declared block types:
40
41HEAD_TYPE=0x72 marker block
42HEAD_TYPE=0x73 archive header
43HEAD_TYPE=0x74 file header
44HEAD_TYPE=0x75 comment header
45HEAD_TYPE=0x76 old style authenticity information
46HEAD_TYPE=0x77 subblock
47HEAD_TYPE=0x78 recovery record
48HEAD_TYPE=0x79 authenticity information
49
50 Comment block is actually used only within other blocks and doesn't
51exist separately.
52
53 Archive processing is made in the following manner:
54
551. Read and check marker block
562. Read archive header
573. Read or skip HEAD_SIZE-sizeof(MAIN_HEAD) bytes
584. If end of archive encountered then terminate archive processing,
59 else read 7 bytes into fields HEAD_CRC, HEAD_TYPE, HEAD_FLAGS,
60 HEAD_SIZE.
615. Check HEAD_TYPE.
62 if HEAD_TYPE==0x74
63 read file header ( first 7 bytes already read )
64 read or skip HEAD_SIZE-sizeof(FILE_HEAD) bytes
65 if (HEAD_FLAGS & 0x100)
66 read or skip HIGH_PACK_SIZE*0x100000000+PACK_SIZE bytes
67 else
68 read or skip PACK_SIZE bytes
69 else
70 read corresponding HEAD_TYPE block:
71 read HEAD_SIZE-7 bytes
72 if (HEAD_FLAGS & 0x8000)
73 read ADD_SIZE bytes
746. go to 4.
75
76
77 ==========================================================================
78 Block Formats
79 ==========================================================================
80
81
82 Marker block ( MARK_HEAD )
83
84
85HEAD_CRC Always 0x6152
862 bytes
87
88HEAD_TYPE Header type: 0x72
891 byte
90
91HEAD_FLAGS Always 0x1a21
922 bytes
93
94HEAD_SIZE Block size = 0x0007
952 bytes
96
97 The marker block is actually considered as a fixed byte
98sequence: 0x52 0x61 0x72 0x21 0x1a 0x07 0x00
99
100
101
102 Archive header ( MAIN_HEAD )
103
104
105HEAD_CRC CRC of fields HEAD_TYPE to RESERVED2
1062 bytes
107
108HEAD_TYPE Header type: 0x73
1091 byte
110
111HEAD_FLAGS Bit flags:
1122 bytes
113 0x01 - Volume attribute (archive volume)
114 0x02 - Archive comment present
115 0x04 - Archive lock attribute
116 0x08 - Solid attribute (solid archive)
117 0x10 - New volume naming scheme ('volname.partN.rar')
118 0x20 - Authenticity information present
119 0x40 - Recovery record present
120 0x80 - Block headers are encrypted
121
122 other bits in HEAD_FLAGS are reserved for
123 internal use
124
125HEAD_SIZE Archive header total size including archive comments
1262 bytes
127
128RESERVED1 Reserved
1292 bytes
130
131RESERVED2 Reserved
1324 bytes
133
134
135Comment block present if (HEAD_FLAGS & 0x02) != 0
136
137
138
139 File header (File in archive)
140
141
142HEAD_CRC CRC of fields from HEAD_TYPE to FILEATTR
1432 bytes and file name
144
145HEAD_TYPE Header type: 0x74
1461 byte
147
148HEAD_FLAGS Bit flags:
1492 bytes
150 0x01 - file continued from previous volume
151 0x02 - file continued in next volume
152 0x04 - file encrypted with password
153 0x08 - file comment present
154 0x10 - information from previous files is used (solid flag)
155 (for RAR 2.0 and later)
156
157 bits 7 6 5 (for RAR 2.0 and later)
158
159 0 0 0 - dictionary size 64 KB
160 0 0 1 - dictionary size 128 KB
161 0 1 0 - dictionary size 256 KB
162 0 1 1 - dictionary size 512 KB
163 1 0 0 - dictionary size 1024 KB
164 1 0 1 - dictionary size 2048 KB
165 1 1 0 - dictionary size 4096 KB
166 1 1 1 - file is directory
167
168 0x100 - HIGH_PACK_SIZE and HIGH_UNP_SIZE fields
169 are present. These fields are used to archive
170 only very large files (larger than 2Gb),
171 for smaller files these fields are absent.
172
173 0x200 - FILE_NAME contains both usual and encoded
174 Unicode name separated by zero. In this case
175 NAME_SIZE field is equal to the length
176 of usual name plus encoded Unicode name plus 1.
177
178 0x400 - the header contains additional 8 bytes
179 after the file name, which are required to
180 increase encryption security (so called 'salt').
181
182 0x800 - Version flag. It is an old file version,
183 a version number is appended to file name as ';n'.
184
185 0x8000 - this bit always is set, so the complete
186 block size is HEAD_SIZE + PACK_SIZE
187 (and plus HIGH_PACK_SIZE, if bit 0x100 is set)
188
189HEAD_SIZE File header full size including file name and comments
1902 bytes
191
192PACK_SIZE Compressed file size
1934 bytes
194
195UNP_SIZE Uncompressed file size
1964 bytes
197
198HOST_OS Operating system used for archiving
1991 byte 0 - MS DOS
200 1 - OS/2
201 2 - Win32
202 3 - Unix
203 4 - Mac OS
204 5 - BeOS
205
206FILE_CRC File CRC
2074 bytes
208
209FTIME Date and time in standard MS DOS format
2104 bytes
211
212UNP_VER RAR version needed to extract file
2131 byte
214
215METHOD Packing method
2161 byte
217
218NAME_SIZE File name size
2192 bytes
220
221ATTR File attributes
2224 bytes
223
224HIGH_PACK_SIZE High 4 bytes of 64 bit value of compressed file size.
2254 bytes Optional value, presents only if bit 0x100 in HEAD_FLAGS
226 is set.
227
228HIGH_UNP_SIZE High 4 bytes of 64 bit value of uncompressed file size.
2294 bytes Optional value, presents only if bit 0x100 in HEAD_FLAGS
230 is set.
231
232FILE_NAME File name - string of NAME_SIZE bytes size
233
234
235Comment block present if (HEAD_FLAGS & 0x08) != 0
236
237
238
239 Comment block
240
241
242HEAD_CRC CRC of fields from HEAD_TYPE to COMM_CRC
2432 bytes
244
245HEAD_TYPE Header type: 0x75
2461 byte
247
248HEAD_FLAGS Bit flags
2492 bytes
250
251HEAD_SIZE Comment header size + comment size
2522 bytes
253
254UNP_SIZE Uncompressed comment size
2552 bytes
256
257UNP_VER RAR version needed to extract comment
2581 byte
259
260METHOD Packing method
2611 byte
262
263COMM_CRC Comment CRC
2642 bytes
265
266COMMENT Comment text
267
268
269
270 Extra info block
271
272
273HEAD_CRC Block CRC
2742 bytes
275
276HEAD_TYPE Header type: 0x76
2771 byte
278
279HEAD_FLAGS Bit flags
2802 bytes
281
282HEAD_SIZE Total block size
2832 bytes
284
285INFO Other data
286
287
288 Subblock
289
290An object in the archive (the block or header) can be followed
291by a subblock. The subblock is dependent upon the main object.
292Subblock can be erased or moved to a new version of the archive
293when it is updated.
294
295 The subblock contains the following fields:
296
297HEAD_CRC Block CRC
2982 bytes
299
300HEAD_TYPE Header type: 0x77
3011 byte
302
303HEAD_FLAGS Bit flags
3042 bytes
305 (HEAD_FLAGS & 0x8000) == 1, because full
306 block size is HEAD_SIZE + DATA_SIZE
307
308HEAD_SIZE Total block size
3092 bytes
310
311DATA_SIZE Total data size
3124 bytes
313
314SUB_TYPE Subblock type
3152 bytes
316
317RESERVED Must be 0
3181 byte
319
320Other Other fields depending on the subblock type
321fields
322
323
324 OS/2 extended attributes subblock
325
326
327HEAD_CRC Block CRC
3282 bytes
329
330HEAD_TYPE Header type: 0x77
3311 byte
332
333HEAD_FLAGS Bit flags
3342 bytes
335 (HEAD_FLAGS & 0x8000) == 1, because full
336 block size is HEAD_SIZE + DATA_SIZE
337
338HEAD_SIZE Total block size
3392 bytes
340
341DATA_SIZE Total data size (packed extended attributes size)
3424 bytes
343
344SUB_TYPE 0x100
3452 bytes
346
347RESERVED Must be 0
3481 byte
349
350UNP_SIZE Uncompressed extended attributes size
3514 bytes
352
353UNP_VER RAR version needed to extract extended attributes
3541 byte
355
356METHOD Packing method
3571 byte
358
359EA_CRC Extended attributes CRC
3604 bytes
361
362
363 ==========================================================================
364 Application notes
365 ==========================================================================
366
367 1. To process an SFX archive you need to skip the SFX module searching
368for the marker block in the archive. There is no marker block sequence (0x52
3690x61 0x72 0x21 0x1a 0x07 0x00) in the SFX module itself.
370
371 2. The CRC is calculated using the standard polynomial 0xEDB88320. In
372case the size of the CRC is less than 4 bytes, only the low order bytes
373are used.
374
375 3. Packing method encoding:
376 0x30 - storing
377 0x31 - fastest compression
378 0x32 - fast compression
379 0x33 - normal compression
380 0x34 - good compression
381 0x35 - best compression
382
383 4. The RAR extraction version number is encoded as 10 * Major version
384+ minor version.
385
386