When testing my driver to be crash safe for various user input, I came
across an issue in my driver that I don't know how to handle. To eliminate
my own driver, I tested the same thing with the original WDK (WDK 6000)
sample osrusbfx2 driver. By modifying the testapp to send erronous input to
the driver, I could get the error/break even there. The sample uses the
parameters\wdf\DbgBreakOnError = 1. Now I wonder how it should be handled by
the driver, as the KMDF says it's an error.
How to reproduce:
To have some common code to look at, I use the sample KMDF osrusbfx2.
Modify the testapp to call the driver with
IOCTL_OSRUSBFX2_GET_7_SEGMENT_DISPLAY and put erronous parameters in the
call:
if (!DeviceIoControl(deviceHandle,
IOCTL_OSRUSBFX2_GET_7_SEGMENT_DISPLAY,
&sevenSegment, // Ptr to InBuffer,
NULL in example
sizeof(UCHAR), // Length of
InBuffer, 0 in example
&sevenSegment, // Ptr to OutBuffer
0, // Length of
OutBuffer
&index, // BytesReturned
0)) { // Ptr to Overlapped
structure
I've only seen it when input buffer pointer and length is valid and the
output buffer pointer is correct but oputput buffer length is zero.
By turning on Parameters\Wdf\DbgBreakOnError, I get:
>KMDF detected potentially invalid operation by canusb.sys. Turn on
>framework verifier to break into the debugger.
Turning on the verifier gives me
>410: FxRequest::CompleteInternal - Caller of this WDFREQUEST 7A104170, Irp
>0x862BB398 is passing an OuputBuffer address even though the
>OutputBufferLength is zero
<yes, there is a spell error in the log: OuputBuffer>
So, here's my question: if this is a driver error, how can it be corrected?
If this is just invalid parameters, why does the KMDF verifier break to the
debugger?
Regards,
Carl-Magnus Segerlund