home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / jsage / zsus / z3help / z.lbr / ZPATCH.HZP / ZPATCH.HLP
Encoding:
Text File  |  1991-11-18  |  18.9 KB  |  445 lines

  1. ;
  2.                                    ZPATCH.COM                                 
  3.  
  4.              Size (recs) CRC   Version    Author/Latest Issue      Disk
  5.                9k (71)   0D28  1.3        Steven Cohen 4/88        Z3COM13
  6.  
  7.   1- Syntax  2- Installation  3- Notes  4- Help File  5- Error Messages       
  8.  
  9.    ZPATCH is a file-oriented  byte  editor  similar  in function to the public 
  10. domain program EDFILE.  It enables you to patch a file byte-by-byte.  This can
  11. be useful when you obtain documented patch addresses known to affect a program
  12. in certain ways.  It is often easier to make  a patch or two to a program than 
  13. to reassemble it, and if you don't have source code, patching is the only way.
  14.  
  15.    To view extensive help on the ZPATCH commands, type:
  16.  
  17.    M - the Movement commands       E - the Edit command
  18.    S - the Search commands         U - the Utility commands
  19.                                    Y - the System commands
  20. :1
  21.  
  22.    Syntax:  ZPATCH     <-- not recommended.  You'll simply be prompted for
  23.                      a file name.
  24.  
  25.             ZPATCH UFN    <-- patch the specified file.  May use DU: or DIR:
  26. :M
  27.             COMMANDS FOR MOVING AROUND THE FILE 
  28.  
  29. < or . - Forward one sector
  30. > or , - Back one sector
  31.  
  32.    These are the main commands for  moving  around  the  file  one sector at a
  33. time.  Note that ZPATCH considers the file to be a ring and if you go past the
  34. end you come around to the beginning and vice versa.
  35.  
  36.  A - Goto Address 
  37.  
  38.    Jumps the display to  the  sector  containing  the address you input.  This
  39. address takes into  account  whatever  offset the program is working under. If 
  40. you enter the edit mode now, patching will begin at the address you specified.
  41.  
  42.  B - Bottom of File 
  43.  
  44.    Jumps the display to the last sector of the file.
  45.  
  46.  
  47.  # - Goto Record #
  48.  
  49.    Jumps the  display  to  the Record number you input.  Note that the current 
  50. record number and # of records  in  display  are  given  in  both  decimal and 
  51. hexadecimal notation at the top of the screen.
  52.  
  53.  T - Top of file 
  54.  
  55.    Jumps display to the beginning of the file.
  56. :S
  57.              SEARCH COMMANDS 
  58.  
  59.  S - Search 
  60.  
  61.    You are  prompted  to  input  a  string  that ZPATCH will search for.  This 
  62. string you input must adhere to rules of syntax explained below or ZPATCH will
  63. not accept it.
  64.  
  65.  
  66.  C - Continue search 
  67.  
  68.    Repeats again  the  last search command you issued.  All parameters entered 
  69. on the original search remain in effect except that the continue search always
  70. starts from  the current  position  even  if  the original search was from the 
  71. beginning.
  72.  
  73.  
  74.              SEARCH SYNTAX RULES 
  75.  
  76.    ASCII strings MUST be entered delimited with double quotes (") at beginning
  77.  and end.
  78.  
  79.    Note that  this  means that a double quote cannot be entered directly as an 
  80. ASCII character, but  must be entered by using its HEX value (22) as described 
  81. below.  Ascii strings are delimited  from  other elements of the search string 
  82. with commas.
  83.  
  84.    HEX bytes are delimited from each other and from ASCII strings with commas.
  85.  
  86. Enter Search String:   "ZPATCH"               
  87. Enter Search String:   5A,50,"AT",43,"H"      
  88. Enter Search String:   1,2F,36,FF,D0,3,38,0,4 
  89.  
  90.    The first  example searches for the same string as the second, illustrating
  91. the proper use of comma and double quote delimiters.
  92.  
  93.  
  94.              SEARCH OPTIONS 
  95.  
  96.    Certain features  of  the  search  may  be  selected  by  the use of option 
  97. characters which  are appended after the string.  Options  are  delimited from
  98. the rest of the string by  a semi-colon after the last character of the search 
  99. string.
  100.  
  101.    The following options are provided:
  102.  
  103.  A  - Start  search  from  beginning  of  file.   (Otherwise  starts  from
  104.       current position)
  105.  
  106.  B  - Search backward from the present position.
  107.  
  108.  7  - Search considering  only the  lowest 7 bits of each character.  This 
  109.       is handy for searching through files created with certain word
  110.       processors.
  111.  
  112.  M  -  Search  with certain bits masked off.  You will be asked for a byte 
  113.       mask value  which  you  can  input in HEX (default), BINARY, or DECIMAL.
  114.       For example to search for any   bytes  whose  high nibble is 0C hex, you
  115.       would select a value that  is  sensitive  to the high four bits (on) and
  116.       not the low four bits. That value is 11110000 binary or F0 hex.  The '7'
  117.       command is just an easier way of selecting  a mask of 01111111 binary or
  118.       7F hex.
  119.  
  120.  S  - Search skipping the first n occurrences of the selected string.  You
  121.      will be prompted for n which can be any number in the range 0-255.
  122.  
  123.  U  - Search without regard for case, that is upper case is considered the
  124.      same as lowercase for A-Z.
  125.  
  126.  Examples of option searches: 
  127.  
  128. "ZPATCH";u   ...matches ZPATCH, zpatch, Zpatch or zPaTch.
  129. "ZPATCH";ub  ...does the same as the above but searches backwards.
  130. "ZPATCH";ub7 ...as above but compares only the low 7 bits.
  131.  
  132.  Aborting a search 
  133.  
  134.    A search  can  be  aborted  simply  by typing control-C while the search is
  135. taking place.
  136.  
  137.  Quick search help 
  138.  
  139.    A quick  summary  of  search  syntax  is  available  by  typing <RETURN> in
  140. response to the "Enter search string (or ? for help)" prompt.
  141. :E
  142.              THE ZPATCH EDITOR 
  143.  
  144.  E - The edit command 
  145.  
  146.    From command mode the edit command puts you into the ZPATCH editor ready to 
  147. patch individual bytes.  You will  see  a  hexadecimal  dump display like this 
  148. one:
  149.  
  150.  ZPATCH 1.0  E2:ZPATCH.COM            Record # 00001 (0001H) of 00067 (0043H)
  151.  
  152.           00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F    0123456789ABCDEF
  153.           -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --    ----------------
  154. 00 0100 - C3 10 01 5A 33 45 4E 56 01 00 F3 FF 00 0F 00 00   <...Z3ENV........>
  155. 00 0110 - 2A 09 01 CD DE 19 CD D2 17 3A 5D 00 FE 2F 20 06   <*........:]../ .>
  156. 00 0120 - 21 5C 09 C3 AA 01 CD 0C 1E 22 B1 09 28 05 7B FE   <!\......."..(.>
  157. 00 0130 - 20 30 06 21 75 09 C3 AA 01 11 10 00 19 22 B3 09   < 0.!u........"..>
  158. 00 0140 - CD BC 1D 20 06 11 87 09 C3 AA 01 11 07 00 19 7E   <... ...........~>
  159. 00 0150 - FE 20 28 06 21 96 09 C3 AA 01 CD 27 09 CD 73 21   <. (.!......'..s!>
  160. 00 0160 - ED 43 A4 0B CD C6 1C 20 23 CD DC 15 2A B3 09 ED   <.C..... #...*...>
  161. 00 0170 - 5B 91 0B 01 0B 00 13 ED B0 11 8E 0B ED A0 ED A0   <[...............>
  162. |     |  \              this is the                    /    \  this is the   /
  163. address   \- - - - - HEXADECIMAL DISPLAY - - - - - - -/      \ASCII DISPLAY /
  164.  
  165.  
  166.    Dump displays look  the  same in EDIT and COMMAND modes but their different 
  167. onscreen menus distinguish them.  When  you  enter  the  EDIT mode your cursor 
  168. will be in the HEXADECIMAL DISPLAY on the byte you will be patching.  Normally
  169. this will be  the  first  byte  of  the  sector,  but  if you enter the editor 
  170. immediately after a successful search the  cursor will point to the first byte 
  171. of the matched string, and  after an A (Address) command the cursor will point 
  172. to the byte at the selected address.
  173.  
  174.    Notice the address display.  The first two digits will be greater than zero
  175. only if  the file length is greater than 64K (or if the offset is large enough 
  176. to make it  appear so.  For  any file shorter than 64K these two digits can be 
  177. ignored, and only the  last four considered.  These  four  digits are the ones 
  178. commonly used to refer  to CP/M and ZCPR3 patch points. ZPATCH prints  a space 
  179. between the first two digits and the last four to help make this a little less
  180. confusing.
  181.  
  182.              CURSOR MOVEMENT 
  183.  
  184.    From EITHER SIDE of the  display  you can move from byte to byte within the
  185. sector using the Wordstar cursor diamond commands
  186.  
  187.         ^E-Up
  188.     ^S-Left         ^D-Right
  189.         ^X-Down
  190.  
  191.    This is same display  is  shown  on the edit mode menu.  If your arrow keys 
  192. are enabled within your ZCPR3 TCAP, these will also perform the same functions
  193. unless they duplicate one of the other Edit Mode command keys described below.
  194.  
  195.    Please note that  ZPATCH treats the display as a ring and moving the cursor 
  196. beyond its limits simply wraps around to the other side.
  197.  
  198.  
  199.              EDIT MODE COMMAND KEYS 
  200.  
  201.    Three commands  control  the  basic  functions of the Edit Mode on both the
  202. hexadecimal side and the ASCII side of the the display.
  203.  
  204.  ^Q  - Quit edit mode without writing  sector  back to disk.  (Please note 
  205.        that the display you see  after this command WILL reflect the edits you 
  206.        have made but they WILL NOT  be  written  to disk unless you type the W 
  207.        command from command mode.  If you move  to  another  sector  the edits 
  208.        will be lost.  The W command  in command mode is a "last chance" option 
  209.        to recover from inadvertently quitting the edit mode.)  A "Not Written"
  210.        message will appear  at  the  bottom  of the screen to let you see that 
  211.        this is the case.
  212.  
  213.  ^W  - Write sector  to  disk  (automatically reverts to command mode).  A
  214.        "Written" message will appear  at  the bottom of the screen letting you 
  215.        know what has happened.
  216.  
  217.  <ESCAPE>  - Switches back and forth between the HEXADECIMAL and ASCII
  218.        displays.  This is the ONLY way to switch between displays.  The cursor
  219.        keys will not do it.
  220.  
  221.  
  222.              EDITING IN THE HEXADECIMAL DISPLAY 
  223.  
  224.    When  in the hexadecimal display,  besides the cursor and command keys 0-9, 
  225. and the hexadecimal letter characters  A-F (upper or lower case).  When one of 
  226. these is pressed the  hexadecimal  display  is  changed to the new hexadecimal 
  227. value and, since this changes the  ASCII  value as well, that is also changed.
  228. Note that ANY byte value  can be entered from the hexadecimal side, even those 
  229. that are not valid ASCII characters.
  230.  
  231.              EDITING IN THE ASCII DISPLAY 
  232.  
  233.    When in  the  ASCII  display  all  keys except control keys will change the
  234. ASCII display, and also update the hexadecimal display with the correct value.
  235. The ASCII display is much easier  to  work in when typing in character strings 
  236. and words.  On the other  hand  not  all  byte  values can be entered from the 
  237. keyboard, and if you need to  enter  a untypable value you MUST do it from the 
  238. hexadecimal side.
  239. :U
  240.              UTILITY COMMANDS 
  241.  
  242.  O  - Enter Offset
  243.  
  244.    ZPATCH automatically selects a  logical offset for the type of file you are 
  245. working with.  .COM files are offset  at  0100H which is the normal address at 
  246. which  they  are  loaded  into  memory.   Z3 system segments are offset to the 
  247. address at which they  are loaded by the Z3 LDR command.  Others are offset to 
  248. 0.  You may change any of these with the O command as often as you like.
  249.  
  250.  P  - Print Sector
  251.  
  252.    Puts the same hex dump display you see on screen to the printer.
  253.  
  254.  W  - Write sector
  255.  
  256.    Although  this  will usually be done from the edit mode, you can also do it 
  257. from the command mode.  This will be useful if you accidentally leave the edit
  258. mode without writing  your  changes to the disk.  After you exit the edit mode 
  259. the message  line  contains  a  message,  either  "Written"  or  "Not Written"
  260. letting you know.
  261. :Y
  262.              SYSTEM COMMANDS 
  263.  
  264.  
  265.    These commands are  available  at all times, and give access to the special 
  266. features of the ZCPR3 system.  They  are  the  ONLY  commands available when a 
  267. file has not been successfully opened for patching.
  268.  
  269.  F  - Give File Name
  270.  
  271.    Enter  a new file name for patching.   The old file is closed and a new one 
  272. opened.
  273.  
  274.  X  - eXit 
  275.  
  276.    Exit the ZPATCH shell.  For your convenience Control-Q also works here.
  277.  
  278.  R  - Run (execute) .COM file 
  279.  
  280.    If the file you are patching is  a .COM file you may execute it from ZPATCH 
  281. with the X command.  Upon finishing  that  program  you  will  be  returned to 
  282. ZPATCH.  Please note, however, that  if  the program you are patching requires 
  283. command line parameters you should use the Z command instead.
  284.  
  285.  Z  - ZCPR3 command 
  286.  
  287.    You are  shown  a  prompt  similar  to the ZCPR3 system prompt and you give
  288. ZPATCH a standard ZCPR3 command line, which your system then executes and upon
  289. completion of the command you  are  returned to ZPATCH still patching the same 
  290. file in the same position.  There is one extended parameter option you have in
  291. this command line:
  292.  
  293.    A $  character as the FIRST character in the command line is interpreted by 
  294. ZPATCH as the  name of the current command.  Thus if you are patching the file 
  295. LZED.COM and want to supply a a file to edit with LZED in the command tail you
  296. can issue the command as LZED TEXT.FIL or simply $ TEXT.FIL.  Please note that
  297. a space must follow the opening $.
  298.  
  299.  H  - Help
  300.  
  301.    Chain to  this  help file.  HELP.COM must be available somewhere along your 
  302. ZCPR3 search path and  ZPATCH. HLP  must be located where HELP.COM can find it 
  303. (either along the path or in a directory named HELP:)
  304.  
  305.    NOTE:  This feature will  only be enabled if the patch byte at 010FH is set 
  306. to 0FFH.  If you are running  a system  without HELP.COM easily accessible you 
  307. will probably be better off doing without it.
  308. :2
  309.  
  310. Installing ZPATCH:
  311.  
  312.    Under ZCPR3.0, ZPATCH is installed using Z3INS as follows:
  313.  
  314.         Z3INS xxx.ENV ZPATCH.COM
  315.  
  316. where xxx is the name of your Environment descriptor, usually SYS.ENV
  317.  
  318.  
  319. ZPATCH PATCH LOCATIONS
  320.  
  321.    These patch  locations  in  the  first  sector of ZPATCH.COM control ZPATCH 
  322. shell functioning.  It's probably  best  to put ZPATCH in the ROOT:  Directory 
  323. and set 010B to 0FFH, but you may prefer another configuration.
  324.  
  325. Location      Default Value    Comments
  326.  
  327. 010BH        0FFH        ; 0FFH if zpatch.com will be located in
  328.                 ; root directory, 0=NO
  329.  
  330. 010CH        0        ; if 010BH is 0, should system search
  331.                 ; the path for zpatch.com? 0=NO 0FFH=YES
  332.  
  333. 010DH        15        ; if 010BH and 010CH are both 0
  334.                  ; make this the user area where
  335.                 ; ZPATCH.COM is to be located
  336. 010EH        0        ; and this the drive (A:=0, B:=1)
  337.  
  338. 010FH        0        ; make 0FFH to allow chaining to this
  339.                 ; help file, leave at 0 to disable feature
  340.  
  341.  
  342. You can easily use ZPATCH to patch ITSELF!
  343.  
  344.    However, one  word of caution.   Since ZPATCH is a shell, do not expect the
  345. patches you have made  to take effect  immediately.  Rather, make the patches, 
  346. quit ZPATCH, then run  it again and  the patches will be in effect.  Actually, 
  347. you COULD see the effects  by EXECUTING ZPATCH with  the  'X' or 'Z' commands, 
  348. but  it  would  be  very  confusing,  as  upon  exiting,  you would reenter an 
  349. unpatched level of ZPATCH.
  350. :3
  351. ZPATCH Notes:
  352.  
  353.    a. ZPATCH  is much easier to use than a debugger because it requires you to
  354.       learn no  unusual syntax,  and because there is no need to calculate the 
  355.       number of 256-byte  "pages" to  be  saved after the patch has been made.
  356.       ZPATCH is also easier than  a disk  editor because  it is not "track and
  357.       sector" oriented and permits paging sequentially through a file.
  358.  
  359.    b. ZPATCH is  a ZCPR3  shell, and  as  such allows you to suspend execution
  360.       of ZPATCH, give  any  valid  system  command line, and then be put right 
  361.       back where you left off.   This can even be done with a single keystroke 
  362.       if the  file  you  are  patching is  a  .COM file.  This enables  you to 
  363.       interactively patch and  see  the  results  of  your  patches  until the 
  364.       program works  as you desire (if the patch doesn't hang your system).
  365.  
  366.    c. ZPATCH allows you  to  print  out each sector displayed.  You can change 
  367.       files on the  fly without leaving ZPATCH.  You can search for particular
  368.       bytes or  byte patterns, or  ASCII strings,  with  options  to disregard 
  369.       case, compare  on 7  bits only, or  in fact, on any combination of bits.
  370.       ZPATCH allows you to  set the OFFSET  or apparent address at which bytes
  371.       appear.  The offset is automatically set for certain types of files.
  372.  
  373.  
  374. ZPATCH Notes (continued):
  375.  
  376.    d. Vs 1.3  is  a  ZCPR33  type-3 utility  that  can  be linked to origin at
  377.       addresses other than  100h.   It  automatically  sets  the  offset  when 
  378.       working on Z33 type-3 .COM files to their correct load address.
  379.  
  380.                          Note on Numeric Input 
  381.  
  382.       Many commands described  below  cause prompts  to be issued that require
  383.       you to input a number.  ZPATCH can read  inputs in Decimal, Hexadecimal,
  384.       or Binary notation.  Each  prompt  displays  the  default  notation that
  385.       ZPATCH is expecting like this:
  386.  
  387.         Enter OFFSET (HEX):
  388.  
  389.       This tells you that if you  simply  enter  the number without a trailing
  390.       indicator  it  will  be  interpreted  as  a HEX number.  So in the above 
  391.       example if you wanted to enter the Hexadecimal number 200H (which equals
  392.       512 decimal or 1000000000 binary) you would enter either
  393.  
  394.                 200        (hex - default),
  395.                 512#        (decimal) or
  396.                 1000000000%    (binary).
  397.  
  398.       If HEX  is not  the  default and  you  wish to enter Hex then follow the 
  399.       number with an "H" as in 200H or F200H.
  400.  
  401.  
  402.                            Numeric Input (continued):
  403.  
  404.       In other words "#" is the indicator  for decimal, "%" for binary and "H"
  405.       for hex.  If this confuses you just answer the prompts with the  default
  406.       notation which  is  the  most  logical  most of the time.  Addresses and
  407.       byte values are most easily given in HEX.   Number of  times to repeat a
  408.       search is easier for most people in DECIMAL and that's the way ZPATCH 
  409.       does it.
  410.  
  411.       Please note that  none  of the above discussion applies to the EDIT mode 
  412.       of ZPATCH which  is explained elsewhere.   All numbers there are assumed 
  413.       to be HEX.
  414.  
  415.       The maximum number that can  be  entered  is  0FFFFFF  hex or 16,777,215 
  416.       decimal.  Entering anything larger wraps around to 0.
  417. :4
  418.  
  419.                               ZPATCH.HLP
  420.  
  421.              Size (recs) CRC   Version    Author/Latest Issue      Disk      
  422.               20k (149)  C492  1.0        Steven Cohen 3/87        Z3HLP3
  423. ==============================================================================
  424.  
  425.    Z-System Help file for ZPATCH.COM.
  426. :5
  427.                             ZPATCH Error Messages: 
  428.  
  429.  Shell stack error 
  430.    Your system must  have  a shell  stack and it must support at least 32-byte 
  431. shell stack entries or  you will get  this error.  Most  ZCPR3 implementations 
  432. support these features, but if yours doesn't  you won't be able to use ZPATCH.
  433.    You can  also  see  this  message  if  your shell stack is full with shells 
  434. beneath it when you invoke ZPATCH.   Removing some  of these other shells will 
  435. allow you to run ZPATCH.
  436.  
  437.  Ext. FCB Error 
  438.    It is assumed your system supports the External File Control Block feature.
  439. Most ZCPR3 systems do, but if yours doesn't you won't be able to run ZPATCH.
  440.  
  441.  Why did you rename ZPATCH? 
  442.    ZPATCH is  a  perfectly wonderful name.  Why change it?  Seriously, you may 
  443. do so, but if you attempt to rename it longer than six characters ZPATCH won't
  444. run.
  445.