HID源码报告描述符相关结构体
2021-09-15
868
1
HDICLASS类驱动解析报告描述符后,将数据存储在HIDCLASS_FDO_EXTENSION结构体成员Common成员的DeviceDescription中。
//
// now get the the collection description
//
//HIDP_DEVICE_DESC DeviceDescription;
Status = HidP_GetCollectionDescription(FDODeviceExtension->ReportDescriptor, FDODeviceExtension->HidDescriptor.DescriptorList[0].wReportLength, NonPagedPool, &FDODeviceExtension->Common.DeviceDescription);
if (!NT_SUCCESS(Status))
{
DPRINT1("[HIDCLASS] Failed to retrieve the collection description %x\n", Status);
Irp->IoStatus.Status = Status;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
return Status;
}
这几个结构体的具体初始化大概流程是:
1.根据报告描述符进行解析成一个临时数据ParserContext
2.根据ParserContext,解析出有多少个Collection
3.根据解析出来的CollectionCount,分别对HIDP_DEVICE_DESC结构体分配这个数量的CollectionDesc和ReportIDs
4.根据临时数据ParserContext,解析出每个Collection对应的PreparsedData,并存于HIDP_COLLECTION_DESC的成员变量PreparsedData和PreparsedDataLength中。
5.根据PreparsedData分别初始化HIDP_REPORT_IDS和HIDP_COLLECTION_DESC中的其它变量
说明:
对于HID_REPORT_TYPE_INPUT,HID_REPORT_TYPE_OUTPUT, HID_REPORT_TYPE_FEATURE描述的REPORT_COUNT,即数据长度比端点设置的字节数小一个字节,这个字节就是报告ID.因为报告ID并不算做报告描述符中描述的有效数据,但在HID数据传输时,数据前必须加一个报告 ID.
HIDP_DEVICE_DESC定义:
typedef struct _HIDP_DEVICE_DESC
{
PHIDP_COLLECTION_DESC CollectionDesc;
ULONG CollectionDescLength;
PHIDP_REPORT_IDS ReportIDs;
ULONG ReportIDsLength;
HIDP_GETCOLDESC_DBG Dbg;
}HIDP_DEVICE_DESC, *PHIDP_DEVICE_DESC;
HIDP_COLLECTION_DESC定义:
typedef struct _HIDP_COLLECTION_DESC
{
USAGE UsagePage;
USAGE Usage;
UCHAR CollectionNumber;
UCHAR Reserved [15];
USHORT InputLength;
USHORT OutputLength;
USHORT FeatureLength;
USHORT PreparsedDataLength;
PHIDP_PREPARSED_DATA PreparsedData;
}HIDP_COLLECTION_DESC, *PHIDP_COLLECTION_DESC;
HIDP_REPORT_IDS定义:
typedef struct _HIDP_REPORT_IDS
{
UCHAR ReportID;
UCHAR CollectionNumber;
USHORT InputLength;
USHORT OutputLength;
USHORT FeatureLength;
}HIDP_REPORT_IDS, *PHIDP_REPORT_IDS;
HIDP_GETCOLDESC_DBG定义:
typedef struct _HIDP_GETCOLDESC_DBG
{
ULONG BreakOffset;
ULONG ErrorCode;
ULONG Args[6];
}HIDP_GETCOLDESC_DBG, *PHIDP_GETCOLDESC_DBG;
HID人机交互QQ群:564808376
UAC音频QQ群:218581009
UVC相机QQ群:331552032
BOT&UASP大容量存储QQ群:258159197
STC-USB单片机QQ群:315457461
USB技术交流QQ群2:580684376
USB技术交流QQ群:952873936