none
DeviceIoControl API question RRS feed

  • Question

  • I am new to Driver development. I came across following code,

    DeviceIoControl(deviceHandle, IOCTL_HID_SET_FEATURE,  voidTypeData, numberofBytes, NULL, 0, &transferredBytes, overlapType)

     

    What does above code mean, I am not getting what  is meant by control command IOCTL_HID_SET_FEATURE.

     

    I can see there is some data in voidTypeData and the numberofBytes, transferredBytes as an output params.

    From this I can decipher it is trying to send the data to device. But, How IOCTL_HID_SET_FEATURE comes into this picture.

     

    Can anyone explain what is the functionality that being achieved here.




    • Edited by Pratap.k Friday, November 25, 2011 6:31 AM
    Thursday, November 24, 2011 1:41 PM

Answers

  • each driver determines what device io control codes you can send it. what type of device are you trying to communicate with?
    d -- This posting is provided "AS IS" with no warranties, and confers no rights.
    • Marked as answer by Pratap.k Monday, November 28, 2011 2:08 PM
    Saturday, November 26, 2011 5:53 AM
  • Drivers have no idea how to handle a particular IOCTL unless someone writes the code to do so.

    There is the Windows Driver Kit (WDK) which contains all nesessary documentation and example code. You can get it from http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=11800

    After you install the WDK, the documentation and examples will be available in the programs menu. Start reading the documentation.

    -- pa

     


    • Edited by Pavel A Sunday, November 27, 2011 11:26 AM
    • Proposed as answer by Vikrant Bansal Monday, November 28, 2011 1:03 PM
    • Marked as answer by Pratap.k Monday, November 28, 2011 2:04 PM
    Sunday, November 27, 2011 10:18 AM

All replies

  • Please reffer MSDN for detailed information on DeviceIoControl.

    Control command means spacial code that will identify the type of spacial request made by usermode application to kernel medo driver. These are generally used to convay some application spacific settings or commands to driver. On receiving such command driver will parse input data according to control command and does processing and return result of operation in output buffer.

    Each driver exposes the control command it supports to the applications.

     Thus DeviceIoControl is the way used by application to comminicate with drivers.


    Thursday, November 24, 2011 2:25 PM
  • read http://msdn.microsoft.com/en-us/library/windows/hardware/ff541184(v=vs.85).aspx for the specifics of this particular IOCTL vlaue.
    d -- This posting is provided "AS IS" with no warranties, and confers no rights.
    Thursday, November 24, 2011 9:39 PM
  • I've searched entire driver and appcode code for IOCTL_HID_SET_FEATURE

    All I see the reference of it  is in DeviceIoControl.

     

    Is it possible to communicate with the device ( Not driver ) using DeviceIoControl ??

     

     


    • Edited by Pratap.k Friday, November 25, 2011 6:32 AM
    Friday, November 25, 2011 6:31 AM
  • I am very new to device drivers, Please bear with me if these are silly questions.

     

    I've seen some references of device exposing control codes for some functionalities, How Do we Call such ( I thought it is through DeviceIoControl ) ??



    • Edited by Pratap.k Friday, November 25, 2011 1:25 PM
    Friday, November 25, 2011 8:10 AM
  • each driver determines what device io control codes you can send it. what type of device are you trying to communicate with?
    d -- This posting is provided "AS IS" with no warranties, and confers no rights.
    • Marked as answer by Pratap.k Monday, November 28, 2011 2:08 PM
    Saturday, November 26, 2011 5:53 AM
  • It is a HID USB Device, which reads/writes to EEPROM.

     

    Quoted: "Each driver determines what device io control codes you can send it"

    Can you refer me an example of how to do that, Because I don't find such kind in the source.

     

    Saturday, November 26, 2011 3:49 PM
  • all of the HID IOCTLs are documented here, http://msdn.microsoft.com/en-us/library/windows/hardware/ff539849(v=VS.85).aspx,  Also look at hid.dll documentation. http://msdn.microsoft.com/en-us/library/windows/hardware/ff538865(v=VS.85).aspx ((all functions that start with HidD_)
    d -- This posting is provided "AS IS" with no warranties, and confers no rights.
    • Proposed as answer by Vikrant Bansal Monday, November 28, 2011 1:03 PM
    • Unproposed as answer by Pratap.k Monday, November 28, 2011 2:08 PM
    Saturday, November 26, 2011 4:28 PM
  • Thanks for the replies, really helpful for me.

     

    Can you answer following also,

    If a Driver wants to Handle a particular IOCTL, how it will do that?

    Any example would be great.

     

    Sunday, November 27, 2011 6:46 AM
  • Pratap.k wrote:
    >
    >Can you answer following also,
    >
    >If a Driver wants to Handle a particular IOCTL, how it will do that?
    >
    >Any example would be great.
     
    Have you done any reading at all?  The WDK contains any number of sample
    drivers that demonstrate how to handle ioctls.
    --
    Tim Roberts, timr@probo.com
    Providenza & Boekelheide, Inc.
     

    Tim Roberts, VC++ MVP Providenza & Boekelheide, Inc.
    Tuesday, November 29, 2011 4:33 AM
  • Quoted: "Have you done any reading at all? "

    I just need to fix something in the code, and already had  existing code in-front of me.

    So, naturally, out of curiosity to understand it at once, All these questions will pop out.





    • Edited by Pratap.k Monday, December 5, 2011 12:47 PM
    Monday, December 5, 2011 12:45 PM
  • For an example of handling an IOCTL, look for IOCTL_TOASTER_DONT_DISPLAY_IN_UI_DEVICE in the WDK src subdirectory. You'll find toast.c that issues the IOCTL, and several pieces that might handle it. I would look at the code in the kmdf\func\featured subdirectory.

     

    JA

    Wednesday, December 21, 2011 4:15 AM