Author: janderwald
Date: Wed Feb 22 21:26:36 2012
New Revision: 55818
URL:
http://svn.reactos.org/svn/reactos?rev=55818&view=rev
Log:
[USBCCGP]
- Fix retrieving string descriptors
Modified:
trunk/reactos/drivers/usb/usbccgp/descriptor.c
trunk/reactos/drivers/usb/usbccgp/function.c
trunk/reactos/drivers/usb/usbccgp/usbccgp.h
Modified: trunk/reactos/drivers/usb/usbccgp/descriptor.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/usb/usbccgp/descri…
==============================================================================
--- trunk/reactos/drivers/usb/usbccgp/descriptor.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/usb/usbccgp/descriptor.c [iso-8859-1] Wed Feb 22 21:26:36 2012
@@ -92,6 +92,64 @@
// done
//
return Status;
+}
+
+NTSTATUS
+NTAPI
+USBCCGP_GetStringDescriptor(
+ IN PDEVICE_OBJECT DeviceObject,
+ IN ULONG DescriptorLength,
+ IN UCHAR DescriptorIndex,
+ IN LANGID LanguageId,
+ OUT PVOID *OutDescriptor)
+{
+ NTSTATUS Status;
+ PUSB_STRING_DESCRIPTOR StringDescriptor;
+ ULONG Size;
+ PVOID Buffer;
+
+ // retrieve descriptor
+ Status = USBCCGP_GetDescriptor(DeviceObject, USB_STRING_DESCRIPTOR_TYPE,
DescriptorLength, DescriptorIndex, LanguageId, OutDescriptor);
+ if (!NT_SUCCESS(Status))
+ {
+ // failed
+ return Status;
+ }
+
+ // get descriptor structure
+ StringDescriptor = (PUSB_STRING_DESCRIPTOR)*OutDescriptor;
+
+ // sanity check
+ ASSERT(StringDescriptor->bLength < DescriptorLength - 2);
+
+ if (StringDescriptor->bLength == 2)
+ {
+ // invalid descriptor
+ FreeItem(StringDescriptor);
+ return STATUS_DEVICE_DATA_ERROR;
+ }
+
+ // calculate size
+ Size = StringDescriptor->bLength + sizeof(WCHAR);
+
+ // allocate buffer
+ Buffer = AllocateItem(NonPagedPool, Size);
+ if (!Buffer)
+ {
+ // no memory
+ FreeItem(StringDescriptor);
+ return STATUS_INSUFFICIENT_RESOURCES;
+ }
+
+ // copy result
+ RtlCopyMemory(Buffer, StringDescriptor->bString, Size -
FIELD_OFFSET(USB_STRING_DESCRIPTOR, bString));
+
+ // free buffer
+ FreeItem(StringDescriptor);
+
+ // store result
+ *OutDescriptor = (PVOID)Buffer;
+ return STATUS_SUCCESS;
}
Modified: trunk/reactos/drivers/usb/usbccgp/function.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/usb/usbccgp/functi…
==============================================================================
--- trunk/reactos/drivers/usb/usbccgp/function.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/usb/usbccgp/function.c [iso-8859-1] Wed Feb 22 21:26:36 2012
@@ -365,8 +365,7 @@
//
// get interface description
//
- Status = USBCCGP_GetDescriptor(FDODeviceExtension->NextDeviceObject,
- USB_STRING_DESCRIPTOR_TYPE,
+ Status = USBCCGP_GetStringDescriptor(FDODeviceExtension->NextDeviceObject,
100 * sizeof(WCHAR),
Descriptor->iFunction,
0x0409, //FIXME
@@ -530,10 +529,9 @@
//
// get interface description
//
- Status = USBCCGP_GetDescriptor(FDODeviceExtension->NextDeviceObject,
- USB_STRING_DESCRIPTOR_TYPE,
- 100 * sizeof(WCHAR),
- Descriptor->iInterface,
+ Status = USBCCGP_GetStringDescriptor(FDODeviceExtension->NextDeviceObject,
+ 100 * sizeof(WCHAR),
+ Descriptor->iInterface,
0x0409, //FIXME
(PVOID*)&DescriptionBuffer);
if (!NT_SUCCESS(Status))
Modified: trunk/reactos/drivers/usb/usbccgp/usbccgp.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/usb/usbccgp/usbccg…
==============================================================================
--- trunk/reactos/drivers/usb/usbccgp/usbccgp.h [iso-8859-1] (original)
+++ trunk/reactos/drivers/usb/usbccgp/usbccgp.h [iso-8859-1] Wed Feb 22 21:26:36 2012
@@ -84,6 +84,15 @@
IN LANGID LanguageId,
OUT PVOID *OutDescriptor);
+NTSTATUS
+NTAPI
+USBCCGP_GetStringDescriptor(
+ IN PDEVICE_OBJECT DeviceObject,
+ IN ULONG DescriptorLength,
+ IN UCHAR DescriptorIndex,
+ IN LANGID LanguageId,
+ OUT PVOID *OutDescriptor);
+
ULONG
CountInterfaceDescriptors(
IN PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor);