Technical Document #38

Technical Document #38
I need to call WD_Transfer() and WD_UsbTransfer() in the Kernel PlugIn. From where do I get hWD to pass to these functions?

NOTE
This document refers to low-level WinDriver API. When using the latest versions, you should use the high-level WDC (PCI) or WDU (USB) API.
Note that the Kernel PlugIn feature is not supported for USB in the latest versions.

To obtain the handle to WinDriver's kernel module (hWD) from the Kernel PlugIn, you can do one of the following:

  • Call WD_Open() directly from the Kernel PlugIn.

    NOTE: WD_UsbTransfer() is part of WinDriver's old USB API, which was used until (and including) version 5.2.2. The USB API from version 6.0.0 and above cannot be used from the Kernel PlugIn. When calling one of the old WinDriver USB APIs — such as WD_UsbTransfer() — from the Kernel PlugIn, you must use this option — i.e., call WD_Open() directly in the kernel — in order to get a handle to WinDriver that can be used in the Kernel PlugIn. You cannot use the handle that is passed from the user mode (as suggested in the second option below) with the WinDriver USB functions.


  • For PCI/PCMCIA/ISA, you can also use the hWD handle, which is passed from the user mode via WD_KernelPlugInOpen(), and received as the second argument of the Kernel PlugIn callback function KP_Open().

    Alternatively, you can also pass the handle from the user mode to the Kernel PlugIn using the pData field of the WD_KERNEL_PLUGIN_CALL struct, which is used in the call to WD_KernelPlugInCall() in the user mode and results in a callback to KP_Call() in the Kernel PlugIn.

After obtaining the handle to WinDriver, the call to WD_Transfer() / WD_UsbTransfer() (or any other WinDriver API that receives a handle to WinDriver as a parameter) is the same as in the user mode.