This section provides a general overview of WinDriver's USB Library (WDU), including
WDU_xxx API calling sequence — see
WDU_xxx
API — see
The WDU library's interface is found in the WinDriver/include/wdu_lib.h and WinDriver/include/windrvr.h header files, which should be included from any source file that calls the WDU API. (wdu_lib.h already includes windrvr.h).
The WinDriver WDU_xxx USB API is designed to support event-driven
transfers between your user-mode USB application and USB devices.
This is in contrast to earlier versions, in which USB devices were initialized
and controlled using a specific sequence of function calls.
You can implement the three user callback functions specified in the next
section: WDU_ATTACH_CALLBACKWDU_DETACH_CALLBACKWDU_POWER_CHANGE_CALLBACK
WDU_ATTACH_CALLBACK). These functions are used to notify your
application when a relevant system event occurs, such as the attaching or
detaching of a USB device. For best performance, minimal processing should be
done in these functions.
Your application calls WDU_Init()WDU_Init() function must also pass pointers to the user
callback functions.
Your application then simply waits to receive a notification of an event. Upon receipt of such a notification, processing continues. Your application may make use of any functions defined in the high- or low-level APIs below. The high-level functions, provided for your convenience, make use of the low-level functions, which in turn use IOCTLs to enable communication between the WinDriver kernel module and your user-mode application.
When exiting, your application calls WDU_Uninit()
The following figure depicts the calling sequence described above. Each vertical line represents a function or process. Each horizontal arrow represents a signal or request, drawn from the initiator to the recipient. Time progresses from top to bottom.
The following piece of meta-code can serve as a framework for your user-mode application's code:
attach()
{
...
if this is my device
/*
Set the desired alternate setting ;
Signal main() about the attachment of this device
*/
return TRUE;
else
return FALSE;
}
detach()
{
...
signal main() about the detachment of this device
...
}
main()
{
WDU_Init(...);
...
while (...)
{
/* wait for new devices */
...
/* issue transfers */
...
}
...
WDU_Uninit();
}
The WinDriver WDU_xxx USB API, provided beginning with version 6.00,
is designed to support event-driven transfers between your user-mode USB
application and USB devices. This is in contrast to earlier versions, in which
USB devices were initialized and controlled using a specific sequence of
function calls.
As a result of this change, you will need to modify your USB applications that
were designed to interface with earlier versions of WinDriver to ensure that
they will work with WinDriver v6.X on all supported platforms and not only on
Microsoft Windows.
You will have to reorganize your application's code so that it conforms with
the framework illustrated by the piece of meta-code provided in
In addition, the functions that collectively define the USB API have been changed. The new functions, described in the next few sections, provide an improved interface between user-mode USB applications and the WinDriver kernel module. Note that the new functions receive their parameters directly, unlike the old functions, which received their parameters using a structure.
The table below lists the legacy functions in the left column and indicates in the right column which function or functions replace(s) each of the legacy functions. Use this table to quickly determine which new functions to use in your new code.
| Problem | Solution |
|---|---|
| High Level API | |
| Previous Function | New Function |
WD_Open()WD_Version()WD_UsbScanDevice()
| WDU_Init() |
WD_UsbDeviceRegister() | WDU_SetInterface() |
WD_UsbGetConfiguration() | WDU_GetDeviceInfo() |
WD_UsbDeviceUnregister() | WDU_Uninit() |
| Low Level API | |
| Previous Function | New Function |
WD_UsbTransfer() |
WDU_Transfer()WDU_TransferDefaultPipe()WDU_TransferBulk()WDU_TransferIsoch()WDU_TransferInterrupt() |
USB_TRANSFER_HALT option | WDU_HaltTransfer() |
WD_UsbResetPipe() | WDU_ResetPipe() |
WD_UsbResetDevice()WD_UsbResetDeviceEx()
| WDU_ResetDevice() |