kmdf accessing buffers for METHOD_XX_DIRECT IOCTL's

I’m confused about how to access buffers under KMDF for METHOD_XX_DIRECT.

My understanding is that with METHOD_XX_DIRECT, you have a small ‘control buffer’ already mapped to kernel space as Irp->AssociatedIrp.SystemBuffer, and a (potentially) large buffer sitting in an MDL at Irp->MdlAddress which the driver can map if required. According to this table:

http://msdn.microsoft.com/en-us/library/windows/hardware/gg583866(v=vs.85).aspx

under the heading “Buffers for IRP_MJ_DEVICE_CONTROL Requests”, I can’t see how I could get SystemBuffer, unless I call WdfRequestRetrieveInputWdmMdl and then get the system address from that. Unless I’m supposed to just go and get it from the IRP myself?

Is there a table or something that explains more clearly for METHOD_XX_DIRECT IOCTLS which WdfRetrieveXxx routine gets what?

Thanks

James

For the system buffer, WdfRequestRetrieveInputBuffer. For the MDL buffer, WdfRequestRetrieveOutputBuffer will give you the system VA for the mapped MDL, otherwise you have WdfRequestRetrieveOutput/InputWdmMdl to get the MDL

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of James Harper
Sent: Tuesday, December 17, 2013 9:40 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] kmdf accessing buffers for METHOD_XX_DIRECT IOCTL’s

I’m confused about how to access buffers under KMDF for METHOD_XX_DIRECT.

My understanding is that with METHOD_XX_DIRECT, you have a small ‘control buffer’ already mapped to kernel space as Irp->AssociatedIrp.SystemBuffer, and a (potentially) large buffer sitting in an MDL at Irp->MdlAddress which the driver can map if required. According to this table:

http://msdn.microsoft.com/en-us/library/windows/hardware/gg583866(v=vs.85).aspx

under the heading “Buffers for IRP_MJ_DEVICE_CONTROL Requests”, I can’t see how I could get SystemBuffer, unless I call WdfRequestRetrieveInputWdmMdl and then get the system address from that. Unless I’m supposed to just go and get it from the IRP myself?

Is there a table or something that explains more clearly for METHOD_XX_DIRECT IOCTLS which WdfRetrieveXxx routine gets what?

Thanks

James


NTDEV is sponsored by OSR

Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

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

>My understanding is that with METHOD_XX_DIRECT, you have a small ‘control buffer’ already

mapped to kernel space as Irp->AssociatedIrp.SystemBuffer,

Yes, which is InputBuffer in DeviceIoControl

and a (potentially) large buffer sitting in an MDL at Irp->MdlAddress which the driver can map if

Yes, which is OutputBuffer in DeviceIoControl.

METHOD_IN and OUT_DIRECT only differ in whether you are allowed to update the second buffer, or it is read-only for you.

So, one of them is “request-response transaction, short question and potentially long answer”.

The second is “write with small additional info”.


Maxim S. Shatskih
Microsoft MVP on File System And Storage
xxxxx@storagecraft.com
http://www.storagecraft.com

Additionally, note that the system buffer ALWAYS uses Buffered I/O. The METHOD_xxx argument basically dictates the method used for the OutBuffer argument (except for METHOD_NEITHER which is special).

Peter
OSR