Jump to content

DevHelp AllocateCtxHook: Difference between revisions

From EDM2
Created page with "==Description== 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..."
 
No edit summary
 
(6 intermediate revisions by 2 users not shown)
Line 1: Line 1:
==Description==
{{DISPLAYTITLE: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.  
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==
==Syntax==
<PRE>
DevHelp_AllocateCtxHook (NPFN HookHandler, PULONG HookHandle)
USHORT APIENTRY DevHelp_AllocateCtxHook (NPFN HookHandler,
                                        PULONG HookHandle)
</PRE>


==Parameters==
==Parameters==
; HookHandler (NPFN)- input - 16 bit offset to context hook handler
;''HookHandler'' (NPFN) - input: 16 bit offset to context hook handler
 
;''HookHandle'' (PULONG) - input: Reserved value - context hook returned
; HookHandle (PULONG): -      - Reserved value - context hook returned


==Return Code==
==Return Code==
Line 17: Line 13:


Possible errors:
Possible errors:
              ERROR_INVALID_PARAMETER (87)
:ERROR_INVALID_PARAMETER (87)


==Remarks==
==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:
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.
    EAX = Value passed on the ArmCtxHook DevHelp call in EAX.
EBX = 0FFFFFFFFH, reserved value.
 
    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 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.  
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==
==Example Code==
Line 34: Line 28:
Calling Sequence in C
Calling Sequence in C
<PRE>
<PRE>
ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
#include  "dhcalls.h"
 
    #include  "dhcalls.h"
 
USHORT APIENTRY DevHelp_AllocateCtxHook (NPFN HookHandler,
                                        PULONG HookHandle)
 
ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ


USHORT APIENTRY DevHelp_AllocateCtxHook (NPFN HookHandler, PULONG HookHandle)
</PRE>
</PRE>


===Assembler===
===Assembler===
Calling Sequence in Assembler
<PRE>
<PRE>
Calling Sequence in Assembler
ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
MOV  EAX,Hook_Handler            ; 16 bit offset to context hook handler
MOV  EAX,Hook_Handler            ; 16 bit offset to context hook handler
MOV  EBX,0FFFFFFFFh              ; Reserved value
MOV  EBX,0FFFFFFFFh              ; Reserved value
Line 56: Line 41:


CALL  [Device_Help]
CALL  [Device_Help]
 
</PRE>
ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
 
Results in Assembler
Results in Assembler
 
<PRE>
ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
 
   'C' Clear if hook allocated.
   'C' Clear if hook allocated.
       EAX = Hook handle - used by ArmCtxHook.
       EAX = Hook handle - used by ArmCtxHook.
Line 70: Line 51:
             Possible errors:
             Possible errors:
               ERROR_INVALID_PARAMETER (87)
               ERROR_INVALID_PARAMETER (87)
ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
</PRE>
</PRE>


==Related Functions==
[[Category:DevHlps]]
*
 
[[Category:The OS/2 API Project]]

Latest revision as of 18:06, 23 May 2025

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) - input
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)