[ros-diffs] [tfaber] 56666: [USBCCGP] - Fix hardware/compatible id generation (still abusing UNICODE_STRING though) - Do not touch unsupported IRP_MN_QUERY_ID requests

tfaber at svn.reactos.org tfaber at svn.reactos.org
Mon May 28 10:15:58 UTC 2012


Author: tfaber
Date: Mon May 28 10:15:58 2012
New Revision: 56666

URL: http://svn.reactos.org/svn/reactos?rev=56666&view=rev
Log:
[USBCCGP]
- Fix hardware/compatible id generation (still abusing UNICODE_STRING though)
- Do not touch unsupported IRP_MN_QUERY_ID requests

Modified:
    trunk/reactos/drivers/usb/usbccgp/function.c
    trunk/reactos/drivers/usb/usbccgp/misc.c
    trunk/reactos/drivers/usb/usbccgp/pdo.c

Modified: trunk/reactos/drivers/usb/usbccgp/function.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/usb/usbccgp/function.c?rev=56666&r1=56665&r2=56666&view=diff
==============================================================================
--- trunk/reactos/drivers/usb/usbccgp/function.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/usb/usbccgp/function.c [iso-8859-1] Mon May 28 10:15:58 2012
@@ -386,9 +386,9 @@
                                                                          FDODeviceExtension->DeviceDescriptor->idProduct,
                                                                          FDODeviceExtension->DeviceDescriptor->bcdDevice,
                                                                          Descriptor->bFirstInterface) + 1;
-    Index = swprintf(&Buffer[Index], L"USB\\VID_%04x&PID_%04x&MI_%02x", FDODeviceExtension->DeviceDescriptor->idVendor,
-                                                                        FDODeviceExtension->DeviceDescriptor->idProduct,
-                                                                        Descriptor->bFirstInterface) + 1;
+    Index += swprintf(&Buffer[Index], L"USB\\VID_%04x&PID_%04x&MI_%02x", FDODeviceExtension->DeviceDescriptor->idVendor,
+                                                                         FDODeviceExtension->DeviceDescriptor->idProduct,
+                                                                         Descriptor->bFirstInterface) + 1;
 
     // allocate result buffer
     DescriptionBuffer = AllocateItem(NonPagedPool, (Index + 1) * sizeof(WCHAR));
@@ -401,7 +401,7 @@
     }
 
     // copy description
-    RtlCopyMemory(DescriptionBuffer, Buffer, Index * sizeof(WCHAR));
+    RtlCopyMemory(DescriptionBuffer, Buffer, (Index + 1) * sizeof(WCHAR));
     FunctionDescriptor->HardwareId.Buffer = DescriptionBuffer;
     FunctionDescriptor->HardwareId.Length = Index * sizeof(WCHAR);
     FunctionDescriptor->HardwareId.MaximumLength = (Index + 1) * sizeof(WCHAR);
@@ -411,8 +411,8 @@
     // now init the compatible id
     //
     Index = swprintf(Buffer, L"USB\\Class_%02x&SubClass_%02x&Prot_%02x", Descriptor->bFunctionClass, Descriptor->bFunctionSubClass, Descriptor->bFunctionProtocol) + 1;
-    Index = swprintf(&Buffer[Index], L"USB\\Class_%04x&SubClass_%04x",  Descriptor->bFunctionClass, Descriptor->bFunctionSubClass) + 1;
-    Index = swprintf(&Buffer[Index], L"USB\\Class_%04x", Descriptor->bFunctionClass) + 1;
+    Index += swprintf(&Buffer[Index], L"USB\\Class_%02x&SubClass_%02x",  Descriptor->bFunctionClass, Descriptor->bFunctionSubClass) + 1;
+    Index += swprintf(&Buffer[Index], L"USB\\Class_%02x", Descriptor->bFunctionClass) + 1;
 
     // allocate result buffer
     DescriptionBuffer = AllocateItem(NonPagedPool, (Index + 1) * sizeof(WCHAR));
@@ -425,7 +425,7 @@
     }
 
     // copy description
-    RtlCopyMemory(DescriptionBuffer, Buffer, Index * sizeof(WCHAR));
+    RtlCopyMemory(DescriptionBuffer, Buffer, (Index + 1) * sizeof(WCHAR));
     FunctionDescriptor->CompatibleId.Buffer = DescriptionBuffer;
     FunctionDescriptor->CompatibleId.Length = Index * sizeof(WCHAR);
     FunctionDescriptor->CompatibleId.MaximumLength = (Index + 1) * sizeof(WCHAR);
@@ -566,7 +566,7 @@
     }
 
     // copy description
-    RtlCopyMemory(DescriptionBuffer, Buffer, Index * sizeof(WCHAR));
+    RtlCopyMemory(DescriptionBuffer, Buffer, (Index + 1) * sizeof(WCHAR));
     FunctionDescriptor->HardwareId.Buffer = DescriptionBuffer;
     FunctionDescriptor->HardwareId.Length = Index * sizeof(WCHAR);
     FunctionDescriptor->HardwareId.MaximumLength = (Index + 1) * sizeof(WCHAR);
@@ -589,7 +589,7 @@
     }
 
     // copy description
-    RtlCopyMemory(DescriptionBuffer, Buffer, Index * sizeof(WCHAR));
+    RtlCopyMemory(DescriptionBuffer, Buffer, (Index + 1) * sizeof(WCHAR));
     FunctionDescriptor->CompatibleId.Buffer = DescriptionBuffer;
     FunctionDescriptor->CompatibleId.Length = Index * sizeof(WCHAR);
     FunctionDescriptor->CompatibleId.MaximumLength = (Index + 1) * sizeof(WCHAR);

Modified: trunk/reactos/drivers/usb/usbccgp/misc.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/usb/usbccgp/misc.c?rev=56666&r1=56665&r2=56666&view=diff
==============================================================================
--- trunk/reactos/drivers/usb/usbccgp/misc.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/usb/usbccgp/misc.c [iso-8859-1] Mon May 28 10:15:58 2012
@@ -166,8 +166,8 @@
     {
         DPRINT1("Function %lu\n", Index);
         DPRINT1("FunctionNumber %lu\n", FunctionDescriptor[Index].FunctionNumber);
-        DPRINT1("HardwareId %wZ\n", &FunctionDescriptor[Index].HardwareId);
-        DPRINT1("CompatibleId %wZ\n", &FunctionDescriptor[Index].CompatibleId);
+        DPRINT1("HardwareId %S\n", FunctionDescriptor[Index].HardwareId.Buffer);
+        DPRINT1("CompatibleId %S\n", FunctionDescriptor[Index].CompatibleId.Buffer);
         DPRINT1("FunctionDescription %wZ\n", &FunctionDescriptor[Index].FunctionDescription);
         DPRINT1("NumInterfaces %lu\n", FunctionDescriptor[Index].NumberOfInterfaces);
 

Modified: trunk/reactos/drivers/usb/usbccgp/pdo.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/usb/usbccgp/pdo.c?rev=56666&r1=56665&r2=56666&view=diff
==============================================================================
--- trunk/reactos/drivers/usb/usbccgp/pdo.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/usb/usbccgp/pdo.c [iso-8859-1] Mon May 28 10:15:58 2012
@@ -272,6 +272,13 @@
         //
         DeviceString = &PDODeviceExtension->FunctionDescriptor->CompatibleId;
     }
+    else
+    {
+        //
+        // unsupported query
+        //
+        return Irp->IoStatus.Status;
+    }
 
     //
     // sanity check
@@ -294,6 +301,7 @@
     // copy buffer
     //
     RtlCopyMemory(Buffer, DeviceString->Buffer, DeviceString->Length);
+    Buffer[DeviceString->Length / sizeof(WCHAR)] = UNICODE_NULL;
     Irp->IoStatus.Information = (ULONG_PTR)Buffer;
 
     return STATUS_SUCCESS;




More information about the Ros-diffs mailing list