Hi,
I’m a driver-newbie and wanted to disable a key (+=) on my laptop and map the RShift key to this. I need this for a crazy reason and I know there are multiple ways of doing this and the driver approach is not necessarily the best, but I wanted to try this and changed the kbfiltr.c as follows. My questions are:
- Is there a better way of ignoring a keypress apart from using the KbFilter_ServiceCallback function ? Can the IsrHook be used in some way ? What needs to be done if I return with ContinueProcessing as FALSE ?
- The following code blocks the += key in most cases. However, whenever I keep pressing the key, a keypress finally escapes the code and is printed. Can someone please tell me what could be wrong with the same.
Thanks,
-AK
VOID
KbFilter_ServiceCallback(
IN PDEVICE_OBJECT DeviceObject,
IN PKEYBOARD_INPUT_DATA InputDataStart,
IN PKEYBOARD_INPUT_DATA InputDataEnd,
IN OUT PULONG InputDataConsumed
)
{
PDEVICE_EXTENSION devExt;
WDFDEVICE hDevice;
PKEYBOARD_INPUT_DATA pTmp1;
PKEYBOARD_INPUT_DATA pTmp2;
PKEYBOARD_INPUT_DATA pEnd;
hDevice = WdfWdmDeviceGetWdfDeviceHandle(DeviceObject);
devExt = FilterGetData(hDevice);
pTmp2 = InputDataStart;
pTmp1 = InputDataStart;
pEnd = InputDataEnd;
while (pTmp2 < pEnd)
{
if (pTmp2->MakeCode != 0x0D)
{
*pTmp1 = *pTmp2;
if (pTmp1->MakeCode == 0x36) // left shift
{
pTmp1->MakeCode = 0x0D;
}
pTmp1++;
}
pTmp2++;
}
pEnd = pTmp1; // pEnd is one more than the end of list
*InputDataConsumed = InputDataEnd - pEnd;
InputDataEnd = pEnd;
(*(PSERVICE_CALLBACK_ROUTINE)(ULONG_PTR) devExt->UpperConnectData.ClassService)(
devExt->UpperConnectData.ClassDeviceObject,
InputDataStart,
InputDataEnd,
InputDataConsumed);
return;
}