31 ULONG InputDataConsumed;
33 if (!DeviceExtension->ClassService)
37 ASSERT(DeviceExtension->ClassService);
38 ASSERT(DeviceExtension->ClassDeviceObject);
44 (*(
PSERVICE_CALLBACK_ROUTINE)DeviceExtension->ClassService)(DeviceExtension->ClassDeviceObject, InputData, InputData + 1, &InputDataConsumed);
67 DPRINT(
"[KBDHID] ScanCode Index %lu ScanCode %x\n",
Index, NewScanCodes[
Index] & 0xFF);
82 if (NewScanCodes[
Index] & 0x80)
127 DPRINT1(
"[KBDHID] ReadCompletion terminating read Status %x\n",
Irp->IoStatus.Status);
144 DPRINT(
"[KBDHID] ReadCompletion %02x %02x %02x %02x %02x %02x %02x %02x %02x\n", DeviceExtension->
Report[0], DeviceExtension->
Report[1], DeviceExtension->
Report[2],
211 DeviceExtension->Irp->MdlAddress = DeviceExtension->ReportMDL;
221 IoStack->
FileObject = DeviceExtension->FileObject;
227 DeviceExtension->ReadReportActive =
TRUE;
259 DPRINT(
"[KBDHID]: IRP_MJ_CREATE\n");
308 DPRINT(
"[KBDHID] KbdHid_InitiateRead: status %x\n",
Status);
387 DPRINT1(
"[KBDHID] IOCTL_KEYBOARD_QUERY_ATTRIBUTES Buffer too small\n");
507 Irp->AssociatedIrp.SystemBuffer,
512 Irp->IoStatus.Information = 0;
527 Irp->AssociatedIrp.SystemBuffer,
532 Irp->IoStatus.Information = 0;
614 ULONG InputBufferSize,
616 ULONG OutputBufferSize,
686 DPRINT1(
"[KBDHID] failed to obtain collection information with %x\n",
Status);
709 DPRINT1(
"[KBDHID] failed to obtain collection information with %x\n",
Status);
833 if (DeviceExtension->
Report)
938 Irp->IoStatus.Status = 0;
static PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP Irp)
#define STATUS_PRIVILEGE_NOT_HELD
PDEVICE_OBJECT PhysicalDeviceObject
#define STATUS_NOT_SUPPORTED
#define STATUS_NOT_IMPLEMENTED
#define NT_SUCCESS(StatCode)
DRIVER_INITIALIZE DriverEntry
#define ExAllocatePoolWithTag(hernya, size, tag)
#define KeRaiseIrql(irql, oldIrql)
#define KeWaitForSingleObject(pEvt, foo, a, b, c)
#define KeInitializeEvent(pEvt, foo, foo2)
#define KeLowerIrql(oldIrql)
#define KeSetEvent(pEvt, foo, foo2)
VOID NTAPI KeClearEvent(IN PKEVENT Event)
#define IOCTL_HID_GET_COLLECTION_DESCRIPTOR
#define IOCTL_HID_FLUSH_QUEUE
_Must_inspect_result_ typedef _Out_ PHIDP_CAPS Capabilities
#define IOCTL_HID_GET_COLLECTION_INFORMATION
HIDAPI NTSTATUS NTAPI HidP_GetCaps(IN PHIDP_PREPARSED_DATA PreparsedData, OUT PHIDP_CAPS Capabilities)
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)
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)
HIDAPI ULONG NTAPI HidP_MaxUsageListLength(IN HIDP_REPORT_TYPE ReportType, IN USAGE UsagePage OPTIONAL, IN PHIDP_PREPARSED_DATA PreparsedData)
#define HIDP_STATUS_SUCCESS
_Must_inspect_result_ _Out_writes_to_ DataLength PHIDP_DATA _Inout_ PULONG _In_ PHIDP_PREPARSED_DATA PreparsedData
#define HIDP_LINK_COLLECTION_UNSPECIFIED
_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)
struct _HIDP_PREPARSED_DATA * PHIDP_PREPARSED_DATA
#define HID_USAGE_PAGE_KEYBOARD
#define IoSetCompletionRoutine(_Irp, _CompletionRoutine, _Context, _InvokeOnSuccess, _InvokeOnError, _InvokeOnCancel)
NTSTATUS NTAPI KbdHid_DeviceControl(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
NTSTATUS NTAPI KbdHid_FreeResources(IN PDEVICE_OBJECT DeviceObject)
NTSTATUS NTAPI KbdHid_ReadCompletion(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PVOID Context)
NTSTATUS NTAPI KbdHid_Power(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
NTSTATUS NTAPI KbdHid_StartDevice(IN PDEVICE_OBJECT DeviceObject)
struct _LOCAL_KEYBOARD_INDICATOR_TRANSLATION LOCAL_KEYBOARD_INDICATOR_TRANSLATION
NTSTATUS NTAPI KbdHid_StartDeviceCompletion(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PVOID Context)
struct _LOCAL_KEYBOARD_INDICATOR_TRANSLATION * PLOCAL_KEYBOARD_INDICATOR_TRANSLATION
VOID KbdHid_DispatchInputData(IN PKBDHID_DEVICE_EXTENSION DeviceExtension, IN PKEYBOARD_INPUT_DATA InputData)
NTSTATUS NTAPI KbdHid_InternalDeviceControl(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
BOOLEAN NTAPI KbdHid_InsertScanCodes(IN PVOID Context, IN PCHAR NewScanCodes, IN ULONG Length)
NTSTATUS NTAPI KbdHid_Flush(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
NTSTATUS NTAPI KbdHid_CreateCompletion(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PVOID Context)
NTSTATUS NTAPI KbdHid_Create(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
NTSTATUS NTAPI KbdHid_Close(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
NTSTATUS KbdHid_SubmitRequest(PDEVICE_OBJECT DeviceObject, ULONG IoControlCode, ULONG InputBufferSize, PVOID InputBuffer, ULONG OutputBufferSize, PVOID OutputBuffer)
NTSTATUS NTAPI KbdHid_Pnp(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
NTSTATUS NTAPI KbdHid_SystemControl(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
VOID NTAPI KbdHid_Unload(IN PDRIVER_OBJECT DriverObject)
static LOCAL_KEYBOARD_INDICATOR_TRANSLATION IndicatorTranslation
NTSTATUS NTAPI KbdHid_AddDevice(IN PDRIVER_OBJECT DriverObject, IN PDEVICE_OBJECT PhysicalDeviceObject)
NTSTATUS KbdHid_InitiateRead(IN PKBDHID_DEVICE_EXTENSION DeviceExtension)
#define KEYBOARD_TYPEMATIC_DELAY_MINIMUM
#define KEYBOARD_TYPE_UNKNOWN
#define MICROSOFT_KBD_FUNC
#define MICROSOFT_KBD_101_TYPE
#define KEYBOARD_TYPEMATIC_DELAY_MAXIMUM
#define KEYBOARD_TYPEMATIC_RATE_MINIMUM
#define KEYBOARD_TYPEMATIC_RATE_DEFAULT
#define IOCTL_INTERNAL_KEYBOARD_ENABLE
#define IOCTL_INTERNAL_KEYBOARD_DISABLE
#define IOCTL_INTERNAL_KEYBOARD_CONNECT
VOID(STDAPICALLTYPE * PSERVICE_CALLBACK_ROUTINE)(IN PVOID NormalContext, IN PVOID SystemArgument1, IN PVOID SystemArgument2, IN OUT PVOID SystemArgument3)
#define IOCTL_INTERNAL_KEYBOARD_DISCONNECT
VOID NTAPI MmBuildMdlForNonPagedPool(IN PMDL Mdl)
#define ExFreePoolWithTag(_P, _T)
static const TBBUTTON Buttons[]
__in UCHAR __in POWER_STATE __in_opt PVOID __in PIO_STATUS_BLOCK IoStatus
_Inout_opt_ PDEVICE_OBJECT _Inout_opt_ PDEVICE_OBJECT _Inout_opt_ PDEVICE_OBJECT * NextDeviceObject
#define IOCTL_KEYBOARD_QUERY_TYPEMATIC
#define KEYBOARD_CAPS_LOCK_ON
struct _KEYBOARD_TYPEMATIC_PARAMETERS KEYBOARD_TYPEMATIC_PARAMETERS
#define IOCTL_KEYBOARD_QUERY_INDICATORS
#define IOCTL_KEYBOARD_SET_INDICATORS
#define IOCTL_KEYBOARD_QUERY_ATTRIBUTES
#define IOCTL_KEYBOARD_QUERY_INDICATOR_TRANSLATION
#define KEYBOARD_SCROLL_LOCK_ON
#define IOCTL_KEYBOARD_SET_TYPEMATIC
struct _KEYBOARD_ATTRIBUTES KEYBOARD_ATTRIBUTES
struct _KEYBOARD_INDICATOR_PARAMETERS KEYBOARD_INDICATOR_PARAMETERS
#define KEYBOARD_NUM_LOCK_ON
_In_ ULONG _In_ ULONG _In_ ULONG Length
#define IRP_MN_SURPRISE_REMOVAL
#define IoSkipCurrentIrpStackLocation(Irp)
#define IoCopyCurrentIrpStackLocationToNext(Irp)
PDEVICE_OBJECT NTAPI IoAttachDeviceToDeviceStack(IN PDEVICE_OBJECT SourceDevice, IN PDEVICE_OBJECT TargetDevice)
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)
VOID NTAPI IoDetachDevice(IN PDEVICE_OBJECT TargetDevice)
VOID NTAPI IoDeleteDevice(IN PDEVICE_OBJECT DeviceObject)
#define IoCompleteRequest
PIRP NTAPI IoAllocateIrp(IN CCHAR StackSize, IN BOOLEAN ChargeQuota)
VOID NTAPI IoReuseIrp(IN OUT PIRP Irp, IN NTSTATUS Status)
BOOLEAN NTAPI IoCancelIrp(IN PIRP Irp)
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)
VOID NTAPI IoFreeIrp(IN PIRP Irp)
POWER_STATE NTAPI PoSetPowerState(IN PDEVICE_OBJECT DeviceObject, IN POWER_STATE_TYPE Type, IN POWER_STATE State)
VOID NTAPI PoStartNextPowerIrp(IN PIRP Irp)
#define FILE_DEVICE_KEYBOARD
#define IRP_MJ_DEVICE_CONTROL
#define STATUS_MORE_PROCESSING_REQUIRED
#define STATUS_BUFFER_TOO_SMALL
PDEVICE_OBJECT ClassDeviceObject
PDEVICE_OBJECT NextDeviceObject
KEYBOARD_TYPEMATIC_PARAMETERS KeyboardTypematic
PUSAGE_AND_PAGE PreviousUsageList
KEVENT ReadCompletionEvent
PUSAGE_AND_PAGE CurrentUsageList
PUSAGE_AND_PAGE MakeUsageList
PUSAGE_AND_PAGE BreakUsageList
PHIDP_PREPARSED_DATA PreparsedData
KEYBOARD_INDICATOR_PARAMETERS KeyboardIndicator
HIDP_KEYBOARD_MODIFIER_STATE ModifierState
KEYBOARD_ATTRIBUTES Attributes
USHORT InputReportByteLength
struct _IO_STACK_LOCATION::@1580::@1581 DeviceIoControl
struct _IO_STACK_LOCATION::@3979::@3983 Read
union _IO_STACK_LOCATION::@1580 Parameters
struct _IO_STACK_LOCATION::@3979::@3980 Create
KEYBOARD_ID KeyboardIdentifier
KEYBOARD_TYPEMATIC_PARAMETERS KeyRepeatMaximum
ULONG InputDataQueueLength
USHORT NumberOfIndicators
KEYBOARD_TYPEMATIC_PARAMETERS KeyRepeatMinimum
USHORT NumberOfFunctionKeys
INDICATOR_LIST IndicatorList[3]
USHORT NumberOfIndicatorKeys
#define RtlCopyMemory(Destination, Source, Length)
#define RtlZeroMemory(Destination, Length)
#define RtlMoveMemory(Destination, Source, Length)
#define STATUS_DEVICE_NOT_CONNECTED
#define STATUS_INVALID_PARAMETER
#define STATUS_SHARING_VIOLATION
#define STATUS_INSUFFICIENT_RESOURCES
_In_ WDFCOLLECTION _In_ ULONG Index
_Must_inspect_result_ _In_ WDFDMAENABLER _In_ _In_opt_ PWDF_OBJECT_ATTRIBUTES Attributes
_In_ PDEVICE_OBJECT DeviceObject
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
_In_ WDFREQUEST _In_ size_t _In_ size_t _In_ ULONG IoControlCode
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR OutputBuffer
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR InputBuffer
_In_ WDFREQUEST _In_ NTSTATUS _In_ ULONG_PTR Information
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetNextIrpStackLocation(_In_ PIRP Irp)
#define IRP_MN_CANCEL_STOP_DEVICE
#define IRP_MN_START_DEVICE
#define IRP_MN_REMOVE_DEVICE
#define IRP_MN_QUERY_STOP_DEVICE
#define IRP_MJ_SYSTEM_CONTROL
#define IRP_MJ_FLUSH_BUFFERS
#define IRP_MN_CANCEL_REMOVE_DEVICE
#define IRP_MJ_INTERNAL_DEVICE_CONTROL
#define IRP_MN_STOP_DEVICE
#define IRP_MN_QUERY_REMOVE_DEVICE
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
_In_ __drv_aliasesMem PSTRING Prefix