home *** CD-ROM | disk | FTP | other *** search
/ ftp.rarlab.com / 2014.05.ftp.rarlab.com.tar / ftp.rarlab.com / rar / rarsco.sfx / TechNote.Txt < prev    next >
Text File  |  1996-11-16  |  9KB  |  364 lines

  1.  
  2.  ██████╗   █████╗  ██████╗
  3.  ██╔══██╗ ██╔══██╗ ██╔══██╗     RAR version 2.01 - Technical information
  4.  ██████╔╝ ███████║ ██████╔╝     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  5.  ██╔══██╗ ██╔══██║ ██╔══██╗
  6.  ██║  ██║ ██║  ██║ ██║  ██║
  7.  ╚═╝  ╚═╝ ╚═╝  ╚═╝ ╚═╝  ╚═╝
  8.  
  9.  ┌────────────────────────────────────────────────────────────────────────┐
  10.  │THE ARCHIVE FORMAT DESCRIBED BELOW IS ONLY VALID FOR VERSIONS SINCE 1.50│
  11.  └────────────────────────────────────────────────────────────────────────┘
  12.  
  13.  ╔════════════════════════════════════════════════════════════════════════╗
  14.  ║ ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ RAR archive file format ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒║
  15.  ╚════════════════════════════════════════════════════════════════════════╝
  16.  
  17.    Archive file consists of variable length blocks. The order of these
  18. blocks may vary, but the first block must be a marker block followed by
  19. an archive header block.
  20.  
  21.    Each block begins with the following fields:
  22.  
  23. HEAD_CRC       2 bytes     CRC of total block or block part
  24. HEAD_TYPE      1 byte      Block type
  25. HEAD_FLAGS     2 bytes     Block flags
  26. HEAD_SIZE      2 bytes     Block size
  27. ADD_SIZE       4 bytes     Optional field - added block size
  28.  
  29.    Field ADD_SIZE present only if (HEAD_FLAGS & 0x8000) != 0
  30.  
  31.    Total block size is HEAD_SIZE if (HEAD_FLAGS & 0x8000) == 0
  32. and HEAD_SIZE+ADD_SIZE if the field ADD_SIZE is present - when
  33. (HEAD_FLAGS & 0x8000) != 0.
  34.  
  35.    In each block the followings bits in HEAD_FLAGS have the same meaning:
  36.  
  37.   0x4000 - if set, older RAR versions will ignore the block
  38.            and remove it when the archive is updated.
  39.            if clear, the block is copied to the new archive
  40.            file when the archive is updated;
  41.  
  42.   0x8000 - if set, ADD_SIZE field is present and the full block
  43.            size is HEAD_SIZE+ADD_SIZE.
  44.  
  45.   Declared block types:
  46.  
  47. HEAD_TYPE=0x72          marker block
  48. HEAD_TYPE=0x73          archive header
  49. HEAD_TYPE=0x74          file header
  50. HEAD_TYPE=0x75          comment header
  51. HEAD_TYPE=0x76          extra information
  52. HEAD_TYPE=0x77          subblock
  53. HEAD_TYPE=0x78          recovery record
  54.  
  55.    Comment block is actually used only within other blocks and doesn't
  56. exist separately.
  57.  
  58.    Archive processing is made in the following manner:
  59.  
  60. 1. Read and check marker block
  61. 2. Read archive header
  62. 3. Read or skip HEAD_SIZE-sizeof(MAIN_HEAD) bytes
  63. 4. If end of archive encountered then terminate archive processing,
  64.    else read 7 bytes into fields HEAD_CRC, HEAD_TYPE, HEAD_FLAGS,
  65.    HEAD_SIZE.
  66. 5. Check HEAD_TYPE.
  67.    In case block read needed:
  68.          if HEAD_TYPE==0x74
  69.            read file header ( first 7 bytes already read )
  70.            read or skip HEAD_SIZE-sizeof(FILE_HEAD) bytes
  71.            read or skip FILE_SIZE bytes
  72.          else
  73.            read corresponding HEAD_TYPE block:
  74.              read HEAD_SIZE-7 bytes
  75.              if (HEAD_FLAGS & 0x8000)
  76.                read ADD_SIZE bytes
  77.    In case block skip needed:
  78.          skip HEAD_SIZE-7 bytes
  79.          if (HEAD_FLAGS & 0x8000)
  80.            skip ADD_SIZE bytes
  81. 6. go to 4.
  82.  
  83.  
  84.  ╔════════════════════════════════════════════════════════════════════════╗
  85.  ║▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒  Block Formats  ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒║
  86.  ╚════════════════════════════════════════════════════════════════════════╝
  87.  
  88.  
  89.    Marker block ( MARK_HEAD )
  90.  
  91.  
  92. HEAD_CRC        Always 0x6152
  93. 2 bytes
  94.  
  95. HEAD_TYPE       Header type: 0x72
  96. 1 byte
  97.  
  98. HEAD_FLAGS      Always 0x1a21
  99. 2 bytes
  100.  
  101. HEAD_SIZE       Block size = 0x0007
  102. 2 bytes
  103.  
  104.    The marker block is actually considered as a fixed byte
  105. sequence: 0x52 0x61 0x72 0x21 0x1a 0x07 0x00
  106.  
  107.  
  108.  
  109.    Archive header ( MAIN_HEAD )
  110.  
  111.  
  112. HEAD_CRC        CRC of fields HEAD_TYPE to RESERVED2
  113. 2 bytes
  114.  
  115. HEAD_TYPE       Header type: 0x73
  116. 1 byte
  117.  
  118. HEAD_FLAGS      Bit flags:
  119. 2 bytes
  120.                 0x01    - Volume attribute (archive volume)
  121.                 0x02    - Archive comment present
  122.                 0x04    - Archive lock attribute
  123.                 0x08    - Solid attribute (solid archive)
  124.                 0x10    - Unused
  125.                 0x20    - Authenticity information present
  126.  
  127.                 other bits in HEAD_FLAGS are reserved for
  128.                 internal use
  129.  
  130. HEAD_SIZE       Archive header total size including archive comments
  131. 2 bytes
  132.  
  133. RESERVED1       Reserved
  134. 2 bytes
  135.  
  136. RESERVED2       Reserved
  137. 4 bytes
  138.  
  139.  
  140. Comment block   present if (HEAD_FLAGS & 0x02) != 0
  141.  
  142.  
  143.  
  144.    File header (File in archive)
  145.  
  146.  
  147. HEAD_CRC        CRC of fields from HEAD_TYPE to FILEATTR
  148. 2 bytes         and file name
  149.  
  150. HEAD_TYPE       Header type: 0x74
  151. 1 byte
  152.  
  153. HEAD_FLAGS      Bit flags:
  154. 2 bytes
  155.                 0x01 - file continued from previous volume
  156.                 0x02 - file continued in next volume
  157.                 0x04 - file encrypted with password
  158.                 0x08 - file comment present
  159.                 0x10 - information from previous files is used (solid flag)
  160.                        (for RAR 2.0 and later)
  161.  
  162.                 bits 7 6 5 (for RAR 2.0 and later)
  163.  
  164.                      0 0 0    - dictionary size   64 Kb
  165.                      0 0 1    - dictionary size  128 Kb
  166.                      0 1 0    - dictionary size  256 Kb
  167.                      0 1 1    - dictionary size  512 Kb
  168.                      1 0 0    - dictionary size 1024 Kb
  169.                      1 0 1    - reserved
  170.                      1 1 0    - reserved
  171.                      1 1 1    - file is directory
  172.  
  173.                 (HEAD_FLAGS & 0x8000) == 1, because full
  174.                 block size is HEAD_SIZE + PACK_SIZE
  175.  
  176. HEAD_SIZE       File header full size including file name and comments
  177. 2 bytes
  178.  
  179. PACK_SIZE       Compressed file size
  180. 4 bytes
  181.  
  182. UNP_SIZE        Uncompressed file size
  183. 4 bytes
  184.  
  185. HOST_OS         Operating system used for archiving
  186. 1 byte                 0 - MS DOS
  187.                        1 - OS/2
  188.                        2 - Win32
  189.                        3 - Unix
  190.  
  191. FILE_CRC        File CRC
  192. 4 bytes
  193.  
  194. FTIME           Date and time in standard MS DOS format
  195. 4 bytes
  196.  
  197. UNP_VER         RAR version needed to extract file
  198. 1 byte
  199.  
  200. METHOD          Packing method
  201. 1 byte
  202.  
  203. NAME_SIZE       File name size
  204. 2 bytes
  205.  
  206. ATTR            File attributes
  207. 4 bytes
  208.  
  209. FILE_NAME       File name - string of NAME_SIZE bytes size
  210.  
  211.  
  212. Comment block   present if (HEAD_FLAGS & 0x08) != 0
  213.  
  214.  
  215.  
  216.   Comment block
  217.  
  218.  
  219. HEAD_CRC        CRC of fields from HEAD_TYPE to COMM_CRC
  220. 2 bytes
  221.  
  222. HEAD_TYPE       Header type: 0x75
  223. 1 byte
  224.  
  225. HEAD_FLAGS      Bit flags
  226. 2 bytes
  227.  
  228. HEAD_SIZE       Comment header size + comment size
  229. 2 bytes
  230.  
  231. UNP_SIZE        Uncompressed comment size
  232. 2 bytes
  233.  
  234. UNP_VER         RAR version needed to extract comment
  235. 1 byte
  236.  
  237. METHOD          Packing method
  238. 1 byte
  239.  
  240. COMM_CRC        Comment CRC
  241. 2 bytes
  242.  
  243. COMMENT         Comment text
  244.  
  245.  
  246.  
  247.   Extra info block
  248.  
  249.  
  250. HEAD_CRC        Block CRC
  251. 2 bytes
  252.  
  253. HEAD_TYPE       Header type: 0x76
  254. 1 byte
  255.  
  256. HEAD_FLAGS      Bit flags
  257. 2 bytes
  258.  
  259. HEAD_SIZE       Total block size
  260. 2 bytes
  261.  
  262. INFO            Other data
  263.  
  264.  
  265.   Subblock
  266.  
  267. An object in the archive (the block or header) can be followed
  268. by a subblock. The subblock is dependant upon the main object.
  269. Subblock can be erased or moved to a new version of the archive
  270. when it is updated.
  271.  
  272.  The subblock contains the following fields:
  273.  
  274. HEAD_CRC        Block CRC
  275. 2 bytes
  276.  
  277. HEAD_TYPE       Header type: 0x77
  278. 1 byte
  279.  
  280. HEAD_FLAGS      Bit flags
  281. 2 bytes
  282.                 (HEAD_FLAGS & 0x8000) == 1, because full
  283.                 block size is HEAD_SIZE + DATA_SIZE
  284.  
  285. HEAD_SIZE       Total block size
  286. 2 bytes
  287.  
  288. DATA_SIZE       Total data size
  289. 4 bytes
  290.  
  291. SUB_TYPE        Subblock type
  292. 2 bytes
  293.  
  294. RESERVED        Must be 0
  295. 1 byte
  296.  
  297. Other           Other fields depending on the subblock type
  298. fields
  299.  
  300.  
  301.   OS/2 extended attributes subblock
  302.  
  303.  
  304. HEAD_CRC        Block CRC
  305. 2 bytes
  306.  
  307. HEAD_TYPE       Header type: 0x77
  308. 1 byte
  309.  
  310. HEAD_FLAGS      Bit flags
  311. 2 bytes
  312.                 (HEAD_FLAGS & 0x8000) == 1, because full
  313.                 block size is HEAD_SIZE + DATA_SIZE
  314.  
  315. HEAD_SIZE       Total block size
  316. 2 bytes
  317.  
  318. DATA_SIZE       Total data size (packed extended attributes size)
  319. 4 bytes
  320.  
  321. SUB_TYPE        0x100
  322. 2 bytes
  323.  
  324. RESERVED        Must be 0
  325. 1 byte
  326.  
  327. UNP_SIZE        Uncompressed extended attributes size
  328. 4 bytes
  329.  
  330. UNP_VER         RAR version needed to extract extended attributes
  331. 1 byte
  332.  
  333. METHOD          Packing method
  334. 1 byte
  335.  
  336. EA_CRC          Extended attributes CRC
  337. 4 bytes
  338.  
  339.  
  340.  ╔════════════════════════════════════════════════════════════════════════╗
  341.  ║▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒  Application notes  ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒║
  342.  ╚════════════════════════════════════════════════════════════════════════╝
  343.  
  344.  
  345.    1. To process an SFX archive you need to skip the SFX module searching
  346. for the marker block in the archive. There is no marker block sequence (0x52
  347. 0x61 0x72 0x21 0x1a 0x07 0x00) in the SFX module itself.
  348.  
  349.    2. The CRC is calculated using the standard polynomial 0xEDB88320. In
  350. case the size of the CRC is less than 4 bytes, only the low order bytes
  351. are used.
  352.  
  353.    3. Packing method encoding:
  354.          0x30 - storing
  355.          0x31 - fastest compression
  356.          0x32 - fast compression
  357.          0x33 - normal compression
  358.          0x34 - good compression
  359.          0x35 - best compression
  360.  
  361.    4. The RAR extraction version number is encoded as 10 * Major version
  362. + minor version.
  363.  
  364.