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