mirror of
https://github.com/reactos/reactos.git
synced 2024-07-07 13:15:07 +00:00
[USBCCGP]
- Fix retrieving string descriptors svn path=/trunk/; revision=55818
This commit is contained in:
parent
17f35a7781
commit
eadaa2c3de
|
@ -94,6 +94,64 @@ USBCCGP_GetDescriptor(
|
||||||
return Status;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
USBCCGP_GetDescriptors(
|
USBCCGP_GetDescriptors(
|
||||||
|
|
|
@ -365,8 +365,7 @@ USBCCGP_InitFunctionDescriptor(
|
||||||
//
|
//
|
||||||
// get interface description
|
// get interface description
|
||||||
//
|
//
|
||||||
Status = USBCCGP_GetDescriptor(FDODeviceExtension->NextDeviceObject,
|
Status = USBCCGP_GetStringDescriptor(FDODeviceExtension->NextDeviceObject,
|
||||||
USB_STRING_DESCRIPTOR_TYPE,
|
|
||||||
100 * sizeof(WCHAR),
|
100 * sizeof(WCHAR),
|
||||||
Descriptor->iFunction,
|
Descriptor->iFunction,
|
||||||
0x0409, //FIXME
|
0x0409, //FIXME
|
||||||
|
@ -530,10 +529,9 @@ USBCCG_InitIdsWithInterfaceDescriptor(
|
||||||
//
|
//
|
||||||
// get interface description
|
// get interface description
|
||||||
//
|
//
|
||||||
Status = USBCCGP_GetDescriptor(FDODeviceExtension->NextDeviceObject,
|
Status = USBCCGP_GetStringDescriptor(FDODeviceExtension->NextDeviceObject,
|
||||||
USB_STRING_DESCRIPTOR_TYPE,
|
100 * sizeof(WCHAR),
|
||||||
100 * sizeof(WCHAR),
|
Descriptor->iInterface,
|
||||||
Descriptor->iInterface,
|
|
||||||
0x0409, //FIXME
|
0x0409, //FIXME
|
||||||
(PVOID*)&DescriptionBuffer);
|
(PVOID*)&DescriptionBuffer);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
|
|
|
@ -84,6 +84,15 @@ USBCCGP_GetDescriptor(
|
||||||
IN LANGID LanguageId,
|
IN LANGID LanguageId,
|
||||||
OUT PVOID *OutDescriptor);
|
OUT PVOID *OutDescriptor);
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
NTAPI
|
||||||
|
USBCCGP_GetStringDescriptor(
|
||||||
|
IN PDEVICE_OBJECT DeviceObject,
|
||||||
|
IN ULONG DescriptorLength,
|
||||||
|
IN UCHAR DescriptorIndex,
|
||||||
|
IN LANGID LanguageId,
|
||||||
|
OUT PVOID *OutDescriptor);
|
||||||
|
|
||||||
ULONG
|
ULONG
|
||||||
CountInterfaceDescriptors(
|
CountInterfaceDescriptors(
|
||||||
IN PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor);
|
IN PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor);
|
||||||
|
|
Loading…
Reference in a new issue