home *** CD-ROM | disk | FTP | other *** search
/ CD-ROM Aktief 1995 #6 / CDA_6.iso / shell / cdrom / rar153 / rar153uk.exe / rar / TECHNOTE.DOC < prev    next >
Text File  |  1994-12-16  |  8KB  |  282 lines

  1.  
  2.  ██████╗   █████╗  ██████╗
  3.  ██╔══██╗ ██╔══██╗ ██╔══██╗     RAR version 1.53 - 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 does not
  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          (value 0 stands for MS DOS)
  176.  
  177. FILE_CRC        File CRC
  178. 4 bytes
  179.  
  180. FTIME           Date and time in standard MS DOS format
  181. 4 bytes
  182.  
  183. UNP_VER         RAR version needed to extract file
  184. 1 byte
  185.  
  186. METHOD          Packing method
  187. 1 byte
  188.  
  189. NAME_SIZE       File name size
  190. 2 bytes
  191.  
  192. ATTR            File attributes
  193. 4 bytes
  194.  
  195. FILE_NAME       File name - string of NAME_LEN bytes size
  196.  
  197.  
  198. Comment block   present if (HEAD_FLAGS & 0x08) != 0
  199.  
  200.  
  201. ????            Other extra included blocks - reserved for
  202.                 future use
  203.  
  204.  
  205.  
  206.   Comment block
  207.  
  208.  
  209. HEAD_CRC        CRC of fields from HEAD_TYPE to COMM_CRC
  210. 2 bytes
  211.  
  212. HEAD_TYPE       Header type: 0x75
  213. 1 byte
  214.  
  215. HEAD_FLAGS      Bit flags
  216. 2 bytes
  217.  
  218. HEAD_SIZE       Comment header size + comment size
  219. 2 bytes
  220.  
  221. UNP_SIZE        Uncompressed comment size
  222. 2 bytes
  223.  
  224. UNP_VER         RAR version needed to extract comment
  225. 1 byte
  226.  
  227. METHOD          Packing method
  228. 1 byte
  229.  
  230. COMM_CRC        Comment CRC
  231. 2 bytes
  232.  
  233. COMMENT         Comment text
  234.  
  235.  
  236.  
  237.   Extra info block
  238.  
  239.  
  240. HEAD_CRC        Block CRC
  241. 2 bytes
  242.  
  243. HEAD_TYPE       Header type: 0x76
  244. 1 byte
  245.  
  246. HEAD_FLAGS      Bit flags
  247. 2 bytes
  248.  
  249. HEAD_SIZE       Total block size
  250. 2 bytes
  251.  
  252. INFO            Other data
  253.  
  254.  
  255.  ╔════════════════════════════════════════════════════════════════════════╗
  256.  ║▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒  Application notes  ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒║
  257.  ╚════════════════════════════════════════════════════════════════════════╝
  258.  
  259.  
  260.    1. Should fields and included blocks be added in the future, their
  261. size would be included in HEAD_SIZE.
  262.  
  263.    2. To process SFX archive you need to skip the SFX module searching
  264. marker block in the archive. There is no marker block sequence (0x52 0x61
  265. 0x72 0x21 0x1a 0x07 0x00) in the SFX module itself.
  266.  
  267.    3. The CRC is calculated using the standard polynomial 0xEDB88320. In
  268. case the size of the CRC is less than 4 bytes, only the low order bytes
  269. are used.
  270.  
  271.    4. Packing method encoding:
  272.          0x30 - storing
  273.          0x31 - fastest compression
  274.          0x32 - fast compression
  275.          0x33 - normal compression
  276.          0x34 - good compression
  277.          0x35 - best compression
  278.  
  279.    5. The RAR extraction version number is encoded as 10 * Major version
  280. + minor version.
  281.  
  282.