123 DeviceExtension->DeviceDescriptor =
NULL;
136 FreeItem(DeviceExtension->DeviceDescriptor);
137 DeviceExtension->DeviceDescriptor =
NULL;
144 DescriptorLength = DeviceExtension->ConfigurationDescriptor->wTotalLength;
149 FreeItem(DeviceExtension->ConfigurationDescriptor);
150 DeviceExtension->ConfigurationDescriptor =
NULL;
161 FreeItem(DeviceExtension->DeviceDescriptor);
162 DeviceExtension->DeviceDescriptor =
NULL;
169 if (DeviceExtension->DeviceDescriptor->iSerialNumber)
180 FreeItem(DeviceExtension->DeviceDescriptor);
181 DeviceExtension->DeviceDescriptor =
NULL;
186 FreeItem(DeviceExtension->ConfigurationDescriptor);
187 DeviceExtension->ConfigurationDescriptor =
NULL;
192 DeviceExtension->SerialNumber =
NULL;
214 ASSERT(ConfigurationDescriptor);
215 ASSERT(OutInterfaceDescriptor);
216 ASSERT(InEndpointDescriptor);
217 ASSERT(OutEndpointDescriptor);
222 *OutInterfaceDescriptor =
NULL;
223 *InEndpointDescriptor =
NULL;
224 *OutEndpointDescriptor =
NULL;
229 CurrentDescriptor = ConfigurationDescriptor;
241 if (*OutInterfaceDescriptor)
264 ASSERT(*OutInterfaceDescriptor);
279 *InEndpointDescriptor = EndpointDescriptor;
286 *OutEndpointDescriptor = EndpointDescriptor;
306 if ((
ULONG_PTR)CurrentDescriptor >= ((
ULONG_PTR)ConfigurationDescriptor + ConfigurationDescriptor->wTotalLength))
319 if (*OutInterfaceDescriptor ==
NULL || *InEndpointDescriptor ==
NULL || *OutEndpointDescriptor ==
NULL)
324 DPRINT1(
"USBSTOR_ScanConfigurationDescriptor: Failed to find InterfaceDescriptor %p InEndpointDescriptor %p OutEndpointDescriptor %p\n", *OutInterfaceDescriptor, *InEndpointDescriptor, *OutEndpointDescriptor);
337 DPRINT1(
"Dumping ConfigurationDescriptor %p\n", ConfigurationDescriptor);
415 DPRINT1(
"USBSTOR_SelectConfiguration failed to set interface %x\n",
Status);
425 if (!DeviceExtension->InterfaceInformation)
494 for(
Index = 0;
Index < DeviceExtension->InterfaceInformation->NumberOfPipes;
Index++)
509 DeviceExtension->BulkInPipeIndex =
Index;
522 DeviceExtension->BulkOutPipeIndex =
Index;
536 if (!BulkInFound || !BulkOutFound)
541 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 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