Return to site

Libusbk Bluetooth

broken image


Module for USB device discovery and enumeration. More...

  1. Libusbk Usb Devices Bluetooth
  2. Libusbk Bluetooth Windows 10

What does the part 'already using libusbk, installation aborted.' I'm using Windows 10 and connected a DS3 controller by USB. Also trying to use it. (, 04:57 PM) mstreurman Wrote: As soon as you install libusbk (this is the dummy driver) as the driver with Zadig to your Bluetooth adapter and put Dolphin into Passthrough mode it should pick it up correctly. Unless you are using the ASUS BT-400, I still haven't gotten Windows/Dolphin to detect it as a Passthrough device.

Data Structures

struct KLST_DEV_COMMON_INFO
Common usb device information structure. More...
struct KLST_DEVINFO
Semi-opaque device information structure of a device list. More...
struct KLST_PATTERN_MATCH
Device list/hot-plug pattern match structure. More...

Defines

#define KLST_STRING_MAX_LEN 256
Allocated length for all strings in a KLST_DEVINFO structure.

Typedefs

typedef KLST_DEV_COMMON_INFO * PKLST_DEV_COMMON_INFO
Pointer to a KLST_DEV_COMMON_INFO structure.
typedef KLST_DEVINFO * KLST_DEVINFO_HANDLE
Pointer to a KLST_DEVINFO structure. (semi-opaque)
typedef KLST_PATTERN_MATCH * PKLST_PATTERN_MATCH
Pointer to a KLST_PATTERN_MATCH structure.
typedef BOOL KUSB_API KLST_ENUM_DEVINFO_CB (_in KLST_HANDLE DeviceList, _in KLST_DEVINFO_HANDLE DeviceInfo, _in PVOID Context)
Device list enumeration function callback typedef.

Enumerations

enum KLST_SYNC_FLAG {
KLST_SYNC_FLAG_NONE = 0L,
KLST_SYNC_FLAG_UNCHANGED = 0x0001,
KLST_SYNC_FLAG_ADDED = 0x0002,
KLST_SYNC_FLAG_REMOVED = 0x0004,
KLST_SYNC_FLAG_CONNECT_CHANGE = 0x0008,
KLST_SYNC_FLAG_MASK = 0x000F
}
Device list sync flags. More...
enum KLST_FLAG {
KLST_FLAG_NONE = 0L,
KLST_FLAG_INCLUDE_RAWGUID = 0x0001,
KLST_FLAG_INCLUDE_DISCONNECT = 0x0002
}
Device list initialization flags. More...

Functions

KUSB_EXP BOOL KUSB_API LstK_Init (_out KLST_HANDLE *DeviceList, _in KLST_FLAG Flags)
Initializes a new usb device list containing all supported devices.
KUSB_EXP BOOL KUSB_API LstK_InitEx (_out KLST_HANDLE *DeviceList, _in KLST_FLAG Flags, _in PKLST_PATTERN_MATCH PatternMatch)
Initializes a new usb device list containing only devices matching a specific class GUID.
KUSB_EXP BOOL KUSB_API LstK_Free (_in KLST_HANDLE DeviceList)
Frees a usb device list.
KUSB_EXP BOOL KUSB_API LstK_Enumerate (_in KLST_HANDLE DeviceList, _in KLST_ENUM_DEVINFO_CB *EnumDevListCB, _inopt PVOID Context)
Enumerates KLST_DEVINFO elements of a KLST_HANDLE.
KUSB_EXP BOOL KUSB_API LstK_Current (_in KLST_HANDLE DeviceList, _out KLST_DEVINFO_HANDLE *DeviceInfo)
Gets the KLST_DEVINFO element for the current position.
KUSB_EXP BOOL KUSB_API LstK_MoveNext (_in KLST_HANDLE DeviceList, _outopt KLST_DEVINFO_HANDLE *DeviceInfo)
Advances the device list current KLST_DEVINFO position.
KUSB_EXP VOID KUSB_API LstK_MoveReset (_in KLST_HANDLE DeviceList)
Sets the device list to its initial position, which is before the first element in the list.
KUSB_EXP BOOL KUSB_API LstK_FindByVidPid (_in KLST_HANDLE DeviceList, _in INT Vid, _in INT Pid, _out KLST_DEVINFO_HANDLE *DeviceInfo)
Find a device by vendor and product id.
KUSB_EXP BOOL KUSB_API LstK_Count (_in KLST_HANDLE DeviceList, _ref PUINT Count)
Counts the number of device info elements in a device list.

Detailed Description

Module for USB device discovery and enumeration.

Typedef Documentation

typedef BOOL KUSB_API KLST_ENUM_DEVINFO_CB(_in KLST_HANDLE DeviceList, _in KLST_DEVINFO_HANDLE DeviceInfo, _in PVOID Context)

Device list enumeration function callback typedef.

Parameters:
DeviceListThe device list DeviceInfo belongs to
DeviceInfoDevice information
ContextUser context that was passed into LstK_Enumerate

Use this typedef as a prototype for an enumeration function with LstK_Enumerate.

Enumeration Type Documentation

Device list sync flags.

Libusbk Bluetooth

These sync flags are also use by the hot plug module to indicate device arrival/removal notifications:

  • DeviceArrival = KLST_SYNC_FLAG_ADDED
  • DeviceRemoval = KLST_SYNC_FLAG_REMOVED
Enumerator:
KLST_SYNC_FLAG_NONE

Cleared/invalid state.

KLST_SYNC_FLAG_UNCHANGED

Unchanged state,.

KLST_SYNC_FLAG_ADDED

Added (Arrival) state,.

KLST_SYNC_FLAG_REMOVED

Removed (Unplugged) state,.

KLST_SYNC_FLAG_CONNECT_CHANGE

Connect changed state.

KLST_SYNC_FLAG_MASK

All states.

Device list initialization flags.

Enumerator:
KLST_FLAG_NONE

No flags (or 0)

KLST_FLAG_INCLUDE_RAWGUID

Enable listings for the raw device interface GUID only. {A5DCBF10-6530-11D2-901F-00C04FB951ED}.

KLST_FLAG_INCLUDE_DISCONNECT

List all libusbK devices including those not currently connected.

Function Documentation

KUSB_EXP BOOL KUSB_API LstK_Init (_out KLST_HANDLE * DeviceList,
_in KLST_FLAGFlags
)

Initializes a new usb device list containing all supported devices.

Parameters:
[out]DeviceListPointer reference that will receive a populated device list.
[in]FlagsSearch, filter, and listing options. see KLST_FLAG
Returns:
On success, TRUE. Otherwise FALSE. Use GetLastError() to get extended error information.

LstK_Init populates DeviceList with connected usb devices that can be used by libusbK.

Note:
if LstK_Init returns TRUE, the device list must be freed with LstK_Free when it is no longer needed.
Examples:
show-device.c.
KUSB_EXP BOOL KUSB_API LstK_InitEx (_out KLST_HANDLE * DeviceList,
_in KLST_FLAGFlags,
_in PKLST_PATTERN_MATCHPatternMatch
)

Initializes a new usb device list containing only devices matching a specific class GUID.

Parameters:
[out]DeviceListPointer reference that will receive a populated device list.
[in]FlagsSearch, filter, and listing options. see KLST_FLAG
[in]PatternMatchPattern Search filter.
Returns:
On success, TRUE. Otherwise FALSE. Use GetLastError() to get extended error information.

LstK_InitEx populates DeviceList with usb devices that can be used by libusbK. Only device matching the KLST_PATTERN_MATCH string are included in the list.

Note:
This function significantly improves performance when used with a device interface guid pattern patch.
if LstK_InitEx returns TRUE, the device list must be freed with LstK_Free when it it's no longer needed.
KUSB_EXP BOOL KUSB_API LstK_Free (_in KLST_HANDLEDeviceList)

Frees a usb device list.

Note:
if LstK_Init returns TRUE, the device list must be freed with LstK_Free when it is no longer needed.
Parameters:
[in]DeviceListThe DeviceList to free.
Returns:
NONE

Frees all resources that were allocated to DeviceList by LstK_Init.

Examples:
config-interface.c, load-driver-api.c, open-device.c, pipe-policy-other.c, pipe-policy-timeout.c, power-policy-suspend.c, show-device.c, xfer-async-loop.c, xfer-async.c, xfer-control.c, xfer-iso-read.c, xfer-iso.c, xfer-stream.c, and xfer-sync.c.
KUSB_EXP BOOL KUSB_API LstK_Enumerate (_in KLST_HANDLEDeviceList,
_in KLST_ENUM_DEVINFO_CB * EnumDevListCB,
_inopt PVOID Context
)

Enumerates KLST_DEVINFO elements of a KLST_HANDLE.

Parameters:
[in]DeviceListThe DeviceList to enumerate.
[in]EnumDevListCBFunction to call for each iteration.
[in]ContextOptional user context pointer.
Returns:
On success, TRUE. Otherwise FALSE. Use GetLastError() to get extended error information.

Calls EnumDevListCB for each element in the device list or until EnumDevListCB returns FALSE.

Examples:
show-device.c.
KUSB_EXP BOOL KUSB_API LstK_Current (_in KLST_HANDLEDeviceList,
_out KLST_DEVINFO_HANDLE * DeviceInfo
)

Gets the KLST_DEVINFO element for the current position.

Parameters:
[in]DeviceListThe DeviceList to retrieve a current KLST_DEVINFO for.
[out]DeviceInfoThe device information.
Returns:
On success, TRUE. Otherwise FALSE. Use GetLastError() to get extended error information.

After a DeviceList is created or after the LstK_MoveReset method is called, the LstK_MoveNext method must be called to advance the device list enumerator to the first element of the DeviceList before calling LstK_Current otherwise, DeviceInfo is undefined.

LstK_Current returns FALSE and sets last error to ERROR_NO_MORE_ITEMS if the last call to LstK_MoveNext returned FALSE, which indicates the end of the DeviceList.

LstK_Current does not move the position of the device list enumerator, and consecutive calls to LstK_Current return the same object until either LstK_MoveNext or LstK_MoveReset is called.

KUSB_EXP BOOL KUSB_API LstK_MoveNext (_in KLST_HANDLEDeviceList,
_outopt KLST_DEVINFO_HANDLE * DeviceInfo
)

Advances the device list current KLST_DEVINFO position.

Parameters:
[in]DeviceListA usb device list returned by LstK_Init
[out]DeviceInfoOn success, contains a pointer to the device information for the current enumerators position.
Returns:
On success, TRUE. Otherwise FALSE. Use GetLastError() to get extended error information.

Libusbk Usb Devices Bluetooth

After a DeviceList is created or after LstK_MoveReset is called, an enumerator is positioned before the first element of the DeviceList and the first call to LstK_MoveNext moves the enumerator over the first element of the DeviceList.

If LstK_MoveNext passes the end of the DeviceList, the enumerator is positioned after the last element in the DeviceList and LstK_MoveNext returns FALSE. When the enumerator is at this position, a subsequent call to LstK_MoveNext will reset the enumerator and it continues from the beginning.

Examples:
show-device.c.
KUSB_EXP VOID KUSB_API LstK_MoveReset (_in KLST_HANDLEDeviceList)

Sets the device list to its initial position, which is before the first element in the list.

Parameters:
[in]DeviceList
Returns:
On success, TRUE. Otherwise FALSE. Use GetLastError() to get extended error information.
Examples:
show-device.c.
KUSB_EXP BOOL KUSB_API LstK_FindByVidPid (_in KLST_HANDLEDeviceList,
_in INT Vid,
_in INT Pid,
_out KLST_DEVINFO_HANDLE * DeviceInfo
)

Libusbk Bluetooth Windows 10

Find a device by vendor and product id.

Parameters:
[in]DeviceListThe DeviceList to retrieve a current KLST_DEVINFO for.
[in]VidID is used in conjunction with the Pid to uniquely identify USB devices, providing traceability to the OEM.
[in]PidID is used in conjunction with the Pid to uniquely identify USB devices, providing traceability to the OEM.
[out]DeviceInfoOn success, the device information pointer, otherwise NULL.
Returns:
  • TRUE if the device was found
  • FALSE if the device was not found or an error occurred.
    • Sets last error to ERROR_NO_MORE_ITEMS if the device was not found.

Searches all elements in DeviceList for usb device matching the specified.

Examples:
show-device.c.
KUSB_EXP BOOL KUSB_API LstK_Count (_in KLST_HANDLEDeviceList,
_ref PUINT Count
)

Counts the number of device info elements in a device list.

Parameters:
[in]DeviceListThe deice list to count.
[in,out]CountOn success, receives the number of KLST_DEVINFO elements in the list.
Returns:
On success, TRUE. Otherwise FALSE. Use GetLastError() to get extended error information.
Examples:
show-device.c.
-->
Libusbk Bluetooth

These sync flags are also use by the hot plug module to indicate device arrival/removal notifications:

  • DeviceArrival = KLST_SYNC_FLAG_ADDED
  • DeviceRemoval = KLST_SYNC_FLAG_REMOVED
Enumerator:
KLST_SYNC_FLAG_NONE

Cleared/invalid state.

KLST_SYNC_FLAG_UNCHANGED

Unchanged state,.

KLST_SYNC_FLAG_ADDED

Added (Arrival) state,.

KLST_SYNC_FLAG_REMOVED

Removed (Unplugged) state,.

KLST_SYNC_FLAG_CONNECT_CHANGE

Connect changed state.

KLST_SYNC_FLAG_MASK

All states.

Device list initialization flags.

Enumerator:
KLST_FLAG_NONE

No flags (or 0)

KLST_FLAG_INCLUDE_RAWGUID

Enable listings for the raw device interface GUID only. {A5DCBF10-6530-11D2-901F-00C04FB951ED}.

KLST_FLAG_INCLUDE_DISCONNECT

List all libusbK devices including those not currently connected.

Function Documentation

KUSB_EXP BOOL KUSB_API LstK_Init (_out KLST_HANDLE * DeviceList,
_in KLST_FLAGFlags
)

Initializes a new usb device list containing all supported devices.

Parameters:
[out]DeviceListPointer reference that will receive a populated device list.
[in]FlagsSearch, filter, and listing options. see KLST_FLAG
Returns:
On success, TRUE. Otherwise FALSE. Use GetLastError() to get extended error information.

LstK_Init populates DeviceList with connected usb devices that can be used by libusbK.

Note:
if LstK_Init returns TRUE, the device list must be freed with LstK_Free when it is no longer needed.
Examples:
show-device.c.
KUSB_EXP BOOL KUSB_API LstK_InitEx (_out KLST_HANDLE * DeviceList,
_in KLST_FLAGFlags,
_in PKLST_PATTERN_MATCHPatternMatch
)

Initializes a new usb device list containing only devices matching a specific class GUID.

Parameters:
[out]DeviceListPointer reference that will receive a populated device list.
[in]FlagsSearch, filter, and listing options. see KLST_FLAG
[in]PatternMatchPattern Search filter.
Returns:
On success, TRUE. Otherwise FALSE. Use GetLastError() to get extended error information.

LstK_InitEx populates DeviceList with usb devices that can be used by libusbK. Only device matching the KLST_PATTERN_MATCH string are included in the list.

Note:
This function significantly improves performance when used with a device interface guid pattern patch.
if LstK_InitEx returns TRUE, the device list must be freed with LstK_Free when it it's no longer needed.
KUSB_EXP BOOL KUSB_API LstK_Free (_in KLST_HANDLEDeviceList)

Frees a usb device list.

Note:
if LstK_Init returns TRUE, the device list must be freed with LstK_Free when it is no longer needed.
Parameters:
[in]DeviceListThe DeviceList to free.
Returns:
NONE

Frees all resources that were allocated to DeviceList by LstK_Init.

Examples:
config-interface.c, load-driver-api.c, open-device.c, pipe-policy-other.c, pipe-policy-timeout.c, power-policy-suspend.c, show-device.c, xfer-async-loop.c, xfer-async.c, xfer-control.c, xfer-iso-read.c, xfer-iso.c, xfer-stream.c, and xfer-sync.c.
KUSB_EXP BOOL KUSB_API LstK_Enumerate (_in KLST_HANDLEDeviceList,
_in KLST_ENUM_DEVINFO_CB * EnumDevListCB,
_inopt PVOID Context
)

Enumerates KLST_DEVINFO elements of a KLST_HANDLE.

Parameters:
[in]DeviceListThe DeviceList to enumerate.
[in]EnumDevListCBFunction to call for each iteration.
[in]ContextOptional user context pointer.
Returns:
On success, TRUE. Otherwise FALSE. Use GetLastError() to get extended error information.

Calls EnumDevListCB for each element in the device list or until EnumDevListCB returns FALSE.

Examples:
show-device.c.
KUSB_EXP BOOL KUSB_API LstK_Current (_in KLST_HANDLEDeviceList,
_out KLST_DEVINFO_HANDLE * DeviceInfo
)

Gets the KLST_DEVINFO element for the current position.

Parameters:
[in]DeviceListThe DeviceList to retrieve a current KLST_DEVINFO for.
[out]DeviceInfoThe device information.
Returns:
On success, TRUE. Otherwise FALSE. Use GetLastError() to get extended error information.

After a DeviceList is created or after the LstK_MoveReset method is called, the LstK_MoveNext method must be called to advance the device list enumerator to the first element of the DeviceList before calling LstK_Current otherwise, DeviceInfo is undefined.

LstK_Current returns FALSE and sets last error to ERROR_NO_MORE_ITEMS if the last call to LstK_MoveNext returned FALSE, which indicates the end of the DeviceList.

LstK_Current does not move the position of the device list enumerator, and consecutive calls to LstK_Current return the same object until either LstK_MoveNext or LstK_MoveReset is called.

KUSB_EXP BOOL KUSB_API LstK_MoveNext (_in KLST_HANDLEDeviceList,
_outopt KLST_DEVINFO_HANDLE * DeviceInfo
)

Advances the device list current KLST_DEVINFO position.

Parameters:
[in]DeviceListA usb device list returned by LstK_Init
[out]DeviceInfoOn success, contains a pointer to the device information for the current enumerators position.
Returns:
On success, TRUE. Otherwise FALSE. Use GetLastError() to get extended error information.

Libusbk Usb Devices Bluetooth

After a DeviceList is created or after LstK_MoveReset is called, an enumerator is positioned before the first element of the DeviceList and the first call to LstK_MoveNext moves the enumerator over the first element of the DeviceList.

If LstK_MoveNext passes the end of the DeviceList, the enumerator is positioned after the last element in the DeviceList and LstK_MoveNext returns FALSE. When the enumerator is at this position, a subsequent call to LstK_MoveNext will reset the enumerator and it continues from the beginning.

Examples:
show-device.c.
KUSB_EXP VOID KUSB_API LstK_MoveReset (_in KLST_HANDLEDeviceList)

Sets the device list to its initial position, which is before the first element in the list.

Parameters:
[in]DeviceList
Returns:
On success, TRUE. Otherwise FALSE. Use GetLastError() to get extended error information.
Examples:
show-device.c.
KUSB_EXP BOOL KUSB_API LstK_FindByVidPid (_in KLST_HANDLEDeviceList,
_in INT Vid,
_in INT Pid,
_out KLST_DEVINFO_HANDLE * DeviceInfo
)

Libusbk Bluetooth Windows 10

Find a device by vendor and product id.

Parameters:
[in]DeviceListThe DeviceList to retrieve a current KLST_DEVINFO for.
[in]VidID is used in conjunction with the Pid to uniquely identify USB devices, providing traceability to the OEM.
[in]PidID is used in conjunction with the Pid to uniquely identify USB devices, providing traceability to the OEM.
[out]DeviceInfoOn success, the device information pointer, otherwise NULL.
Returns:
  • TRUE if the device was found
  • FALSE if the device was not found or an error occurred.
    • Sets last error to ERROR_NO_MORE_ITEMS if the device was not found.

Searches all elements in DeviceList for usb device matching the specified.

Examples:
show-device.c.
KUSB_EXP BOOL KUSB_API LstK_Count (_in KLST_HANDLEDeviceList,
_ref PUINT Count
)

Counts the number of device info elements in a device list.

Parameters:
[in]DeviceListThe deice list to count.
[in,out]CountOn success, receives the number of KLST_DEVINFO elements in the list.
Returns:
On success, TRUE. Otherwise FALSE. Use GetLastError() to get extended error information.
Examples:
show-device.c.
-->

In this topic, you will learn about how a WinUSB device is recognized in Windows 8.

The information in this topic applies to you if you are an OEM or independent hardware vendor (IHV) developing a device for which you want to use Winusb.sys as the function driver and want to load the driver automatically without having to provide a custom INF.

  • WinUSB Device
    • WinUSB device installation by using the in-box Winusb.inf

What is a WinUSB device

A WinUSB device is a Universal Serial Bus (USB) device whose firmware defines certain Microsoft operating system (OS) feature descriptors that report the compatible ID as 'WINUSB'.

The purpose of a WinUSB device is to enable Windows to load Winusb.sys as the device's function driver without a custom INF file. For a WinUSB device, you are not required to distribute INF files for your device, making the driver installation process simple for end users. Conversely, if you need to provide a custom INF, you should not define your device as a WinUSB device and specify the hardware ID of the device in the INF.

Microsoft provides Winusb.inf that contains information required by to install Winusb.sys as the device driver for a USB device.

Before Windows 8, to load Winusb.sys as the function driver, you needed to provide a custom INF. The custom INF specifies the device-specific hardware ID and also includes sections from the in-box Winusb.inf. Those sections are required for instantiating the service, copying inbox binaries, and registering a device interface GUID that applications required to find the device and talk to it. For information about writing a custom INF, see WinUSB (Winusb.sys) Installation.

In Windows 8, the in-box Winusb.inf file has been updated to enable Windows to automatically match the INF with a WinUSB device.

WinUSB device installation by using the in-box Winusb.inf

In Windows 8, the in-box Winusb.inf file has been updated. The INF includes an install section that references a compatible ID called 'USBMS_COMP_WINUSB'.

The updated INF also includes a new setup class called 'USBDevice'.

The 'USBDevice' setup class is available for those devices for which Microsoft does not provide an in-box driver. Typically, such devices do not belong to well-defined USB classes such as Audio, Bluetooth, and so on, and require a custom driver. If your device is a WinUSB device, most likely, the device does not belong to a USB class. Therefore, your device must be installed under 'USBDevice' setup class. The updated Winusb.inf facilitates that requirement.

About using the USBDevice class:

Do not use the 'USB' setup class for unclassified devices. That class is reserved for installing controllers, hubs, and composite devices. Misusing the 'USB' class can lead to significant reliability and performance issues. For unclassified devices, use 'USBDevice'.

In Windows 8, to use 'USBDevice' device class, simply add this to your INF:

In Device Manager you will see a new node USB Universal Serial Bus devices and your device appears under that node.

In Windows 7, in addition to the preceding lines, you need to create these registry settings in the INF:

In Device Manager, you will see your device appear under USB Universal Serial Bus devices. However, the device class description is derived from the registry setting specified in your INF.

-Eliyas Yakub, Microsoft Windows USB Core Team

Note that the 'USBDevice' class is not limited to WinUSB. If you have a custom driver for your device, you can use the 'USBDevice' setup class in the custom INF.

During device enumeration, the USB driver stack reads the compatible ID from the device. If the compatible ID is 'WINUSB', Windows uses it as the device identifier and finds a match in the updated in-box Winusb.inf, and then loads Winusb.sys as the device's function driver.

This image is for a single interface MUTT device that is defined as a WinUSB device and as a result Winusb.sys gets loaded as the function driver for the device.

For versions of Windows earlier than Windows 8, the updated Winusb.inf is available through Windows Update. If your computer is configured to get driver update automatically, WinUSB driver will get installed without any user intervention by using the new INF package.

How to change the device description for a WinUSB device

For a WinUSB device, Device Manager shows 'WinUsb Device' as the device description. That string is derived from Winusb.inf. If there are multiple WinUSB devices, all devices get the same device description.

To uniquely identify and differentiate the device in Device Manager, Windows 8 provides a new property on a device class that instructs the system to give precedence to the device description reported by the device (in its iProduct string descriptor) over the description in the INF. The 'USBDevice' class defined in Windows 8 sets this property. In other words, when a device is installed under 'USBDevice' class, system queries the device for a device description and sets the Device Manager string to whatever is retrieved in the query. In that case, the device description provided in the INF is ignored. Notice the device description strings: 'MUTT' in the preceding image. The string is provided by the USB device in its product string descriptor.

The new class property is not supported on earlier versions of Windows. To have a customized device description on an earlier version of Windows, you have to write your own custom INF.

How to configure a WinUSB device

To identify a USB device as a WinUSB device, the device firmware must have Microsoft OS Descriptors. For information about the descriptors, see the specifications described here: Microsoft OS Descriptors.

Supporting extended feature descriptors

In order for the USB driver stack to know that the device supports extended feature descriptors, the device must define an OS string descriptor that is stored at string index 0xEE. During enumeration, the driver stack queries for the string descriptor. If the descriptor is present, the driver stack assumes that the device contains one or more OS feature descriptors and the data that is required to retrieve those feature descriptors.

The retrieved string descriptor has a bMS_VendorCode field value. The value indicates the vendor code that the USB driver stack must use to retrieve the extended feature descriptor.

For information about how to define an OS string descriptor, see 'The OS String Descriptor' in the specifications described here: Microsoft OS Descriptors.

Setting the compatible ID

An extended compat ID OS feature descriptor that is required to match the in-box Winusb.inf and load the WinUSB driver module.

The extended compat ID OS feature descriptor includes a header section followed by one or more function sections depending on whether the device is a composite or non-composite device. The header section specifies the length of the entire descriptor, number of function sections, and version number. For a non-composite device, the header is followed by one function section associated with the device's only interface. The compatibleID field of that section must specify 'WINUSB' as the field value. For a composite device, there are multiple function sections. The compatibleID field of each function section must specify 'WINUSB'.

Registering a device interface GUID

An extended properties OS feature descriptor that is required to register its device interface GUID. The GUID is required to find the device from an application or service, configure the device, and perform I/O operations.

In previous versions of Windows, device interface GUID registration is done through the custom INF. Starting in Windows 8, your device should report the interface GUID by using extended properties OS feature descriptor.

The extended properties OS feature descriptor includes a header section that is followed by one or more custom property sections. The header section describes the entire extended properties descriptor, including its total length, the version number, and the number of custom property sections. To register the device interface GUID, add a custom property section that sets the bPropertyName field to 'DeviceInterfaceGUID' and wPropertyNameLength to 40 bytes. Generate a unique device interface GUID by using a GUID generator and set the bPropertyData field to that GUID, such as '{8FE6D4D7-49DD-41E7-9486-49AFC6BFE475}'. Note that the GUID is specified as a Unicode string and the length of the string is 78 bytes (including the null terminator).

bPropertyData78 bytes

7B 00 38 00 46 00 45 00 36 00 44 00 34 00 44 00 37 00 2D 00 34 00 39 00 00 44 00 2D 00 34 00 31 00 45 00 37 00 2D 00 39 00 34 00 38 00 36 00 2D 00 34 00 39 00 41 00 46 00 43 00 36 00 42 00 46 00 45 00 34 00 37 00 35 00 7D 00 00 00

Property value is {8FE6D4D7-49DD-41E7-9486-49AFC6BFE475}.

During device enumeration, The USB driver stack then retrieves the DeviceInterfaceGUID value from the extended properties OS feature descriptor and registers the device in the device's hardware key. An application can retrieve the value by using SetupDiXxx APIs (See SetupDiOpenDevRegKey). For more information, see How to Access a USB Device by Using WinUSB Functions.

Enabling or disabling WinUSB power management features

Before Windows 8, to configure power management features of WinUSB, you had to write registry entry values in the HW.AddReg section of your custom INF.

In Windows 8, you can specify power settings in device. You can report values through the extended properties OS feature descriptor that enable or disable features in WinUSB for that device. There are two features that we can be configured: selective suspend and system wake. Selective suspend allows the device to enter low-power state when it is idle. System wake refers to the ability to a device to wake up a system when the system is in low-power state.

For information about power management features of WinUSB, see WinUSB Power Management.

Property nameDescription
DeviceIdleEnabledThis value is set to 1 to indicate that the device can power down when idle (selective suspend).
DefaultIdleStateThis value is set to 1 to indicate that the device can be suspended when idle by default.
DefaultIdleTimeoutThis value is set to 5000 in milliseconds to indicate the amount of time in milliseconds to wait before determining that a device is idle.
UserSetDeviceIdleEnabledThis value is set to 1 to allow the user to control the ability of the device to enable or disable USB selective suspend. A check box Allow the computer to turn off this device to save power on the device Power Management property page and the user can check or uncheck the box to enable or disable USB selective suspend.
SystemWakeEnabledThis value is set to 1 to allow the user to control the ability of the device to wake the system from a low-power state. When enabled, the Allow this device to wake the computer check box appears in the device power management property page. The user can check or uncheck the box to enable or disable USB system wake.

For example, to enable selective suspend on the device, add a custom property section that sets the bPropertyName field to a Unicode string, 'DeviceIdleEnabled' and wPropertyNameLength to 36 bytes. Set the bPropertyData field to '0x00000001'. The property values are stored as little-endian 32-bit integers.

During enumeration, the USB driver stack reads the extended properties feature descriptors and creates registry entries under this key:

HKEY_LOCAL_MACHINESystemCurrentControlSetEnumUSBDevice Parameters

This image shows sample settings for a WinUSB device.

For additional examples, see the specifications on Microsoft OS Descriptors.

Related topics





broken image