[USBCCGP]

- Fix hardware/compatible id generation (still abusing UNICODE_STRING though)
- Do not touch unsupported IRP_MN_QUERY_ID requests

svn path=/trunk/; revision=56666
This commit is contained in:
Thomas Faber 2012-05-28 10:15:58 +00:00
parent 6cf1774c1e
commit 5536a02214
3 changed files with 19 additions and 11 deletions

View file

@ -386,9 +386,9 @@ USBCCGP_InitFunctionDescriptor(
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 @@ USBCCGP_InitFunctionDescriptor(
}
// 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 @@ USBCCGP_InitFunctionDescriptor(
// 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 @@ USBCCGP_InitFunctionDescriptor(
}
// 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 @@ USBCCG_InitIdsWithInterfaceDescriptor(
}
// 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 @@ USBCCG_InitIdsWithInterfaceDescriptor(
}
// 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);

View file

@ -166,8 +166,8 @@ DumpFunctionDescriptor(
{
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);

View file

@ -272,6 +272,13 @@ USBCCGP_PdoHandleQueryId(
//
DeviceString = &PDODeviceExtension->FunctionDescriptor->CompatibleId;
}
else
{
//
// unsupported query
//
return Irp->IoStatus.Status;
}
//
// sanity check
@ -294,6 +301,7 @@ USBCCGP_PdoHandleQueryId(
// copy buffer
//
RtlCopyMemory(Buffer, DeviceString->Buffer, DeviceString->Length);
Buffer[DeviceString->Length / sizeof(WCHAR)] = UNICODE_NULL;
Irp->IoStatus.Information = (ULONG_PTR)Buffer;
return STATUS_SUCCESS;