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
pDeviceInfo Pointer to a USB device information structure [B.5.2.3]; Valid until the end of the function
pUserData Pointer 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
pUserData Pointer 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
pUserData Pointer 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 on Windows.