1

WDK kbfiltr.cコールバック ルーチンを編集して、Escキーをインターセプトし、'E' に置き換えました。
常に 2 つの 'E' に置き換わること以外は機能します。
したがって、押すEscと「ee」が出力されます。コードは次のとおりです。

{
PKEYBOARD_INPUT_DATA pCur = InputDataStart; 

PDEVICE_EXTENSION   devExt;
WDFDEVICE   hDevice;

hDevice = WdfWdmDeviceGetWdfDeviceHandle(DeviceObject);
devExt = FilterGetData(hDevice);

while (pCur < InputDataEnd)
{
ULONG consumed = 0;

if (pCur->MakeCode == 0x01) {//Esc
pCur->MakeCode = 0x12; //E
}
else{
pCur++;
continue;
}

// indicate one packet at a time
(*(PSERVICE_CALLBACK_ROUTINE)(ULONG_PTR) 
devExt->UpperConnectData.ClassService)(
devExt->UpperConnectData.ClassDeviceObject,
pCur,
pCur+1,
&consumed);
pCur++;
}
// tell the caller you consumed everything
*InputDataConsumed = (InputDataEnd-InputDataStart);

(*(PSERVICE_CALLBACK_ROUTINE)(ULONG_PTR) devExt->UpperConnectData.ClassService)(
devExt->UpperConnectData.ClassDeviceObject,
InputDataStart,
InputDataEnd,
InputDataConsumed);
}

私が間違っていることを知っている人はいますか?

4

1 に答える 1

1

これはコーディングエラーだったと思います。以下のようにコードを変更すると、動作するようです。

    {
PKEYBOARD_INPUT_DATA pCur = InputDataStart; 

PDEVICE_EXTENSION   devExt;
WDFDEVICE   hDevice;

hDevice = WdfWdmDeviceGetWdfDeviceHandle(DeviceObject);
devExt = FilterGetData(hDevice);

while (pCur < InputDataEnd)
{
ULONG consumed = 0;

if (pCur->MakeCode == 0x01) {//Esc
pCur->MakeCode = 0x12; //E
}

// indicate one packet at a time
(*(PSERVICE_CALLBACK_ROUTINE)(ULONG_PTR) 
devExt->UpperConnectData.ClassService)(
devExt->UpperConnectData.ClassDeviceObject,
pCur,
pCur+1,
&consumed);
pCur++;
}
// tell the caller you consumed everything
*InputDataConsumed = (InputDataEnd-InputDataStart);

}
于 2013-04-16T11:46:24.390 に答える