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

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

EvtIoDeviceControl no METHOD_NEITHER?

Kurt_BrausewetterKurt_Brausewetter Member Posts: 43
Hi
I build a Filter Driver with KMDF and in the AddDevice Methode i register an EvtIoDeviceControl.
Works fine for all METHOD_BUFFERED
But when i send a IOCTL_KS_PROPERTY (IOCTL_KS_ENABLE_EVENT, IOCTL_KS_DISABLE_EVENT, IOCTL_KS_METHOD, IOCTL_KS_WRITE_STREAM, IOCTL_KS_READ_STREAM, IOCTL_KS_RESET_STATE, IOCTL_KS_HANDSHAKE) it dosn't take effect in the EvtIoDeviceControl! (works fine with the underlying device but not with the event in the filter)

Have EvtIoDeviceControl problems with METHOD_NEITHER and how solve it?

Comments

  • Doron_HolanDoron_Holan Member - All Emails Posts: 10,435
    Are you filtering above or below ks? KMDF doesn't care at the request presentation level how the IOCTL buffers are encoded. My guess is that a driver above you is consuming these IOCTLs and turning them into something else

    d

    -----Original Message-----
    From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@t-online.de
    Sent: Tuesday, September 13, 2011 11:37 AM
    To: Windows System Software Devs Interest List
    Subject: [ntdev] EvtIoDeviceControl no METHOD_NEITHER?

    Hi
    I build a Filter Driver with KMDF and in the AddDevice Methode i register an EvtIoDeviceControl.
    Works fine for all METHOD_BUFFERED
    But when i send a IOCTL_KS_PROPERTY (IOCTL_KS_ENABLE_EVENT, IOCTL_KS_DISABLE_EVENT, IOCTL_KS_METHOD, IOCTL_KS_WRITE_STREAM, IOCTL_KS_READ_STREAM, IOCTL_KS_RESET_STATE, IOCTL_KS_HANDSHAKE) it dosn't take effect in the EvtIoDeviceControl! (works fine with the underlying device but not with the event in the filter)

    Have EvtIoDeviceControl problems with METHOD_NEITHER and how solve it?

    ---
    NTDEV is sponsored by OSR

    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
  • The Filter is above (Upper Filter)...

    oh, forgot to say, i port the WDM to a KMDF Filter...
    And the WDM work also fine with the IOCTL_KS_PROPERTY in the filter!!

    BTW: I'd never change the INF (only the stikt KMDF-Section, and the device driver is not my own!!!)
    only: the device driver is WDM! (is this a problem)

    ?request? work's the KS-System-proxy different between WDM and KMDF Filter's ??? (I think NO!)
  • Tim_RobertsTim_Roberts Member - All Emails Posts: 13,002
    xxxxx@t-online.de wrote:
    > I build a Filter Driver with KMDF and in the AddDevice Methode i register an EvtIoDeviceControl.
    > Works fine for all METHOD_BUFFERED
    > But when i send a IOCTL_KS_PROPERTY (IOCTL_KS_ENABLE_EVENT, IOCTL_KS_DISABLE_EVENT, IOCTL_KS_METHOD, IOCTL_KS_WRITE_STREAM, IOCTL_KS_READ_STREAM, IOCTL_KS_RESET_STATE, IOCTL_KS_HANDSHAKE) it dosn't take effect in the EvtIoDeviceControl! (works fine with the underlying device but not with the event in the filter)
    >
    > Have EvtIoDeviceControl problems with METHOD_NEITHER and how solve it?

    If you are an upper filter, this works just fine. I've done it many
    times with filters on top of USBAudio.sys.

    Lower filters don't see the KS ioctls. They get converted to other
    requests by that point.

    Writes to usbaudio.sys are not done with IOCTL_KS_WRITE_STREAM.
    Instead, stream.sys and usbaudio.sys exchange a set of function pointers
    with IOCTL_KS_HANDSHAKE, and the streaming is done through those
    function calls.

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

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

  • Tim_RobertsTim_Roberts Member - All Emails Posts: 13,002
    xxxxx@t-online.de wrote:
    > The Filter is above (Upper Filter)...
    >
    > oh, forgot to say, i port the WDM to a KMDF Filter...
    > And the WDM work also fine with the IOCTL_KS_PROPERTY in the filter!!

    Did you set a synchronization scope? You should set
    SynchronizationScope to WdfSychronizationScopeNone when you create your
    queue. You need to be in the original processes context for a
    METHOD_NEITHER request.

    How do you know you're not seeing the ioctls? Can we see the code that
    creates your queue, and your Ioctl handler?

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

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

  • ~~~~~~~ Queue ~~~~~~~~~~~~~~~~~~~~
    WDF_IO_QUEUE_CONFIG_INIT_DEFAULT_QUEUE(&ioQueueConfig,
    WdfIoQueueDispatchSequential);
    //switch(bdatype.vals.tun){
    // case AMC_BDA_DVBS:{
    // ### There is no distinction in the instant need
    ioQueueConfig.EvtIoDeviceControl = ttFilterEvtIoDeviceControl;
    // break;
    // }
    //}
    status = WdfIoQueueCreate(device,
    &ioQueueConfig,
    WDF_NO_OBJECT_ATTRIBUTES,
    WDF_NO_HANDLE // pointer to default queue
    );
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    switch(IoControlCode){
    case 0x232004: //60 I2cRead
    if(OutputBufferLength != 60){
    ttFilterForwardRequest(Request, iotarget);
    return;
    };
    byteReturn = 60;
    status = WdfRequestRetrieveInputBuffer(Request, byteReturn, &pI2C, NULL);
    if(NT_SUCCESS(status)) status = WdfRequestRetrieveOutputBuffer(Request, byteReturn, &pBuff, NULL);
    if(NT_SUCCESS(status)) filterCallBrandFunction(I2CRead, status, filterExt, filterExt->bdatype.vals.brand, filterExt->bdatype.vals.bus, ttype, iotarget, pI2C);
    if(NT_SUCCESS(status)) RtlMoveMemory(pBuff, pI2C, byteReturn);
    break;
    case 0x2320C0: //32 DebiSetup
    //byteReturn=32;
    //break;
    case 0x2320C4: //32 DebiGetLastError
    case 0x2320C8: //8 DebiOut8
    case 0x2320CC: //8 DebiOut16 //No
    case 0x2320D0: //8 DebiIn8
    case 0x2320D4: //8 DebiIn16 //No
    case 0x232100: //8 RegisterIRQ //No
    case 0x232104: //8 UnRegisterIRQ //No
    case 0x232140: //4 SetTSInputPort
    status = STATUS_FAIL_CHECK;
    break;
    case IOCTL_KS_PROPERTY:
    //###################################################################################
    //KdBreakPoint();
    status = WdfRequestRetrieveUnsafeUserInputBuffer(Request, 0, &pBuff, &byteReturn);
    if(byteReturn > 0) {
    if(NT_SUCCESS(status)) status = WdfRequestProbeAndLockUserBufferForRead(Request, pBuff, byteReturn, &memBuff);
    if(NT_SUCCESS(status)) pProp = WdfMemoryGetBuffer(memBuff, NULL);
    RtlStringFromGUID(&pProp->Property.Set, &ucsGUID);
    status = WdfRequestRetrieveUnsafeUserOutputBuffer(Request, 0, &pBuff, &byteReturn);
    retProp =(long *) &byteReturn;
    if(byteReturn > 0) {
    if(NT_SUCCESS(status)) status = WdfRequestProbeAndLockUserBufferForRead(Request, pBuff, byteReturn, &memBuff);
    if(NT_SUCCESS(status)) retProp = WdfMemoryGetBuffer(memBuff, NULL);
    };
    byteReturn=0;
    KdPrint(("KSPopSet: %S, Id: %d, Flags: %d, Node: %d, Value: %d\n", ucsGUID.Buffer, pProp->Property.Id, pProp->Property.Flags, pProp->NodeId, *retProp));
    };
    //status = WdfDeviceEnqueueRequest(device, Request);
    //break;
    ////###################################################################################
    case IOCTL_KS_ENABLE_EVENT: // Send all other knowed "KS" IOCTLs down to Device
    case IOCTL_KS_DISABLE_EVENT:
    case IOCTL_KS_METHOD:
    case IOCTL_KS_WRITE_STREAM:
    case IOCTL_KS_READ_STREAM:
    case IOCTL_KS_RESET_STATE:
    case IOCTL_KS_HANDSHAKE:
    default:
    ttFilterForwardRequest(Request, iotarget);
    return;
    };
    if (!NT_SUCCESS(status)) {
    DbgPrint("FilterEvtIoDeviceControl: %X failed with : 0x%X\n", IoControlCode, status);
    WdfRequestComplete(Request, status);
    return;
    }
    WdfRequestCompleteWithInformation(Request, status, byteReturn);
    return;
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  • WdfSynchronizationScopeNone: Why that???

    OK describe my problem:
    I'm not interested on the IOCTL_KS_... but i have overtakes!
    Some IOCTL_KS_PROPERTY is overtaken a "normal" IOCTL (see my source above, the are many more "case's" in the switsh statement!)
    So i will "trace" the IOCTL_KS_... in order to the ohter's...

    oh astonishment: the IOCTL_KS_... are not in the "Automatic Synchronization of KMDF" WHY???
  • Doron_HolanDoron_Holan Member - All Emails Posts: 10,435
    If you ask for some type of sync scope or execution level other than the default (none), KMDF may change the IRQL or current process context (ie a work item to thunk to passive), thus making METHOD_NEITHER buffers impossible to capture and probe properly and in the right context.

    I have no idea what overtakes are. Do you mean overlapping constant values in your switch so that the compiler complains that 2 case statements are for the same constant value?

    -----Original Message-----
    From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@t-online.de
    Sent: Tuesday, September 13, 2011 1:05 PM
    To: Windows System Software Devs Interest List
    Subject: RE:[ntdev] EvtIoDeviceControl no METHOD_NEITHER?

    WdfSynchronizationScopeNone: Why that???

    OK describe my problem:
    I'm not interested on the IOCTL_KS_... but i have overtakes!
    Some IOCTL_KS_PROPERTY is overtaken a "normal" IOCTL (see my source above, the are many more "case's" in the switsh statement!) So i will "trace" the IOCTL_KS_... in order to the ohter's...

    oh astonishment: the IOCTL_KS_... are not in the "Automatic Synchronization of KMDF" WHY???

    ---
    NTDEV is sponsored by OSR

    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
  • sorry i'm not a native:
    overtake = ueberholen
    in german dic:
    overtaken
    overhauled
    outdistanced
    outstripped
    overtook

    i only want the all IOCTL's are processed i the order it was send for the app
    but in my queue config it was bypassed some IOCTL_KS_ (overtook??)

    question:
    must i disable the "auto Synchronization" and syncronize the EvtIoDeviceControl "manually"
    is there no other way??
  • sorry:
    i only want that all IOCTL's are processed in that order, it was send from the application!!
  • Doron_HolanDoron_Holan Member - All Emails Posts: 10,435
    So are you saying that you are seeing the IOCTLs being presented out of order wrt how the application sent them? Or are you using a sequential queue because you think it will enforce order?

    d

    -----Original Message-----
    From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@t-online.de
    Sent: Tuesday, September 13, 2011 1:51 PM
    To: Windows System Software Devs Interest List
    Subject: RE:[ntdev] EvtIoDeviceControl no METHOD_NEITHER?

    sorry:
    i only want that all IOCTL's are processed in that order, it was send from the application!!

    ---
    NTDEV is sponsored by OSR

    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
  • I hoped, sequential enforce order!
    But it isn't so :-(

    What can i do?
    How to setup the queue?
    Which is the Syncronice methode, i must seach for?
  • Doron_HolanDoron_Holan Member - All Emails Posts: 10,435
    You should get the requests in the order the app sent them with no sync scope and no execution level explicitly set.

    -----Original Message-----
    From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@t-online.de
    Sent: Tuesday, September 13, 2011 2:28 PM
    To: Windows System Software Devs Interest List
    Subject: RE:[ntdev] EvtIoDeviceControl no METHOD_NEITHER?

    I hoped, sequential enforce order!
    But it isn't so :-(

    What can i do?
    How to setup the queue?
    Which is the Syncronice methode, i must seach for?

    ---
    NTDEV is sponsored by OSR

    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
  • sorry for the question, i'm not a nativ english speaker!

    With:
    ~~~~~~~ Queue ~~~~~~~~~~~~~~~~~~~~
    WDF_IO_QUEUE_CONFIG_INIT_DEFAULT_QUEUE(&ioQueueConfig,
    WdfIoQueueDispatchSequential);
    //switch(bdatype.vals.tun){
    // case AMC_BDA_DVBS:{
    // ### There is no distinction in the instant need
    ioQueueConfig.EvtIoDeviceControl = ttFilterEvtIoDeviceControl;
    // break;
    // }
    //}
    status = WdfIoQueueCreate(device,
    &ioQueueConfig,
    WDF_NO_OBJECT_ATTRIBUTES,
    WDF_NO_HANDLE // pointer to default queue
    );
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    i have no scope set
    and i never set anywhere the execution level

    so i must search for a other reason for this effect??

    thx for the lesson ;-)
  • Doron_HolanDoron_Holan Member - All Emails Posts: 10,435
    You are setting the scope with WdfIoQueueDispatchSequential. You want WdfIoQueueDispatchParallel

    d

    -----Original Message-----
    From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@t-online.de
    Sent: Tuesday, September 13, 2011 3:30 PM
    To: Windows System Software Devs Interest List
    Subject: RE:[ntdev] EvtIoDeviceControl no METHOD_NEITHER?

    sorry for the question, i'm not a nativ english speaker!

    With:
    ~~~~~~~ Queue ~~~~~~~~~~~~~~~~~~~~
    WDF_IO_QUEUE_CONFIG_INIT_DEFAULT_QUEUE(&ioQueueConfig,
    WdfIoQueueDispatchSequential);
    //switch(bdatype.vals.tun){
    // case AMC_BDA_DVBS:{
    // ### There is no distinction in the instant need
    ioQueueConfig.EvtIoDeviceControl = ttFilterEvtIoDeviceControl;
    // break;
    // }
    //}
    status = WdfIoQueueCreate(device,
    &ioQueueConfig,
    WDF_NO_OBJECT_ATTRIBUTES,
    WDF_NO_HANDLE // pointer to default queue
    );
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    i have no scope set
    and i never set anywhere the execution level

    so i must search for a other reason for this effect??

    thx for the lesson ;-)

    ---
    NTDEV is sponsored by OSR

    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
  • Tim_RobertsTim_Roberts Member - All Emails Posts: 13,002
    xxxxx@t-online.de wrote:
    > sorry for the question, i'm not a nativ english speaker!
    > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    > i have no scope set
    > and i never set anywhere the execution level
    >
    > so i must search for a other reason for this effect??

    Although I think you will eventually want to set the sync scope to None,
    that would not cause you to miss ioctls.

    Did you call WdfFdoInitSetFilter? What is your test application? Are
    you creating a complete DirectShow graph, or are you just creating an
    IBaseFilter for your device and fetching the IKsControl interface from that?

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

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

  • >Although I think you will eventually want to set the sync scope to None,
    >that would not cause you to miss ioctls.
    --
    WdfIoQueueDispatchParallel now sufficient or not?




    >Did you call WdfFdoInitSetFilter? What is your test application? Are
    >you creating a complete DirectShow graph, or are you just creating an
    >IBaseFilter for your device and fetching the IKsControl interface from that?
    --
    It is a manufacturer-specific, Windows XP embedded application of which I haven't the source code.
    But I can see the entire graph by using the Graph Editor (From Network Providor up to the render's).
  • >Did you call WdfFdoInitSetFilter?
    WdfFdoInitSetFilter is called
  • Ups...
    I have declared
    #pragma alloc_text (PAGE,xxx)
    and use the macro
    PAGED_CODE()
    for the function's
    DriverEntry
    EvtDeviceAdd
    EvtDevicePrepareHardware
    EvtDeviceReleaseHardware
    EvtDeviceFileCreate *
    EvtFileClose
    EvtIoDeviceControl *
    ForwardRequest (is used in * marked function)

    i have disabled that inEvtIoDeviceControl and ForwardRequest but the result isn't really better (OK a little, i get now the IOCTL_KS_* from the Pin in requested Order)

    should I anything/everything more...
  • nonsense:
    DriverEntry is #pragma alloc_text (INIT, DriverEntry)

    sorry
  • Ok it's solved:
    have "banished" all "PAGED_CODE()" and "alloc_text PAGE" and work with WdfWaitLook... in EvtIoDeviceControl => All in Order!!!!!!
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