acmfiu@serss0.fiu.edu (ACMFIU) (01/19/91)
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). albert chin
toddpw@nntp-server.caltech.edu (Todd P. Whitesel) (01/19/91)
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
dlyons@Apple.COM (David A. Lyons) (01/28/91)
In article <1991Jan18.231501.7352@nntp-server.caltech.edu> toddpw@nntp-server.caltech.edu (Todd P. Whitesel) writes: >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. Note that SetDefaultTPT is officially for use by the system. If you're going to call it yourself, at least do it at "init" time, not in the middle of an application! One effect it has is to make the currently-loaded RAM tools *stay* loaded, even when an application is no longer using them. Also, be careful not to assume that a particular function pointer table is already in RAM. GetTSPtr returns a pointer to an FPT, but that table may be in ROM or RAM! If it's not already in RAM, call SetTSPtr with a FPT of the appropriate size, with zeroes for all functions you don't want to patch. -- David A. Lyons, Apple Computer, Inc. | DAL Systems Apple II System Software Engineer | P.O. Box 875 America Online: Dave Lyons | Cupertino, CA 95015-0875 GEnie: D.LYONS2 or DAVE.LYONS CompuServe: 72177,3233 Internet/BITNET: dlyons@apple.com UUCP: ...!ames!apple!dlyons My opinions are my own, not Apple's.
ericmcg@pnet91.cts.com (Eric Mcgillicuddy) (02/09/91)
I use GetTSptr and save the value and then call SetTSptr to add in my routines. If the initialization fails for some reason (I have a half dozen or so Memory Manager calls to patch) then it just restores the old ptr and ends. Aside from NoewHandle, I just have to do some stuff to update my data and then JML to the existing routines. I use GetFuncPtr prior to switching TS pointers and use self modifying (to avoid eating bank $0 memory which is verboten to an INIT) code. NewHandle is special because I need to do stuff after the call is completed. Basically I clone the parameters and reissue the call with a JSL <NewHandle>. I then extract the returned value, do my stuff and return the value expected. Works fine. CheckHandle also works fine despite the fact I make a couple of additional MM toolcalls (RestoreHandle mainly) before passing on control. (also has to restore old PurgeLevel, which I may have altered previosly) ViM also includes a new toolcall, DeRefHandle, which Checks, Lockas and returns a pointer to the memory whose Handle was given. $3002 when installed. UUCP: bkj386!pnet91!ericmcg INET: ericmcg@pnet91.cts.com