63 Collection->StringID = LocalItemState->StringIndex;
64 Collection->PhysicalID = LocalItemState->DesignatorIndex;
70 ASSERT(LocalItemState->UsageStack);
72 if (LocalItemState->UsageStackUsed > 0)
77 UsageValue.
u.
Extended = LocalItemState->UsageStack[0].u.Extended;
79 else if (LocalItemState->UsageMinimumSet)
84 UsageValue.
u.
Extended = LocalItemState->UsageMinimum.u.Extended;
86 else if (LocalItemState->UsageMaximumSet)
91 UsageValue.
u.
Extended = LocalItemState->UsageMaximum.u.Extended;
131 ULONG CollectionCount;
136 CollectionCount = CurrentCollection->
NodeCount + 1;
142 if (!NewAllocCollection)
150 if (CurrentCollection->NodeCount)
166 NewAllocCollection[CurrentCollection->NodeCount] = (
struct __HID_COLLECTION__*)NewCollection;
172 CurrentCollection->
Nodes = NewAllocCollection;
261 Report->
Type = ReportType;
290 if (CurrentCollection->ReportCount)
295 CopyFunction(NewReportArray, CurrentCollection->Reports,
sizeof(
PHID_REPORT) * CurrentCollection->ReportCount);
306 NewReportArray[CurrentCollection->ReportCount] = NewReport;
307 CurrentCollection->Reports = NewReportArray;
308 CurrentCollection->ReportCount++;
378 if (Report->ItemCount + ReportCount <= Report->ItemAllocated)
419 *OutReport = NewReport;
451 *NewMinimum = Minimum;
452 *NewMaximum = Maximum;
464 ULONG LogicalMinimum;
465 ULONG LogicalMaximum;
466 ULONG PhysicalMinimum;
467 ULONG PhysicalMaximum;
475 LogicalMinimum = GlobalItemState->LogicalMinimum;
476 LogicalMaximum = GlobalItemState->LogicialMaximum;
477 if (LogicalMinimum > LogicalMaximum)
489 PhysicalMinimum = GlobalItemState->PhysicalMinimum;
490 PhysicalMaximum = GlobalItemState->PhysicalMaximum;
491 if (PhysicalMinimum > PhysicalMaximum)
505 if (ItemData->ArrayVariable ==
FALSE)
510 UsageMinimum = LocalItemState->UsageMinimum.u.Extended;
511 UsageMaximum = LocalItemState->UsageMaximum.u.Extended;
518 if (ReportItemIndex < LocalItemState->UsageStackUsed)
523 UsageValue = LocalItemState->UsageStack[ReportItemIndex];
530 UsageValue = LocalItemState->UsageMinimum;
535 UsageValue.
u.
Extended += ReportItemIndex;
537 if (LocalItemState->UsageMaximumSet)
539 if (UsageValue.
u.
Extended > LocalItemState->UsageMaximum.u.Extended)
544 UsageValue.
u.
Extended = LocalItemState->UsageMaximum.u.Extended;
552 UsageMinimum = UsageMaximum = UsageValue.
u.
Extended;
558 ReportItem->ByteOffset = (Report->ReportSize / 8);
559 ReportItem->Shift = (Report->ReportSize % 8);
560 ReportItem->Mask = ~(0xFFFFFFFF << GlobalItemState->ReportSize);
561 ReportItem->BitCount = GlobalItemState->ReportSize;
562 ReportItem->HasData = (ItemData->DataConstant ==
FALSE);
563 ReportItem->Array = (ItemData->ArrayVariable == 0);
564 ReportItem->Relative = (ItemData->Relative !=
FALSE);
565 ReportItem->Minimum = LogicalMinimum;
566 ReportItem->Maximum = LogicalMaximum;
567 ReportItem->UsageMinimum = UsageMinimum;
568 ReportItem->UsageMaximum = UsageMaximum;
573 Report->ReportSize += GlobalItemState->ReportSize;
669 if (NewReport != Report)
717 PUCHAR CurrentOffset, ReportEnd;
719 ULONG CurrentItemSize;
728 CurrentOffset = ReportDescriptor;
731 if (ReportDescriptor >= ReportEnd)
795 CurrentItemSize += CurrentLongItem->
DataSize;
808 if (CurrentItemSize == 1)
810 else if (CurrentItemSize == 2)
812 else if (CurrentItemSize == 4)
828 switch(CurrentItem->
Type)
884 CurrentCollection = NewCollection;
896 CurrentCollection = CurrentCollection->
Root;
897 ASSERT(CurrentCollection);
903 switch (CurrentItem->
Tag) {
917 DebugFunction(
"[HIDPARSE] Unknown ReportType Tag %x Type %x Size %x CurrentItemSize %x\n", CurrentItem->
Tag, CurrentItem->
Type, CurrentItem->
Size, CurrentItemSize);
972 switch (CurrentItem->
Tag) {
1030 ASSERT(LinkedGlobalItemState);
1040 ParserContext->
GlobalItemState.
Next = (
struct __GLOBAL_ITEM_STATE__*)LinkedGlobalItemState;
1084 switch (CurrentItem->
Tag)
1139 = CurrentItemSize ==
sizeof(
ULONG);
1144 DebugFunction(
"[HIDPARSE] ITEM_TAG_LOCAL_USAGE_MAXIMUM Data %x ItemSize %x %x\n",
Data, CurrentItemSize, CurrentItem->
Size);
1147 = CurrentItemSize ==
sizeof(
ULONG);
1202 CurrentOffset += CurrentItemSize +
sizeof(
ITEM_PREFIX);
1204 }
while (CurrentOffset < ReportEnd);
1211 while(LinkedGlobalItemState !=
NULL)
1213 DebugFunction(
"[HIDPARSE] Freeing GlobalState %p\n", LinkedGlobalItemState);
1227 LinkedGlobalItemState = NextLinkedGlobalItemState;
1239 *OutParser = ParserContext;
1262 if (CollectionNumber < ParserContext->RootCollection->NodeCount)
1273 DebugFunction(
"HIDPARSE] No such collection %lu\n", CollectionNumber);
_Must_inspect_result_ _In_ FLT_CONTEXT_TYPE _In_ SIZE_T ContextSize
VOID NTAPI ZeroFunction(IN PVOID Item, IN ULONG ItemSize)
VOID __cdecl DebugFunction(IN LPCSTR FormatStr,...)
PVOID NTAPI AllocFunction(IN ULONG ItemSize)
VOID NTAPI FreeFunction(IN PVOID Item)
#define HIDP_STATUS_SUCCESS
_Must_inspect_result_ _In_ UCHAR ReportID
#define HIDP_STATUS_REPORT_DOES_NOT_EXIST
#define HIDP_STATUS_INTERNAL_ERROR
_Must_inspect_result_ _Out_writes_to_ DataLength PHIDP_DATA _Inout_ PULONG _In_ PHIDP_PREPARSED_DATA _In_ ULONG ReportLength
#define HIDP_STATUS_USAGE_NOT_FOUND
ULONG HidParser_CalculateContextSize(IN PHID_COLLECTION Collection)
NTSTATUS HidParser_BuildCollectionContext(IN PHID_COLLECTION RootCollection, IN PVOID Context, IN ULONG ContextSize)
NTSTATUS HidParser_AddReportToCollection(IN PHID_PARSER_CONTEXT ParserContext, IN PHID_COLLECTION CurrentCollection, IN PHID_REPORT NewReport)
ULONG HidParser_GetContextSize(IN PVOID ParserContext, IN ULONG CollectionIndex)
BOOLEAN HidParser_UpdateCurrentCollectionReport(IN PHID_COLLECTION Collection, IN PHID_REPORT Report, IN PHID_REPORT NewReport)
NTSTATUS HidParser_FindReport(IN PHID_PARSER_CONTEXT ParserContext, IN UCHAR ReportType, IN UCHAR ReportID, OUT PHID_REPORT *OutReport)
NTSTATUS HidParser_AllocateCollection(IN PHID_COLLECTION ParentCollection, IN UCHAR Type, IN PLOCAL_ITEM_STATE LocalItemState, OUT PHID_COLLECTION *OutCollection)
VOID HidParser_SignRange(IN ULONG Minimum, IN ULONG Maximum, OUT PULONG NewMinimum, OUT PULONG NewMaximum)
NTSTATUS HidParser_FindReportInCollection(IN PHID_COLLECTION Collection, IN UCHAR ReportType, IN UCHAR ReportID, OUT PHID_REPORT *OutReport)
NTSTATUS HidParser_AddMainItem(IN PHID_PARSER_CONTEXT ParserContext, IN PHID_REPORT Report, IN PGLOBAL_ITEM_STATE GlobalItemState, IN PLOCAL_ITEM_STATE LocalItemState, IN PMAIN_ITEM_DATA ItemData, IN PHID_COLLECTION Collection)
BOOLEAN HidParser_UpdateCollectionReport(IN PHID_PARSER_CONTEXT ParserContext, IN PHID_REPORT Report, IN PHID_REPORT NewReport)
NTSTATUS HidParser_BuildContext(IN PVOID ParserContext, IN ULONG CollectionIndex, IN ULONG ContextSize, OUT PVOID *CollectionContext)
NTSTATUS HidParser_AddCollection(IN PHID_COLLECTION CurrentCollection, IN PHID_COLLECTION NewCollection)
VOID HidParser_FreeCollection(IN PHID_COLLECTION Collection)
NTSTATUS HidParser_GetReport(IN PHID_PARSER_CONTEXT ParserContext, IN PHID_COLLECTION Collection, IN UCHAR ReportType, IN UCHAR ReportID, IN UCHAR CreateIfNotExists, OUT PHID_REPORT *OutReport)
NTSTATUS HidParser_ReserveReportItems(IN PHID_REPORT Report, IN ULONG ReportCount, OUT PHID_REPORT *OutReport)
NTSTATUS HidParser_ParseReportDescriptor(IN PUCHAR ReportDescriptor, IN ULONG ReportLength, OUT PVOID *OutParser)
VOID HidParser_DeleteReport(IN PHID_REPORT Report)
NTSTATUS HidParser_InitReportItem(IN PHID_REPORT Report, IN PHID_REPORT_ITEM ReportItem, IN PGLOBAL_ITEM_STATE GlobalItemState, IN PLOCAL_ITEM_STATE LocalItemState, IN PMAIN_ITEM_DATA ItemData, IN ULONG ReportItemIndex)
PHID_COLLECTION HidParser_GetCollection(PHID_PARSER_CONTEXT ParserContext, IN ULONG CollectionNumber)
ULONG HidParser_NumberOfTopCollections(IN PVOID ParserCtx)
NTSTATUS HidParser_AllocateReport(IN UCHAR ReportType, IN UCHAR ReportID, OUT PHID_REPORT *OutReport)
#define ITEM_TAG_GLOBAL_PUSH
struct __GLOBAL_ITEM_STATE_ * PGLOBAL_ITEM_STATE
struct ITEM_PREFIX * PITEM_PREFIX
#define COLLECTION_LOGICAL
#define ITEM_TAG_MAIN_COLLECTION
#define ITEM_TAG_GLOBAL_UNIT
struct _HID_REPORT * PHID_REPORT
#define ITEM_TAG_GLOBAL_USAGE_PAGE
#define ITEM_TAG_GLOBAL_LOGICAL_MAXIMUM
#define ITEM_TAG_GLOBAL_POP
struct usage_value * PUSAGE_VALUE
#define ITEM_TAG_LOCAL_DESIGNATOR_MAXIMUM
struct _HID_REPORT HID_REPORT
struct __HID_COLLECTION__ * PHID_COLLECTION
#define HID_REPORT_TYPE_ANY
#define ITEM_TAG_GLOBAL_REPORT_COUNT
struct MAIN_ITEM_DATA * PMAIN_ITEM_DATA
#define ITEM_TAG_LOCAL_USAGE
#define ITEM_TAG_GLOBAL_REPORT_ID
#define ITEM_TAG_GLOBAL_UNIT_EXPONENT
#define ITEM_TAG_LOCAL_STRING_MINIMUM
#define ITEM_TAG_GLOBAL_PHYSICAL_MINIMUM
#define ITEM_TAG_LOCAL_STRING_MAXIMUM
#define ITEM_TAG_GLOBAL_PHYSICAL_MAXIMUM
#define ITEM_TAG_MAIN_END_COLLECTION
#define ITEM_TAG_LOCAL_DESIGNATOR_MINIMUM
#define ITEM_TAG_LOCAL_USAGE_MINIMUM
#define ITEM_TAG_LOCAL_USAGE_MAXIMUM
#define ITEM_TAG_LOCAL_STRING_INDEX
struct LONG_ITEM * PLONG_ITEM
#define ITEM_TAG_GLOBAL_LOGICAL_MINIMUM
#define ITEM_TAG_GLOBAL_REPORT_SIZE
struct HID_PARSER_CONTEXT * PHID_PARSER_CONTEXT
#define ITEM_TAG_MAIN_INPUT
struct SHORT_ITEM * PSHORT_ITEM
#define ITEM_TAG_LOCAL_DESIGNATOR_INDEX
#define ITEM_TAG_MAIN_OUTPUT
#define ITEM_TAG_MAIN_FEATURE
LOCAL_ITEM_STATE LocalItemState
GLOBAL_ITEM_STATE GlobalItemState
PHID_COLLECTION RootCollection
ULONG UsageStackAllocated
union SHORT_ITEM::@4331 Data
struct __GLOBAL_ITEM_STATE__ * Next
struct __HID_COLLECTION__ * Root
struct __HID_COLLECTION__ ** Nodes
union usage_value::@4332 u
struct usage_value::@4332::@4333 s
#define HID_REPORT_TYPE_INPUT
#define HID_REPORT_TYPE_FEATURE
#define HID_REPORT_TYPE_OUTPUT
WDF_EXTERN_C_START typedef _Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFCOLLECTION * Collection
_In_ WDFCOLLECTION _In_ ULONG Index
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _In_opt_ PWDF_OBJECT_ATTRIBUTES _In_ WDFCOLLECTION Collection
_Inout_ PSIZE_T _In_opt_ PMDLX _In_ MM_ROTATE_DIRECTION _In_ PMM_ROTATE_COPY_CALLBACK_FUNCTION CopyFunction