Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!hoptoad!tim From: tim@hoptoad.uucp (Tim Maroney) Newsgroups: comp.sys.mac.programmer Subject: Re: How to do a LEGAL tail-patch Message-ID: <6541@hoptoad.uucp> Date: 15 Feb 89 23:17:18 GMT References: <1272@ccnysci.UUCP> Reply-To: tim@hoptoad.UUCP (Tim Maroney) Organization: Eclectic Software, San Francisco Lines: 25 In article <1272@ccnysci.UUCP> alexis@ccnysci.UUCP (Alexis Rosen) writes: > >I've been thinking about this for a couple of days now. Here's my scheme. >Does anyone see any flaws? > >Procedure MyPatch >SetTrapAddress to original trap address >Trap to original trap using A-line instruction >SetTrapAddress back to @MyPatch (&MyPatch for C people) >Fixup stack and return Nope, doesn't work. Imagine that GetResource checks to see if it's being called from GetFontInfo by looking at the return address. The reason you have to avoid tail patching is because if you just call the old GetResource from inside your patch of GetResource, the return address is inside your patch instead of inside GetFontInfo. Your approach has exactly the same problem. When your patch code calls the trap, the return address is inside your code, not inside GetFontInfo, the real caller. -- Tim Maroney, Consultant, Eclectic Software, sun!hoptoad!tim "Its failings notwithstanding, there is much to be said in favor of journalism in that by giving us the opinion of the uneducated, it keeps us in touch with the ignorance of the community." -- Oscar Wilde