IWDFUsbTargetDevice::RetrieveDescriptor method

The RetrieveDescriptor method retrieves a USB descriptor, which can describe a device, configuration, or string.

Syntax


HRESULT RetrieveDescriptor(
  [in]       UCHAR DescriptorType,
  [in]       UCHAR Index,
  [in]       USHORT LanguageID,
  [in, out]  ULONG *BufferLength,
  [out]      PVOID Buffer
);

Parameters

DescriptorType [in]

A value that specifies the type of descriptor to return. This parameter corresponds to the bDescriptorType field of a standard device descriptor, whose values are described in the Universal Serial Bus specification. (This resource may not be available in some languages and countries.) Some of these values are listed in the description of the DescriptorType member of the _URB_CONTROL_DESCRIPTOR_REQUEST structure.

Index [in]

The index of the descriptor, according to the Universal Serial Bus specification. (This resource may not be available in some languages and countries.)

LanguageID [in]

The identifier of the language, if the UMDF driver requests a string descriptor; otherwise, this parameter is zero.

BufferLength [in, out]

A pointer to a variable that, on input, contains the size, in bytes, of the buffer that the Buffer points to. If the operation succeeds, the variable receives the number of bytes that the framework copied into the buffer.

Buffer [out]

A pointer to a caller-supplied buffer that receives the USB descriptor. The type of buffer should match the value specified in DescriptorType.

Return value

RetrieveDescriptor returns one of the following values:

Return codeDescription
S_OK

RetrieveDescriptor successfully retrieved the USB descriptor.

E_OUTOFMEMORY

RetrieveDescriptor encountered an allocation failure.

An error code that is defined in Winerror.h

This value corresponds to the error code that the WinUsb API returned.

 

Remarks

For information about valid descriptor types that a UMDF driver can pass for the DescriptorType parameter, see the WinUsb_GetDescriptor function.

The RetrieveDescriptor method generates a UMDF request and synchronously sends the request to the I/O target.

Examples

The following code example retrieves a USB configuration descriptor.


HRESULT
CUmdfHidDevice::RetrieveConfigDescriptor(
    __out_bcount(ConfigDescriptorCb) PUSB_CONFIGURATION_DESCRIPTOR *ConfigDescriptor,
    __out ULONG *ConfigDescriptorCb
    )
{
    ULONG descriptorCb = sizeof(USB_CONFIGURATION_DESCRIPTOR);
    USB_CONFIGURATION_DESCRIPTOR descriptorHeader;
    PBYTE descriptorBuffer;
    HRESULT hr;

    //
    // Get the configuration descriptor at index 0
    //

    hr = m_UsbTargetDevice->RetrieveDescriptor(
                            USB_CONFIGURATION_DESCRIPTOR_TYPE,
                            0,
                            0,
                            &descriptorCb,
                            &descriptorHeader
                            );
    //
    // Store the buffer in the output parameter, or delete it.
    //
    if (SUCCEEDED(hr)) {
        *ConfigDescriptor = (PUSB_CONFIGURATION_DESCRIPTOR) (descriptorHeader);
        *ConfigDescriptorCb = descriptorCb;
    }
    else {
        delete[] descriptorHeader;
    }
    return hr;
}

Requirements

End of support

Unavailable in UMDF 2.0 and later.

Minimum UMDF version

1.5

Header

Wudfusb.h (include Wudfusb.h)

DLL

WUDFx.dll

See also

IWDFUsbTargetDevice
WinUsb_GetDescriptor

 

 

Send comments about this topic to Microsoft

Show:
© 2014 Microsoft. All rights reserved.