DevHelp_AllocateCtxHook
This service allocates a context hook for use by a physical device driver that needs task time processing, but has no task time thread available to complete it.
Syntax
DevHelp_AllocateCtxHook (NPFN HookHandler, PULONG HookHandle)
Parameters
- HookHandler (NPFN)
- - input - 16 bit offset to context hook handler
- HookHandle (PULONG)
- - Reserved value - context hook returned
Return Code
Success Indicator: 0
Possible errors:
- ERROR_INVALID_PARAMETER (87)
Remarks
When the context hook is armed and triggers, the Hook_Handler function is called with the following parameters passed on the call to ArmCtxHook:
EAX = Value passed on the ArmCtxHook DevHelp call in EAX. EBX = 0FFFFFFFFH, reserved value.
The hook handler is responsible for saving and restoring registers on entry and exit. The hook handler address should be zero-extended when it is moved into EAX.
The DS register must be set to the physical device driver's data segment prior to issuing the call. If the device driver has issued a call to PhysToVirt referencing the DS register, it should restore DS to its original value. The Hook_Handler cannot be preempted. The Hook_Handler must reside in the same segment in which the AllocateCtxHook is made.
Example Code
C
Calling Sequence in C
#include "dhcalls.h" USHORT APIENTRY DevHelp_AllocateCtxHook (NPFN HookHandler, PULONG HookHandle)
Assembler
Calling Sequence in Assembler
MOV EAX,Hook_Handler ; 16 bit offset to context hook handler MOV EBX,0FFFFFFFFh ; Reserved value MOV DL,DevHlp_AllocateCtxHook CALL [Device_Help]
Results in Assembler
'C' Clear if hook allocated. EAX = Hook handle - used by ArmCtxHook. 'C' Set if error. EAX = Error code. Possible errors: ERROR_INVALID_PARAMETER (87)