19.4.4 Monitoring the Critical Error Flag

DOS sets the Critical Error flag to a nonzero value when it detects a critical error. It then invokes Interrupt 24h (Critical Error Handler) and clears the flag when Interrupt 24h returns. DOS functions higher than 0Ch are illegal during critical error processing. Therefore, a TSR that calls DOS must not execute while the Critical Error flag is set.

DOS versions 3.1 and later locate the Critical Error flag in the byte preceding the InDos flag. A single call to Function 34h (Get Address of InDos Flag) thus effectively returns the addresses of both flags. For earlier versions of DOS or for the compatibility version of DOS in OS/2, a TSR must call Function 34h and then scan the segment returned in the ES register for one of the two following sequences of instructions:

; Sequence of instructions in DOS Versions 2.0 - 3.0

cmp ss:[CriticalErrorFlag], 0

jne @F

int 28h

; Sequence of instructions in OS/2's compatibility

; version of DOS

test [CriticalErrorFlag], 0FFh

jnz @F

push ss:[ ? ]

int 28h

The question mark inside brackets in the PUSH statement above indicates that the operand for the PUSH instruction can be any legal operand.

In either version of DOS, the operand field in the first instruction gives the flag's offset. The value in ES determines the segment address. The example program presented in Section 19.8 demonstrates how to locate the Critical Error flag with this technique.