Technical Note OS525
System Error Handler Q&As

CONTENTS

This Technical Note contains a collection of archived Q&As relating to a specific topic - questions sent the Developer Support Center (DSC) along with answers from the DSC engineers. Current Q&As can be found on the Macintosh Technical Q&As web site.

Dec 01 1992






Disabling Macintosh force quit option

Date written: 9/15/92

Last reviewed: 6/14/93

Is there a way to disable the force quit option from System 7?

The force quit is handled by calling SysErr with an error code (or selector) of 20002 (Ox4E22). The error code is passed in register D0. A simple patch to this trap, and a check for that selector will allow you to abort its function:

***************************** 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

Back to top

Downloadables

Acrobat gif

Acrobat version of this Note (40K).

Download



Developer Documentation | Technical Q&As | Development Kits | Sample Code