***************************** DontForceQuit *****************************
INCLUDE 'traps.a'
INCLUDE 'SysEqu.a'
INCLUDE 'SysErr.a'
kSysError EQU $A9C9
PatchIt PROC EXPORT ;Apps invoke this by calling PATCHIT() in C;
IMPORT MySysError ;Trap patch code
IMPORT OldSysError ;Pointer to original Trap Code
; This trap patcher leaves the patch in the app heap
; it will be unpatched when the app quits. For a persistent
; patch, the patch must be installed at INIT time in the system heap
lea OldSysError,a1 ;get the address of the pointer saver
move.w #kSysError,d0 ;now get address of SysError routine
_GetTrapAddress ,NEWTOOL
move.l a0,(a1) ;save it for later
move.w #kSysError,d0 ;set up trap num
lea MySysError,a0 ;set up new trap address
_SetTrapAddress ,NEWTOOL ;install the patch
rts ;exit
ENDP
MySysError PROC EXPORT
IMPORT OldSysError
cmpi.w #20002,d0 ;first, check for the right selector
bne.s PassItOn ;if not ours, let the real SysError have it
rts ;if selector matches, return to sender
PassItOn
move.l OldSysError,-(sp) ;leave all registers unmolested
rts
ENDP
OldSysError PROC EXPORT
DC.L 0
ENDP
END
|