Hook_VMM_Fault

include vmm.inc

mov     eax, FaultNo            ; fault number
mov     esi, OFFSET32 FaultProc ; points to a fault handler
VMMCall Hook_VMM_Fault

jc      not_installed           ; carry flag set if not installed
; The following line is optional. See the following comments section.
mov     [Previous], esi         ; points to previous fault handler (if any)
 

Installs a fault handler procedure for faults encountered by VMM or other virtual devices. Virtual devices typically install fault handlers while processing the Sys_Critical_Init control message to handle faults, such as general protection faults, that the VMM fault handlers cannot handle. The VMM installs its fault handlers after the Sys_Critical_Init control message. Virtual devices install fault handlers after Sys_Critical_Init to handle faults before the fault is passed to the VMM fault handlers. Uses ESI, Flags.

FaultNo
Fault number for which to install the fault handler. The fault number cannot be 02h, and must not be greater than 4Fh.
FaultProc
Address of the fault handler to install. For more information about the handler, see below.

A virtual device can install a fault handler while processing the Sys_Critical_Init message, or at a later time. When a fault occurs, fault handlers installed after the Sys_Critical_Init message receive control first, the VMM fault handlers receive control next, and fault handlers installed during the Sys_Critical_Init message receive control last. (Of course, dynamically-loaded VxDs have no choice but to install the fault handler after Sys_Critical_Init, since they haven't yet been loaded at the time the Sys_Critical_Init message is broadcast.)

The system disables interrupts and calls the fault handler as follows:

mov     ebx, VM                 ; current VM handle
mov     ebp, OFFSET32 stkfrm    ; points to VMM re-entrant stack frame
call    [FaultProc]
 

The VM parameter is a handle identifying the current virtual machine, and the stkfrm parameter points to the VMM re-entrant fault stack frame.

The EBP register does not point to a client register structure.

The fault handler may call asynchronous services only.

If the fault handler does not process the fault, it should pass the fault to the previous fault handler (if any), making sure that all registers are preserved (not just the registers containing input parameters).

If the fault handler processes the fault or if there is no previous fault handler, the handler should return without chaining by executing a near ret instruction (not an iret instruction).

The fault handler can modify the EAX, EBX, ECX, EDX, ESI, and EDI registers.

Do not use this service to install a fault handler for the Non-Maskable Interrupt (NMI). Instead, a virtual device must use the Get_NMI_Handler_Addr and Set_NMI_Handler_Addr services.

Do not use this service to install handlers for hardware interrupts. Instead, a virtual device must use virtual PIC device services.

See Also

Hook_PM_Fault, Hook_V86_Fault