home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / jsage / znode3 / uploads / zpatch13.lbr / ZPATCH.HZP / ZPATCH.HLP
Encoding:
Text File  |  1993-06-07  |  18.3 KB  |  481 lines

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