阅读:2453回复:1
紧急求救:驱动程序中如何读取USB设备的字符串描述符
DDK上有如下示例:
USB_STRING_DESCRIPTOR UCD, *pFullUSD; UsbBuildGetDescriptorRequest( pURB, // points to the URB to be filled in sizeof(_URB_CONTROL_DESCRIPTOR_REQUEST), USB_STRING_DESCRIPTOR_TYPE, i, // index of string descriptor langID, // language ID of string. &USD, // points to a USB_STRING_DESCRIPTOR. NULL, sizeof(USB_STRING_DESCRIPTOR), NULL ); pFullUSD = ExAllocatePool(NonPagedPool, UCD.wTotalLength); UsbBuildGetDescriptorRequest( pURB, // points to the URB to be filled in sizeof(_URB_CONTROL_DESCRIPTOR_REQUEST), USB_STRING_DESCRIPTOR_TYPE, i, // index of string descriptor langID, // language ID of string pFullUSD, NULL, USD.bLength, NULL ); 但是上述代码中的USD是什么?UCD如何初始化?得到的字符串是不是在pFullUSD-> bString中? 谢谢各位! |
|
沙发#
发布于:2008-04-13 15:13
问题已经解决:
USB_STRING_DESCRIPTOR *UCD, *pFullUSD; UCD = ExAllocatePool(NonPagedPool, sizeof(USB_STRING_DESCRIPTOR)); UsbBuildGetDescriptorRequest( urb, (USHORT) sizeof (struct _URB_CONTROL_DESCRIPTOR_REQUEST), USB_STRING_DESCRIPTOR_TYPE, index, // index of string descriptor (USHORT)0x0409, // language ID of string. UCD, // points to a USB_STRING_DESCRIPTOR. NULL, sizeof(USB_STRING_DESCRIPTOR), NULL ); ntStatus = UsbCom_CallUSBD(DeviceObject, urb);//自定义 if (!(NT_SUCCESS(ntStatus))) { ExFreePool(UCD); goto UsbCom_ConfigureDevice_Exit1; } pFullUSD = ExAllocatePool(NonPagedPool, UCD->bLength); UsbBuildGetDescriptorRequest( urb, // points to the URB to be filled in (USHORT) sizeof (struct _URB_CONTROL_DESCRIPTOR_REQUEST), USB_STRING_DESCRIPTOR_TYPE, index, // index of string descriptor (USHORT)0x0409, // language ID of string pFullUSD, NULL, UCD->bLength, NULL ); ntStatus = UsbCom_CallUSBD(DeviceObject, urb); if (!(NT_SUCCESS(ntStatus))) { ExFreePool(pFullUSD); ExFreePool(UCD); goto UsbCom_ConfigureDevice_Exit1; }else{ //获取的字符串位于pFullUSD->bString中 ExFreePool(UCD); ExFreePool(pFullUSD); } |
|