Path: utzoo!attcan!uunet!lll-winken!lll-lcc!ames!pasteur!ucbvax!hoptoad!tim From: tim@hoptoad.uucp (Tim Maroney) Newsgroups: comp.sys.mac.programmer Subject: Re: Patching Trap Calling under Multifinder Keywords: patch trap multifinder Message-ID: <4778@hoptoad.uucp> Date: 28 Jun 88 06:00:07 GMT References: <1988Jun22.111251.394@mntgfx.mentor.com> Reply-To: tim@hoptoad.UUCP (Tim Maroney) Organization: Eclectic Software, San Francisco Lines: 41 In article <1988Jun22.111251.394@mntgfx.mentor.com> tomc@mntgfx.mentor.com (Tom Carstensen) writes: >Here's a repost of my original posting: >> What I'm trying to do is patch _DrawMenuBar, to >> call a routine that simply sets a global flag, and then >> calls the actual _DrawMenuBar. > >> This works great NOT using Multifinder, but BOOM/Crash >> under Multifinder. > >> I tried restoring/installing the patch on suspend/resume >> events, but it still crashed. > >> What can and can't I do?? What you can't do is patch traps and assume that A5 is the same inside the patch. This is explicitly stated in one of the technical notes (I don't remember the number, but I believe the title was "Don't Use Register A5 Inside Trap Patches", originally enough.) If you want access to your A5, you will have to manage it yourself, and be sure to set it back to what the system passed you when you return. My guess is that A5 is switched into MultiFinder global space when DrawMenuBar is called - your global reference is writing into a MultiFinder global, the task scheduler gets a wee bit confused, and that's all she wrote. This is only a guess, so don't hold me to it, but it would account for what you saw if it's a correct guess. As the aforementioned technical note also says, don't patch traps if you can help it, and I have to say that this seems like an odd use of trap patching. All you're going to catch is DrawMenuBar calls issued by your own application, so why not set the global flag when you call DrawMenuBar? Maybe you left out the one part that would make this irridesce with the lustre of practicality for me - as presented, it seems like an example of "tricks to avoid". -- Tim Maroney, Consultant, Eclectic Software, sun!hoptoad!tim "Strong men tremble when they hear it. They've got cause enough to fear it; It's even blacker than they smear it! No one mentions -- my name." - Bill Sykes, "Oliver"