DosSetVec

This call allows a process to register an address to be used when a machine exception occurs.

Syntax
DosSetVec (VecNum, Routine, PrevAddress)

Parameters

 * VecNum (USHORT) - input : Number of the vector to be serviced by this routine. Valid values are:
 * 00 - Divide overflow
 * 04 - Overflow
 * 05 - Bound
 * 06 - Invalid opcode
 * 07 - Processor extension not available
 * 16 - Processor extension error.


 * Routine (PFN) - input : Address of a routine to be entered when the exception occurs. If this parameter is 0, any previous address is de-registered.
 * PrevAddress (PFN) - output : Address of the previous handler routine. This is provided so a handler may be set, then later restored to the previous handler.

Return Code

 * rc (USHORT) - return:Return code descriptions are:
 * 0 ERROR_INVALID_FUNCTION
 * 50 ERROR_NOT_SUPPORTED

Remarks
The DosSetVec process is analogous to setting an address in the interrupt vector table when running in 8086 mode.

Should an exception occur, and the process has registered a handler, that handler is entered as if its address had been stored in the CPU's interrupt vector, except that the interrupt is still enabled. If no address has been registered for that vector, the process terminates.

When a process registers an exception handler for VecNum 7 (processor extension not available), the machine status word (MSW) for that process is set to indicate that a numeric processor extension (NPX) 287 is not present in the machine. The Emulate bit is set and the Monitor Processor bit is reset. This is done without regard for the true state of the hardware.

When a process de-registers a handler for VecNum 7, the MSW is set to reflect the true state of the hardware.

When an NPX287 exception is processing, the NPX287 status word is passed to the exception handler by being pushed on the stack before the exception handler is invoked. When the exception handler has completed execution, this word must be popped from the stack before an IRET is issued to return to the exception handler interface routine.

Family API Considerations
Some options operate differently in the DOS mode than in OS/2 mode. Therefore, the following restriction applies to DosSetVec when coding for the DOS mode.

VecNum = 7 not supported.

C

 * 1) define INCL_DOSMISC

USHORT rc = DosSetVec(VecNum, Routine, PrevAddress);

USHORT VecNum;      /* Function request code */ PFN    Routine;     /* Handler routine */ PFN    PrevAddress; /* Previous handler address (returned) */

USHORT rc;         /* return code */ 

MASM
 EXTRN DosSetVec:FAR INCL_DOSMISC     EQU 1

PUSH  WORD    VecNum        ;Function request code PUSH@ OTHER   Routine       ;Handler routine address PUSH@ DWORD   PrevAddress   ;Previous handler address (returned) CALL  DosSetVec

Returns WORD 