88 DeviceExtension->DeviceDescriptor =
NULL;
96 FreeItem(DeviceExtension->DeviceDescriptor);
97 DeviceExtension->DeviceDescriptor =
NULL;
102 DescriptorLength = DeviceExtension->ConfigurationDescriptor->wTotalLength;
105 FreeItem(DeviceExtension->ConfigurationDescriptor);
106 DeviceExtension->ConfigurationDescriptor =
NULL;
112 FreeItem(DeviceExtension->DeviceDescriptor);
113 DeviceExtension->DeviceDescriptor =
NULL;
118 if (DeviceExtension->DeviceDescriptor->iSerialNumber)
124 FreeItem(DeviceExtension->DeviceDescriptor);
125 DeviceExtension->DeviceDescriptor =
NULL;
127 FreeItem(DeviceExtension->ConfigurationDescriptor);
128 DeviceExtension->ConfigurationDescriptor =
NULL;
130 DeviceExtension->SerialNumber =
NULL;
149 ASSERT(ConfigurationDescriptor);
150 ASSERT(OutInterfaceDescriptor);
151 ASSERT(InEndpointDescriptor);
152 ASSERT(OutEndpointDescriptor);
154 *OutInterfaceDescriptor =
NULL;
155 *InEndpointDescriptor =
NULL;
156 *OutEndpointDescriptor =
NULL;
159 CurrentDescriptor = ConfigurationDescriptor;
165 if (*OutInterfaceDescriptor)
178 ASSERT(*OutInterfaceDescriptor);
185 *InEndpointDescriptor = EndpointDescriptor;
189 *OutEndpointDescriptor = EndpointDescriptor;
202 if ((
ULONG_PTR)CurrentDescriptor >= ((
ULONG_PTR)ConfigurationDescriptor + ConfigurationDescriptor->wTotalLength))
210 if (*OutInterfaceDescriptor ==
NULL || *InEndpointDescriptor ==
NULL || *OutEndpointDescriptor ==
NULL)
212 DPRINT1(
"USBSTOR_ScanConfigurationDescriptor: Failed to find InterfaceDescriptor %p InEndpointDescriptor %p OutEndpointDescriptor %p\n", *OutInterfaceDescriptor, *InEndpointDescriptor, *OutEndpointDescriptor);
222 DPRINT1(
"Dumping ConfigurationDescriptor %p\n", ConfigurationDescriptor);
276 DPRINT1(
"USBSTOR_SelectConfiguration failed to set interface %x\n",
Status);
284 if (!DeviceExtension->InterfaceInformation)
326 for (
Index = 0;
Index < DeviceExtension->InterfaceInformation->NumberOfPipes;
Index++)
332 DeviceExtension->BulkInPipeIndex =
Index;
340 DeviceExtension->BulkOutPipeIndex =
Index;
349 if (!BulkInFound || !BulkOutFound)
352 DPRINT1(
"USBSTOR_GetPipeHandles> BulkInFound %c BulkOutFound %c missing!!!\n", BulkInFound, BulkOutFound);
#define NT_SUCCESS(StatCode)
struct _FDO_DEVICE_EXTENSION * PFDO_DEVICE_EXTENSION
VOID DumpConfigurationDescriptor(PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor)
NTSTATUS NTAPI USBSTOR_GetDescriptor(IN PDEVICE_OBJECT DeviceObject, IN UCHAR DescriptorType, IN ULONG DescriptorLength, IN UCHAR DescriptorIndex, IN LANGID LanguageId, OUT PVOID *OutDescriptor)
NTSTATUS USBSTOR_GetDescriptors(IN PDEVICE_OBJECT DeviceObject)
NTSTATUS USBSTOR_GetPipeHandles(IN PFDO_DEVICE_EXTENSION DeviceExtension)
NTSTATUS USBSTOR_SelectConfigurationAndInterface(IN PDEVICE_OBJECT DeviceObject, IN PFDO_DEVICE_EXTENSION DeviceExtension)
NTSTATUS NTAPI USBSTOR_ScanConfigurationDescriptor(IN PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor, OUT PUSB_INTERFACE_DESCRIPTOR *OutInterfaceDescriptor, OUT PUSB_ENDPOINT_DESCRIPTOR *InEndpointDescriptor, OUT PUSB_ENDPOINT_DESCRIPTOR *OutEndpointDescriptor)
NTSTATUS USBSTOR_SyncUrbRequest(IN PDEVICE_OBJECT DeviceObject, OUT PURB UrbRequest)
PVOID AllocateItem(IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes)
VOID FreeItem(IN PVOID Item)
#define ExFreePoolWithTag(_P, _T)
#define STATUS_DEVICE_CONFIGURATION_ERROR
struct _URB_SELECT_CONFIGURATION UrbSelectConfiguration
struct _URB_CONTROL_DESCRIPTOR_REQUEST UrbControlDescriptorRequest
struct _URB_SELECT_INTERFACE UrbSelectInterface
PUSB_INTERFACE_DESCRIPTOR InterfaceDescriptor
UCHAR bConfigurationValue
#define RtlCopyMemory(Destination, Source, Length)
#define STATUS_UNSUCCESSFUL
#define STATUS_INSUFFICIENT_RESOURCES
struct _USB_CONFIGURATION_DESCRIPTOR * PUSB_CONFIGURATION_DESCRIPTOR
#define USB_ENDPOINT_TYPE_INTERRUPT
#define USB_CONFIGURATION_DESCRIPTOR_TYPE
#define USB_ENDPOINT_DESCRIPTOR_TYPE
struct _USB_INTERFACE_DESCRIPTOR * PUSB_INTERFACE_DESCRIPTOR
#define MAXIMUM_USB_STRING_LENGTH
#define USB_DEVICE_DESCRIPTOR_TYPE
#define USB_STRING_DESCRIPTOR_TYPE
struct _USB_ENDPOINT_DESCRIPTOR * PUSB_ENDPOINT_DESCRIPTOR
#define USB_ENDPOINT_TYPE_MASK
#define USB_INTERFACE_DESCRIPTOR_TYPE
#define USB_ENDPOINT_TYPE_BULK
#define USB_ENDPOINT_DIRECTION_IN(x)
struct _USBD_INTERFACE_INFORMATION * PUSBD_INTERFACE_INFORMATION
PURB NTAPI USBD_CreateConfigurationRequestEx(PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor, PUSBD_INTERFACE_LIST_ENTRY InterfaceList)
#define UsbBuildGetDescriptorRequest(urb, length, descriptorType, descriptorIndex, languageId, transferBuffer, transferBufferMDL, transferBufferLength, link)
_In_ ULONG _In_ PVOID _In_ LONG DescriptorType
#define UsbBuildSelectInterfaceRequest(urb, length, configurationHandle, interfaceNumber, alternateSetting)
_In_ PUSBD_INTERFACE_LIST_ENTRY InterfaceList
#define GET_SELECT_INTERFACE_REQUEST_SIZE(totalPipes)
struct _USBD_INTERFACE_LIST_ENTRY * PUSBD_INTERFACE_LIST_ENTRY
_In_ WDFCOLLECTION _In_ ULONG Index
_In_ PDEVICE_OBJECT DeviceObject
_Must_inspect_result_ _In_ WDFDEVICE _In_ LPCGUID _Out_ PINTERFACE Interface
_Must_inspect_result_ _In_ WDFIORESLIST _In_ PIO_RESOURCE_DESCRIPTOR Descriptor
_In_ WDFUSBINTERFACE _In_ UCHAR _Out_ PUSB_INTERFACE_DESCRIPTOR InterfaceDescriptor