none
WdfIoTargetCreate RRS feed

  • Question

  • Hello:

    I am in attempt to send an IOCTL to my own driver. So, the first thing that I do is to create an iotarget for my device.

    Below is the code:

    WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&ioTargetAttrib, TARGET_DEVICE_INFO);

    status = WdfIoTargetCreate(MUXFCtx->remCtrlDev,

       &ioTargetAttrib,

       &ioTarget

       );

    I got the below compilation error:

    4>c:\work-dir\svn-source\filter-driver\development_branch\development\src\muxf\muxf_driver.c(1923) : error C2065: '_WDF_TARGET_DEVICE_INFO_TYPE_INFO' : undeclared identifier
    4>c:\work-dir\svn-source\filter-driver\development_branch\development\src\muxf\muxf_driver.c(1923) : error C2223: left of '->UniqueType' must point to struct/union
    3>c:\work-dir\svn-source\filter-driver\development_branch\development\src\muxf\muxf_driver.c(1923) : error C2065: '_WDF_TARGET_DEVICE_INFO_TYPE_INFO' : undeclared identifier
    3>c:\work-dir\svn-source\filter-driver\development_branch\development\src\muxf\muxf_driver.c(1923) : error C2223: left of '->UniqueType' must point to struct/union
    3>link : error LNK1181: cannot open input file 'c:\work-dir\svn-source\filter-driver\development_branch\development\src\muxf\objfre_wxp_x86\i386\muxf_driver.obj'

    It complains this line:

    WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&ioTargetAttrib, TARGET_DEVICE_INFO);

    According to the WDK doc, Wdm.h should include the definition of this, but apparently not.

    Below is the requirement text from WDK help:

    Headers: Declared in WdfIoTarget.h. Include Wdf.h.

    Does anyone have any idea ?

    thanks,

    Kiet


    KAL

    Thursday, January 24, 2013 12:52 AM

Answers

  • You have to declare the context type using WDF_DECLARE_CONTEXT_TYPE_WITH_NAME in your own header

    d -- This posting is provided "AS IS" with no warranties, and confers no rights.

    Thursday, January 24, 2013 3:33 AM

All replies

  • No it is not wdm.h is wdf.h these are different files.  But the real question is why are you trying to send an IOCTL to your own driver, this is not normal behavior and probably reprsents a bug.


    Don Burn Windows Filesystem and Driver Consulting Website: http://www.windrvr.com Blog: http://msmvps.com/blogs/WinDrvr

    Thursday, January 24, 2013 12:55 AM
  • sorry, that was a typo from my part. I did inlude the correct header file, that is Wdf.h. And have the compile error as I posted.

    Now, to answer your question. No, this is not a bug. The driver exposes various IOCTL so that a user application can put the driver into various state. By default, the driver goes to a default state. There multiple appliations that access the driver and it is harder to synchronize these applications so that they do the right thing and puttting the driver in the desire state.

    We make a concious decision to have the driver comes up with the initial state and have it move to the desire state without having to change our state machine.... Not sure if I make myself clear.

    Kiet


    KAL

    Thursday, January 24, 2013 1:11 AM
  • Did you also have wdm.h or ntddk.h or ntifs.h before wdf.h?  Without them would get your failures.   That your state machine is not abstracted enough to require the IOCTL, as a former manager and mentor I would find disturbing.


    Don Burn Windows Filesystem and Driver Consulting Website: http://www.windrvr.com Blog: http://msmvps.com/blogs/WinDrvr

    Thursday, January 24, 2013 1:35 AM
  • I do have these header files and still get the failure. Now with regards to the state machine. By design, the state machine was designed intentionally like this, that is would not allow an external application to put it in S2 without first going to S1. This was an invalid use case in the original design. Option 2 is to change the state machine, yes, it is cleaner but would be more work.

    K


    KAL

    Thursday, January 24, 2013 2:16 AM
  • You have to declare the context type using WDF_DECLARE_CONTEXT_TYPE_WITH_NAME in your own header

    d -- This posting is provided "AS IS" with no warranties, and confers no rights.

    Thursday, January 24, 2013 3:33 AM
  • Duh ... thanks.

    KAL

    Thursday, January 24, 2013 3:57 AM