home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / sys / mac / programm / 20225 < prev    next >
Encoding:
Internet Message Format  |  1992-12-22  |  2.7 KB

  1. 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
  2. From: absurd@apple.apple.com (Tim Dierks, software saboteur)
  3. Newsgroups: comp.sys.mac.programmer
  4. Subject: Re: Problem with patch to HFSDispatch
  5. Message-ID: <absurd-221292190600@seuss.apple.com>
  6. Date: 23 Dec 92 03:10:35 GMT
  7. References: <1992Dec22.182710.26751@panix.com>
  8. Sender: news@gallant.apple.com
  9. Followup-To: comp.sys.mac.programmer
  10. Organization: MacDTS Marauders
  11. Lines: 59
  12.  
  13. In article <1992Dec22.182710.26751@panix.com>, rmah@panix.com (Robert Mah)
  14. wrote:
  15. > In an extension that works fine on most systems, but some people seem to 
  16. > be getting freezes when they shut down/restart their machine.  I'm not 
  17. > sure, but I think it might be related to my patching HFSDispatch.
  18. > I'm using register a1 to hold the adress of the real trap -- is there
  19. > something wrong with this?  Anyone care to comment?
  20. > Some code...
  21. > /* 
  22. >  *  We need to trap whenever the user moves a directory (selector 5).
  23. >  */
  24. > pascal void FSDispatchPatch()
  25. > {
  26. >     asm{
  27. >         movem.l  a4, -(sp)                 ; save registers
  28. >         lea      main, a4                  ; setup globals
  29. >         cmp.w    #5, d0                    ; if not CatMove
  30. >         bne.s    @1 
  31. >         move.w   #1, gNeedsUpdate          ; set the gNeedsUpdate flag
  32. > @1      move.l   realHFSDispatchTrap, a1   ; grab the addr of the real thing
  33. >         movem.l  (sp)+, a4                 ; restore registers
  34. >         jmp      (a1)                      ; jump to real HFSDispatch
  35. >     }
  36. > }
  37.  
  38. Your problem is that you're destroying A1; it's used as a parameter by
  39. some HFSDispatch selectors.
  40.  
  41. While you could do this by trashing a different register, which isn't
  42. used, you could always use the slightly more complex but somewhat more
  43. clever method.
  44.  
  45.           clr.l    -(sp)                     ; save room for forwarding
  46. address   
  47. >         movem.l  a4, -(sp)                 ; save registers
  48. >         lea      main, a4                  ; setup globals
  49. >         cmp.w    #5, d0                    ; if not CatMove
  50. >         bne.s    @1 
  51. >         move.w   #1, gNeedsUpdate          ; set the gNeedsUpdate flag
  52.   @1      move.l   realHFSDispatchTrap,4(a7) ; store forwarding address on
  53. stack
  54. >         movem.l  (sp)+, a4                 ; restore registers
  55.           rts                                ; jump to real HFSDispatch
  56.  
  57. Note that this preserves all the registers by using the trick of using
  58. an RTS to pop the jump address off of the stack, allowing you to restore
  59. all your registers first.
  60.  
  61. (Well, I always thought it was neat, anyway.)
  62.  
  63. Have a great holiday, one and all- I'm off to home till Jan 6; I'll
  64. be gone (netwise) till then.
  65.  
  66. Tim Dierks
  67. MacDTS pinball addict
  68.