WdfRequestOutputBuffer(), buffer too small?

Hello,

We have a kmdf driver that uses buffered I/O and only processs IOCTL requests. I have a function that gets the input/output buffers, and it works properly for all of our IOCTL function codes except one… The user mode application passes in the sizeof the INPUTBUFFER and OUTPUTBUFFER structures as well as their sizes (65552 bytes, 66052 bytes, respectively). When we call WdfRequestOutputBuffer(), it fails with STATUS_BUFFER_TOO_SMALL, but we are passing in the output buffer’s size (66052), which came from the user mode IOCTL request. The following code works properly with our other functions that use the following function, so I don’t really understand why it isn’t working. I am hoping that another set of eyes will see my error… I would appreciate any suggestions. :slight_smile:

Thank you,

Mike

NTSTATUS GetInputOutputBuffers(
IN WDFREQUEST theRequest,
IN OUT WDFMEMORY* theInputMemory,
IN OUT WDFMEMORY* theOutputMemory,
IN OUT VOID** theInputBuffer,
IN OUT VOID** theOutputBuffer,
IN OUT size_t theInputBufferLength,
IN OUT size_t theOutputBufferLength)
{
NTSTATUS status = STATUS_SUCCESS;

PAGED_CODE();

// Get the request buffer and perform write operation here
status = WdfRequestRetrieveInputMemory(theRequest, theInputMemory);
if (NT_SUCCESS(status))
{
status = WdfRequestRetrieveInputBuffer(theRequest, theInputBufferLength, theInputBuffer, NULL);
if (NT_SUCCESS(status))
{
// Okay, we have the input buffer… Now, let’s get the output buffer…
status = WdfRequestRetrieveOutputMemory(theRequest, theOutputMemory);
if (NT_SUCCESS(status))
{
status = WdfRequestRetrieveOutputBuffer(theRequest, theOutputBufferLength, theOutputBuffer, NULL);
if (!NT_SUCCESS(status))
{
TraceEvents(TRACE_LEVEL_ERROR, DBG_IOCTL,
“File=‘%s’, Line=%d, Function=‘%s’, Status=0x%x %s\n”,
FILE, LINE,FUNCTION, status,
“Get output buffer and its size failed.”);
}
}
else
{
TraceEvents(TRACE_LEVEL_ERROR, DBG_IOCTL,
“File=‘%s’, Line=%d, Function=‘%s’, Status=0x%x %s\n”,
FILE, LINE,FUNCTION, status,
“Get output WDFMEMORY failed.”);
}
}
else
{
TraceEvents(TRACE_LEVEL_ERROR, DBG_IOCTL,
“File=‘%s’, Line=%d, Function=‘%s’, Status=0x%x %s\n”,
FILE, LINE,FUNCTION, status,
“Get input buffer and its size failed.”);
}
}
else
{
TraceEvents(TRACE_LEVEL_ERROR, DBG_IOCTL,
“File=‘%s’, Line=%d, Function=‘%s’, Status=0x%x %s\n”,
FILE, LINE,FUNCTION, status,
“Get input WDFMEMORY failed.”);
}

return status;
}

Please disregard this posting. I discovered that the user mode application was passing in a pointer to a pointer for the IOCTL call… Different developers with different code… Anyway, all is well! :slight_smile: