home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!usc!sdd.hp.com!think.com!yale.edu!spool.mu.edu!olivea!apple!goofy!mumbo.apple.com!gallant.apple.com!seuss.apple.com!user
- From: absurd@apple.apple.com (Tim Dierks, software saboteur)
- Newsgroups: comp.sys.mac.programmer
- Subject: Re: Problem with patch to HFSDispatch
- Message-ID: <absurd-221292190600@seuss.apple.com>
- Date: 23 Dec 92 03:10:35 GMT
- References: <1992Dec22.182710.26751@panix.com>
- Sender: news@gallant.apple.com
- Followup-To: comp.sys.mac.programmer
- Organization: MacDTS Marauders
- Lines: 59
-
- In article <1992Dec22.182710.26751@panix.com>, rmah@panix.com (Robert Mah)
- wrote:
- >
- > In an extension that works fine on most systems, but some people seem to
- > be getting freezes when they shut down/restart their machine. I'm not
- > sure, but I think it might be related to my patching HFSDispatch.
- >
- > I'm using register a1 to hold the adress of the real trap -- is there
- > something wrong with this? Anyone care to comment?
- >
- > Some code...
- >
- > /*
- > * We need to trap whenever the user moves a directory (selector 5).
- > */
- > pascal void FSDispatchPatch()
- > {
- > asm{
- > movem.l a4, -(sp) ; save registers
- > lea main, a4 ; setup globals
- > cmp.w #5, d0 ; if not CatMove
- > bne.s @1
- > move.w #1, gNeedsUpdate ; set the gNeedsUpdate flag
- > @1 move.l realHFSDispatchTrap, a1 ; grab the addr of the real thing
- > movem.l (sp)+, a4 ; restore registers
- > jmp (a1) ; jump to real HFSDispatch
- > }
- > }
-
- Your problem is that you're destroying A1; it's used as a parameter by
- some HFSDispatch selectors.
-
- While you could do this by trashing a different register, which isn't
- used, you could always use the slightly more complex but somewhat more
- clever method.
-
- clr.l -(sp) ; save room for forwarding
- address
- > movem.l a4, -(sp) ; save registers
- > lea main, a4 ; setup globals
- > cmp.w #5, d0 ; if not CatMove
- > bne.s @1
- > move.w #1, gNeedsUpdate ; set the gNeedsUpdate flag
- @1 move.l realHFSDispatchTrap,4(a7) ; store forwarding address on
- stack
- > movem.l (sp)+, a4 ; restore registers
- rts ; jump to real HFSDispatch
-
- Note that this preserves all the registers by using the trick of using
- an RTS to pop the jump address off of the stack, allowing you to restore
- all your registers first.
-
- (Well, I always thought it was neat, anyway.)
-
- Have a great holiday, one and all- I'm off to home till Jan 6; I'll
- be gone (netwise) till then.
-
- Tim Dierks
- MacDTS pinball addict
-