B.3  USB User Callback Functions

B.3.1  WDU_ATTACH_CALLBACK

PURPOSE

• WinDriver calls this function when a new device, matching the given criteria, is attached, provided it is not yet controlled by another driver.
This callback is called once for each matching interface.

PROTOTYPE
typedef BOOL (DLLCALLCONV *WDU_ATTACH_CALLBACK)(
    WDU_DEVICE_HANDLE hDevice,
    WDU_DEVICE *pDeviceInfo,
    PVOID pUserData);
PARAMETERS
NameTypeInput/Output
hDeviceWDU_DEVICE_HANDLEInput
pDeviceInfoWDU_DEVICE*Input
pUserDataPVOIDInput
DESCRIPTION
NameDescription
hDeviceA unique identifier for the device/interface
pDeviceInfoPointer to a USB device information structure [B.5.2.3]; Valid until the end of the function
pUserDataPointer to user-mode data for the callback, as passed to WDU_Init [B.4.1] within the event table parameter (pEventTable->pUserData)
RETURN VALUE

If the WD_ACKNOWLEDGE flag was set in the call to WDU_Init [B.4.1] (within the dwOptions parameter), the callback function should check if it wants to control the device, and if so return TRUE (otherwise – return FALSE).
If the WD_ACKNOWLEDGE flag was not set in the call to WDU_Init, then the return value of the callback function is insignificant.

B.3.2  WDU_DETACH_CALLBACK

PURPOSE
• WinDriver calls this function when a controlled device has been detached from the system.
PROTOTYPE
typedef void (DLLCALLCONV *WDU_DETACH_CALLBACK)(
    WDU_DEVICE_HANDLE hDevice,
    PVOID pUserData);
PARAMETERS
NameTypeInput/Output
hDeviceWDU_DEVICE_HANDLEInput
pUserDataPVOIDInput
DESCRIPTION
NameDescription
hDeviceA unique identifier for the device/interface
pUserDataPointer to user-mode data for the callback, as passed to WDU_Init [B.4.1] within the event table parameter (pEventTable->pUserData)
RETURN VALUE
None

B.3.3  WDU_POWER_CHANGE_CALLBACK

PURPOSE
• WinDriver calls this function when a controlled device has changed its power settings.
PROTOTYPE
typedef BOOL (DLLCALLCONV *WDU_POWER_CHANGE_CALLBACK)(
    WDU_DEVICE_HANDLE hDevice,
    DWORD dwPowerState,
    PVOID pUserData);
PARAMETERS
NameTypeInput/Output
dwPowerStateDWORDInput
pUserDataPVOIDInput
DESCRIPTION
NameDescription
hDeviceA unique identifier for the device/interface
dwPowerStateNumber of the power state selected
pUserDataPointer to user-mode data for the callback, as passed to WDU_Init [B.4.1] within the event table parameter (pEventTable->pUserData)
RETURN VALUE
TRUE/FALSE. Currently there is no significance to the return value.
REMARKS
  • This callback is supported only in Windows operating systems, starting from Windows 2000.