include vmm.inc
include dosmgr.inc
; Install a hook procedure
GetVxDServiceOrdinal eax, DOSMGR_End_V86_App
mov esi, OFFSET32 HookProc
VMMcall Hook_Device_Service
jc error
This service is called internally by DOSMGR when a V86-mode application has ended execution. VxDs which wish to be notified of this activity must hook this service. VxDs must not call this service directly. The hook procedure must be a 4.0 Hook_Proc style procedure.
VxDs which monitor resources may wish to hook this service (and the corresponding DOSMGR_Begin_V86_App) in order to allocate and free resources for each MS-DOS-based application. To monitor Windows-based applications, VxDs should monitor the system control calls related to threads.
The system calls the hook procedure as follows:
mov ebx, VMHandle
mov esi, HighLinearPSP
mov dx, AppPSP
mov cx, AppExitCode
CH | Application exit type |
CH = 0 | Normal termination |
CH = 1 | Terminated via Ctrl+C |
CH = 2 | Terminated due to critical error (e.g., disk I/O error) |
CH = 3 | Terminated and stayed resident |
CL | Application return code (application-specific value) |
Any VxD which hooks the service must pass the call down to the previously-installed hook, preserving all registers, (except Flags) even registers reserved for future use.
Do not assume that the high bytes of the EDX and ECX registers will be zero.