WdfIoTargetSendIoctlSynchronously returns STATUS_BUFFER_TOO_SMALL

WdfIoTargetSendIoctlSynchronously returns STATUS_BUFFER_TOO_SMALL

Driver Calling IOCTL

//Describe the input buffer
WDF_MEMORY_DESCRIPTOR_INIT_BUFFER(&InputBuffer, &MyBuffer, sizeof(MyBuffer)); // size = 0x52

// Send the write request synchronously.
status = WdfIoTargetSendIoctlSynchronously(
IoTarget,
NULL,
(ULONG) IOCTL_XXXX, // BUFFERED_IO
&InputBuffer,
NULL,
NULL,
&BytesReturned);
if (!NT_SUCCESS(status)) {?} // status is STATUS_BUFFER_TOO_SMALL

Code on the IoTarget

  • WdfRequestRetrieveInputBuffer (Request, 2, (PVOID *) &InputBuffer, &InputSize);
    // InputSize is now 0x52
  • I process the data and call WdfRequestSetInformation(Request, 0x28) before completing the request.
    // 0x28 is what I want the Information to be.

When the WdfIoTargetSendIoctlSynchronously returns, I see that the BytesReturned = 0x28 as I expect, but I get an error STATUS_BUFFER_TOO_SMALL. I know that the framework is trying to copy from the SystemBuffer to my buffer, but why? I have specified the OutputBuffer as NULL when I called WdfIoTargetSendIoctlSynchronously.

Thanks
Umesh

xxxxx@gmail.com wrote:

WdfIoTargetSendIoctlSynchronously returns STATUS_BUFFER_TOO_SMALL

Code on the IoTarget

  • WdfRequestRetrieveInputBuffer (Request, 2, (PVOID *) &InputBuffer, &InputSize);
    // InputSize is now 0x52
  • I process the data and call WdfRequestSetInformation(Request, 0x28) before completing the request.
    // 0x28 is what I want the Information to be.

When the WdfIoTargetSendIoctlSynchronously returns, I see that the BytesReturned = 0x28 as I expect, but I get an error STATUS_BUFFER_TOO_SMALL. I know that the framework is trying to copy from the SystemBuffer to my buffer, but why? I have specified the OutputBuffer as NULL when I called WdfIoTargetSendIoctlSynchronously.

This is just an additional semantic that KMDF imposes. The Information
field is always used to specify how many bytes to copy to the output
buffer. If there is no output buffer, that’s an error. In
kernel-to-kernel communication, it is possible to use the Information
field for arbitrary out-of-band communication, but KMDF doesn’t know
whether this request came from user-mode or kernel-mode, so it raises
the error.

You have a couple of choices. The easiest is to pass &InputBuffer as
the output buffer.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

What NTSTATUS value are you completing the request with?

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@gmail.com
Sent: Wednesday, February 27, 2013 12:23 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] WdfIoTargetSendIoctlSynchronously returns STATUS_BUFFER_TOO_SMALL

WdfIoTargetSendIoctlSynchronously returns STATUS_BUFFER_TOO_SMALL

Driver Calling IOCTL

//Describe the input buffer
WDF_MEMORY_DESCRIPTOR_INIT_BUFFER(&InputBuffer, &MyBuffer, sizeof(MyBuffer)); // size = 0x52

// Send the write request synchronously.
status = WdfIoTargetSendIoctlSynchronously(
IoTarget,
NULL,
(ULONG) IOCTL_XXXX, // BUFFERED_IO
&InputBuffer,
NULL,
NULL,
&BytesReturned);
if (!NT_SUCCESS(status)) {?} // status is STATUS_BUFFER_TOO_SMALL

Code on the IoTarget

  • WdfRequestRetrieveInputBuffer (Request, 2, (PVOID *) &InputBuffer, &InputSize); // InputSize is now 0x52
  • I process the data and call WdfRequestSetInformation(Request, 0x28) before completing the request.
    // 0x28 is what I want the Information to be.

When the WdfIoTargetSendIoctlSynchronously returns, I see that the BytesReturned = 0x28 as I expect, but I get an error STATUS_BUFFER_TOO_SMALL. I know that the framework is trying to copy from the SystemBuffer to my buffer, but why? I have specified the OutputBuffer as NULL when I called WdfIoTargetSendIoctlSynchronously.

Thanks
Umesh


NTDEV is sponsored by OSR

OSR is HIRING!! See http://www.osr.com/careers

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

I was assuming that the framework returns this error, but looks like I was
completing it with the STATUS_BUFFER_TOO_SMALL. I was missing a break from
my IOCTL switch that resulted in a wrong status value in the completion
call.

Thanks for your help
Umesh

On 27 February 2013 13:56, Doron Holan wrote:

> What NTSTATUS value are you completing the request with?
>
> -----Original Message-----
> From: xxxxx@lists.osr.com [mailto:
> xxxxx@lists.osr.com] On Behalf Of xxxxx@gmail.com
> Sent: Wednesday, February 27, 2013 12:23 PM
> To: Windows System Software Devs Interest List
> Subject: [ntdev] WdfIoTargetSendIoctlSynchronously returns
> STATUS_BUFFER_TOO_SMALL
>
> WdfIoTargetSendIoctlSynchronously returns STATUS_BUFFER_TOO_SMALL
>
> Driver Calling IOCTL
> ============
> //Describe the input buffer
> WDF_MEMORY_DESCRIPTOR_INIT_BUFFER(&InputBuffer, &MyBuffer,
> sizeof(MyBuffer)); // size = 0x52
>
> // Send the write request synchronously.
> status = WdfIoTargetSendIoctlSynchronously(
> IoTarget,
> NULL,
> (ULONG) IOCTL_XXXX, // BUFFERED_IO
> &InputBuffer,
> NULL,
> NULL,
> &BytesReturned);
> if (!NT_SUCCESS(status)) {?} // status is STATUS_BUFFER_TOO_SMALL
>
> Code on the IoTarget
> ==============
> - WdfRequestRetrieveInputBuffer (Request, 2, (PVOID *) &InputBuffer,
> &InputSize); // InputSize is now 0x52
> - I process the data and call WdfRequestSetInformation(Request, 0x28)
> before completing the request.
> // 0x28 is what I want the Information to be.
>
> When the WdfIoTargetSendIoctlSynchronously returns, I see that the
> BytesReturned = 0x28 as I expect, but I get an error
> STATUS_BUFFER_TOO_SMALL. I know that the framework is trying to copy from
> the SystemBuffer to my buffer, but why? I have specified the OutputBuffer
> as NULL when I called WdfIoTargetSendIoctlSynchronously.
>
> Thanks
> Umesh
>
>
> —
> NTDEV is sponsored by OSR
>
> OSR is HIRING!! See http://www.osr.com/careers
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer
>
> —
> NTDEV is sponsored by OSR
>
> OSR is HIRING!! See http://www.osr.com/careers
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer
>

Gad! I *hate* it when that happens. It just happened to me last week in some test code, as I was trying to ship a driver to a client. Arrrgh.

Shouldn’t the compiler or C++ have some feature you can twiddle or something that makes falling-through from one case to the other an error (like, you know… make C++ be a little more like C#)?

Peter
OSR

I’ve always wished there was a keyword “fallthrough”, and then you’d
have to either have a “break” or a “fallthrough” before the next case.

–mkj

On 2/27/2013 6:07 PM, xxxxx@osr.com wrote:

Gad! I *hate* it when that happens. It just happened to me last week in some test code, as I was trying to ship a driver to a client. Arrrgh.

Shouldn’t the compiler or C++ have some feature you can twiddle or something that makes falling-through from one case to the other an error (like, you know… make C++ be a little more like C#)?

Peter
OSR

“I can answer any question, so long as you agree that
‘I don’t know’ is an answer.”
– Isaac Asimov


//
// Michael K. Jones
// Stone Hill Consulting, LLC
// http://www.stonehill.com
//_______________________________________________

Closest you have is the __fallthrough annotation, http://msdn.microsoft.com/en-us/library/ms235402(v=VS.80).aspx

d

Or PC-lint -fallthrough comment.

Michal

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:bounce-527565-
xxxxx@lists.osr.com] On Behalf Of xxxxx@Microsoft.com
Sent: Thursday, February 28, 2013 6:47 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] WdfIoTargetSendIoctlSynchronously returns
STATUS_BUFFER_TOO_SMALL

Closest you have is the __fallthrough annotation,
http://msdn.microsoft.com/en-us/library/ms235402(v=VS.80).aspx

d


NTDEV is sponsored by OSR

OSR is HIRING!! See http://www.osr.com/careers

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

NOTE: The information in this message is intended for the personal and confidential use of the designated recipient(s) named above. To the extent the recipient(s) is/are bound by a non-disclosure agreement, or other agreement that contains an obligation of confidentiality, with AuthenTec, then this message and/or any attachments shall be considered confidential information and subject to the confidentiality terms of that agreement. If the reader of this message is not the intended recipient named above, you are notified that you have received this document in error, and any review, dissemination, distribution or copying of this message is strictly prohibited. If you have received this document in error, please delete the original message and notify the sender immediately.
Thank You!
AuthenTec, Inc. http://www.authentec.com/

Does Prefast whine if you don’t use the fallthough annotation? This was in my test code, so I had code analysis turned down to minimum (the driver, by contrast, was at max).

Peter
OSR

Not sure what level it starts showing up

d

Bent from my phone


From: xxxxx@osr.commailto:xxxxx
Sent: ?2/?28/?2013 5:42 PM
To: Windows System Software Devs Interest Listmailto:xxxxx
Subject: RE:[ntdev] WdfIoTargetSendIoctlSynchronously returns STATUS_BUFFER_TOO_SMALL

Does Prefast whine if you don’t use the fallthough annotation? This was in my test code, so I had code analysis turned down to minimum (the driver, by contrast, was at max).

Peter
OSR


NTDEV is sponsored by OSR

OSR is HIRING!! See http://www.osr.com/careers

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer</mailto:xxxxx></mailto:xxxxx>