Dear,
I started developping a lower filter for a mouse device, thanks to advices picked from this thread I posted a week ago :
http://social.msdn.microsoft.com/Forums/en/wdk/thread/8159c403-283a-46d7-9418-a591639e1b6f
I went for the lower filter as it seemed to be simpler to me for now, due to my little understanding of the framework. I started from the filter toaster sample.
For the moment, I’m simply trying to invert left/right click by altering a HID report. Presently I’m doing the following :
-
Registering EvtIoRead in the default queue : ioQueueConfig.EvtIoRead = FilterEvtIoRead;
-
Printing the request buffer content, then trying to alter the buffer content, then printing the new buffer :
typedef struct __MOUSE_REPORT
{
unsigned char a;
unsigned char b;
unsigned char c;
unsigned char d;
unsigned char e;
unsigned char f;
unsigned char g;
}
MOUSE_REPORT, *PMOUSE_REPORT;
/* … */
VOID
FilterEvtIoRead (
IN WDFQUEUE Queue,
IN WDFREQUEST Request,
IN size_t Length
)
{
NTSTATUS status = STATUS_SUCCESS;
WDFDEVICE device;
PMOUSE_REPORT buffer;
UNREFERENCED_PARAMETER(Queue);
UNREFERENCED_PARAMETER(Request);
UNREFERENCED_PARAMETER(Length);
device = WdfIoQueueGetDevice(Queue);
// Get buffer out of WDFREQUEST
status = WdfRequestRetrieveOutputBuffer(Request,
sizeof(MOUSE_REPORT),
&buffer,
NULL);
if(!NT_SUCCESS(status)){
KdPrint((“WdfRequestRetrieveInputBuffer failed %x\n”, status));
}
KdPrint((“IoRead \t\t– %x %x %x %x %x %x %x\n”, buffer->a, buffer->b, buffer->c, buffer->d, buffer->e, buffer->f, buffer->g));
// Alter buffer : left click <-> right click.
if(buffer->b == 1)
buffer->b = 2;
else if(buffer->b == 2)
buffer->b = 1;
KdPrint((“IoRead ALT \t– %x %x %x %x %x %x %x\n”, buffer->a, buffer->b, buffer->c, buffer->d, buffer->e, buffer->f, buffer->g));
if (!NT_SUCCESS(status)) {
WdfRequestComplete(Request, status);
return;
}
FilterForwardRequest(Request, WdfDeviceGetIoTarget(device));
}
The initial buffer is precisely what I except it to be, ie. the HID report sent by the mouse. However, the way I modify it does not change anything to the way the mouse works. I suspect I’m modifying a temporary buffer.
Could you please tell me what’s the correct way to do this job ?
Best regards,