/*++ Copyright (c) 1997 Microsoft Corporation Module Name: kbfilter.h Abstract: This module contains the common private declarations for the keyboard packet filter Environment: kernel mode only Notes: Revision History: --*/ #ifndef KBFILTER_H #define KBFILTER_H #include "ntddk.h" #include "kbdmou.h" #include #include #define KBFILTER_POOL_TAG (ULONG) 'tlfK' #undef ExAllocatePool #define ExAllocatePool(type, size) \ ExAllocatePoolWithTag (type, size, KBFILTER_POOL_TAG) #if DBG #define TRAP() DbgBreakPoint() #define DbgRaiseIrql(_x_,_y_) KeRaiseIrql(_x_,_y_) #define DbgLowerIrql(_x_) KeLowerIrql(_x_) #define DebugPrint(_x_) DbgPrint _x_ #else // DBG #define TRAP() #define DbgRaiseIrql(_x_,_y_) #define DbgLowerIrql(_x_) #define DebugPrint(_x_) #endif #define MIN(_A_,_B_) (((_A_) < (_B_)) ? (_A_) : (_B_)) typedef struct _DEVICE_EXTENSION { // // A backpointer to the device object for which this is the extension // PDEVICE_OBJECT Self; // // "THE PDO" (ejected by the root bus or ACPI) // PDEVICE_OBJECT PDO; // // The top of the stack before this filter was added. AKA the location // to which all IRPS should be directed. // PDEVICE_OBJECT TopOfStack; // // Number of creates sent down // LONG EnableCount; // // The real connect data that this driver reports to // CONNECT_DATA UpperConnectData; // // Previous initialization and hook routines (and context) // PVOID UpperContext; PI8042_KEYBOARD_INITIALIZATION_ROUTINE UpperInitializationRoutine; PI8042_KEYBOARD_ISR UpperIsrHook; // // Write function from within KbFilter_IsrHook // IN PI8042_ISR_WRITE_PORT IsrWritePort; // // Queue the current packet (ie the one passed into KbFilter_IsrHook) // IN PI8042_QUEUE_PACKET QueueKeyboardPacket; // // Context for IsrWritePort, QueueKeyboardPacket // IN PVOID CallContext; // // current power state of the device // DEVICE_POWER_STATE DeviceState; BOOLEAN Started; BOOLEAN SurpriseRemoved; BOOLEAN Removed; } DEVICE_EXTENSION, *PDEVICE_EXTENSION; // // Prototypes // NTSTATUS KbFilter_AddDevice( IN PDRIVER_OBJECT DriverObject, IN PDEVICE_OBJECT BusDeviceObject ); NTSTATUS KbFilter_CreateClose ( IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp ); NTSTATUS KbFilter_DispatchPassThrough( IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp ); NTSTATUS KbFilter_InternIoCtl ( IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp ); NTSTATUS KbFilter_IoCtl ( IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp ); NTSTATUS KbFilter_PnP ( IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp ); NTSTATUS KbFilter_Power ( IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp ); NTSTATUS KbFilter_InitializationRoutine( IN PDEVICE_OBJECT DeviceObject, // InitializationContext IN PVOID SynchFuncContext, IN PI8042_SYNCH_READ_PORT ReadPort, IN PI8042_SYNCH_WRITE_PORT WritePort, OUT PBOOLEAN TurnTranslationOn ); BOOLEAN KbFilter_IsrHook( PDEVICE_OBJECT DeviceObject, // IsrContext PKEYBOARD_INPUT_DATA CurrentInput, POUTPUT_PACKET CurrentOutput, UCHAR StatusByte, PUCHAR DataByte, PBOOLEAN ContinueProcessing, PKEYBOARD_SCAN_STATE ScanState ); VOID KbFilter_ServiceCallback( IN PDEVICE_OBJECT DeviceObject, IN PKEYBOARD_INPUT_DATA InputDataStart, IN PKEYBOARD_INPUT_DATA InputDataEnd, IN OUT PULONG InputDataConsumed ); VOID KbFilter_Unload ( IN PDRIVER_OBJECT DriverObject ); #endif // KBFILTER_H