Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

200 lines
3.9 KiB

  1. /*++
  2. Copyright (c) 1997 Microsoft Corporation
  3. Module Name:
  4. kbfilter.h
  5. Abstract:
  6. This module contains the common private declarations for the keyboard
  7. packet filter
  8. Environment:
  9. kernel mode only
  10. Notes:
  11. Revision History:
  12. --*/
  13. #ifndef KBFILTER_H
  14. #define KBFILTER_H
  15. #include "ntddk.h"
  16. #include "kbdmou.h"
  17. #include <ntddkbd.h>
  18. #include <ntdd8042.h>
  19. #define KBFILTER_POOL_TAG (ULONG) 'tlfK'
  20. #undef ExAllocatePool
  21. #define ExAllocatePool(type, size) \
  22. ExAllocatePoolWithTag (type, size, KBFILTER_POOL_TAG)
  23. #if DBG
  24. #define TRAP() DbgBreakPoint()
  25. #define DbgRaiseIrql(_x_,_y_) KeRaiseIrql(_x_,_y_)
  26. #define DbgLowerIrql(_x_) KeLowerIrql(_x_)
  27. #define DebugPrint(_x_) DbgPrint _x_
  28. #else // DBG
  29. #define TRAP()
  30. #define DbgRaiseIrql(_x_,_y_)
  31. #define DbgLowerIrql(_x_)
  32. #define DebugPrint(_x_)
  33. #endif
  34. #define MIN(_A_,_B_) (((_A_) < (_B_)) ? (_A_) : (_B_))
  35. typedef struct _DEVICE_EXTENSION
  36. {
  37. //
  38. // A backpointer to the device object for which this is the extension
  39. //
  40. PDEVICE_OBJECT Self;
  41. //
  42. // "THE PDO" (ejected by the root bus or ACPI)
  43. //
  44. PDEVICE_OBJECT PDO;
  45. //
  46. // The top of the stack before this filter was added. AKA the location
  47. // to which all IRPS should be directed.
  48. //
  49. PDEVICE_OBJECT TopOfStack;
  50. //
  51. // Number of creates sent down
  52. //
  53. LONG EnableCount;
  54. //
  55. // The real connect data that this driver reports to
  56. //
  57. CONNECT_DATA UpperConnectData;
  58. //
  59. // Previous initialization and hook routines (and context)
  60. //
  61. PVOID UpperContext;
  62. PI8042_KEYBOARD_INITIALIZATION_ROUTINE UpperInitializationRoutine;
  63. PI8042_KEYBOARD_ISR UpperIsrHook;
  64. //
  65. // Write function from within KbFilter_IsrHook
  66. //
  67. IN PI8042_ISR_WRITE_PORT IsrWritePort;
  68. //
  69. // Queue the current packet (ie the one passed into KbFilter_IsrHook)
  70. //
  71. IN PI8042_QUEUE_PACKET QueueKeyboardPacket;
  72. //
  73. // Context for IsrWritePort, QueueKeyboardPacket
  74. //
  75. IN PVOID CallContext;
  76. //
  77. // current power state of the device
  78. //
  79. DEVICE_POWER_STATE DeviceState;
  80. BOOLEAN Started;
  81. BOOLEAN SurpriseRemoved;
  82. BOOLEAN Removed;
  83. } DEVICE_EXTENSION, *PDEVICE_EXTENSION;
  84. //
  85. // Prototypes
  86. //
  87. NTSTATUS
  88. KbFilter_AddDevice(
  89. IN PDRIVER_OBJECT DriverObject,
  90. IN PDEVICE_OBJECT BusDeviceObject
  91. );
  92. NTSTATUS
  93. KbFilter_CreateClose (
  94. IN PDEVICE_OBJECT DeviceObject,
  95. IN PIRP Irp
  96. );
  97. NTSTATUS
  98. KbFilter_DispatchPassThrough(
  99. IN PDEVICE_OBJECT DeviceObject,
  100. IN PIRP Irp
  101. );
  102. NTSTATUS
  103. KbFilter_InternIoCtl (
  104. IN PDEVICE_OBJECT DeviceObject,
  105. IN PIRP Irp
  106. );
  107. NTSTATUS
  108. KbFilter_IoCtl (
  109. IN PDEVICE_OBJECT DeviceObject,
  110. IN PIRP Irp
  111. );
  112. NTSTATUS
  113. KbFilter_PnP (
  114. IN PDEVICE_OBJECT DeviceObject,
  115. IN PIRP Irp
  116. );
  117. NTSTATUS
  118. KbFilter_Power (
  119. IN PDEVICE_OBJECT DeviceObject,
  120. IN PIRP Irp
  121. );
  122. NTSTATUS
  123. KbFilter_InitializationRoutine(
  124. IN PDEVICE_OBJECT DeviceObject, // InitializationContext
  125. IN PVOID SynchFuncContext,
  126. IN PI8042_SYNCH_READ_PORT ReadPort,
  127. IN PI8042_SYNCH_WRITE_PORT WritePort,
  128. OUT PBOOLEAN TurnTranslationOn
  129. );
  130. BOOLEAN
  131. KbFilter_IsrHook(
  132. PDEVICE_OBJECT DeviceObject, // IsrContext
  133. PKEYBOARD_INPUT_DATA CurrentInput,
  134. POUTPUT_PACKET CurrentOutput,
  135. UCHAR StatusByte,
  136. PUCHAR DataByte,
  137. PBOOLEAN ContinueProcessing,
  138. PKEYBOARD_SCAN_STATE ScanState
  139. );
  140. VOID
  141. KbFilter_ServiceCallback(
  142. IN PDEVICE_OBJECT DeviceObject,
  143. IN PKEYBOARD_INPUT_DATA InputDataStart,
  144. IN PKEYBOARD_INPUT_DATA InputDataEnd,
  145. IN OUT PULONG InputDataConsumed
  146. );
  147. VOID
  148. KbFilter_Unload (
  149. IN PDRIVER_OBJECT DriverObject
  150. );
  151. #endif // KBFILTER_H