Author: janderwald
Date: Thu Jan 5 00:13:50 2012
New Revision: 54836
URL:
http://svn.reactos.org/svn/reactos?rev=54836&view=rev
Log:
[USB-BRINGUP]
- Create a pesudo random instance id
- Fixes assert when plugin usb devices whose device descriptor don't provide a serial
number
Modified:
branches/usb-bringup/drivers/usb/usbhub_new/fdo.c
Modified: branches/usb-bringup/drivers/usb/usbhub_new/fdo.c
URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup/drivers/usb/usbhub_…
==============================================================================
--- branches/usb-bringup/drivers/usb/usbhub_new/fdo.c [iso-8859-1] (original)
+++ branches/usb-bringup/drivers/usb/usbhub_new/fdo.c [iso-8859-1] Thu Jan 5 00:13:50
2012
@@ -954,6 +954,28 @@
UsbChildExtension->usInstanceId.MaximumLength =
UsbChildExtension->usInstanceId.Length;
DPRINT1("Usb InstanceId %wZ\n",
&UsbChildExtension->usInstanceId);
}
+ else
+ {
+ //
+ // the device did not provide a serial number, lets create a pseudo instance id
+ //
+ Index = swprintf(BufferPtr,
L"USB\\Vid_%04x&Pid_%04x&1A0700BC\0",
UsbChildExtension->DeviceDesc.idVendor, UsbChildExtension->DeviceDesc.idProduct) +
1;
+ UsbChildExtension->usInstanceId.Buffer = (LPWSTR)ExAllocatePool(NonPagedPool,
Index * sizeof(WCHAR));
+ if (UsbChildExtension->usInstanceId.Buffer == NULL)
+ {
+ DPRINT1("Error: failed to allocate %lu bytes\n", Index *
sizeof(WCHAR));
+ goto Cleanup;
+ }
+
+ //
+ // copy instance id
+ //
+ RtlCopyMemory(UsbChildExtension->usInstanceId.Buffer, BufferPtr,
wcslen(BufferPtr) * sizeof(WCHAR));
+ UsbChildExtension->usInstanceId.Length =
UsbChildExtension->usDeviceId.MaximumLength = Index * sizeof(WCHAR);
+
+ DPRINT1("usDeviceId %wZ\n", &UsbChildExtension->usInstanceId);
+ }
+
return Status;