Technote

  • November 2019
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Technote as PDF for free.

More details

  • Words: 1,098
  • Pages: 5
rar version 3.60 - 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

crc of total block or block part block type block flags block size 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) == 0 and 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 and remove it if clear, the file when the

rar versions will ignore the block when the archive is updated. block is copied to the new archive 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 head_type=0x73 head_type=0x74 head_type=0x75 head_type=0x76 head_type=0x77 head_type=0x78 head_type=0x79 head_type=0x7a

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.

read and check marker block read archive header read or skip head_size-sizeof(main_head) bytes 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 bytes 6. go to 4. ========================================================================== block formats ========================================================================== marker block ( mark_head ) head_crc 2 bytes

always 0x6152

head_type 1 byte

header type: 0x72

head_flags 2 bytes

always 0x1a21

head_size 2 bytes

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 2 bytes

crc of fields head_type to reserved2

head_type 1 byte

header type: 0x73

head_flags 2 bytes

bit flags: 0x0001 0x0002

- volume attribute (archive volume) - archive comment present rar 3.x uses the separate comment block and does not set this flag.

0x0004 0x0008 0x0010 0x0020

-

archive lock attribute solid attribute (solid archive) new volume naming scheme ('volname.partn.rar') authenticity information present rar 3.x does not set this flag.

0x0040 0x0080 0x0100

- recovery record present - block headers are encrypted - first volume (set only by rar 3.0 and later)

other bits in head_flags are reserved for internal use head_size 2 bytes

archive header total size including archive comments

reserved1 2 bytes

reserved

reserved2 4 bytes

reserved

file header (file in archive) head_crc 2 bytes

crc of fields from head_type to fileattr and file name

head_type 1 byte

header type: 0x74

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

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. if this flag is present, but file_name does not contain zero bytes, it means that file name is encoded using utf-8. 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'. 0x1000 - extended time field present. 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 2 bytes

file header full size including file name and comments

pack_size 4 bytes

compressed file size

unp_size 4 bytes

uncompressed file size

host_os 1 byte

operating system used for archiving 0 - ms dos 1 - os/2 2 - win32 3 - unix 4 - mac os 5 - beos

file_crc 4 bytes

file crc

ftime 4 bytes

date and time in standard ms dos format

unp_ver 1 byte

rar version needed to extract file

method 1 byte

packing method

version number is encoded as 10 * major version + minor version.

0x30 - storing

0x31 0x32 0x33 0x34 0x35

-

fastest compression fast compression normal compression good compression best compression

name_size 2 bytes

file name size

attr 4 bytes

file attributes

high_pack_size 4 bytes

high 4 bytes of 64 bit value of compressed file size. optional value, presents only if bit 0x100 in head_flags is set.

high_unp_size 4 bytes

high 4 bytes of 64 bit value of uncompressed file size. optional value, presents only if bit 0x100 in head_flags is set.

file_name

file name - string of name_size bytes size

salt 8 bytes

present if (head_flags & 0x400) != 0

ext_time variable size

present if (head_flags & 0x1000) != 0

other new fields may appear here. ========================================================================== application notes ========================================================================== 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 are used.

Related Documents