none
Should WDF_DEVICE_IO_TYPE in WDF driver match with the CTL_CODE in application? RRS feed

  • Question

  • In WDF driver,

    void WdfDeviceInitSetIoType( [in] PWDFDEVICE_INIT    DeviceInit, [in] WDF_DEVICE_IO_TYPE IoType );

    IoType can be WdfDeviceIoNeither, WdfDeviceIoBuffered, WdfDeviceIoDirect.

    And in application,

    DeviceIoControl(hDevice,
    Spw_PCIe_IOCTL_BUFFERED,
    &x1,
    1,
    &x,
    1,
    &nOutput,
    NULL)
    )

    #define Spw_PCIe_IOCTL_BUFFERED CTL_CODE(FILE_DEVICE_UNKNOWN, 0x800, METHOD_BUFFERED, FILE_ANY_ACCESS)
    #define Spw_PCIe_IOCTL_IN_DIRECT CTL_CODE(FILE_DEVICE_UNKNOWN, 0x801, METHOD_IN_DIRECT, FILE_ANY_ACCESS)
    #define Spw_PCIe_IOCTL_OUT_DIRECT CTL_CODE(FILE_DEVICE_UNKNOWN, 0x802, METHOD_OUT_DIRECT, FILE_ANY_ACCESS)

    My question is if I use WdfDeviceInitSetIoType(DeviceInit, WdfDeviceIoBuffered) in my driver,is it

    necessary I have to use Spw_PCIe_IOCTL_BUFFERED as CTL_CODE for DeviceIoControl in my application?

    Or it doesn't matter to use any of these CTL_CODEs.

    Thank you!


    Sunday, May 10, 2015 12:42 PM

Answers

  • The two are not tied together, the WdfDeviceInitSetIoType sets the buffering type for things like read and write.  IOCTL's are different in that each IOCTL has its own buffering type, and is processed based on that.


    Don Burn Windows Driver Consulting Website: http://www.windrvr.com

    Sunday, May 10, 2015 12:54 PM

All replies

  • The two are not tied together, the WdfDeviceInitSetIoType sets the buffering type for things like read and write.  IOCTL's are different in that each IOCTL has its own buffering type, and is processed based on that.


    Don Burn Windows Driver Consulting Website: http://www.windrvr.com

    Sunday, May 10, 2015 12:54 PM
  • Thanks Mr Burn!You are always warm-hearted and helpful! 

    I am still not clear that if I can use DeviceIoControl (I know it is used to send some CTLs) as "little" read&write to read or write small-size memory?

    Thanks again!

    Sunday, May 10, 2015 2:17 PM
  • Thanks Mr Burn!You are always warm-hearted and helpful! 

    I am still not clear that if I can use DeviceIoControl (I know it is used to send some CTLs) as "little" read&write to read or write small-size memory?

    Thanks again!

    Sunday, May 10, 2015 2:18 PM
  • Yes you can use it to send and receive memory from a driver.  A lot of drivers I develop for clients are for specialized devices, and have no read or write routines at all, only DeviceIoControl calls. 

    Just think about the size of the data when you are choosing the METHOD.  METHOD_BUFFERED is typically the fastest for small (less the 16KB) buffers, and METHOD_IN_DIRECT and METHOD_OUT_DIRECT should be used for larger buffers than that.


    Don Burn Windows Driver Consulting Website: http://www.windrvr.com

    Sunday, May 10, 2015 2:26 PM
  • Thank you Burn!Got it.
    Monday, May 11, 2015 1:21 AM