home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS 1999 January / Simtel-MSDOS-Jan1999-CD1.iso / arcers / arj260x.exe / TECHNOTE.DOC < prev    next >
Text File  |  1997-11-16  |  13KB  |  301 lines

  1.  
  2.      ARJ TECHNICAL INFORMATION                                   July 1997
  3.  
  4.  
  5.      ** IMPORTANT NEWS ****************************************************
  6.  
  7.      Some archiver support programs have designed ARJ archive
  8.      identification schemes that are not reliable.  At ARJ 2.50, there
  9.      are now three versions of the ARJSFX self-extraction module.  The
  10.      18K byte ARJSFX module and the larger ARJSFXV module support
  11.      ARJ-SECURITY.  The standard 16K byte ARJSFX module does NOT support
  12.      ARJ-SECURITY.  For the first time, the ARJ-SECURITY fields in the
  13.      main ARJ header are publicly defined.
  14.  
  15.      In addition, the main ARJ header in self-extracting archives MAY NOT
  16.      immediately follow the EXE module now.
  17.  
  18.      ARJ has used the same ARJ archive identification scheme since ARJ
  19.      1.0.  The following is the algorithm:
  20.  
  21.      (1) find the ARJ header id bytes 0x60, 0xEA,
  22.      (2) read the next two bytes as the header record size in bytes,
  23.      (3) if the record size is greater than 2600, go back to the header
  24.          id file position, increment the file position, and go back to
  25.          step (1),
  26.      (4) read the header record based upon the previous byte count,
  27.      (5) calculate the 32 bit CRC of the header record data,
  28.      (6) read the next four bytes as the actual header record CRC,
  29.      (7) if the actual CRC does not equal the calculated CRC, go back
  30.          to the header id file position, increment the file position,
  31.          and go back to step (1).
  32.  
  33.      It is acceptable to start this identification algorithm at a point
  34.      just after the ARJ self-extraction EXE portion of an archive.  This
  35.      algorithm is fully demonstrated in the UNARJ C source code. A portion
  36.      of that source code is excerpted at the end of this document.
  37.  
  38.      As of ARJ 2.10, the SFX executable modules are pre-compressed
  39.      using LZEXE.  This may cause false indications with EXE scanning
  40.      programs showing that an ARJ SFX archive is a LZEXE compressed
  41.      file.  Only the executable header module is LZEXE compressed.
  42.      The actual archive is ARJ compressed, of course.  The LZEXE
  43.      header is modified to avoid extraction by UNLZEXE type programs.
  44.      UNLZEXE may truncate an ARJ self-extractor of its archive.
  45.  
  46.      All SFX modules have an identification string located in the
  47.      first 1000 characters of the executable.  The identification
  48.      string is "aRJsfX" without the quotes and in the exact case.
  49.  
  50.      When using listfiles with ARJ, ARJ support programs should use the
  51.      "-p" option to ensure that ARJ will only extract the selected files
  52.      from an ARJ archive.  In addition, the listfiles should contain the
  53.      full pathname information as stored in the ARJ archive.  This avoids
  54.      the problem accessing files that have the same filename but different
  55.      paths.
  56.  
  57.      There is an extended header bug in older versions of ARJ, AV.C and
  58.      UNARJ.C.  The extended header processing in read_header() should
  59.      skip 4 bytes for the extended header CRC and not 2.  This is NOT a
  60.      current problem as no versions of ARJ use the extended header.
  61.  
  62.      **********************************************************************
  63.  
  64.  
  65.      Modification history:
  66.      Date      Description of modification:
  67.      --------  ------------------------------------------------------------
  68.      03/11/97  Added methods 8 and 9.
  69.      06/21/96  Added information about new encryption scheme.
  70.      04/11/96  Added information about chapters. Obsoleted backup files.
  71.      07/07/95  Added information about SFX id string.
  72.      11/03/94  Improved SFX identification information.
  73.      01/21/94  Added find_header() routine.
  74.      03/17/93  Added information about ARJSFX change.
  75.      02/17/93  Added description of ARJ security fields.
  76.                Added archive date-modified field.
  77.      12/03/91  Added BACKUP flag to header arj flags.
  78.      11/21/91  Described the two types of headers separately.
  79.      11/11/91  Added information about the change in text mode processing.
  80.      06/28/91  Added several new HOST OS numbers.
  81.      05/19/91  Improved the description of extended header processing.
  82.      05/11/91  Simplified this document.  Added volume label type.
  83.      03/11/91  Added directory file type.
  84.      02/23/91  Added more comments.
  85.      01/10/91  Corrected timestamp description and header order of file mode.
  86.      10/30/90  Corrected values of flags in ARJ flags.
  87.  
  88.  
  89.      ARJ archives contains three types of header blocks:
  90.  
  91.         Archive main header - This is located at the head of the archive
  92.         Local file header   - This is located before each archived file
  93.         Chapter header      - This is usually located each series of
  94.                               chapter files.
  95.  
  96.      Structure of main header (low order byte first):
  97.  
  98.      Bytes Description
  99.      ----- -------------------------------------------------------------------
  100.        2   header id (main and local file) = 0x60 0xEA
  101.        2   basic header size (from 'first_hdr_size' thru 'comment' below)
  102.                  = first_hdr_size + strlen(filename) + 1 + strlen(comment) + 1
  103.                  = 0 if end of archive
  104.                  maximum header size is 2600
  105.  
  106.        1   first_hdr_size (size up to and including 'extra data')
  107.        1   archiver version number
  108.        1   minimum archiver version to extract
  109.        1   host OS   (0 = MSDOS, 1 = PRIMOS, 2 = UNIX, 3 = AMIGA, 4 = MAC-OS)
  110.                      (5 = OS/2, 6 = APPLE GS, 7 = ATARI ST, 8 = NEXT)
  111.                      (9 = VAX VMS, 10 = WIN95)
  112.        1   arj flags
  113.                      (0x01 = GARBLED_FLAG)
  114.                      (0x02 = OLD_SECURED_FLAG)
  115.                      (0x04 = VOLUME_FLAG)  indicates presence of succeeding
  116.                                            volume
  117.                      (0x08 = NOT USED)
  118.                      (0x10 = PATHSYM_FLAG) indicates archive name translated
  119.                                            ("\" changed to "/")
  120.                      (0x20 = BACKUP_FLAG)  obsolete
  121.                      (0x40 = SECURED_FLAG)
  122.                      (0x80 = ALTNAME_FLAG) indicates dual-name archive
  123.        1   security version (2 = current)
  124.        1   file type        (must equal 2)
  125.        1   reserved
  126.        4   date time when original archive was created
  127.        4   date time when archive was last modified
  128.        4   archive size (currently used only for secured archives)
  129.        4   security envelope file position
  130.        2   filespec position in filename
  131.        2   length in bytes of security envelope data
  132.        1   encryption version (0 and 1 = old, 2 = new)
  133.        1   last chapter
  134.        ?   (currently none)
  135.  
  136.        ?   filename of archive when created (null-terminated string)
  137.        ?   archive comment  (null-terminated string)
  138.  
  139.        4   basic header CRC
  140.  
  141.        2   1st extended header size (0 if none)
  142.        ?   1st extended header (currently not used)
  143.        4   1st extended header's CRC (not present when 0 extended header size)
  144.  
  145.  
  146.      Structure of local file header (low order byte first):
  147.  
  148.      Bytes Description
  149.      ----- -------------------------------------------------------------------
  150.        2   header id (main and local file) = 0x60 0xEA
  151.        2   basic header size (from 'first_hdr_size' thru 'comment' below)
  152.                  = first_hdr_size + strlen(filename) + 1 + strlen(comment) + 1
  153.                  = 0 if end of archive
  154.                  maximum header size is 2600
  155.  
  156.        1   first_hdr_size (size up to and including 'extra data')
  157.        1   archiver version number
  158.        1   minimum archiver version to extract
  159.        1   host OS   (0 = MSDOS, 1 = PRIMOS, 2 = UNIX, 3 = AMIGA, 4 = MAC-OS)
  160.                      (5 = OS/2, 6 = APPLE GS, 7 = ATARI ST, 8 = NEXT)
  161.                      (9 = VAX VMS, 10 = WIN95)
  162.        1   arj flags (0x01 = GARBLED_FLAG) indicates passworded file
  163.                      (0x02 = NOT USED)
  164.                      (0x04 = VOLUME_FLAG)  indicates continued file to next
  165.                                            volume (file is split)
  166.                      (0x08 = EXTFILE_FLAG) indicates file starting position
  167.                                            field (for split files)
  168.                      (0x10 = PATHSYM_FLAG) indicates filename translated
  169.                                            ("\" changed to "/")
  170.                      (0x20 = BACKUP_FLAG)  obsolete
  171.        1   method    (0 = stored, 1 = compressed most ... 4 compressed fastest)
  172.                      (8 = no data, no CRC, 9= no data)
  173.        1   file type (0 = binary,    1 = 7-bit text)
  174.                      (3 = directory, 4 = volume label)
  175.                      (5 = chapter label)
  176.        1   reserved
  177.        4   date time modified
  178.        4   compressed size
  179.        4   original size (this will be different for text mode compression)
  180.        4   original file's CRC
  181.        2   filespec position in filename
  182.        2   file access mode
  183.        1   first chapter of file's lifespan
  184.        1   last chapter of file's lifespan
  185.        ?   extra data
  186.            4 bytes for extended file starting position when used
  187.            (these bytes are present when EXTFILE_FLAG is set).
  188.            0 bytes otherwise.
  189.  
  190.        ?   filename (null-terminated string)
  191.        ?   comment  (null-terminated string)
  192.  
  193.        4   basic header CRC
  194.  
  195.        2   1st extended header size (0 if none)
  196.        ?   1st extended header (currently not used)
  197.        4   1st extended header's CRC (not present when 0 extended header size)
  198.  
  199.        ...
  200.  
  201.        ?   compressed file
  202.  
  203.  
  204.       Structure of archive chapter header (low order byte first):
  205.  
  206.      Bytes Description
  207.      ----- -------------------------------------------------------------------
  208.        2  header id (comment and local file) = 0xEA60 or 60000U
  209.        2  basic header size (from 'first_hdr_size' thru 'comment' below)
  210.                 = first_hdr_size + strlen(filename) + 1 + strlen(comment) + 1
  211.                 = 0 if end of archive
  212.  
  213.        1  first_hdr_size (size up to 'extra data')
  214.        1  archiver version number
  215.        1  minimum archiver version to extract
  216.        1  host OS   (0 = MSDOS, 1 = PRIMOS, 2 = UNIX, 3 = AMIGA, 4 = MACDOS)
  217.                     (5 = OS/2, 6 = APPLE GS, 7 = ATARI ST, 8 = NEXT)
  218.                      (9 = VAX VMS, 10 = WIN95)
  219.        1  arj flags (0x01 = GARBLED_FLAG, 0x02 = RESERVED)
  220.                     (0x04 = VOLUME_FLAG,  0x08 = EXTFILE_FLAG)
  221.                     (0x10 = PATHSYM_FLAG,
  222.                     (0x20 = BACKUP_FLAG)   OBSOLETE < 2.50a
  223.                     (0x40 = RESERVED)
  224.        1  method    (0 = stored, 1 = compressed most ... 4 compressed fastest)
  225.        1  file type (0 = binary, 1 = text, 2 = comment header, 3 = directory)
  226.                     (4 = label, 5 = chapter)
  227.        1  ?
  228.        4  date time stamp created
  229.        4  ?
  230.        4  ?
  231.        4  original file's CRC
  232.        2  entryname position in filename
  233.        2  file access mode
  234.        1  chapter range start
  235.        1  chapter range end
  236.        ?  extra data
  237.           4 bytes for extended file position
  238.  
  239.        ?  filename (null-terminated)
  240.        ?  comment  (null-terminated)
  241.  
  242.        4  basic header CRC
  243.  
  244.        2  1st extended header size (0 if none)
  245.        ?  1st extended header
  246.        4  1st extended header's CRC
  247.  
  248.        ...
  249.  
  250.  
  251.      Time stamp format:
  252.  
  253.         31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
  254.        |<---- year-1980 --->|<- month ->|<--- day ---->|
  255.  
  256.         15 14 13 12 11 10  9  8  7  6  5  4  3  2  1  0
  257.        |<--- hour --->|<---- minute --->|<- second/2 ->|
  258.  
  259.  
  260.      Routine to find an ARJ Header record:
  261.  
  262.        long find_header(FILE *fd)
  263.        {
  264.            long arcpos, lastpos;
  265.            int c;
  266.  
  267.            arcpos = file_tell(fd);
  268.            file_seek(fd, 0L, SEEK_END);
  269.            lastpos = file_tell(fd) - 2;
  270.            for ( ; arcpos < lastpos; arcpos++)
  271.            {
  272.                file_seek(fd, arcpos, SEEK_SET);
  273.                c = fget_byte(fd);
  274.                while (arcpos < lastpos)
  275.                {
  276.                    if (c != HEADER_ID_LO)  /* low order first */
  277.                        c = fget_byte(fd);
  278.                    else if ((c = fget_byte(fd)) == HEADER_ID_HI)
  279.                        break;
  280.                    arcpos++;
  281.                }
  282.                if (arcpos >= lastpos)
  283.                    break;
  284.                if ((headersize = fget_word(fd)) <= HEADERSIZE_MAX)
  285.                {
  286.                    crc = CRC_MASK;
  287.                    fread_crc(header, (int) headersize, fd);
  288.                    if ((crc ^ CRC_MASK) == fget_crc(fd))
  289.                    {
  290.                        file_seek(fd, arcpos, SEEK_SET);
  291.                        return arcpos;
  292.                    }
  293.                }
  294.            }
  295.            return -1;          /* could not find a valid header */
  296.        }
  297.  
  298.  
  299.      end of document
  300.  
  301.