Author: janderwald
Date: Thu Mar 1 15:51:59 2012
New Revision: 55945
URL:
http://svn.reactos.org/svn/reactos?rev=55945&view=rev
Log:
[LIBUSB]
- Check the device descriptor is valid
- Implement function to return max packet size
Modified:
trunk/reactos/lib/drivers/libusb/common_interfaces.h
trunk/reactos/lib/drivers/libusb/usb_device.cpp
Modified: trunk/reactos/lib/drivers/libusb/common_interfaces.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/libusb/common_…
==============================================================================
--- trunk/reactos/lib/drivers/libusb/common_interfaces.h [iso-8859-1] (original)
+++ trunk/reactos/lib/drivers/libusb/common_interfaces.h [iso-8859-1] Thu Mar 1 15:51:59
2012
@@ -664,6 +664,13 @@
virtual NTSTATUS AbortPipe(IN PUSB_ENDPOINT_DESCRIPTOR EndpointDescriptor) = 0;
+//-----------------------------------------------------------------------------------------
+//
+// GetMaxPacketSize
+//
+// Description: aborts all pending requsts
+
+ virtual UCHAR GetMaxPacketSize() = 0;
};
typedef IUSBDevice *PUSBDEVICE;
Modified: trunk/reactos/lib/drivers/libusb/usb_device.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/libusb/usb_dev…
==============================================================================
--- trunk/reactos/lib/drivers/libusb/usb_device.cpp [iso-8859-1] (original)
+++ trunk/reactos/lib/drivers/libusb/usb_device.cpp [iso-8859-1] Thu Mar 1 15:51:59 2012
@@ -54,6 +54,7 @@
virtual NTSTATUS SelectConfiguration(IN PUSB_CONFIGURATION_DESCRIPTOR
ConfigurationDescriptor, IN PUSBD_INTERFACE_INFORMATION Interface, OUT
USBD_CONFIGURATION_HANDLE *ConfigurationHandle);
virtual NTSTATUS SelectInterface(IN USBD_CONFIGURATION_HANDLE ConfigurationHandle, IN
OUT PUSBD_INTERFACE_INFORMATION Interface);
virtual NTSTATUS AbortPipe(IN PUSB_ENDPOINT_DESCRIPTOR EndpointDescriptor);
+ virtual UCHAR GetMaxPacketSize();
// local function
@@ -342,17 +343,30 @@
// store new device address
m_DeviceAddress = DeviceAddress;
- // check that setting device address succeeded by retrieving the device descriptor
+ // fetch device descriptor
Status = CreateDeviceDescriptor();
if (!NT_SUCCESS(Status))
{
+ DPRINT1("CUSBbDevice::SetDeviceAddress> failed to retrieve device
descriptor with device address set Error %x\n", Status);
+ // return error status
+ return Status;
+ }
+
+ // check for invalid device descriptor
+ if (m_DeviceDescriptor.bLength != sizeof(USB_DEVICE_DESCRIPTOR) ||
+ m_DeviceDescriptor.bDescriptorType != USB_DEVICE_DESCRIPTOR_TYPE ||
+ m_DeviceDescriptor.bNumConfigurations == 0)
+ {
// failed to retrieve device descriptor
- DPRINT1("CUSBbDevice::SetDeviceAddress> failed to retrieve device
descriptor with device address set Error %x\n", Status);
- m_DeviceAddress = OldAddress;
+ DPRINT1("CUSBbDevice::SetDeviceAddress> device returned bogus device
descriptor\n");
+ DumpDeviceDescriptor(&m_DeviceDescriptor);
// return error status
- return Status;
- }
+ return STATUS_UNSUCCESSFUL;
+ }
+
+ // dump device descriptor
+ DumpDeviceDescriptor(&m_DeviceDescriptor);
// sanity checks
PC_ASSERT(m_DeviceDescriptor.bNumConfigurations);
@@ -633,10 +647,9 @@
if (NT_SUCCESS(Status))
{
//
- // informal dbg print
+ // copy device descriptor
//
RtlCopyMemory(&m_DeviceDescriptor, Buffer, sizeof(USB_DEVICE_DESCRIPTOR));
- DumpDeviceDescriptor(&m_DeviceDescriptor);
}
//
@@ -1211,6 +1224,12 @@
return m_Queue->AbortDevicePipe(m_DeviceAddress, EndpointDescriptor);
}
+UCHAR
+CUSBDevice::GetMaxPacketSize()
+{
+ return m_DeviceDescriptor.bMaxPacketSize0;
+}
+
//----------------------------------------------------------------------------------------
NTSTATUS