How to get USB config descriptor in App program

Hi,

I found this in example code to show how to read USB configuration descriptor in application program:

success = DeviceIoControl(hDEV,
IOCTL_BULKUSB_GET_CONFIG_DESCRIPTOR,
buf,
siz,
buf,
siz,
&nBytes,
NULL);

returned buf contains configuration descriptor. The IOCTL_BULKUSB_GET_CONFIG_DESCRIPTOR is pre-defined as:

#define BULKUSB_IOCTL_INDEX 0x0000
#define IOCTL_BULKUSB_GET_CONFIG_DESCRIPTOR CTL_CODE(FILE_DEVICE_UNKNOWN, \
BULKUSB_IOCTL_INDEX, \
METHOD_BUFFERED, \
FILE_ANY_ACCESS)

I have looked up msdn for CTL_CODE, but I can’t understand why define this combination (IOCTL_BULKUSB_GET_CONFIG_DESCRIPTOR) could be used to get configuration descriptor. Can anybody help me to understand this? Is there any way to read other descriptors, for example, interface descriptor? thanks very much.

> I found this in example code to show how to read USB configuration descriptor in

application program:

success = DeviceIoControl(hDEV,
IOCTL_BULKUSB_GET_CONFIG_DESCRIPTOR,

Please ignore the BulkUSB sample code. It will eventually be removed from the WDK.

Look at the USBView sample code in the WDK. It can read complete Configuration Descriptors from USB devices, which include the Interface Descriptors.

xxxxx@hotmail.com wrote:


I have looked up msdn for CTL_CODE, but I can’t understand why define this combination (IOCTL_BULKUSB_GET_CONFIG_DESCRIPTOR) could be used to get configuration descriptor. Can anybody help me to understand this? Is there any way to read other descriptors, for example, interface descriptor? thanks very much.

If you have a driver in the mix, the driver needs to know about the
descriptors. Applications typically do not. Now, using something like
WinUSB blurs this line; the application becomes the driver. There are
WinUSB requests to read the descriptors.

Once you have your own driver, it’s easy to add an ioctl like this to
return the descriptors, although it is rarely useful.

The interface and endpoint descriptors are part of the configuration
descriptor.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

Hi everybody.

I got this. Thanks for your help very much.