How to Build Your Own VxDCall Wrappers (131030)
The information in this article applies to:
- Microsoft Windows 98 Driver Development Kit (DDK)
This article was previously published under Q131030 SUMMARY
The sample found on the Microsoft Development Platform DDK CD in
\DDK\BASE\SAMPLES\CVXD32 implements two methods of "wrapping" VxDCalls in
the C programming language.
MORE INFORMATION
A wrapper is a friendly function call or method that hides implementation
details of a difficult programming interface. The VxD in
\DDK\BASE\SAMPLES\CVXD32 implements two different wrappers for submitting
VxDCalls in C.
The first method uses inline functions pre-defined in \DDK\INC32\VMM.H.
Here is the Get_Sys_VM_Handle example:
HVM VXDINLINE
Get_Sys_VM_Handle(VOID)
{
HVM hvm;
Touch_Register(ebx)
VxDCall(Get_Sys_VM_Handle);
_asm mov [hvm], ebx
return(hvm);
}
Because standard C appends an underscore to the beginning of a symbol there
is no conflict with the VMM_Service Get_Sys_VM_Handle.
You can also find the definitions of HVM, VXDINLINE, and Touch_Register in
VMM.H file. In this way, you can use inline assembly and hide the details
in an inline function in a header file. There are, however, limitations to
using inline functions for your wrappers:
- They must return no more than a dword to avoid a problem with C++.
- They must have a restricted arguement list so that no parameters are
used as temporary stack and all registers are preserved.
The second method makes calls to the Virtual Keyboard Device services. In
VKDWRAPS.H macros in \DDK\INC32\VXDWRAPS.H are used to define wrapper
functions that are implemented in assembly found in VKDGKO.ASM.
MAKE_HEADER and PREPEND are wrappers themselves to hide the implemtation of
the segment structure of a VxD. In this way, arguements can be passed to
and from VxD services. Notice that the Get_Sys_VM_Handle inline assembly is
used to return the handle, but if more significant pre- or post-processing
is required, you should implement the wrapper in Assembler.
Unlike VMM.H, the include files defining most VxD services have no
predefined C wrappers for their services. Therefore, it is the
responsibility of the programmer to build inline and assembly wrappers for
the services needed. In this way, any VxD service is callable from C.
In VxDWraps.Inc, you can find wrapper declarations for the following
groups of functions:
VMMReg
VMMReg
ConfigMg
Shell
VxDLdr
VComm
IRS
VPowerD
Be sure to include the appropriate header (.h) file before VxDWraps.h in
your source code.
Modification Type: | Minor | Last Reviewed: | 5/24/2004 |
---|
Keywords: | KB131030 |
---|
|