DevHelp DynamicAPI

This service allows a physical device driver to dynamically create a call gate to a Ring 0 service (worker function) contained within the physical device driver.

C
 USHORT APIENTRY DevHelp_DynamicAPI(PVOID RoutineAddress,                                   USHORT ParmCount,                                   USHORT Flags,                                   PSEL   CallGateSel) 

Assembler
 MOV  BX, Worker_Low     ; If 16:16 address, ax = selector MOV  AX, Worker_High    ;                   bx = offset ; If 32-bit linear, ax = high order ;                  bx = low order

MOV  CX, Parm_Count     ; If 16-bit call gate, cx = WORD count ; If 32-bit call gate, cx = DWORD count

MOV  DH, Flag           ; Bit 0 (mask =1) on  = 16-bit call gate ;                off = 32-bit call gate ; Bit 1 (mask =2) on = 16:16 worker address ;                off = linear worker address

MOV  DL,DevHlp_DynamicAPI

CALL [Device_Help] 

C

 * RoutineAddress (PVOID) - input : 16:16 address or the 32 bit Linear address of the routine for which a call gate is requested.
 * ParmCount (USHORT) - input : Parameter count (not to exceed 16 for a 16 bit call gate and 8 for 32 bit call gate.
 * Flags (USHORT) - input : Flag for the type of call gate being requested.
 * DYNAPI_CALLGATE16  16:16 CallGate
 * DYNAPI_CALLGATE32   0:32 CallGate
 * DYNAPI_ROUTINE16   16:16 Routine Addr
 * DYNAPI_ROUTINE32    0:32 Routine Addr


 * CallGateSel (PSEL) - output : Pointer to the call gate selector to be returned.

Assembler
 MOV  BX, Worker_Low     ; If 16:16 address, ax = selector MOV  AX, Worker_High    ;                   bx = offset ; If 32-bit linear, ax = high order ;                  bx = low order

MOV  CX, Parm_Count     ; If 16-bit call gate, cx = WORD count ; If 32-bit call gate, cx = DWORD count

MOV  DH, Flag           ; Bit 0 (mask =1) on  = 16-bit call gate ;                off = 32-bit call gate ; Bit 1 (mask =2) on = 16:16 worker address ;                off = linear worker address

MOV  DL,DevHlp_DynamicAPI

CALL [Device_Help] 

C
Success indicator: 0

Possible errors: None.

Assembler
 'C' Clear if successful. DI = Callgate selector.

'C' Set if error. EAX = Error code. 

Remarks
The function generates an indirect call to the worker through the returned call gate. The worker routine is given control in kernel mode. Exit kernel mode is performed upon returning from the worker. The worker routine receives control with SI containing the offset into the stack, where the user parameters have been copied. If the API worker returns with the carry flag clear, AX/EAX is set to 0 prior to returning to the calling application. If the carry flag is set, an error code might be returned in AX.

Parm_count cannot exceed 16 for 16-bit call gates, and cannot exceed 8 for 32-bit call gates.

A 16:16 worker routine returns to the kernel with an RETF instruction. A 32-bit linear worker routine returns with an RETFD instruction.

C

 * 1) include "dhcalls.h"

USHORT APIENTRY DevHelp_DynamicAPI(PVOID RoutineAddress,                                   USHORT ParmCount,                                   USHORT Flags,                                   PSEL   CallGateSel) 