From f81fb355aeee2a60e2b939ac86b35122d7ed0509 Mon Sep 17 00:00:00 2001 From: Eric Kohl Date: Sun, 12 Sep 2021 14:40:26 +0200 Subject: [PATCH] [KBDHID] Implement IOCTL_KEYBOARD_QUERY_INDICATOR_TRANSLATION --- drivers/hid/kbdhid/kbdhid.c | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/drivers/hid/kbdhid/kbdhid.c b/drivers/hid/kbdhid/kbdhid.c index b07a7d8445c..e994d97d774 100644 --- a/drivers/hid/kbdhid/kbdhid.c +++ b/drivers/hid/kbdhid/kbdhid.c @@ -10,6 +10,18 @@ #include "kbdhid.h" +/* This structure starts with the same layout as KEYBOARD_INDICATOR_TRANSLATION */ +typedef struct _LOCAL_KEYBOARD_INDICATOR_TRANSLATION { + USHORT NumberOfIndicatorKeys; + INDICATOR_LIST IndicatorList[3]; +} LOCAL_KEYBOARD_INDICATOR_TRANSLATION, *PLOCAL_KEYBOARD_INDICATOR_TRANSLATION; + +static LOCAL_KEYBOARD_INDICATOR_TRANSLATION IndicatorTranslation = { 3, { + {0x3A, KEYBOARD_CAPS_LOCK_ON}, + {0x45, KEYBOARD_NUM_LOCK_ON}, + {0x46, KEYBOARD_SCROLL_LOCK_ON}}}; + + VOID KbdHid_DispatchInputData( IN PKBDHID_DEVICE_EXTENSION DeviceExtension, @@ -522,11 +534,24 @@ KbdHid_InternalDeviceControl( return STATUS_SUCCESS; case IOCTL_KEYBOARD_QUERY_INDICATOR_TRANSLATION: - /* not implemented */ - DPRINT1("IOCTL_KEYBOARD_QUERY_INDICATOR_TRANSLATION not implemented\n"); - Irp->IoStatus.Status = STATUS_NOT_IMPLEMENTED; + if (IoStack->Parameters.DeviceIoControl.OutputBufferLength < sizeof(LOCAL_KEYBOARD_INDICATOR_TRANSLATION)) + { + /* buffer too small */ + Irp->IoStatus.Status = STATUS_BUFFER_TOO_SMALL; + IoCompleteRequest(Irp, IO_NO_INCREMENT); + return STATUS_INVALID_PARAMETER; + } + + /* copy translations */ + RtlCopyMemory(Irp->AssociatedIrp.SystemBuffer, + &IndicatorTranslation, + sizeof(LOCAL_KEYBOARD_INDICATOR_TRANSLATION)); + + /* done */ + Irp->IoStatus.Status = STATUS_SUCCESS; + Irp->IoStatus.Information = sizeof(LOCAL_KEYBOARD_INDICATOR_TRANSLATION); IoCompleteRequest(Irp, IO_NO_INCREMENT); - return STATUS_NOT_IMPLEMENTED; + return STATUS_SUCCESS; } /* unknown control code */