Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!wuarchive!cs.utexas.edu!usc!apple!tecot From: tecot@Apple.COM (Ed Tecot) Newsgroups: comp.sys.mac.programmer Subject: Re: converting tail patches to head patches... Message-ID: <36872@apple.Apple.COM> Date: 30 Nov 89 03:44:01 GMT References: <63359@tiger.oxy.edu> <5437@internal.Apple.COM> Distribution: usa Organization: Apple Computer Inc, Cupertino, CA Lines: 31 In article <5437@internal.Apple.COM> chewy@apple.com (Paul Snively) writes: >Now for the good news: if you're trying to patch _SystemTask, you can >probably get away with it, because I don't believe that _SystemTask is >called from within the ROM, which means that it won't be patched by us >with this nasty come-from code that's causing all of the headaches. As >Larry Rosenstein pointed out, you have a higher probability of being >"patch safe" with traps that have a high probability of not being called >from ROM. Actually, Paul is wrong. SystemTask is called from ROM, in particular, by ModalDialog and WaitNextEvent. It's possible that it is called in other places as well. However, it is called in relatively few places (compared to NewHandle or GetResource), and is therefore safer to tail patch. Note, that it is not 100% safe, and in this case, it's relatively easy to convert the tail patch to a head patch, since SystemTask doesn't return anything. Use MySystemTask (your patch goes here) JMP OldSystemTask instead of MySystemTask JSR OldSystemTask (patch code here) RTS and your code is 2 bytes shorter and 24 cycles faster as well. _emt