📄 technote.txt
字号:
RAR version 2.90 - 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 theseblocks may vary, but the first block must be a marker block followed byan archive header block. Each block begins with the following fields:HEAD_CRC 2 bytes CRC of total block or block partHEAD_TYPE 1 byte Block typeHEAD_FLAGS 2 bytes Block flagsHEAD_SIZE 2 bytes Block sizeADD_SIZE 4 bytes Optional field - added block size Field ADD_SIZE present only if (HEAD_FLAGS & 0x8000) != 0 Total block size is HEAD_SIZE if (HEAD_FLAGS & 0x8000) == 0and HEAD_SIZE+ADD_SIZE if the field ADD_SIZE is present - when(HEAD_FLAGS & 0x8000) != 0. In each block the followings bits in HEAD_FLAGS have the same meaning: 0x4000 - if set, older RAR versions will ignore the block and remove it when the archive is updated. if clear, the block is copied to the new archive file when the archive is updated; 0x8000 - if set, ADD_SIZE field is present and the full block size is HEAD_SIZE+ADD_SIZE. Declared block types:HEAD_TYPE=0x72 marker blockHEAD_TYPE=0x73 archive headerHEAD_TYPE=0x74 file headerHEAD_TYPE=0x75 comment headerHEAD_TYPE=0x76 old style authenticity informationHEAD_TYPE=0x77 subblockHEAD_TYPE=0x78 recovery recordHEAD_TYPE=0x79 authenticity information Comment block is actually used only within other blocks and doesn'texist separately. Archive processing is made in the following manner:1. Read and check marker block2. Read archive header3. Read or skip HEAD_SIZE-sizeof(MAIN_HEAD) bytes4. If end of archive encountered then terminate archive processing, else read 7 bytes into fields HEAD_CRC, HEAD_TYPE, HEAD_FLAGS, 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 bytes6. go to 4. ========================================================================== Block Formats ========================================================================== Marker block ( MARK_HEAD )HEAD_CRC Always 0x61522 bytesHEAD_TYPE Header type: 0x721 byteHEAD_FLAGS Always 0x1a212 bytesHEAD_SIZE Block size = 0x00072 bytes The marker block is actually considered as a fixed bytesequence: 0x52 0x61 0x72 0x21 0x1a 0x07 0x00 Archive header ( MAIN_HEAD )HEAD_CRC CRC of fields HEAD_TYPE to RESERVED22 bytesHEAD_TYPE Header type: 0x731 byteHEAD_FLAGS Bit flags:2 bytes 0x01 - Volume attribute (archive volume) 0x02 - Archive comment present 0x04 - Archive lock attribute 0x08 - Solid attribute (solid archive) 0x10 - Unused 0x20 - Authenticity information present other bits in HEAD_FLAGS are reserved for internal useHEAD_SIZE Archive header total size including archive comments2 bytesRESERVED1 Reserved2 bytesRESERVED2 Reserved4 bytesComment block present if (HEAD_FLAGS & 0x02) != 0 File header (File in archive)HEAD_CRC CRC of fields from HEAD_TYPE to FILEATTR2 bytes and file nameHEAD_TYPE Header type: 0x741 byteHEAD_FLAGS Bit flags:2 bytes 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) (for RAR 2.0 and later) 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 - reserved 1 1 0 - reserved 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. 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 comments2 bytesPACK_SIZE Compressed file size4 bytesUNP_SIZE Uncompressed file size4 bytesHOST_OS Operating system used for archiving1 byte 0 - MS DOS 1 - OS/2 2 - Win32 3 - Unix 4 - Mac OS 5 - BeOSFILE_CRC File CRC4 bytesFTIME Date and time in standard MS DOS format4 bytesUNP_VER RAR version needed to extract file1 byteMETHOD Packing method1 byteNAME_SIZE File name size2 bytesATTR File attributes4 bytesHIGH_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 is set.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 is set.FILE_NAME File name - string of NAME_SIZE bytes sizeComment block present if (HEAD_FLAGS & 0x08) != 0 Comment blockHEAD_CRC CRC of fields from HEAD_TYPE to COMM_CRC2 bytesHEAD_TYPE Header type: 0x751 byteHEAD_FLAGS Bit flags2 bytesHEAD_SIZE Comment header size + comment size2 bytesUNP_SIZE Uncompressed comment size2 bytesUNP_VER RAR version needed to extract comment1 byteMETHOD Packing method1 byteCOMM_CRC Comment CRC2 bytesCOMMENT Comment text Extra info blockHEAD_CRC Block CRC2 bytesHEAD_TYPE Header type: 0x761 byteHEAD_FLAGS Bit flags2 bytesHEAD_SIZE Total block size2 bytesINFO Other data SubblockAn object in the archive (the block or header) can be followedby a subblock. The subblock is dependent upon the main object.Subblock can be erased or moved to a new version of the archivewhen it is updated. The subblock contains the following fields:HEAD_CRC Block CRC2 bytesHEAD_TYPE Header type: 0x771 byteHEAD_FLAGS Bit flags2 bytes (HEAD_FLAGS & 0x8000) == 1, because full block size is HEAD_SIZE + DATA_SIZEHEAD_SIZE Total block size2 bytesDATA_SIZE Total data size4 bytesSUB_TYPE Subblock type2 bytesRESERVED Must be 01 byteOther Other fields depending on the subblock typefields OS/2 extended attributes subblockHEAD_CRC Block CRC2 bytesHEAD_TYPE Header type: 0x771 byteHEAD_FLAGS Bit flags2 bytes (HEAD_FLAGS & 0x8000) == 1, because full block size is HEAD_SIZE + DATA_SIZEHEAD_SIZE Total block size2 bytesDATA_SIZE Total data size (packed extended attributes size)4 bytesSUB_TYPE 0x1002 bytesRESERVED Must be 01 byteUNP_SIZE Uncompressed extended attributes size4 bytesUNP_VER RAR version needed to extract extended attributes1 byteMETHOD Packing method1 byteEA_CRC Extended attributes CRC4 bytes ========================================================================== Application notes ========================================================================== 1. To process an SFX archive you need to skip the SFX module searchingfor the marker block in the archive. There is no marker block sequence (0x520x61 0x72 0x21 0x1a 0x07 0x00) in the SFX module itself. 2. The CRC is calculated using the standard polynomial 0xEDB88320. Incase the size of the CRC is less than 4 bytes, only the low order bytesare used. 3. Packing method encoding: 0x30 - storing 0x31 - fastest compression 0x32 - fast compression 0x33 - normal compression 0x34 - good compression 0x35 - best compression 4. The RAR extraction version number is encoded as 10 * Major version+ minor version.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -