Inspired by the following article - http://www.osronline.com/article.cfm?article=446 - I decided to try it out and write a simple filter driver for IMAGE class devices (webcams).
I have succesfully created and installed a simple filter driver that passes through all requests and prints out some information to DbgView.
Then, I have experimented with blocking IOCTL_KS_READ_STREAM control code - simply marked it as completed with WdfRequestComplete(request, STATUS_UNSUCCESSFUL).
Then, I planned to modify the requested picture (e.g. fill it with green color) and finally complications arose.
IOCTL_KS_READ_STREAM: Queue 0x0000057FE4E51758, Request 0x0000057FE4F2FCD8 OutputBufferLength 128 InputBufferLength 0 IoControlCode 3096599
From the debug output I see that I should supply something to the OutputBuffer.
However, the documenation says about InputBuffer - “The application places a pointer to an array of KSSTREAM_HEADER structures in the InBuffer parameter. Each describes a packet of data to be read.” (http://msdn.microsoft.com/en-us/library/windows/hardware/ff560827(v=vs.85).aspx)
Also, I couldn’t get neither the output nor the input one with WdfRequestRetrieveOutputBuffer routine. I receive an error - STATUS_INVALID_DEVICE_REQUEST. I’m pretty sure that it means “something about neither buffered nor direct I/O” - but I cannot get what should I do with that.
Another article (http://msdn.microsoft.com/en-us/library/windows/hardware/ff565432(v=vs.85).aspx) says something about “checking the validity of the user buffer’s address range and check whether the appropriate read or write access is permitted, using the ProbeForRead and ProbeForWrite support routines.”
I’m not sure if I’m on the right way. What should I do to get access to data buffer in order to modify it? I hope Tim R. could give me a clue…
Thanks a lot,
Anton