Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!spool2.mu.edu!sdd.hp.com!usc!jarthur!nntp-server.caltech.edu!toddpw From: toddpw@nntp-server.caltech.edu (Todd P. Whitesel) Newsgroups: comp.sys.apple2 Subject: Re: patching toolbox calls Message-ID: <1991Jan18.231501.7352@nntp-server.caltech.edu> Date: 18 Jan 91 23:15:01 GMT References: <2039@kluge.fiu.edu> Organization: California Institute of Technology, Pasadena Lines: 26 acmfiu@serss0.fiu.edu (ACMFIU) writes: >How would I patch out the text toolking _WriteChar and, when that call gets >made, have it call my own routine (this is a general question and could apply >to ALL toolbox calls, i just picked an easy one). There are two ways to do it. You'll need toolbox ref volume 2, maybe ref 3. 1. patch out the tool locator vectors at e1/0 and e1/4 to jump to your routine; your routine should check X to see if your calls are being made and if not it should pass control to the old vector. toolbox ref volume 2 and the firmware ref tell you all you need to know about this (especially the difference between e1/0 and e1/4 which is not that big a deal). This technique is not recommended by me any more, because system 5.0.x provides a new tool call to allow direct patches to the tool system itself. 2. patch out the specific functions you want, using GetTSPtr to get the function pointer table (the format is explained in Appendix A of toolbox ref 2) and SetDefaultTPT (this is documented in toolbox ref 3 but I can type it in if you want) to notify the system that the current tool state should be preserved. I haven't got confirmed reports of a SetDefaultTPT implementation yet. Writing a PatchTool library function and distributing it is on my list of things to do. Todd Whitesel toddpw @ tybalt.caltech.edu