include vmm.inc
mov eax, FaultNo ; fault number
mov esi, OFFSET32 FaultProc ; points to a fault handler
VMMCall Hook_V86_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 V86 mode faults. Virtual devices typically install fault handlers while processing the Sys_Critical_Init 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.
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, because 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 crs ; points to a Client_Reg_Struc
call [FaultProc]
The VM parameter is a handle identifying the current virtual machine, and the crs parameter points to a Client_Reg_Struc structure containing the register values for the current virtual machine.
If the fault procedure does not process the fault, it should pass the fault to the previous fault handler, as stored into the hook variable, making sure that all registers are preserved (not just the registers containing input parameters).
The default fault handler crashes the virtual machine, except for faults 0 (divide), 1 (trace), 3 (breakpoint), 4 (overflow), 5 (bound), and 7 (coprocessor), which are reflected as interrupts.
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.
Hook_PM_Fault, Hook_VMM_Fault