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

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

Sending IOCTL Request ioTarget

I want to make an WdfIoTargetSendIoctlSynchronously call. All is clear but the only thing left is how to get the "ioTarget" inside of EvtDeviceAdd in the filter driver.
I know that the most of you know that but for me it is not clear how to get the IoTarget. There are so many functions.

Comments

  • Doron_HolanDoron_Holan Posts: 10,360
    Are you sending it down the stack? WdfDeviceGetIoTarget will return the target for down the stack. If elsewhere, you need create your own and open it.

    d

    -----Original Message-----
    From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@x-publisher.com
    Sent: Friday, February 9, 2018 8:16 AM
    To: Windows System Software Devs Interest List <xxxxx@lists.osr.com>
    Subject: [ntdev] Sending IOCTL Request ioTarget

    I want to make an WdfIoTargetSendIoctlSynchronously call. All is clear but the only thing left is how to get the "ioTarget" inside of EvtDeviceAdd in the filter driver.
    I know that the most of you know that but for me it is not clear how to get the IoTarget. There are so many functions.




    ---
    NTDEV is sponsored by OSR

    Visit the list online at: <https://na01.safelinks.protection.outlook.com/?url=http://www.osronline.com/showlists.cfm?list=ntdev&amp;data=04|01|[email protected]|a45cface517a484e2a9208d56fd86b8a|ee3303d7fb734b0c8589bcd847f1c277|1|0|636537897663511681|Unknown|TWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwifQ==|-1&amp;sdata=kI1tMvjijlpGGUI+Rg/WMbGJ8Th0n3uYxtpp+uMTJuc=&amp;reserved=0&gt;

    MONTHLY seminars on crash dump analysis, WDF, Windows internals and software drivers!
    Details at <https://na01.safelinks.protection.outlook.com/?url=http://www.osr.com/seminars&amp;data=04|01|[email protected]|a45cface517a484e2a9208d56fd86b8a|ee3303d7fb734b0c8589bcd847f1c277|1|0|636537897663511681|Unknown|TWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwifQ==|-1&amp;sdata=dgIr5MnxmxFklTSz3Z3H6sCRyjwNlCDR5BYbye2bI8o=&amp;reserved=0&gt;

    To unsubscribe, visit the List Server section of OSR Online at <https://na01.safelinks.protection.outlook.com/?url=http://www.osronline.com/page.cfm?name=ListServer&amp;data=04|01|[email protected]|a45cface517a484e2a9208d56fd86b8a|ee3303d7fb734b0c8589bcd847f1c277|1|0|636537897663511681|Unknown|TWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwifQ==|-1&amp;sdata=C42GP7CifMHjyL8AlrnwL5KMC2IvBKugYm4IJK8llQI=&amp;reserved=0&gt;
  • I want the KEYBOARD_EXTENDED_ATTRIBUTES from the actual keyboard.
    Thank you.
  • <quote>
    I want the KEYBOARD_EXTENDED_ATTRIBUTES from the actual keyboard.
    </quote>

    That's nice, but it doesn't answer the question: To which device in the system do you want to send your IOCTL? If its the Device Object directly below you, you want your Local I/O Target, which you retrieve (as Doron said) with WdfDeviceGetIoTarget.

    If you want to send your IOCTL to a DIFFERENT device in the system, you can open an I/O Target to that device by name or using a given WDM Device Object pointer.

    Peter
    OSR
    @OSRDrivers

    Peter Viscarola
    OSR
    @OSRDrivers

  • Ok, I thought it was clear because I wrote "EvtDeviceAdd". As I know this function is called for each keyboard, virtual or physical in the system. I think it is clear now.
    Thank you.
  • Tim_RobertsTim_Roberts Posts: 12,619
    xxxxx@x-publisher.com wrote:
    > I want to make an WdfIoTargetSendIoctlSynchronously call. All is clear but the only thing left is how to get the "ioTarget" inside of EvtDeviceAdd in the filter driver.
    > I know that the most of you know that but for me it is not clear how to get the IoTarget. There are so many functions.

    The KMDF designers have done an excellent job of naming their methods,
    so many times it is quite possible to guess what you need.  KMDF is a
    tree of objects, where each node has stored a copy of the its
    parents/owners/associates.  So, in a case like this, you need to ask
    yourself, "what information do I need, and what resources do I have?" 
    You need a WDFIOTARGET.  You have a WDFDEVICE.  When you need to ask an
    X for a Y, the KMDF rule is that the routine is called XGetY.  So, look
    for WdfDeviceGetIoTarget, and there it is.

    Sometimes you have to go through several steps.  For example, to get a
    WDFDEVICE from a WDFREQUEST, you have to go through the WDFQUEUE
    (WdfRequestGetIoQueue, WdfIoQueueGetDevice).

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

    Tim Roberts, [email protected]
    Providenza & Boekelheide, Inc.

  • Yes, I see there is a systematic but I know that I must know more.
    For example: If I call now WdfDeviceGetIoTarget with the device handle I get that this device does not support this IOCTL and therefore I thought.
    Ok, I remembered that there is a connection and in this connection I have done:
    devExt->UpperConnectData = *connectData;
    and here I looked at
    PDEVICE_OBJECT ClassDeviceObject;
    If I look in PDEVICE_OBJECT I see
    struct _DRIVER_OBJECT *DriverObject;
    struct _DEVICE_OBJECT *NextDevice;
    struct _DEVICE_OBJECT *AttachedDevice;
    Which one should I use now?
    Questions after questions! :-(
  • Tim_RobertsTim_Roberts Posts: 12,619
    xxxxx@x-publisher.com wrote:
    > Yes, I see there is a systematic but I know that I must know more.
    > For example: If I call now WdfDeviceGetIoTarget with the device handle I get that this device does not support this IOCTL and therefore I thought.
    > Ok, I remembered that there is a connection and in this connection I have done:
    > devExt->UpperConnectData = *connectData;
    > and here I looked at
    > PDEVICE_OBJECT ClassDeviceObject;
    > If I look in PDEVICE_OBJECT I see
    > struct _DRIVER_OBJECT *DriverObject;
    > struct _DEVICE_OBJECT *NextDevice;
    > struct _DEVICE_OBJECT *AttachedDevice;
    > Which one should I use now?

    None of them.  Those are all going the wrong direction -- upward.  The
    hardware is below you, at WdfDeviceGetIoTarget(hDevice).

    Are you trying to send IOCTL_KEYBOARD_QUERY_EXTENDED_ATTRIBUTES?  What
    operating system are you using for testing?  That ioctl was not added
    until Windows 10.

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

    Tim Roberts, [email protected]
    Providenza & Boekelheide, Inc.

  • Oh!
    Yes, I want this IOCTL_KEYBOARD_QUERY_EXTENDED_ATTRIBUTES. I work with the latest win10.
  • I tried with other Ioctl like IOCTL_KEYBOARD_SET_INDICATORS and always get error 0xc0000010.

    status = WdfIoTargetSendIoctlSynchronously(
    WdfDeviceGetIoTarget(device),
    WDF_NO_HANDLE, // Request WDF_NO_HANDLE
    IoctlControlCode,
    pInputDesc,
    pOutputDesc,
    NULL, // PWDF_REQUEST_SEND_OPTIONS
    NULL);
    Any ideas?
  • The filter driver is above kbdclass as Upperfilter. This is the reason that I get 0xc0000010. If I set it below kbdclass the function works.

    Now I tried WDF_IO_TARGET_OPEN_PARAMS_INIT_OPEN_BY_NAME. Is this the way to go?
  • Doron_HolanDoron_Holan Posts: 10,360
    Open by name will open the top of the stack , essentially opening your driver if you are above kbdclass. The recommended location is below kbdclass because it is rather restrictive about who can open it and what io gets through.

    Bent from my phone
    ________________________________
    From: xxxxx@lists.osr.com on behalf of xxxxx@x-publisher.com
    Sent: Saturday, February 10, 2018 6:42:16 AM
    To: Windows System Software Devs Interest List
    Subject: RE:[ntdev] Sending IOCTL Request ioTarget

    The filter driver is above kbdclass as Upperfilter. This is the reason that I get 0xc0000010. If I set it below kbdclass the function works.

    Now I tried WDF_IO_TARGET_OPEN_PARAMS_INIT_OPEN_BY_NAME. Is this the way to go?

    ---
    NTDEV is sponsored by OSR

    Visit the list online at:

    MONTHLY seminars on crash dump analysis, WDF, Windows internals and software drivers!
    Details at

    To unsubscribe, visit the List Server section of OSR Online at
  • English is not my first language therefore I ask the following questions for my better understanding.
    My filter driver modifies the keyboard data. Can this also be done if the filter driver is below kbdclass? I tested it without modification and it do not work below kdbdclass.

    Is it right that a filter driver which is above can not set keyboard indicators? If I can't set the indicators it is not so easy to change the input data because I must know for example the state of the capslock.
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!