Hook_Device_Service

include vmm.inc

GetDeviceServiceOrdinal eax, Service
mov     esi, OFFSET32 HookProc  ; points to the hook procedure to install
VMMCall Hook_Device_Service

jc      not_installed           ; carry flag set if error
IF WIN31COMPAT
mov     [Real_Proc], esi
ENDIF
 

Allows one virtual device to monitor or replace the services of another virtual device, or of the VMM itself. Uses ESI, Flags.

Service
Virtual device or VMM service to hook.
HookProc
Address of the hook procedure to install. The hook procedure is called with the same parameters as the service specified by the Service parameter.

When a dynamically-loaded VxD is unloaded, it must remove any service hook procedures it has installed by using the Unhook_Device_Service service.

Virtual devices that use this service must use extreme care to preserve the full functionality of the virtual device whose services are monitored or replaced.

More than one virtual device can hook a device service. The last hook installed is the first one called.

The hook procedure must save and restore registers that are not modified by the hooked service. Also, if flags are a passed as an entry or exit parameter, the hook procedure must also preserve the flags.

If the hooked service uses the C calling convention, the hook procedure must copy the entire parameter stack frame before attempting to call the hooked service. If the hooked service uses a register-based calling convention, the hook procedure must preserve all registers, even registers that are not currently used as input or output parameters.

The hook procedure must have been declared with the HOOK_PROC attribute to the BeginProc macro.

See Also

Unhook_Device_Service