ReactOS  0.4.15-dev-3165-gdf6fff7
kbdhid.c
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS HID Stack
3  * LICENSE: GPL - See COPYING in the top level directory
4  * FILE: drivers/hid/kbdhid/kbdhid.c
5  * PURPOSE: Keyboard HID Driver
6  * PROGRAMMERS:
7  * Michael Martin (michael.martin@reactos.org)
8  * Johannes Anderwald (johannes.anderwald@reactos.org)
9  */
10 
11 #include "kbdhid.h"
12 
13 /* This structure starts with the same layout as KEYBOARD_INDICATOR_TRANSLATION */
18 
20  {0x3A, KEYBOARD_CAPS_LOCK_ON},
21  {0x45, KEYBOARD_NUM_LOCK_ON},
22  {0x46, KEYBOARD_SCROLL_LOCK_ON}}};
23 
24 
25 VOID
27  IN PKBDHID_DEVICE_EXTENSION DeviceExtension,
28  IN PKEYBOARD_INPUT_DATA InputData)
29 {
30  KIRQL OldIrql;
31  ULONG InputDataConsumed;
32 
33  if (!DeviceExtension->ClassService)
34  return;
35 
36  /* sanity check */
37  ASSERT(DeviceExtension->ClassService);
38  ASSERT(DeviceExtension->ClassDeviceObject);
39 
40  /* raise irql */
42 
43  /* dispatch input data */
44  (*(PSERVICE_CALLBACK_ROUTINE)DeviceExtension->ClassService)(DeviceExtension->ClassDeviceObject, InputData, InputData + 1, &InputDataConsumed);
45 
46  /* lower irql to previous level */
48 }
49 
50 BOOLEAN
51 NTAPI
54  IN PCHAR NewScanCodes,
55  IN ULONG Length)
56 {
57  KEYBOARD_INPUT_DATA InputData;
58  ULONG Index;
59  PKBDHID_DEVICE_EXTENSION DeviceExtension;
60  CHAR Prefix = 0;
61 
62  /* get device extension */
63  DeviceExtension = Context;
64 
65  for(Index = 0; Index < Length; Index++)
66  {
67  DPRINT("[KBDHID] ScanCode Index %lu ScanCode %x\n", Index, NewScanCodes[Index] & 0xFF);
68 
69  /* check if this is E0 or E1 prefix */
70  if (NewScanCodes[Index] == (CHAR)0xE0 || NewScanCodes[Index] == (CHAR)0xE1)
71  {
72  Prefix = NewScanCodes[Index];
73  continue;
74  }
75 
76  /* init input data */
77  RtlZeroMemory(&InputData, sizeof(KEYBOARD_INPUT_DATA));
78 
79  /* use keyboard unit id */
80  InputData.UnitId = DeviceExtension->KeyboardTypematic.UnitId;
81 
82  if (NewScanCodes[Index] & 0x80)
83  {
84  /* scan codes with 0x80 flag are a key break */
85  InputData.Flags |= KEY_BREAK;
86  }
87 
88  /* set a prefix if needed */
89  if (Prefix)
90  {
91  InputData.Flags |= (Prefix == (CHAR)0xE0 ? KEY_E0 : KEY_E1);
92  Prefix = 0;
93  }
94 
95  /* store key code */
96  InputData.MakeCode = NewScanCodes[Index] & 0x7F;
97 
98  /* dispatch scan codes */
99  KbdHid_DispatchInputData(Context, &InputData);
100  }
101 
102  /* done */
103  return TRUE;
104 }
105 
106 
107 NTSTATUS
108 NTAPI
111  IN PIRP Irp,
112  IN PVOID Context)
113 {
114  PKBDHID_DEVICE_EXTENSION DeviceExtension;
116  ULONG ButtonLength;
117 
118  /* get device extension */
119  DeviceExtension = Context;
120 
121  if (Irp->IoStatus.Status == STATUS_PRIVILEGE_NOT_HELD ||
122  Irp->IoStatus.Status == STATUS_DEVICE_NOT_CONNECTED ||
123  Irp->IoStatus.Status == STATUS_CANCELLED ||
124  DeviceExtension->StopReadReport)
125  {
126  /* failed to read or should be stopped*/
127  DPRINT1("[KBDHID] ReadCompletion terminating read Status %x\n", Irp->IoStatus.Status);
128 
129  /* report no longer active */
130  DeviceExtension->ReadReportActive = FALSE;
131 
132  /* request stopping of the report cycle */
133  DeviceExtension->StopReadReport = FALSE;
134 
135  /* signal completion event */
136  KeSetEvent(&DeviceExtension->ReadCompletionEvent, 0, 0);
138  }
139 
140  //
141  // print out raw report
142  //
143  ASSERT(DeviceExtension->ReportLength >= 9);
144  DPRINT("[KBDHID] ReadCompletion %02x %02x %02x %02x %02x %02x %02x %02x %02x\n", DeviceExtension->Report[0], DeviceExtension->Report[1], DeviceExtension->Report[2],
145  DeviceExtension->Report[3], DeviceExtension->Report[4], DeviceExtension->Report[5],
146  DeviceExtension->Report[6], DeviceExtension->Report[7], DeviceExtension->Report[8]);
147 
148 
149  /* get current usages */
150  ButtonLength = DeviceExtension->UsageListLength;
153  DeviceExtension->CurrentUsageList,
154  &ButtonLength,
155  DeviceExtension->PreparsedData,
156  DeviceExtension->Report,
157  DeviceExtension->ReportLength);
159 
160  /* FIXME check if needs mapping */
161 
162  /* get usage difference */
164  DeviceExtension->CurrentUsageList,
165  DeviceExtension->BreakUsageList,
166  DeviceExtension->MakeUsageList,
167  DeviceExtension->UsageListLength);
169 
170  /* replace previous usage list with current list */
171  RtlMoveMemory(DeviceExtension->PreviousUsageList,
172  DeviceExtension->CurrentUsageList,
173  sizeof(USAGE_AND_PAGE) * DeviceExtension->UsageListLength);
174 
175  /* translate break usage list */
177  DeviceExtension->UsageListLength,
179  &DeviceExtension->ModifierState,
181  DeviceExtension);
183 
184  /* translate new usage list */
186  DeviceExtension->UsageListLength,
188  &DeviceExtension->ModifierState,
190  DeviceExtension);
192 
193  /* re-init read */
194  KbdHid_InitiateRead(DeviceExtension);
195 
196  /* stop completion */
198 }
199 
200 NTSTATUS
202  IN PKBDHID_DEVICE_EXTENSION DeviceExtension)
203 {
204  PIO_STACK_LOCATION IoStack;
206 
207  /* re-use irp */
208  IoReuseIrp(DeviceExtension->Irp, STATUS_SUCCESS);
209 
210  /* init irp */
211  DeviceExtension->Irp->MdlAddress = DeviceExtension->ReportMDL;
212 
213  /* get next stack location */
214  IoStack = IoGetNextIrpStackLocation(DeviceExtension->Irp);
215 
216  /* init stack location */
217  IoStack->Parameters.Read.Length = DeviceExtension->ReportLength;
218  IoStack->Parameters.Read.Key = 0;
219  IoStack->Parameters.Read.ByteOffset.QuadPart = 0LL;
220  IoStack->MajorFunction = IRP_MJ_READ;
221  IoStack->FileObject = DeviceExtension->FileObject;
222 
223  /* set completion routine */
224  IoSetCompletionRoutine(DeviceExtension->Irp, KbdHid_ReadCompletion, DeviceExtension, TRUE, TRUE, TRUE);
225 
226  /* read is active */
227  DeviceExtension->ReadReportActive = TRUE;
228 
229  /* start the read */
230  Status = IoCallDriver(DeviceExtension->NextDeviceObject, DeviceExtension->Irp);
231 
232  /* done */
233  return Status;
234 }
235 
236 NTSTATUS
237 NTAPI
240  IN PIRP Irp,
241  IN PVOID Context)
242 {
245 }
246 
247 
248 NTSTATUS
249 NTAPI
252  IN PIRP Irp)
253 {
254  PIO_STACK_LOCATION IoStack;
256  KEVENT Event;
257  PKBDHID_DEVICE_EXTENSION DeviceExtension;
258 
259  DPRINT("[KBDHID]: IRP_MJ_CREATE\n");
260 
261  /* get device extension */
262  DeviceExtension = DeviceObject->DeviceExtension;
263 
264  /* get stack location */
266 
267  /* copy stack location to next */
269 
270  /* init event */
272 
273  /* prepare irp */
275 
276  /* call lower driver */
277  Status = IoCallDriver(DeviceExtension->NextDeviceObject, Irp);
278  if (Status == STATUS_PENDING)
279  {
280  /* request pending */
282  }
283 
284  /* check for success */
285  if (!NT_SUCCESS(Status))
286  {
287  /* failed */
288  Irp->IoStatus.Status = Status;
290  return Status;
291  }
292 
293  /* is the driver already in use */
294  if (DeviceExtension->FileObject == NULL)
295  {
296  /* did the caller specify correct attributes */
297  ASSERT(IoStack->Parameters.Create.SecurityContext);
298  if (IoStack->Parameters.Create.SecurityContext->DesiredAccess)
299  {
300  /* store file object */
301  DeviceExtension->FileObject = IoStack->FileObject;
302 
303  /* reset event */
304  KeClearEvent(&DeviceExtension->ReadCompletionEvent);
305 
306  /* initiating read */
307  Status = KbdHid_InitiateRead(DeviceExtension);
308  DPRINT("[KBDHID] KbdHid_InitiateRead: status %x\n", Status);
309  if (Status == STATUS_PENDING)
310  {
311  /* report irp is pending */
313  }
314  }
315  }
316 
317  /* complete request */
318  Irp->IoStatus.Status = Status;
320  return Status;
321 }
322 
323 
324 NTSTATUS
325 NTAPI
328  IN PIRP Irp)
329 {
330  PKBDHID_DEVICE_EXTENSION DeviceExtension;
331 
332  /* get device extension */
333  DeviceExtension = DeviceObject->DeviceExtension;
334 
335  DPRINT("[KBDHID] IRP_MJ_CLOSE ReadReportActive %x\n", DeviceExtension->ReadReportActive);
336 
337  if (DeviceExtension->ReadReportActive)
338  {
339  /* request stopping of the report cycle */
340  DeviceExtension->StopReadReport = TRUE;
341 
342  /* wait until the reports have been read */
344 
345  /* cancel irp */
346  IoCancelIrp(DeviceExtension->Irp);
347  }
348 
349  DPRINT("[KBDHID] IRP_MJ_CLOSE ReadReportActive %x\n", DeviceExtension->ReadReportActive);
350 
351  /* remove file object */
352  DeviceExtension->FileObject = NULL;
353 
354  /* skip location */
356 
357  /* pass irp to down the stack */
358  return IoCallDriver(DeviceExtension->NextDeviceObject, Irp);
359 }
360 
361 NTSTATUS
362 NTAPI
365  IN PIRP Irp)
366 {
367  PIO_STACK_LOCATION IoStack;
368  PKBDHID_DEVICE_EXTENSION DeviceExtension;
371 
372  /* get current stack location */
374 
375  DPRINT("[KBDHID] InternalDeviceControl %x\n", IoStack->Parameters.DeviceIoControl.IoControlCode);
376 
377  /* get device extension */
378  DeviceExtension = DeviceObject->DeviceExtension;
379 
380  switch (IoStack->Parameters.DeviceIoControl.IoControlCode)
381  {
383  /* verify output buffer length */
384  if (IoStack->Parameters.DeviceIoControl.OutputBufferLength < sizeof(KEYBOARD_ATTRIBUTES))
385  {
386  /* invalid request */
387  DPRINT1("[KBDHID] IOCTL_KEYBOARD_QUERY_ATTRIBUTES Buffer too small\n");
388  Irp->IoStatus.Status = STATUS_BUFFER_TOO_SMALL;
391  }
392 
393  /* get output buffer */
394  Attributes = Irp->AssociatedIrp.SystemBuffer;
395 
396  /* copy attributes */
398  &DeviceExtension->Attributes,
399  sizeof(KEYBOARD_ATTRIBUTES));
400 
401  /* complete request */
402  Irp->IoStatus.Information = sizeof(KEYBOARD_ATTRIBUTES);
403  Irp->IoStatus.Status = STATUS_SUCCESS;
405  return STATUS_SUCCESS;
406 
408  /* verify input buffer length */
409  if (IoStack->Parameters.DeviceIoControl.InputBufferLength < sizeof(CONNECT_DATA))
410  {
411  /* invalid request */
412  Irp->IoStatus.Status = STATUS_INVALID_PARAMETER;
415  }
416 
417  /* is it already connected */
418  if (DeviceExtension->ClassService)
419  {
420  /* already connected */
421  Irp->IoStatus.Status = STATUS_SHARING_VIOLATION;
424  }
425 
426  /* get connect data */
427  Data = IoStack->Parameters.DeviceIoControl.Type3InputBuffer;
428 
429  /* store connect details */
430  DeviceExtension->ClassDeviceObject = Data->ClassDeviceObject;
431  DeviceExtension->ClassService = Data->ClassService;
432 
433  /* completed successfully */
434  Irp->IoStatus.Status = STATUS_SUCCESS;
436  return STATUS_SUCCESS;
437 
439  /* not implemented */
440  Irp->IoStatus.Status = STATUS_NOT_IMPLEMENTED;
442  return STATUS_NOT_IMPLEMENTED;
443 
445  /* not supported */
446  Irp->IoStatus.Status = STATUS_NOT_SUPPORTED;
448  return STATUS_NOT_SUPPORTED;
449 
451  /* not supported */
452  Irp->IoStatus.Status = STATUS_NOT_SUPPORTED;
454  return STATUS_NOT_SUPPORTED;
455 
457  if (IoStack->Parameters.DeviceIoControl.OutputBufferLength < sizeof(KEYBOARD_INDICATOR_PARAMETERS))
458  {
459  /* buffer too small */
460  Irp->IoStatus.Status = STATUS_BUFFER_TOO_SMALL;
463  }
464 
465  /* copy indicators */
466  RtlCopyMemory(Irp->AssociatedIrp.SystemBuffer,
467  &DeviceExtension->KeyboardIndicator,
469 
470  /* complete request */
471  Irp->IoStatus.Status = STATUS_SUCCESS;
472  Irp->IoStatus.Information = sizeof(KEYBOARD_INDICATOR_PARAMETERS);
474  return STATUS_NOT_IMPLEMENTED;
475 
477  if (IoStack->Parameters.DeviceIoControl.OutputBufferLength < sizeof(KEYBOARD_TYPEMATIC_PARAMETERS))
478  {
479  /* buffer too small */
480  Irp->IoStatus.Status = STATUS_BUFFER_TOO_SMALL;
483  }
484 
485  /* copy indicators */
486  RtlCopyMemory(Irp->AssociatedIrp.SystemBuffer,
487  &DeviceExtension->KeyboardTypematic,
489 
490  /* done */
491  Irp->IoStatus.Status = STATUS_SUCCESS;
492  Irp->IoStatus.Information = sizeof(KEYBOARD_TYPEMATIC_PARAMETERS);
494  return STATUS_SUCCESS;
495 
497  if (IoStack->Parameters.DeviceIoControl.InputBufferLength < sizeof(KEYBOARD_INDICATOR_PARAMETERS))
498  {
499  /* invalid parameter */
500  Irp->IoStatus.Status = STATUS_INVALID_PARAMETER;
503  }
504 
505  /* copy indicators */
506  RtlCopyMemory(&DeviceExtension->KeyboardIndicator,
507  Irp->AssociatedIrp.SystemBuffer,
509 
510  /* done */
511  Irp->IoStatus.Status = STATUS_SUCCESS;
512  Irp->IoStatus.Information = 0;
514  return STATUS_SUCCESS;
515 
517  if (IoStack->Parameters.DeviceIoControl.InputBufferLength < sizeof(KEYBOARD_TYPEMATIC_PARAMETERS))
518  {
519  /* invalid parameter */
520  Irp->IoStatus.Status = STATUS_INVALID_PARAMETER;
523  }
524 
525  /* copy indicators */
526  RtlCopyMemory(&DeviceExtension->KeyboardTypematic,
527  Irp->AssociatedIrp.SystemBuffer,
529 
530  /* done */
531  Irp->IoStatus.Status = STATUS_SUCCESS;
532  Irp->IoStatus.Information = 0;
534  return STATUS_SUCCESS;
535 
537  if (IoStack->Parameters.DeviceIoControl.OutputBufferLength < sizeof(LOCAL_KEYBOARD_INDICATOR_TRANSLATION))
538  {
539  /* buffer too small */
540  Irp->IoStatus.Status = STATUS_BUFFER_TOO_SMALL;
543  }
544 
545  /* copy translations */
546  RtlCopyMemory(Irp->AssociatedIrp.SystemBuffer,
549 
550  /* done */
551  Irp->IoStatus.Status = STATUS_SUCCESS;
552  Irp->IoStatus.Information = sizeof(LOCAL_KEYBOARD_INDICATOR_TRANSLATION);
554  return STATUS_SUCCESS;
555  }
556 
557  /* unknown control code */
558  DPRINT1("[KBDHID] Unknown DeviceControl %x\n", IoStack->Parameters.DeviceIoControl.IoControlCode);
559  /* unknown request not supported */
560  Irp->IoStatus.Status = STATUS_NOT_SUPPORTED;
562  return STATUS_NOT_SUPPORTED;
563 }
564 
565 NTSTATUS
566 NTAPI
569  IN PIRP Irp)
570 {
571  PKBDHID_DEVICE_EXTENSION DeviceExtension;
572 
573  /* get device extension */
574  DeviceExtension = DeviceObject->DeviceExtension;
575 
576  /* skip stack location */
578 
579  /* pass and forget */
580  return IoCallDriver(DeviceExtension->NextDeviceObject, Irp);
581 }
582 
583 NTSTATUS
584 NTAPI
587  IN PIRP Irp)
588 {
589  PKBDHID_DEVICE_EXTENSION DeviceExtension;
590 
591  DeviceExtension = DeviceObject->DeviceExtension;
594  return PoCallDriver(DeviceExtension->NextDeviceObject, Irp);
595 }
596 
597 NTSTATUS
598 NTAPI
601  IN PIRP Irp)
602 {
603  PKBDHID_DEVICE_EXTENSION DeviceExtension;
604 
605  DeviceExtension = DeviceObject->DeviceExtension;
607  return IoCallDriver(DeviceExtension->NextDeviceObject, Irp);
608 }
609 
610 NTSTATUS
614  ULONG InputBufferSize,
616  ULONG OutputBufferSize,
618 {
619  KEVENT Event;
620  PKBDHID_DEVICE_EXTENSION DeviceExtension;
621  PIRP Irp;
624 
625  /* get device extension */
626  DeviceExtension = DeviceObject->DeviceExtension;
627 
628  /* init event */
630 
631  /* build request */
633  DeviceExtension->NextDeviceObject,
634  InputBuffer,
635  InputBufferSize,
636  OutputBuffer,
637  OutputBufferSize,
638  FALSE,
639  &Event,
640  &IoStatus);
641  if (!Irp)
642  {
643  /* no memory */
645  }
646 
647  /* send request */
648  Status = IoCallDriver(DeviceExtension->NextDeviceObject, Irp);
649  if (Status == STATUS_PENDING)
650  {
651  /* wait for request to complete */
653  Status = IoStatus.Status;
654  }
655 
656  /* done */
657  return Status;
658 }
659 
660 NTSTATUS
661 NTAPI
664 {
666  ULONG Buttons;
670  PKBDHID_DEVICE_EXTENSION DeviceExtension;
672 
673  /* get device extension */
674  DeviceExtension = DeviceObject->DeviceExtension;
675 
676  /* query collection information */
679  0,
680  NULL,
682  &Information);
683  if (!NT_SUCCESS(Status))
684  {
685  /* failed to query collection information */
686  DPRINT1("[KBDHID] failed to obtain collection information with %x\n", Status);
687  return Status;
688  }
689 
690  /* lets allocate space for preparsed data */
692  if (!PreparsedData)
693  {
694  /* no memory */
695  DPRINT1("[KBDHID] no memory size %u\n", Information.DescriptorSize);
697  }
698 
699  /* now obtain the preparsed data */
702  0,
703  NULL,
704  Information.DescriptorSize,
705  PreparsedData);
706  if (!NT_SUCCESS(Status))
707  {
708  /* failed to get preparsed data */
709  DPRINT1("[KBDHID] failed to obtain collection information with %x\n", Status);
711  return Status;
712  }
713 
714  /* lets get the caps */
717  {
718  /* failed to get capabilities */
719  DPRINT1("[KBDHID] failed to obtain caps with %x\n", Status);
721  return Status;
722  }
723 
724  DPRINT("[KBDHID] Usage %x UsagePage %x InputReportLength %lu\n", Capabilities.Usage, Capabilities.UsagePage, Capabilities.InputReportByteLength);
725 
726  /* init input report */
728  ASSERT(DeviceExtension->ReportLength);
729  DeviceExtension->Report = ExAllocatePoolWithTag(NonPagedPool, DeviceExtension->ReportLength, KBDHID_TAG);
730  ASSERT(DeviceExtension->Report);
731  RtlZeroMemory(DeviceExtension->Report, DeviceExtension->ReportLength);
732 
733  /* build mdl */
734  DeviceExtension->ReportMDL = IoAllocateMdl(DeviceExtension->Report,
735  DeviceExtension->ReportLength,
736  FALSE,
737  FALSE,
738  NULL);
739  ASSERT(DeviceExtension->ReportMDL);
740 
741  /* init mdl */
742  MmBuildMdlForNonPagedPool(DeviceExtension->ReportMDL);
743 
744  /* get max number of buttons */
746  DPRINT("[KBDHID] Buttons %lu\n", Buttons);
747  ASSERT(Buttons > 0);
748 
749  /* now allocate an array for those buttons */
751  if (!Buffer)
752  {
753  /* no memory */
756  }
757  DeviceExtension->UsageListBuffer = Buffer;
758 
759  /* init usage lists */
760  RtlZeroMemory(Buffer, sizeof(USAGE_AND_PAGE) * 4 * Buttons);
761  DeviceExtension->CurrentUsageList = Buffer;
762  Buffer += Buttons;
763  DeviceExtension->PreviousUsageList = Buffer;
764  Buffer += Buttons;
765  DeviceExtension->MakeUsageList = Buffer;
766  Buffer += Buttons;
767  DeviceExtension->BreakUsageList = Buffer;
768 
769  //
770  // FIMXE: implement device hacks
771  //
772  // UsageMappings
773  // KeyboardTypeOverride
774  // KeyboardSubTypeOverride
775  // KeyboardNumberTotalKeysOverride
776  // KeyboardNumberFunctionKeysOverride
777  // KeyboardNumberIndicatorsOverride
778 
779  /* store number of buttons */
780  DeviceExtension->UsageListLength = (USHORT)Buttons;
781 
782  /* store preparsed data */
783  DeviceExtension->PreparsedData = PreparsedData;
784 
785  /* completed successfully */
786  return STATUS_SUCCESS;
787 }
788 
789 NTSTATUS
790 NTAPI
793  IN PIRP Irp,
794  IN PVOID Context)
795 {
798 }
799 
800 NTSTATUS
801 NTAPI
804 {
805  PKBDHID_DEVICE_EXTENSION DeviceExtension;
806 
807  /* get device extension */
808  DeviceExtension = DeviceObject->DeviceExtension;
809 
810  /* free resources */
811  if (DeviceExtension->PreparsedData)
812  {
813  ExFreePoolWithTag(DeviceExtension->PreparsedData, KBDHID_TAG);
814  DeviceExtension->PreparsedData = NULL;
815  }
816 
817  if (DeviceExtension->UsageListBuffer)
818  {
819  ExFreePoolWithTag(DeviceExtension->UsageListBuffer, KBDHID_TAG);
820  DeviceExtension->UsageListBuffer = NULL;
821  DeviceExtension->CurrentUsageList = NULL;
822  DeviceExtension->PreviousUsageList = NULL;
823  DeviceExtension->MakeUsageList = NULL;
824  DeviceExtension->BreakUsageList = NULL;
825  }
826 
827  if (DeviceExtension->ReportMDL)
828  {
829  IoFreeMdl(DeviceExtension->ReportMDL);
830  DeviceExtension->ReportMDL = NULL;
831  }
832 
833  if (DeviceExtension->Report)
834  {
835  ExFreePoolWithTag(DeviceExtension->Report, KBDHID_TAG);
836  DeviceExtension->Report = NULL;
837  }
838 
839  return STATUS_SUCCESS;
840 }
841 
842 NTSTATUS
843 NTAPI
846  IN PIRP Irp)
847 {
848  PIO_STACK_LOCATION IoStack;
849  PKBDHID_DEVICE_EXTENSION DeviceExtension;
850 
851  /* get device extension */
852  DeviceExtension = DeviceObject->DeviceExtension;
853 
854  /* skip current stack location */
856 
857  /* get next stack location */
858  IoStack = IoGetNextIrpStackLocation(Irp);
859 
860  /* change request to hid flush queue request */
862  IoStack->Parameters.DeviceIoControl.IoControlCode = IOCTL_HID_FLUSH_QUEUE;
863 
864  /* call device */
865  return IoCallDriver(DeviceExtension->NextDeviceObject, Irp);
866 }
867 
868 NTSTATUS
869 NTAPI
872  IN PIRP Irp)
873 {
874  PIO_STACK_LOCATION IoStack;
875  KEVENT Event;
877  PKBDHID_DEVICE_EXTENSION DeviceExtension;
878 
879  /* get device extension */
880  DeviceExtension = DeviceObject->DeviceExtension;
881 
882  /* get current irp stack */
884  DPRINT("[KBDHID] IRP_MJ_PNP Request: %x\n", IoStack->MinorFunction);
885 
886  switch (IoStack->MinorFunction)
887  {
888  case IRP_MN_STOP_DEVICE:
890  /* free resources */
892  /* fall through */
897  /* indicate success */
898  Irp->IoStatus.Status = STATUS_SUCCESS;
899 
900  /* skip irp stack location */
902 
903  /* dispatch to lower device */
904  return IoCallDriver(DeviceExtension->NextDeviceObject, Irp);
905 
907  /* FIXME synchronization */
908 
909  /* cancel irp */
910  IoCancelIrp(DeviceExtension->Irp);
911 
912  /* free resources */
914 
915  /* indicate success */
916  Irp->IoStatus.Status = STATUS_SUCCESS;
917 
918  /* skip irp stack location */
920 
921  /* dispatch to lower device */
922  Status = IoCallDriver(DeviceExtension->NextDeviceObject, Irp);
923 
924  IoFreeIrp(DeviceExtension->Irp);
925  IoDetachDevice(DeviceExtension->NextDeviceObject);
927  return Status;
928 
929  case IRP_MN_START_DEVICE:
930  /* init event */
932 
933  /* copy stack location */
935 
936  /* set completion routine */
938  Irp->IoStatus.Status = 0;
939 
940  /* pass request */
941  Status = IoCallDriver(DeviceExtension->NextDeviceObject, Irp);
942  if (Status == STATUS_PENDING)
943  {
945  Status = Irp->IoStatus.Status;
946  }
947 
948  if (!NT_SUCCESS(Status))
949  {
950  /* failed */
951  Irp->IoStatus.Status = Status;
953  return Status;
954  }
955 
956  /* lets start the device */
958  DPRINT("KbdHid_StartDevice %x\n", Status);
959 
960  /* complete request */
961  Irp->IoStatus.Status = Status;
963 
964  /* done */
965  return Status;
966 
967  default:
968  /* skip irp stack location */
970 
971  /* dispatch to lower device */
972  return IoCallDriver(DeviceExtension->NextDeviceObject, Irp);
973  }
974 }
975 
976 NTSTATUS
977 NTAPI
981 {
984  PKBDHID_DEVICE_EXTENSION DeviceExtension;
986 
987  /* create device object */
989  sizeof(KBDHID_DEVICE_EXTENSION),
990  NULL,
992  0,
993  FALSE,
994  &DeviceObject);
995  if (!NT_SUCCESS(Status))
996  {
997  /* failed to create device object */
998  return Status;
999  }
1000 
1001  /* now attach it */
1003  if (!NextDeviceObject)
1004  {
1005  /* failed to attach */
1008  }
1009 
1010  /* get device extension */
1011  DeviceExtension = DeviceObject->DeviceExtension;
1012 
1013  /* zero extension */
1014  RtlZeroMemory(DeviceExtension, sizeof(KBDHID_DEVICE_EXTENSION));
1015 
1016  /* init device extension */
1017  DeviceExtension->NextDeviceObject = NextDeviceObject;
1019 
1020  /* init keyboard attributes */
1024  DeviceExtension->Attributes.NumberOfIndicators = 3; // caps, num lock, scroll lock
1025  DeviceExtension->Attributes.NumberOfKeysTotal = 101;
1026  DeviceExtension->Attributes.InputDataQueueLength = 1;
1031 
1032  /* allocate irp */
1033  DeviceExtension->Irp = IoAllocateIrp(NextDeviceObject->StackSize, FALSE);
1034 
1035  /* FIXME handle allocation error */
1036  ASSERT(DeviceExtension->Irp);
1037 
1038  /* set power state to D0 */
1039  State.DeviceState = PowerDeviceD0;
1041 
1042  /* init device object */
1045 
1046  /* completed successfully */
1047  return STATUS_SUCCESS;
1048 }
1049 
1050 VOID
1051 NTAPI
1054 {
1055  UNIMPLEMENTED;
1056 }
1057 
1058 
1059 NTSTATUS
1060 NTAPI
1063  IN PUNICODE_STRING RegPath)
1064 {
1065  /* initialize driver object */
1066  DriverObject->MajorFunction[IRP_MJ_CREATE] = KbdHid_Create;
1067  DriverObject->MajorFunction[IRP_MJ_CLOSE] = KbdHid_Close;
1071  DriverObject->MajorFunction[IRP_MJ_POWER] = KbdHid_Power;
1072  DriverObject->MajorFunction[IRP_MJ_PNP] = KbdHid_Pnp;
1074  DriverObject->DriverUnload = KbdHid_Unload;
1075  DriverObject->DriverExtension->AddDevice = KbdHid_AddDevice;
1076 
1077  /* done */
1078  return STATUS_SUCCESS;
1079 }
NTSTATUS KbdHid_InitiateRead(IN PKBDHID_DEVICE_EXTENSION DeviceExtension)
Definition: kbdhid.c:201
#define DO_DEVICE_INITIALIZING
Definition: env_spec_w32.h:399
KEYBOARD_TYPEMATIC_PARAMETERS KeyRepeatMaximum
Definition: ntddkbd.h:131
signed char * PCHAR
Definition: retypes.h:7
#define IRP_MN_CANCEL_REMOVE_DEVICE
#define DO_POWER_PAGABLE
PFILE_OBJECT FileObject
Definition: kbdhid.h:96
#define IN
Definition: typedefs.h:39
#define KBDHID_TAG
Definition: kbdhid.h:148
return STATUS_NOT_SUPPORTED
PUSAGE_AND_PAGE MakeUsageList
Definition: kbdhid.h:71
#define STATUS_PRIVILEGE_NOT_HELD
Definition: DriverTester.h:9
#define IOCTL_KEYBOARD_QUERY_TYPEMATIC
Definition: ntddkbd.h:41
_In_ __drv_aliasesMem PSTRING Prefix
Definition: rtlfuncs.h:1630
#define IRP_MJ_CREATE
Definition: rdpdr.c:44
#define LL
Definition: tui.h:84
#define IOCTL_KEYBOARD_QUERY_INDICATOR_TRANSLATION
Definition: ntddkbd.h:38
#define IRP_MN_REMOVE_DEVICE
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_Must_inspect_result_ _Out_writes_to_ DataLength PHIDP_DATA _Inout_ PULONG _In_ PHIDP_PREPARSED_DATA PreparsedData
Definition: hidpi.h:333
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
PUSAGE_AND_PAGE BreakUsageList
Definition: kbdhid.h:66
UCHAR Type
Definition: ntddkbd.h:101
PUSAGE_AND_PAGE PreviousUsageList
Definition: kbdhid.h:61
#define IRP_MJ_FLUSH_BUFFERS
VOID NTAPI IoReuseIrp(IN OUT PIRP Irp, IN NTSTATUS Status)
Definition: irp.c:1971
#define STATUS_MORE_PROCESSING_REQUIRED
Definition: shellext.h:68
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
#define TRUE
Definition: types.h:120
HIDAPI ULONG NTAPI HidP_MaxUsageListLength(IN HIDP_REPORT_TYPE ReportType, IN USAGE UsagePage OPTIONAL, IN PHIDP_PREPARSED_DATA PreparsedData)
Definition: hidp.c:79
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
NTSTATUS NTAPI KbdHid_Create(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: kbdhid.c:250
PDEVICE_OBJECT ClassDeviceObject
Definition: kbdhid.h:36
NTSTATUS NTAPI KbdHid_FreeResources(IN PDEVICE_OBJECT DeviceObject)
Definition: kbdhid.c:802
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG _In_opt_ PVOID Data
Definition: wdfdevice.h:4527
char CHAR
Definition: xmlstorage.h:175
#define IRP_MJ_PNP
Definition: cdrw_usr.h:52
VOID NTAPI MmBuildMdlForNonPagedPool(IN PMDL Mdl)
Definition: mdlsup.c:415
LONG NTSTATUS
Definition: precomp.h:26
INDICATOR_LIST IndicatorList[3]
Definition: kbdhid.c:16
struct _LOCAL_KEYBOARD_INDICATOR_TRANSLATION LOCAL_KEYBOARD_INDICATOR_TRANSLATION
_In_ ULONG _In_ ULONG State
Definition: potypes.h:516
VOID NTAPI IoDetachDevice(IN PDEVICE_OBJECT TargetDevice)
Definition: device.c:1296
#define KEYBOARD_CAPS_LOCK_ON
Definition: ntddkbd.h:81
KEYBOARD_TYPEMATIC_PARAMETERS KeyboardTypematic
Definition: kbdhid.h:126
PDEVICE_OBJECT PhysicalDeviceObject
Definition: btrfs_drv.h:1155
#define KEY_BREAK
Definition: ntddkbd.h:71
PDEVICE_OBJECT NextDeviceObject
Definition: kbdhid.h:21
LONG NTAPI KeSetEvent(IN PKEVENT Event, IN KPRIORITY Increment, IN BOOLEAN Wait)
Definition: eventobj.c:159
NTSTATUS NTAPI KeWaitForSingleObject(IN PVOID Object, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: wait.c:416
struct _KEYBOARD_TYPEMATIC_PARAMETERS KEYBOARD_TYPEMATIC_PARAMETERS
_In_ WDFREQUEST _In_ NTSTATUS _In_ ULONG_PTR Information
Definition: wdfrequest.h:1044
USHORT NumberOfKeysTotal
Definition: ntddkbd.h:128
struct _LOCAL_KEYBOARD_INDICATOR_TRANSLATION * PLOCAL_KEYBOARD_INDICATOR_TRANSLATION
#define IOCTL_HID_GET_COLLECTION_DESCRIPTOR
Definition: hidclass.h:58
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:264
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
#define IoSetCompletionRoutine(_Irp, _CompletionRoutine, _Context, _InvokeOnSuccess, _InvokeOnError, _InvokeOnCancel)
Definition: irp.cpp:498
struct _KEYBOARD_INDICATOR_PARAMETERS KEYBOARD_INDICATOR_PARAMETERS
FORCEINLINE VOID IoCopyCurrentIrpStackLocationToNext(_Inout_ PIRP Irp)
Definition: iofuncs.h:2868
UCHAR KIRQL
Definition: env_spec_w32.h:591
PUSAGE_AND_PAGE CurrentUsageList
Definition: kbdhid.h:56
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
return STATUS_NOT_IMPLEMENTED
NTSTATUS NTAPI KbdHid_ReadCompletion(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PVOID Context)
Definition: kbdhid.c:109
#define KEYBOARD_TYPEMATIC_RATE_MINIMUM
Definition: kbdhid.h:131
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
#define STATUS_SHARING_VIOLATION
Definition: udferr_usr.h:154
#define FALSE
Definition: types.h:117
_In_ PIRP Irp
Definition: csq.h:116
#define IRP_MN_QUERY_REMOVE_DEVICE
_Must_inspect_result_ typedef _Out_ PHIDP_CAPS Capabilities
Definition: hidclass.h:103
#define IOCTL_KEYBOARD_SET_TYPEMATIC
Definition: ntddkbd.h:44
#define KEYBOARD_TYPEMATIC_DELAY_MAXIMUM
Definition: kbdhid.h:135
PDEVICE_OBJECT NTAPI IoAttachDeviceToDeviceStack(IN PDEVICE_OBJECT SourceDevice, IN PDEVICE_OBJECT TargetDevice)
Definition: device.c:966
NTSTATUS KbdHid_SubmitRequest(PDEVICE_OBJECT DeviceObject, ULONG IoControlCode, ULONG InputBufferSize, PVOID InputBuffer, ULONG OutputBufferSize, PVOID OutputBuffer)
Definition: kbdhid.c:611
_In_ PVOID _In_ ULONG Event
Definition: iotypes.h:467
#define HID_USAGE_PAGE_KEYBOARD
Definition: hidusage.h:181
KEYBOARD_INDICATOR_PARAMETERS KeyboardIndicator
Definition: kbdhid.h:121
unsigned char BOOLEAN
#define KEYBOARD_TYPE_UNKNOWN
Definition: kbdhid.h:140
#define MICROSOFT_KBD_FUNC
Definition: kbdhid.h:139
KEVENT ReadCompletionEvent
Definition: kbdhid.h:31
#define MICROSOFT_KBD_101_TYPE
Definition: kbdhid.h:141
#define IoCompleteRequest
Definition: irp.c:1240
#define IOCTL_INTERNAL_KEYBOARD_DISABLE
Definition: kbdmou.h:65
Definition: bufpool.h:45
BOOLEAN NTAPI KbdHid_InsertScanCodes(IN PVOID Context, IN PCHAR NewScanCodes, IN ULONG Length)
Definition: kbdhid.c:52
HIDAPI NTSTATUS NTAPI HidP_GetCaps(IN PHIDP_PREPARSED_DATA PreparsedData, OUT PHIDP_CAPS Capabilities)
Definition: hidp.c:26
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
Definition: wdfdriver.h:213
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR OutputBuffer
Definition: wdfiotarget.h:859
KEYBOARD_TYPEMATIC_PARAMETERS KeyRepeatMinimum
Definition: ntddkbd.h:130
#define STATUS_DEVICE_NOT_CONNECTED
Definition: udferr_usr.h:160
VOID NTAPI KbdHid_Unload(IN PDRIVER_OBJECT DriverObject)
Definition: kbdhid.c:1052
KIRQL OldIrql
Definition: mm.h:1502
#define IRP_MN_QUERY_STOP_DEVICE
NTSTATUS NTAPI DriverEntry(IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING RegPath)
Definition: kbdhid.c:1061
Status
Definition: gdiplustypes.h:24
#define IOCTL_KEYBOARD_QUERY_INDICATORS
Definition: ntddkbd.h:35
#define IOCTL_INTERNAL_KEYBOARD_DISCONNECT
Definition: kbdmou.h:59
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR InputBuffer
Definition: wdfiotarget.h:949
#define IRP_MN_SURPRISE_REMOVAL
Definition: ntifs_ex.h:408
static const TBBUTTON Buttons[]
Definition: mplay32.c:41
#define IRP_MN_STOP_DEVICE
#define ASSERT(a)
Definition: mode.c:44
USAGE UsagePage
Definition: hidpi.h:151
NTSTATUS NTAPI KbdHid_InternalDeviceControl(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: kbdhid.c:363
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_PENDING
Definition: ntstatus.h:82
_In_ WDFCOLLECTION _In_ ULONG Index
#define DO_BUFFERED_IO
Definition: env_spec_w32.h:394
struct _HIDP_PREPARSED_DATA * PHIDP_PREPARSED_DATA
Definition: hidpi.h:39
USHORT NumberOfIndicators
Definition: ntddkbd.h:127
NTSTATUS NTAPI KbdHid_Pnp(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: kbdhid.c:870
#define IRP_MN_START_DEVICE
#define STATUS_CANCELLED
Definition: udferr_usr.h:170
NTSTATUS NTAPI KbdHid_Flush(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: kbdhid.c:844
#define IRP_MJ_INTERNAL_DEVICE_CONTROL
_Must_inspect_result_ HIDAPI NTSTATUS NTAPI HidP_TranslateUsageAndPagesToI8042ScanCodes(_In_reads_(UsageListLength) PUSAGE_AND_PAGE ChangedUsageList, _In_ ULONG UsageListLength, _In_ HIDP_KEYBOARD_DIRECTION KeyAction, _Inout_ PHIDP_KEYBOARD_MODIFIER_STATE ModifierState, _In_ PHIDP_INSERT_SCANCODES InsertCodesProcedure, _In_opt_ PVOID InsertCodesContext)
VOID NTAPI IoFreeMdl(PMDL Mdl)
Definition: iomdl.c:146
#define IOCTL_INTERNAL_KEYBOARD_CONNECT
Definition: kbdmou.h:56
#define IOCTL_HID_GET_COLLECTION_INFORMATION
Definition: hidclass.h:59
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
_Inout_opt_ PDEVICE_OBJECT _Inout_opt_ PDEVICE_OBJECT _Inout_opt_ PDEVICE_OBJECT * NextDeviceObject
Definition: ndis.h:4640
NTSTATUS NTAPI KbdHid_StartDevice(IN PDEVICE_OBJECT DeviceObject)
Definition: kbdhid.c:662
VOID(STDAPICALLTYPE * PSERVICE_CALLBACK_ROUTINE)(IN PVOID NormalContext, IN PVOID SystemArgument1, IN PVOID SystemArgument2, IN OUT PVOID SystemArgument3)
Definition: kbdmou.h:86
#define IRP_MJ_POWER
#define IRP_MJ_CLOSE
Definition: rdpdr.c:45
NTSTATUS NTAPI KbdHid_DeviceControl(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: kbdhid.c:567
struct _KEYBOARD_ATTRIBUTES KEYBOARD_ATTRIBUTES
_In_ WDFREQUEST _In_ size_t _In_ size_t _In_ ULONG IoControlCode
Definition: wdfio.h:318
KEYBOARD_ID KeyboardIdentifier
Definition: ntddkbd.h:124
UCHAR Subtype
Definition: ntddkbd.h:102
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetNextIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2695
#define KEY_E1
Definition: ntddkbd.h:73
NTSTATUS NTAPI KbdHid_CreateCompletion(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PVOID Context)
Definition: kbdhid.c:238
#define IRP_MJ_SYSTEM_CONTROL
NTSTATUS NTAPI KbdHid_SystemControl(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: kbdhid.c:599
#define KEYBOARD_TYPEMATIC_RATE_DEFAULT
Definition: kbdhid.h:133
PMDL NTAPI IoAllocateMdl(IN PVOID VirtualAddress, IN ULONG Length, IN BOOLEAN SecondaryBuffer, IN BOOLEAN ChargeQuota, IN PIRP Irp)
Definition: iomdl.c:22
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2793
VOID NTAPI IoDeleteDevice(IN PDEVICE_OBJECT DeviceObject)
Definition: device.c:1251
#define HIDP_LINK_COLLECTION_UNSPECIFIED
Definition: hidpi.h:185
PFILE_OBJECT FileObject
Definition: iotypes.h:3169
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
VOID NTAPI PoStartNextPowerIrp(IN PIRP Irp)
Definition: power.c:746
USAGE Usage
Definition: hidpi.h:150
USHORT NumberOfFunctionKeys
Definition: ntddkbd.h:126
NTSTATUS NTAPI KbdHid_AddDevice(IN PDRIVER_OBJECT DriverObject, IN PDEVICE_OBJECT PhysicalDeviceObject)
Definition: kbdhid.c:978
unsigned short USHORT
Definition: pedump.c:61
NTSTATUS NTAPI KbdHid_StartDeviceCompletion(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PVOID Context)
Definition: kbdhid.c:791
#define KEY_E0
Definition: ntddkbd.h:72
#define KEYBOARD_SCROLL_LOCK_ON
Definition: ntddkbd.h:83
ULONG InputDataQueueLength
Definition: ntddkbd.h:129
#define NULL
Definition: types.h:112
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218
VOID NTAPI KeRaiseIrql(KIRQL NewIrql, PKIRQL OldIrql)
Definition: spinlock.c:27
#define IoSkipCurrentIrpStackLocation(Irp)
Definition: ntifs_ex.h:421
NTSTATUS NTAPI KbdHid_Close(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: kbdhid.c:326
#define IOCTL_INTERNAL_KEYBOARD_ENABLE
Definition: kbdmou.h:62
PIRP NTAPI IoBuildDeviceIoControlRequest(IN ULONG IoControlCode, IN PDEVICE_OBJECT DeviceObject, IN PVOID InputBuffer, IN ULONG InputBufferLength, IN PVOID OutputBuffer, IN ULONG OutputBufferLength, IN BOOLEAN InternalDeviceIoControl, IN PKEVENT Event, IN PIO_STATUS_BLOCK IoStatusBlock)
Definition: irp.c:881
#define DPRINT1
Definition: precomp.h:8
#define IRP_MJ_READ
Definition: rdpdr.c:46
BOOLEAN NTAPI IoCancelIrp(IN PIRP Irp)
Definition: irp.c:1101
struct tagContext Context
Definition: acpixf.h:1034
VOID NTAPI IoFreeIrp(IN PIRP Irp)
Definition: irp.c:1666
PHIDP_PREPARSED_DATA PreparsedData
Definition: kbdhid.h:76
#define IOCTL_KEYBOARD_QUERY_ATTRIBUTES
Definition: ntddkbd.h:32
#define KEYBOARD_NUM_LOCK_ON
Definition: ntddkbd.h:82
__in UCHAR __in POWER_STATE __in_opt PVOID __in PIO_STATUS_BLOCK IoStatus
Definition: mxum.h:155
unsigned int ULONG
Definition: retypes.h:1
#define IO_NO_INCREMENT
Definition: iotypes.h:598
NTSTATUS NTAPI IoCreateDevice(IN PDRIVER_OBJECT DriverObject, IN ULONG DeviceExtensionSize, IN PUNICODE_STRING DeviceName, IN DEVICE_TYPE DeviceType, IN ULONG DeviceCharacteristics, IN BOOLEAN Exclusive, OUT PDEVICE_OBJECT *DeviceObject)
Definition: device.c:1031
#define UNIMPLEMENTED
Definition: debug.h:115
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
POWER_STATE NTAPI PoSetPowerState(IN PDEVICE_OBJECT DeviceObject, IN POWER_STATE_TYPE Type, IN POWER_STATE State)
Definition: power.c:717
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
NTSTATUS NTAPI KbdHid_Power(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: kbdhid.c:585
PIRP NTAPI IoAllocateIrp(IN CCHAR StackSize, IN BOOLEAN ChargeQuota)
Definition: irp.c:615
#define HIDP_STATUS_SUCCESS
Definition: hidpi.h:248
KEYBOARD_ATTRIBUTES Attributes
Definition: kbdhid.h:111
#define IRP_MN_CANCEL_STOP_DEVICE
#define STATUS_SUCCESS
Definition: shellext.h:65
USHORT UsageListLength
Definition: kbdhid.h:51
#define DPRINT
Definition: sndvol32.h:71
HIDAPI NTSTATUS NTAPI HidP_GetUsagesEx(IN HIDP_REPORT_TYPE ReportType, IN USHORT LinkCollection, OUT PUSAGE_AND_PAGE ButtonList, IN OUT ULONG *UsageLength, IN PHIDP_PREPARSED_DATA PreparsedData, IN PCHAR Report, IN ULONG ReportLength)
Definition: hidp.c:161
VOID NTAPI KeLowerIrql(KIRQL NewIrql)
Definition: spinlock.c:39
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:3128
#define IOCTL_KEYBOARD_SET_INDICATORS
Definition: ntddkbd.h:47
VOID NTAPI KeClearEvent(IN PKEVENT Event)
Definition: eventobj.c:22
#define KEYBOARD_TYPEMATIC_DELAY_MINIMUM
Definition: kbdhid.h:134
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
#define CHAR(Char)
#define IOCTL_HID_FLUSH_QUEUE
Definition: hidclass.h:57
HRESULT Create([out]ITransactionReceiver **ppReceiver)
#define FILE_DEVICE_KEYBOARD
Definition: winioctl.h:117
USHORT InputReportByteLength
Definition: hidpi.h:152
static LOCAL_KEYBOARD_INDICATOR_TRANSLATION IndicatorTranslation
Definition: kbdhid.c:19
HIDAPI NTSTATUS NTAPI HidP_UsageAndPageListDifference(IN PUSAGE_AND_PAGE PreviousUsageList, IN PUSAGE_AND_PAGE CurrentUsageList, OUT PUSAGE_AND_PAGE BreakUsageList, OUT PUSAGE_AND_PAGE MakeUsageList, IN ULONG UsageListLength)
Definition: hidp.c:176
HIDP_KEYBOARD_MODIFIER_STATE ModifierState
Definition: kbdhid.h:116
VOID KbdHid_DispatchInputData(IN PKBDHID_DEVICE_EXTENSION DeviceExtension, IN PKEYBOARD_INPUT_DATA InputData)
Definition: kbdhid.c:26
#define IRP_MJ_DEVICE_CONTROL
Definition: rdpdr.c:52
_Must_inspect_result_ _In_ WDFDMAENABLER _In_ _In_opt_ PWDF_OBJECT_ATTRIBUTES Attributes