Path: utzoo!utgpu!attcan!uunet!microsoft!johnte From: johnte@microsoft.UUCP (John Terranova) Newsgroups: comp.sys.mac.programmer Subject: Re: Tail patches Message-ID: <8627@microsoft.UUCP> Date: 6 Nov 89 18:02:54 GMT References: <1459@sequent.cs.qmc.ac.uk> Reply-To: johnte@microsoft.UUCP (John Terranova) Organization: Microsoft Corp., Redmond WA Lines: 57 In article <1459@sequent.cs.qmc.ac.uk> jeremyr@cs.qmc.ac.uk (Jeremy Roussak) writes: > >I hope the net will pardon my ignorance, but I have seen a few comments >recently about "tail patching" of traps and have a couple of questions: > >1. What exactly are "tail patches"? A patch is a lump of code that you want to execute instead of/in addition to normal system/ROM code. You make the system jump table point to your code and you remember the previous contents so that you can replace it later, if needed. A tail patch is a patch whose first action (or, atleast, an early action) is to call the original code, then process some data based on the original results. A very good example of a tail patch was in MacTutor some months ago (I have no idea which issue). That tail patch patched GetNextEvent and modified events such that any key event with both the shift and caps lock key down would generate a lower case letter. As is done on PCs. I will leave it to the reader to decide if one would actually want the Mac to emulate the PC in this regard. >2. If they are what I suspect they are, why are they bad? I don't know what you suspect they are, but they are bad for a fairly simple reason. Apple patches the ROM. Apple patches much of the ROM. Apple patches so much of the ROM that sometimes I think it would be easier to just issue a replacement ROM (at a nominal charge, of course :-). If Apple were to replace entire routines which need a small patch, then the system would grow that much more. Instead, they pull off some tricks to replace only pieces of routines. I'm not exactly clear why, but this requires some routines to need to check who called them to determine what to do. This code needs to know if the ROM called them or an app did. It determines this by checking the return address on the stack. If you tail patch then the routine is never called from ROM (it's called from the heap). Some ROM code then becomes confused, which is a bad thing. I hope this helps. I hope this makes sense. I heard this explanation once some time ago. Probably about the time of that MacTutor article. BTW: a recent MacTutor article says that Apple won't outlaw tail patches and they beat the alternative (lots of grungy assembly code). Don't mind that article. Tail patches are evil. They already break the system. Avoid them. >Thank you for your help! Your Welcome. >Jeremy Roussak -----------------------+----------------------------+------------------------- John Terranova | What the Hell do I know? | I speak/type for me johnte@microsoft.uucp | I come from Waunakee! | and no one else. -----------------------+----------------------------+------------------------- "You look so good; you feel good, too. When they see you shake it, baby everybody's gonna pay attention to you and you and you." --Gerard, Shake It