Call_When_VM_Returns

include vmm.inc

mov     eax, TimeOut            ; milliseconds until time out
mov     edx, RefData            ; reference data
mov     esi, OFFSET32 Callback  ; address of callback function
VMMCall Call_When_VM_Returns
 

Installs a callback function that receives control when a virtual machine executes the iret instruction for the current interrupt. Uses Client_CS, Client_EIP, Flags.

TimeOut
Number of milliseconds to wait before calling the callback procedure. The time out occurs only if the iret instruction is not executed before the specified time elapses. If this parameter is positive, the system calls the callback when time elapses. If this parameter is negative, the system calls the callback when time elapses and calls it again when the iret instruction is executed. If this parameter is zero, the system ignores the time out.
RefData
Reference data to be passed to the callback procedure. Can be any 32-bit value, but is typically the address of a driver-defined structure.
Callback
Address of the callback procedure. For more information about the callback procedure, see below.

A virtual device typically uses this service in a callback procedure that it installed using the Hook_V86_Int_Chain service. This service directs the system to replace the return address for the interrupt with the address of the callback procedure. That is, the system pushes the callback procedure address on the stack when it creates the stack frame for the interrupt. The system then passes the interrupt to the virtual machine.

When the virtual machine executes the iret instruction, the callback procedure receives control and can carry out tasks. After the callback procedure returns, the system restores the original interrupt return address and execution continues as if returning from the interrupt.