home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ANA015.ZIP / ANA.DOC next >
Text File  |  1990-08-27  |  15KB  |  345 lines

  1. ANA Command summary
  2. Prepared by: Paul C. Tam
  3. For Version 0.15
  4. Published on 24 July 1990
  5.  
  6.     I was rushing to finish this document, some parts may be confusing. I
  7.     appreciate any comment or enhancement of this document. This version of
  8.     ANA are free, please feel free to copy.
  9.  
  10. 0   HIGHLIGHTS
  11.  
  12.     * Interpret binary data in structures YOU defined.
  13.     * Rearrange data bytes before interpretation.
  14.     * Report current machine data types.
  15.     * Dump binary data in very flexible format.
  16.     * Dump multiple files in same screen.
  17.     * Same user interface across various platforms.
  18.     * Built in calculator/converter.
  19.     * Save output to disk to future use.
  20.     * Search for patterns.
  21.     * Execute Operating System command with exit utility.
  22.     * And more......
  23.  
  24.  
  25. 1   INTER-OPERABILITY
  26.  
  27.     Inter-operational seems to be a hot buzzword these days. This software will
  28.     do just that. Since the software is extremely portable, there are versions
  29.     running on almost any operating system that has a C compiler. They have
  30.     exactly the same look and feel across all platforms.
  31.  
  32. 2   Introduction
  33.  
  34.      ANA is an utility program to assist users (especailly software developer)
  35. who are interested in ANAlyzing the binary contents of any file. This program
  36. may be easier for users who know C since the terminology used here is C like.
  37.      Its major function is primarily to display the hexadecimal contents of any
  38. file interactively. On top of it, there are a lot of features built in to make
  39. this utility more flexible and useful. Some of these features include: able to
  40. dump the display buffer into a file, set the display length and base, pack the
  41. display and search for combination of bytes (search has not yet been built).
  42.      An unique feature of this utility is perhaps its ability to analyze
  43. certain structure. This feature is especially geared for software developers.
  44. Sometimes data files are an array of records, each record contains information
  45. of different types. For example, the data file maybe a control file of a print
  46. queue. There are a number of records in there to represent the number of files
  47. waiting to be printed. Each record in turns contains different fields, these
  48. fields may indicate the file name to be printed, its priority and so on. They
  49. may have data type of character (1 byte), integer (2 or 4 bytes) and ASCII
  50. string.
  51.      Using ANA, user can create an ASCII file in which the structure is defined.
  52. ANA then maps the data file into the structure and intreprets them as a series
  53. of fields instead of a string of bytes.
  54.  
  55. 3    How to invoke ANA
  56.  
  57.      ANA can be invoked in any one of the following ways:
  58.  
  59.      1) ANA
  60.      2) ANA <data_file_name>
  61.      3) ANA <data_file_name> <start_address> <length_of_buffer>
  62.  
  63. 4    Inputs
  64.  
  65.      Inputs can be of form hexidecimal, decimal or ascii. Numerical inputs are
  66.      interpreted according to the default base, however they can be overridden
  67.      by a prefix. Any input prefixed by 0x are always hex no matter what the
  68.      current default state is and any input prefixed with \ are always decimal.
  69.      Single ascii character must be between single quotes, ascii string,
  70.      however, must be between a pair of delimitor which can be any characters.
  71.      e.g. command s strings is the same as command s 'tring', they both search
  72.      for "tring".
  73.  
  74. 5    Report
  75.  
  76.      Unpacked -
  77.  0x00000000: 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F |................|
  78.  0x00000010: 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F |................|
  79.  
  80.      Packed -
  81.  000102030405060708090A0B0C0D0E0F
  82.  101112131415161718191A1B1C1D1E1F
  83.  
  84.      The report format is fairly flexible. Report address, report data can be in
  85. either hexadecimal or decimal. The above format can vary depends on a
  86. number of parameters, these parameters can be set by various commands. However,
  87. the following are the default parameters unless otherwise overridden by their
  88. corresponding commands.
  89.  
  90.      Parameters     Defaults       Commands
  91.      Pack Mode      Unpacked       p (packed)
  92.      Address Base   Hexadecimal    b a (base)
  93.      Data Base        Hexadecimal       b d 
  94.      Buffer size    240 bytes      l (length)
  95.      Report width   16 bytes       w (width)
  96.      Start address  0              a (address)
  97.  
  98.  
  99. 6    Command Descriptions
  100.  
  101.      6.1  ? - Help
  102.           Display a brief description of commands available. This is useful for
  103.           commands review.
  104.  
  105.      6.2  ENTER - Display next buffer
  106.           Data is read from file into the data buffer and displayed. Then the
  107.           next starting address is updated so that the next ENTER will display
  108.           the following data.
  109.  
  110.      6.3  l - Set new buffer length
  111.           Define the size of the data buffer on the next display.
  112.  
  113.      6.4  a - Set new starting address
  114.           Define a new starting address of the data file rather than the
  115.           continuation of the last display buffer.
  116.  
  117.      6.5.1  b a - Toggle report address base
  118.           In the unpack mode, the address of the first byte of each report line
  119.           is shown. This address can be of base hexadecimal or decimal. This
  120.           command toggle the base.
  121.  
  122.      6.5.2  b d - Toggle report data base
  123.           Data reported can be of base hexadecimal or decimal. This command
  124.       toggle the base.
  125.  
  126.      6.5.3  b i - Toggle input base
  127.           All numerical inputs are interpreted on the current default base, this
  128.       command toggle the base. However, inputs prefixed with 0x are always 
  129.       interpreted as hex and inputs prefixed with \ are always decimal.
  130.  
  131.      6.6  c - Calculator functions
  132.           Sometimes it is necessary to do some arithmatic operations on the data
  133.           displayed. A simple set of arithmatic functions are available in ANA.
  134.           Currently, the calculator can only do integer arithmatic and is
  135.           limited to two operands and one operator (with only one exception for
  136.           conversion). The syntax of this command is the command keyword
  137.           followed by the operation followed by an ENTER. The following are
  138.           examples and descriptions of all available operations. Suppose X and
  139.           Y are two integers.
  140.  
  141.                c X * Y   ( X multiply Y )
  142.                c X / Y   ( X divided by Y )
  143.                c X + Y   ( X plus Y )
  144.                c X - Y   ( X minus Y )
  145.                c X % Y   ( reminder of X divided by Y )
  146.                c X & Y   ( X bit and with Y )
  147.                c X | Y   ( X bit or with Y )
  148.                c X ^ Y   ( X bit xor with Y )
  149.                c X > Y   ( X right shift Y bits )
  150.                c X < Y   ( X left shift Y bits )
  151.                c X       ( X can be hex, decimal or ASCII )
  152.  
  153.  
  154.      6.7  d - Download structure description file
  155.           Each structure description file maps only one structure, sometimes it
  156.           is desirable to map data to a different structure. This command loads
  157.           another descritpion file for the next mapping.
  158.      6.8  D - continuously dump
  159.       The whole work file starting at current location will be displayed 
  160.       continuously until the end of the file.
  161.  
  162.      6.9  i - information desk
  163.       This command display valuable information. Information includes the
  164.           data types in bytes of current machine, current work file name,
  165.           number, size, maximum work file allowed to open, number of work file
  166.           currently opened and the user input base, report data base and report
  167.           address base. Also the mapping alignments (read m command).
  168.  
  169.      6.10 m - Map data to structure
  170.           Maps the data in the data buffer just displayed into the structure
  171.           described by the SDF. Mapping currently starts at the beginning of
  172.           the data buffer, therefore user may have to adjust the starting
  173.           address before the mapping.
  174.       Data type will normally be aligned in a structure. For example, a
  175.           'short' after a 'char' will be put in even boundary and the byte after
  176.           the 'char' is meaningless. This utility will allow user to specify its
  177.           alignment boundary. The arguments are i for int, l for long, f for
  178.           float and d for double. Their defaults values are displayed in
  179.           information desk ('i'). 
  180.  
  181.      6.11 o - open another work file
  182.       More than one file can be worked on, this command open another work
  183.           file.
  184.  
  185.      6.12 p - Toggle packed display mode
  186.           As discussed above, report format can be either packed or
  187.           unpacked, this command toggle this format.
  188.  
  189.      6.13 q - Quit analyzer
  190.           Terminate and exit program.
  191.  
  192.      6.14 s - search for a pattern
  193.       a pattern is searched starting at current location. The pattern can be
  194.       a series of hex or decimal number, or an ascii string in a pair of
  195.       delimiters.
  196.  
  197.      6.15 t - Transfer data buffer to disk
  198.           It is possible to store the buffer just displayed into a disk file,
  199.       using this command will do just that. At the first execution of this
  200.           command, the user will be prompted for the disk file name unless it is      entered with the command. Any subsequent transfer will be appended to
  201.           the named file and any file name entered in the command line will be
  202.           ignored.
  203.  
  204.      6.16 u - use a different work file
  205.       If there are multiple work files opened (read o command), this command
  206.           is used to switch to a different work file.
  207.  
  208.      6.17 V - Display current version
  209.           This command displays the current version of the software and
  210.           copyright message.
  211.  
  212.      6.18 w - Set display row width
  213.           Especially after changing to packed display format from unpacked
  214.           format, usually it is desirable to display more data in one line. This
  215.           command allows user to adjust the display width. 
  216.  
  217.      6.19 z - zap old data with new data
  218.       Be care when using this command, it will replace the old data at
  219.           current location with the new data. There is no recovery from it. Data
  220.       like 's' command can be hex, decimal or ascii.
  221.  
  222.      6.20 ! - OS escape
  223.       Run a regular Operating System command.
  224.  
  225.      6.21 0 - Redisplay buffer
  226.           Sometimes data may be scrolled off the screen, this command will
  227.           redisplay data that was just displayed.
  228.  
  229.      6.22 + - report the next display buffer
  230.  
  231.      6.23 - - report the previous display buffer.
  232.  
  233.  
  234. 7    Structure mapping
  235.  
  236.      Mapping structure is one of the unique feature in this software. Rather
  237.      than just dumping the data file in bytes, user can define a structure
  238.      definition file (hereon called SDF) from which the data can be intrepreted
  239.      in a more flexible way. The SDF is a pure ASCII file in which each line
  240.      represents one data field and the whole file together defines a structure
  241.      to be mapped.
  242.  
  243.      The way to use this feature is of the following steps:
  244.      First, the SDF is created through any editor, this file must be named
  245.      "ana.fmt".
  246.      Second, display the beginning of the data structure by change the start
  247.      address and hit ENTER.
  248.      Finally, activate the mapping command to map the data buffer.
  249.  
  250.      Each line in the SDF represents one data type field, every line has the
  251.      following format:
  252.  
  253.      keyword user_defined_id [length/byte_arrangement]
  254.  
  255.      All types except "string" the third optional field is for byte rearrange-
  256.      ment. In case of data type string, a length field has to be specified
  257.      to indicate how many bytes are in the string. The user defined name is used
  258.      to assist user to identify the field, its content is arbitrary and is
  259.      limited to 20 characters. Name more than 20 characters will be truncated.
  260.  
  261.      The keywords currently supported are:
  262.  
  263.           int       signed interger
  264.           char      single character (byte)
  265.           string    string of characters
  266.           long      long signed integer
  267.           short     short signed integer
  268.           ulong     unsigned long integer
  269.           ushort    unsigned short integer
  270.           uint      unsigned integer
  271.           float     floating point number
  272.           double    double floating point number
  273.  
  274.      To allow more flexibility, it is also possible to interactively download
  275.      a new SDF so that more than one structure can be analyzed in a data file.
  276.  
  277.      EXAMPLE:
  278.      Suppose there is a file of employee records, each record starts with an
  279.      employee name of 10 characters, then an employee number of type long,
  280.      followed by his salary which is of type integer. Let's further assume that
  281.      integer is two bytes and a long integer is four bytes. Instead of just
  282.      dumping the data file in bytes, it is more useful to dump them in a more
  283.      descriptive form, in this case a string, a long integer and an integer.
  284.      SDF should look like this:
  285.  
  286.           string employee_name 10
  287.           long employee_no.
  288.           int  employee_salary
  289.  
  290.      When the ANA utility is executed, ANA detects the existance of the SDF,
  291.      it will then build the internal structure and enable the mapping facility.
  292.      User can display the portion of data that needs to be analyzed, and then
  293.      activates the mapping command, the display may look something like:
  294.  
  295.           employee_name = (John Doe  )
  296.           employee_no. = 999999 (0xF423F)
  297.           employee_salary = 5000 (0x1388)
  298.  
  299.      Notice that the string is shown inside a pair of paranthesis. The integers
  300.      are shown in decimal and have their corresponding hexadecimal values.
  301.  
  302.      User should be aware that computer always put data into their corresponding
  303.      type boundary. For example, for a machine that uses a two byte integer, a
  304.      structure like
  305.           structure {
  306.                character A;
  307.                integer 1;
  308.           }
  309.           may be stored as follow:
  310.                41 XX 00 01
  311.                    or
  312.                41 00 01
  313.  
  314.      In the first case, the character falls in the even boundary, since the
  315.      integer has to start also at the even boundary, there is a garbage byte in
  316.      between which does not mean anything. While in the second case, the
  317.      character falls in the odd boundary and therefore the integer can be put
  318.      right after the character.
  319.  
  320.      For the same reason, sometimes it is very confusing to just look at the
  321.      data byte by byte. It is better off to use the structure mapping.
  322.  
  323.      Furthermore, different CPUs have different characteristics. Some align
  324.      integer and long into even boundary while other might align integer in even
  325.      boundary and long in 4 byte boundary. This software will allow user to
  326.      customize the alignment. Command m [i/l/f/d] specify the alignment of the
  327.      data type used in structure mapping.
  328.  
  329.      To make life harder, some CPU swap bytes (our beloved 80x86 architecture)
  330.      and some don't. The third optional field in the format file are just for
  331.      that. It specifies the data rearrangement sequence. For example, an integer
  332.      made of 4 bytes is stored in a file as 0x11 0x22 0x33 0x44 (0x011223344),
  333.      a line in the format file:
  334.          int sample 
  335.      yields an output of
  336.          sample = 287454020 (0x11223344)
  337.      but if the format file is written as:
  338.          int sample 4321
  339.      the output will be
  340.          sample = 1144201745 (0x44332211)
  341.  
  342.      This feature is really useful if for example, someone tries to dump a file
  343. created in a 68000 machine in a 8086 machine.
  344.  
  345.