Path: utzoo!utgpu!attcan!uunet!husc6!rutgers!apple!lsr From: lsr@Apple.COM (Larry Rosenstein) Newsgroups: comp.sys.mac.programmer Subject: Re: Multifinder: how do I patch GetNextEvent? Message-ID: <18914@apple.Apple.COM> Date: 17 Oct 88 16:04:56 GMT References: <747@ttrdf.UUCP> <10050025@eecs.nwu.edu> <2456@spray.CalComp.COM> <7374@well.UUCP> <5654@hoptoad.uucp> Organization: Advanced Technology Group, Apple Computer Lines: 38 In article <5654@hoptoad.uucp> tim@hoptoad.UUCP (Tim Maroney) writes: > >Let's look at a case. Say that GetNamedResource checks the return address >to see if it's being called from a ROM Font Manager routine, and that routine >has a tail patch for some reason. When the "old" software for the Font The problem occurs when there is a tail-patch of GetNamedResource (for example, in an INIT). The system patches are installed at boot time, while the INIT patches are installed afterwards. So now the Font Manager calls GetNamedResource which calls the INIT code. The INIT code calls the original GetNamedResource via a JSR, which leaves the return address in the INIT code. This means that the system patch does not recognize the return address, and the "bug" in the Font Manager is not fixed. This assumes that the INIT patch code exits by doing an RTS and returning the result gotten by the JSR to the old GetNamedResource. Under this circumstance, the bug fix code would not be executed. If it exits by calling the old GetNamedResource again (with the original parameters), then everything should be fine. The internal JSR simply becomes another call to GetNamedResource. (I don't write system patches, however, so there may be something else I haven't thought of that makes this idea wrong.) Patching the ROM in a "safe" way requires some ingenuity. Often ones first idea of how to do it makes some incorrect assumption, or requires a tail patch. The trick is to look at the problem from a different point of view, in order to come up with a solution that works. Larry Rosenstein, Object Specialist Apple Computer, Inc. 20525 Mariani Ave, MS 46-B Cupertino, CA 95014 AppleLink:Rosenstein1 domain:lsr@Apple.COM UUCP:{sun,voder,nsc,decwrl}!apple!lsr