Windows System Software -- Consulting, Training, Development -- Unique Expertise, Guaranteed Results

Before Posting...
Please check out the Community Guidelines in the Announcements and Administration Category.

kmdf accessing buffers for METHOD_XX_DIRECT IOCTL's

James_HarperJames_Harper Member Posts: 1,615
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

Comments

  • Doron_HolanDoron_Holan Member - All Emails Posts: 10,435
    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
    d
  • Maxim_S._ShatskihMaxim_S._Shatskih Member Posts: 10,396
    >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
  • Peter_Viscarola_(OSR)Peter_Viscarola_(OSR) Administrator Posts: 7,265
    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

    Peter Viscarola
    OSR
    @OSRDrivers

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Upcoming OSR Seminars
Developing Minifilters 29 July 2019 OSR Seminar Space
Writing WDF Drivers 23 Sept 2019 OSR Seminar Space
Kernel Debugging 21 Oct 2019 OSR Seminar Space
Internals & Software Drivers 18 Nov 2019 Dulles, VA