home *** CD-ROM | disk | FTP | other *** search
/ The Best of Select: Games Special 11 / CD_1.iso / xtra / rar155 / technote.doc < prev    next >
Text File  |  1995-08-15  |  9KB  |  362 lines

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