/ * ================================================================================================================================================================ ================ This document is translated by LXLEVES, because the ability is limited, more or less will have deficiencies, hoping Han Han; please respect the translator's labor, do not modify arbitrarily Translator's original meaning; this translation follows the original format in the organization, if you understand problems in some places, please read full text, you will get satisfactory results; additionally, if you want to add a comment for this document, or for publication If you have this, please keep here, thank you; if you have basic understanding of the C language, you will be more likely to accept the logic of this article, such as a few places '&' and '==' expressed meaning.
============================================================================================================================================================================================================= =============== * / RAR 2.02 version - Technical information ~~~~~~~~~~~~~~~~ == =====================================================th description only after the 1.50 version Archive file =============================================== ============== RAR file file format ================================= ===================== The file file consists of many unknown blocks.
The order of these blocks may be diverse, but the first block must comply with the specific format of the file file. Each block consists of the following parts: Head_Crc 2 Bytes block CRC Verification Head_type 1 Bytes block properties Head_flags 2 Bytes block tag head_size 2 Bytes block size add_size 4 Bytes Arbitrary Area - block added size add_size only (HEAD_FLAGS & 0X8000)! = 0 There is actual sense (Head_Flags & 0x8000) == 0 When the total size of the block is equal to Head_Size, if add_size makes sense (ie, when (head_flags & 0x8000)! = 0), the block is always The size is equal to the sum of Head_Size and Add_Size. In each block, the following tags included in the head_flags have the same meaning: 0x4000 --- If set, the low version of RAR will skip, and this block will be removed when the file file is updated; If set, the block is copied to a new file file when the file file is updated. 0x8000 --- If set, add_size will be valid, and the size of the whole block is the sum of Head_Size and Add_Size. Published block type: Head_type = 0x72 Markup block (Marker Block) Head_type = 0x73 RAR file header (File header) head_type = 0x74 file header (File header) head_type = 0x75 comment header Head_Type = 0x76 Extra Information Head_TYPE = 0x77 Supplementary Block (Subblock) Head_Type = 0x78 Recovery Record The Note Block is actually used simultaneously with other blocks and will not exist.
Archive file processing consists of the following link; : If head_type == 0x74 reads the file header (the first 7 bytes I have read) Read or skip the Head_Size-SizeOf by the Head_Size-SizeOf (File_Head) byte to read the File_SIZE Byte Otherwise, read the corresponding Head_Type block: Read Take the hEAD_SIZE-7 byte If (head_flags & 0x8000) reads the add_size byte, you need to skip the block: Skip the Head_Size-7 byte If (head_flags & 0x8000) skips Add_SIZE byte 6, go to 4.
============================================================================================================================================================================================================= = Block format ============================================== ===== Mark the block (Marker Block (Mark_Head))
HEAD_CRC is always 0x61522 bytes
HEAD_TYPE block properties: 0x721 bytes
Head_flags is always 0x1a212 bytes
HEAD_SIZE block size = 0x00072 BYTES
The tagged block is actually considered a fixed byte sequence: 0x52 0x61 0x72 0x21 0x1a 0x07 0x00
Archive file header (Main_Head)
The CRC2 byte reserved in the Head_Crc Head_Type area
HEAD_TYPE block properties: 0x731 bytes
Head_flags tag bits: 2 bytes 0x01 volume properties (file file volume) 0x02 Current file comment 0x04 file lock attribute 0x08 Solid file 0x10 Unused 0x20 currently trusted information
Other words are reserved for internal use
Head_size contains 2-byte of the file header of the archive comment
Reserved1 reserves 2 bytes
Reserved2 reserves 4 bytes
Comment block (head_flags & 0x02)! = 0 is valid
File head (file header (file in the file)))
Head_CRC CRC authentication from Head_Type to FileAttr and file names 2 bytes
HEAD_TYPE block properties: 0x741 bytes
Head_flags tag bits: 2 bytes 0x01 - Previous volume Continuation 0x02 - Next Volume Document Document 0x04 - Document 0x08 - File Note 0x10 - File Note 0x10 - Use the previous file (fixed tag) (for RAR2. 0 and later) bits 7 6 5 (suitable for RAR2.0 and later)
0 0 - Dictionary size 64 KB 0 0 1 - Dictionary size 128 kB 0 1 0 - Dictionary size 256 kB 0 1 - Dictionary size 512 KB 1 0 0 - Dictionary size 1024 KB 1 0 1 - Reserved 1 1 0 - Reserved 1 1 1 - Directory Sign
(Head_Flags & 0x8000) == 1, because the full block size is Head_Size Pack_SIZE
Head_size file header contains a full foothold of file names and comments 2 bytes
Pack_size compressed file size 4 bytes
UNP_SIZE Uncompressed File Size 4 bytes
Host_OS file application operating system 1 byte 0 - MS DOS 1 - OS / 2 2 - Win32 3 - UNIX
FILE_CRC file CRC4 byte
FTIME Time and Date, MS DOS Standard Format 4 bytes
UNP_VER unpacking file required (Minimum) RAR version 1 byte
Method bag method 1 byte
Name_size file name occupied space size 2 bytes
Attr file attribute 4 bytes
FILE_NAME File Name - String of Name_Size tags
Comment block when (Head_Flags & 0x08)! = 0 is valid
Comment block
Head_crc from Head_Type to Comm_Cr_Crc's CRC2 byte
HEAD_TYPE block properties: 0x751 bytes
Head_flags flag 2 byte
HEAD_SIZE Note Head Size Notes 2 bytes
Unp_size uncompressed annotation size 2 bytes
UNP_VER unpacking file required (Minimum) RAR version 1 byte
Method bag method 1 byte
Comm_Crc Comment CRC2 byte
Comment Commentation Text
Extra INFO Block
HEAD_CRC block CRC2 byte
HEAD_TYPE block properties: 0x761 bytes
Head_flags flag 2 byte
Head_size block total size 2 bytes
INFO other data
Supplemental block (Subblock)
An object (block or block head) in the file file can follow a supplemental block. This supplemental block is subordinate to the primary object. When the file file is updated, the supplemental block can be removed or transferred to a new file file. Supplemental blocks consists of the following areas:
HEAD_CRC block CRC2 byte
HEAD_TYPE block properties: 0x771 bytes
Head_flags flag 2 byte (Head_flags & 0x8000) == 1, because the size of the full block is Head_Size Data_Size
Head_size total block size 2 bytes
Data_size total data size 4 bytes
Sub_Type Supplement Block 2 byte
RESERVED must be 01 bytes
Other Areas (Other Fields) other areas depend on the supplemental block (Subblock)
OS / 2 System Supplementary Block (Extended Attributes)
HEAD_CRC block CRC2 byte
HEAD_TYPE block properties: 0x771 byte Head_flags flag 2 byte (Head_Flags & 0x8000) == 1, because the size of the full block is Head_Size Data_SIZE
Head_size total block size 2 bytes
Data_Size total data size (including extended attributes) 4-byte sub_type 0x1002 bytes
RESERVED must be 01 bytes
UNP_SIZE Uncompressed Extension Property Size 4 bytes
UNP_VER unpacking file required (Minimum) RAR version 1 byte
Method bag method 1 byte
EA_CRC Extended Attributes CRC4 byte
============================================================================================================================================================================================================= = Operating instructions ================================================== === 1. To handle SFX files you need to skip the SFX module in the file file to find a marker block (MARKER Block). (Because) The MARKER Block sequence (0x52 0x61 0x72 0x21 0x1a 0x07 0x00) is not made in the SFX module itself (0x52 0x61 0x72 0x21 0x1a 0x07 0x00).
2. CRC verification uses standard polynomial (Standard Polynomial) to calculate 0xedb88320, where only low bytes are used in the case where the CRC storage space is less than 4 bytes.
3. Package method code: 0x30 - Solvite 0x31 - Quick compression 0x32 - Faster compression 0x33 - Standard compression 0x34 - Better compression 0x35 - Preferably compressed 4. Unemployed files (lowest) RAR version of the RAR version The way is 10 * main version (MAJOR VERSION) small version.