mirror of
https://github.com/reactos/reactos.git
synced 2025-08-04 08:15:41 +00:00
[USBHUB]
- Handle devices which provide indicate a serial number but not provide one - Fixes device installation initialization for F5D8053 N Wireless USB Adapter svn path=/trunk/; revision=57799
This commit is contained in:
parent
327c78d386
commit
da0a97394f
1 changed files with 36 additions and 41 deletions
|
@ -1022,54 +1022,49 @@ CreateDeviceIds(
|
|||
0,
|
||||
(PVOID*)&SerialBuffer,
|
||||
&UsbChildExtension->usInstanceId.Length);
|
||||
if (!NT_SUCCESS(Status))
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1("USBHUB: GetUsbStringDescriptor failed with status %x\n", Status);
|
||||
// construct instance id buffer
|
||||
Index = swprintf(Buffer, L"%04d&%s", HubDeviceExtension->InstanceCount, SerialBuffer) + 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));
|
||||
return STATUS_INSUFFICIENT_RESOURCES;
|
||||
}
|
||||
|
||||
//
|
||||
// copy instance id
|
||||
//
|
||||
RtlCopyMemory(UsbChildExtension->usInstanceId.Buffer, Buffer, Index * sizeof(WCHAR));
|
||||
UsbChildExtension->usInstanceId.Length = UsbChildExtension->usInstanceId.MaximumLength = Index * sizeof(WCHAR);
|
||||
ExFreePool(SerialBuffer);
|
||||
|
||||
DPRINT("Usb InstanceId %wZ InstanceCount %x\n", &UsbChildExtension->usInstanceId, HubDeviceExtension->InstanceCount);
|
||||
return Status;
|
||||
}
|
||||
|
||||
// construct instance id buffer
|
||||
Index = swprintf(Buffer, L"%04d&%s", HubDeviceExtension->InstanceCount, SerialBuffer) + 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));
|
||||
Status = STATUS_INSUFFICIENT_RESOURCES;
|
||||
return Status;
|
||||
}
|
||||
|
||||
//
|
||||
// copy instance id
|
||||
//
|
||||
RtlCopyMemory(UsbChildExtension->usInstanceId.Buffer, Buffer, Index * sizeof(WCHAR));
|
||||
UsbChildExtension->usInstanceId.Length = UsbChildExtension->usInstanceId.MaximumLength = Index * sizeof(WCHAR);
|
||||
ExFreePool(SerialBuffer);
|
||||
|
||||
DPRINT("Usb InstanceId %wZ InstanceCount %x\n", &UsbChildExtension->usInstanceId, HubDeviceExtension->InstanceCount);
|
||||
}
|
||||
else
|
||||
|
||||
//
|
||||
// the device did not provide a serial number, or failed to retrieve the serial number
|
||||
// lets create a pseudo instance id
|
||||
//
|
||||
Index = swprintf(Buffer, L"%04d&%04d", HubDeviceExtension->InstanceCount, UsbChildExtension->PortNumber) + 1;
|
||||
UsbChildExtension->usInstanceId.Buffer = (LPWSTR)ExAllocatePool(NonPagedPool, Index * sizeof(WCHAR));
|
||||
if (UsbChildExtension->usInstanceId.Buffer == NULL)
|
||||
{
|
||||
//
|
||||
// the device did not provide a serial number, lets create a pseudo instance id
|
||||
//
|
||||
Index = swprintf(Buffer, L"%04d&%04d", HubDeviceExtension->InstanceCount, UsbChildExtension->PortNumber) + 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));
|
||||
Status = STATUS_INSUFFICIENT_RESOURCES;
|
||||
return Status;
|
||||
}
|
||||
|
||||
//
|
||||
// copy instance id
|
||||
//
|
||||
RtlCopyMemory(UsbChildExtension->usInstanceId.Buffer, Buffer, Index * sizeof(WCHAR));
|
||||
UsbChildExtension->usInstanceId.Length = UsbChildExtension->usInstanceId.MaximumLength = Index * sizeof(WCHAR);
|
||||
|
||||
DPRINT("usDeviceId %wZ\n", &UsbChildExtension->usInstanceId);
|
||||
DPRINT1("Error: failed to allocate %lu bytes\n", Index * sizeof(WCHAR));
|
||||
Status = STATUS_INSUFFICIENT_RESOURCES;
|
||||
return Status;
|
||||
}
|
||||
|
||||
//
|
||||
// copy instance id
|
||||
//
|
||||
RtlCopyMemory(UsbChildExtension->usInstanceId.Buffer, Buffer, Index * sizeof(WCHAR));
|
||||
UsbChildExtension->usInstanceId.Length = UsbChildExtension->usInstanceId.MaximumLength = Index * sizeof(WCHAR);
|
||||
|
||||
DPRINT("usDeviceId %wZ\n", &UsbChildExtension->usInstanceId);
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue