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.

266 lines
5.1 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 WinKey_H
  14. #define WinKey_H
  15. #include "ntddk.h"
  16. #include "kbdmou.h"
  17. #include <ntddmou.h>
  18. #include <ntddkbd.h>
  19. #include <ntdd8042.h>
  20. #include "wmilib.h"
  21. #include "winkeycmn.h"
  22. #define WinKey_POOL_TAG (ULONG) 'KniW'
  23. #undef ExAllocatePool
  24. #define ExAllocatePool(type, size) \
  25. ExAllocatePoolWithTag (type, size, WinKey_POOL_TAG)
  26. #if DBG
  27. #define TRAP() DbgBreakPoint()
  28. #define DbgRaiseIrql(_x_,_y_) KeRaiseIrql(_x_,_y_)
  29. #define DbgLowerIrql(_x_) KeLowerIrql(_x_)
  30. #define DebugPrint(_x_) DbgPrint _x_
  31. #else // DBG
  32. #define TRAP()
  33. #define DbgRaiseIrql(_x_,_y_)
  34. #define DbgLowerIrql(_x_)
  35. #define DebugPrint(_x_)
  36. #endif
  37. #define MIN(_A_,_B_) (((_A_) < (_B_)) ? (_A_) : (_B_))
  38. typedef struct _DEVICE_EXTENSION
  39. {
  40. //
  41. // A backpointer to the device object for which this is the extension
  42. //
  43. PDEVICE_OBJECT Self;
  44. //
  45. // "THE PDO" (ejected by the root bus or ACPI)
  46. //
  47. PDEVICE_OBJECT PDO;
  48. //
  49. // The top of the stack before this filter was added. AKA the location
  50. // to which all IRPS should be directed.
  51. //
  52. PDEVICE_OBJECT TopOfStack;
  53. //
  54. // Number of creates sent down
  55. //
  56. LONG EnableCount;
  57. //
  58. // The real connect data that this driver reports to
  59. //
  60. CONNECT_DATA UpperConnectData;
  61. //
  62. // WMI info
  63. //
  64. WMILIB_CONTEXT WmiLibInfo;
  65. //
  66. // Previous initialization and hook routines (and context)
  67. //
  68. PI8042_KEYBOARD_INITIALIZATION_ROUTINE UpperInitializationRoutine;
  69. PVOID UpperContext;
  70. PI8042_KEYBOARD_ISR UpperIsrHook;
  71. //
  72. // Write function from within WinKey_IsrHook
  73. //
  74. IN PI8042_ISR_WRITE_PORT IsrWritePort;
  75. //
  76. // Queue the current packet (ie the one passed into WinKey_IsrHook)
  77. //
  78. IN PI8042_QUEUE_PACKET QueueKeyboardPacket;
  79. //
  80. // Context for IsrWritePort, QueueKeyboardPacket
  81. //
  82. IN PVOID CallContext;
  83. //
  84. // current power state of the device
  85. //
  86. DEVICE_POWER_STATE DeviceState;
  87. BOOLEAN Started;
  88. BOOLEAN SurpriseRemoved;
  89. BOOLEAN Removed;
  90. } DEVICE_EXTENSION, *PDEVICE_EXTENSION;
  91. typedef struct _GLOBALS {
  92. UNICODE_STRING RegistryPath;
  93. } GLOBALS;
  94. extern GLOBALS Globals;
  95. //
  96. // Prototypes
  97. //
  98. NTSTATUS
  99. WinKey_AddDevice(
  100. IN PDRIVER_OBJECT DriverObject,
  101. IN PDEVICE_OBJECT BusDeviceObject
  102. );
  103. NTSTATUS
  104. WinKey_CreateClose (
  105. IN PDEVICE_OBJECT DeviceObject,
  106. IN PIRP Irp
  107. );
  108. NTSTATUS
  109. WinKey_DispatchPassThrough(
  110. IN PDEVICE_OBJECT DeviceObject,
  111. IN PIRP Irp
  112. );
  113. NTSTATUS
  114. WinKey_InternIoCtl (
  115. IN PDEVICE_OBJECT DeviceObject,
  116. IN PIRP Irp
  117. );
  118. NTSTATUS
  119. WinKey_IoCtl (
  120. IN PDEVICE_OBJECT DeviceObject,
  121. IN PIRP Irp
  122. );
  123. NTSTATUS
  124. WinKey_PnP (
  125. IN PDEVICE_OBJECT DeviceObject,
  126. IN PIRP Irp
  127. );
  128. NTSTATUS
  129. WinKey_Power (
  130. IN PDEVICE_OBJECT DeviceObject,
  131. IN PIRP Irp
  132. );
  133. NTSTATUS
  134. WinKey_InitializationRoutine(
  135. IN PDEVICE_OBJECT DeviceObject, // InitializationContext
  136. IN PVOID SynchFuncContext,
  137. IN PI8042_SYNCH_READ_PORT ReadPort,
  138. IN PI8042_SYNCH_WRITE_PORT WritePort,
  139. OUT PBOOLEAN TurnTranslationOn
  140. );
  141. BOOLEAN
  142. WinKey_IsrHook(
  143. PDEVICE_OBJECT DeviceObject, // IsrContext
  144. PKEYBOARD_INPUT_DATA CurrentInput,
  145. POUTPUT_PACKET CurrentOutput,
  146. UCHAR StatusByte,
  147. PUCHAR DataByte,
  148. PBOOLEAN ContinueProcessing,
  149. PKEYBOARD_SCAN_STATE ScanState
  150. );
  151. VOID
  152. WinKey_ServiceCallback(
  153. IN PDEVICE_OBJECT DeviceObject,
  154. IN PKEYBOARD_INPUT_DATA InputDataStart,
  155. IN PKEYBOARD_INPUT_DATA InputDataEnd,
  156. IN OUT PULONG InputDataConsumed
  157. );
  158. NTSTATUS
  159. WinKey_SystemControl(
  160. IN PDEVICE_OBJECT DeviceObject,
  161. IN PIRP Irp
  162. );
  163. NTSTATUS
  164. WinKey_SetWmiDataItem(
  165. IN PDEVICE_OBJECT DeviceObject,
  166. IN PIRP Irp,
  167. IN ULONG GuidIndex,
  168. IN ULONG InstanceIndex,
  169. IN ULONG DataItemId,
  170. IN ULONG BufferSize,
  171. IN PUCHAR Buffer
  172. );
  173. NTSTATUS
  174. WinKey_SetWmiDataBlock(
  175. IN PDEVICE_OBJECT DeviceObject,
  176. IN PIRP Irp,
  177. IN ULONG GuidIndex,
  178. IN ULONG InstanceIndex,
  179. IN ULONG BufferSize,
  180. IN PUCHAR Buffer
  181. );
  182. NTSTATUS
  183. WinKey_QueryWmiDataBlock(
  184. IN PDEVICE_OBJECT DeviceObject,
  185. IN PIRP Irp,
  186. IN ULONG GuidIndex,
  187. IN ULONG InstanceIndex,
  188. IN ULONG InstanceCount,
  189. IN OUT PULONG InstanceLengthArray,
  190. IN ULONG BufferAvail,
  191. OUT PUCHAR Buffer
  192. );
  193. NTSTATUS
  194. WinKey_QueryWmiRegInfo(
  195. IN PDEVICE_OBJECT DeviceObject,
  196. OUT ULONG *RegFlags,
  197. OUT PUNICODE_STRING InstanceName,
  198. OUT PUNICODE_STRING *RegistryPath,
  199. OUT PUNICODE_STRING MofResourceName,
  200. OUT PDEVICE_OBJECT *Pdo
  201. );
  202. VOID
  203. WinKey_Unload (
  204. IN PDRIVER_OBJECT DriverObject
  205. );
  206. #endif // WinKey_H