Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!thunder.mcrcim.mcgill.edu!snorkelwacker.mit.edu!apple!agate!dog.ee.lbl.gov!ux5.lbl.gov!beard From: beard@ux5.lbl.gov (Patrick C Beard) Newsgroups: comp.sys.mac.programmer Subject: Re: Problem with GetNextEvent trap patch in MultiFinder Message-ID: <9093@dog.ee.lbl.gov> Date: 17 Jan 91 03:39:07 GMT References: <1991Jan15.200340.28431@bronze.ucs.indiana.edu> Reply-To: beard@ux5.lbl.gov (Patrick C Beard) Organization: Berkeley Systems, Inc. Lines: 43 X-Local-Date: Wed, 16 Jan 91 19:39:07 PST In article <1991Jan15.200340.28431@bronze.ucs.indiana.edu> cmcclary@bronze.ucs.indiana.edu (Charles McClary) writes: #I am trying to patch the GetNextEvent trap A970. My test patch #seems to work correctly in Finder, but not in MultiFinder. In #MultiFinder, when a desktop icon (disk icon) is covered up by a #volume or folder window and the window is then moved to uncover #the icon, the portion of the desktop icon which was covered remains #invisible. This does not happen in finder. Below is the source code #for the patch. I am using Think C 4.0. What an I leaving out? You, sir, are tail-patching GetNextEvent, which is most certainly a no-no. (I know, I've attempted it before, and had EXACTLY this behaviour.) #pascal Boolean NewGetNextEvent(eventMask, theEvent) #inteventMask; #EventRecord* theEvent; #{ #SetUpA4(); # #CallPascalB(eventMask, theEvent, oldGetNextEvent); essentially: asm { move.l oldGetNextEvent, a0 move.w eventMask,-(sp) pea theEvent jsr (a0) } # #RestoreA4(); #} The only way to patch GetNextEvent safely, that I've found, is to use a head patch, which basically means, do your patch behaviour, then jump directly to the old address. This part obviously has to be done in assembly language. Exercise for the reader. -- ------------------------------------------------------------------------------- - Patrick Beard, Macintosh Programmer (beard@lbl.gov) - - Berkeley Systems, Inc. "..............Good day!" - Paul Harvey - -------------------------------------------------------------------------------