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

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

NdisRegisterDeviceEx problem

Alex_GrigAlex_Grig Member Posts: 3,238
I registered a control device for my NDIS 6.30 NIC miniport. But when I'm calling CreateFile from the application, my IRP_MJ_CREATE handler doesn't get called, although CreateFile succeeds, and NDIS internal CREATE handler is called. Is it supposed to work for miniports?

Comments

  • Thomas_DivineThomas_Divine Member Posts: 325
    You are using NdisRegisterDeviceEx?

    Is your application running with elevated privileges? If it works with
    elevated privileges look at the SDDL passed to NdisregsiterDeviceEx and/or
    parameters passed to UM CreateFile.

    Thomas F. Divine


    -----Original Message-----
    From: xxxxx@lists.osr.com
    [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@broadcom.com
    Sent: Monday, June 24, 2013 3:02 PM
    To: Windows System Software Devs Interest List
    Subject: [ntdev] NdisRegisterDeviceEx problem

    I registered a control device for my NDIS 6.30 NIC miniport. But when I'm
    calling CreateFile from the application, my IRP_MJ_CREATE handler doesn't
    get called, although CreateFile succeeds, and NDIS internal CREATE handler
    is called. Is it supposed to work for miniports?

    ---
    NTDEV is sponsored by OSR

    Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

    OSR is HIRING!! See http://www.osr.com/careers

    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
  • Alex_GrigAlex_Grig Member Posts: 3,238
    Well, since CreateFile succeeds, the caller has enough priviliges.
  • Jeffrey_Tippet_[MSFT]Jeffrey_Tippet_[MSFT] Member - All Emails Posts: 541
    This should work. Is the NDIS internal routine ndisDummyIrpHandler? What status code does that routine leave in the return value register? If you dps on the device extension, do you see your create handler buried somewhere in NDIS's context structure? (A pointer to your IRP handlers is stored inline in the device extension, without any extra indirection, so you should be able to find it with dps.)

    For control devices created with NdisRegisterDeviceEx, NDIS does no filtering of create IRPs (or any IRP except PNP, for that matter). If you provided the IRP handler in NDIS_DEVICE_OBJECT_ATTRIBUTES, it should be called by NDIS. You can disassemble the dummy handler; it's not very large or complex.
  • matt_sykesmatt_sykes Member - All Emails Posts: 270
    clear the 'do device initialising' flag on the device perhaps? god knows this has caught me out on non ndis control device creation enough times. :)
  • Jeffrey_Tippet_[MSFT]Jeffrey_Tippet_[MSFT] Member - All Emails Posts: 541
    NDIS helpfully clears DO_DEVICE_INITIALIZING for you before NdisRegisterDeviceEx returns :)
  • Alex_GrigAlex_Grig Member Posts: 3,238
    Ok. The problem was found actually in the test application code.
  • Alex_GrigAlex_Grig Member Posts: 3,238
    Now I'm getting a problem with getting IRP_MN_QUERY_RELATIONS/TargetRelation in the CDO. Looks like NDIS is not forwarding any IRP_MJ_PNP to the custom handler. Now how do I register for the device removal? I can't open a handle to the regular FDO from an user account.
  • Jeffrey_Tippet_[MSFT]Jeffrey_Tippet_[MSFT] Member - All Emails Posts: 541
    Right, NDIS does not forward IRP_MJ_PNP. (In case you ask: that's the only major IRP we don't forward.)

    I'm not sure I understand the goal. If you want to be generically notified from a user account when a NIC is removed, listen for WM_DEVICECHANGE.

    -----Original Message-----
    From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@broadcom.com
    Sent: Tuesday, July 2, 2013 4:20 PM
    To: Windows System Software Devs Interest List
    Subject: RE:[ntdev] NdisRegisterDeviceEx problem

    Now I'm getting a problem with getting IRP_MN_QUERY_RELATIONS/TargetRelation in the CDO. Looks like NDIS is not forwarding any IRP_MJ_PNP to the custom handler. Now how do I register for the device removal? I can't open a handle to the regular FDO from an user account.

    ---
    NTDEV is sponsored by OSR

    Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

    OSR is HIRING!! See http://www.osr.com/careers

    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
  • Alex_GrigAlex_Grig Member Posts: 3,238
    @Jeffrey Tippet:

    >I'm not sure I understand the goal.

    The CDO is used to send custom IOCTLs to the NDIS driver, to implement NDSPI. We need to allow for clean device removal, so we want to register for the removal notification on the handle. This requires that the CDO handles QUERY_RELATIONS/TargetRelation.

    Devnode change notification only happens after the device actually handles REMOVE_DEVICE and is not suitable for applications that open a handle to the device.
  • Jeffrey_Tippet_[MSFT]Jeffrey_Tippet_[MSFT] Member - All Emails Posts: 541
    Got it. I don't know a good way to cleanly sever usermode handles to a control device when a miniport is removed. The best I can think of is an inverted call that gets completed when the miniport is halted, and you hope the usermode app obeys and closes its handle before you need to recreate a device object with the same name.
  • Alex_GrigAlex_Grig Member Posts: 3,238
    >The best I can think of is an inverted call that gets completed when the miniport is halted,

    I'm afraid MiniportHalt will not be called until all IRPs into the CDO are completed.
  • David_R._CattleyDavid_R._Cattley Member - All Emails Posts: 2,112
    I have a miniport with a cdo per adapter which does wait for the cdo to cleanly drain & shutdown during mphalt.

    It is ndis5 however.

    Cheers,
    Dave Cattley

    Sent from my Windows Phone
    ________________________________
    From: xxxxx@broadcom.com
    Sent: ‎7/‎3/‎2013 9:59 AM
    To: Windows System Software Devs Interest List
    Subject: RE:[ntdev] NdisRegisterDeviceEx problem

    >The best I can think of is an inverted call that gets completed when the miniport is halted,

    I'm afraid MiniportHalt will not be called until all IRPs into the CDO are completed.

    ---
    NTDEV is sponsored by OSR

    Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

    OSR is HIRING!! See http://www.osr.com/careers

    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
  • Alex_GrigAlex_Grig Member Posts: 3,238
    >I have a miniport with a cdo per adapter which does wait for the cdo to cleanly
    drain & shutdown during mphalt.

    >It is ndis5 however.

    I wonder if NDIS5 actually does forward the PNP IRP to the CDO dispatch. Because NDIS6 is totally new code written.
  • David_R._CattleyDavid_R._Cattley Member - All Emails Posts: 2,112
    > I wonder if NDIS5 actually does forward the PNP IRP to the CDO dispatch.

    I doubt it but I cannot say. If it does, my CDO dispatch does not care as it does not process it. In other words, the desired outcome was achieved without being able to process PnP IRPs.

    Cheers,
    Dave Cattley
  • Jeffrey_Tippet_[MSFT]Jeffrey_Tippet_[MSFT] Member - All Emails Posts: 541
    No, the NDIS5 and NDIS6 CDOs share the same NDIS implementation. Neither allows IRP_MJ_PNP to reach your handlers.
  • Alex_GrigAlex_Grig Member Posts: 3,238
    >Neither allows IRP_MJ_PNP to reach your handlers.

    That's a regrettable shortcoming.
  • David_R._CattleyDavid_R._Cattley Member - All Emails Posts: 2,112
    > >Neither allows IRP_MJ_PNP to reach your handlers.
    >
    > That's a regrettable shortcoming.

    as well as not being able to have the CDO dispatch responsibility delegated to KMDF in an NDIS-KMDF driver :(

    Cheers,
    Dave Cattley
  • Doron_HolanDoron_Holan Member - All Emails Posts: 10,435
    Even if ndis delegated like you suggest, it wouldn't work when kmdf is initialized in miniport mode. Miniport allows you to use lower edge objects (Io targets, DMA, etc), it doesn't allow for Io queues

    d

    Bent from my Phone
    ________________________________
    From: Dave Cattley
    Sent: ?7/?8/?2013 11:48 AM
    To: Windows System Software Devs Interest List
    Subject: RE: [ntdev] NdisRegisterDeviceEx problem

    > >Neither allows IRP_MJ_PNP to reach your handlers.
    >
    > That's a regrettable shortcoming.

    as well as not being able to have the CDO dispatch responsibility delegated to KMDF in an NDIS-KMDF driver :(

    Cheers,
    Dave Cattley


    ---
    NTDEV is sponsored by OSR

    Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

    OSR is HIRING!! See http://www.osr.com/careers

    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
  • David_R._CattleyDavid_R._Cattley Member - All Emails Posts: 2,112
    I understand the current state of affairs. Some time back (DevCon long ago) we discussed whether or not CDO functionality (not PnP) might be able to be wired up in Miniport Mode to allow use of requests, queues, etc. In any event, it was a fantasy request. It seemed like it might be doable but perhaps not.

    Cheers,
    Dave Cattley

    From: xxxxx@microsoft.com
    To: xxxxx@lists.osr.com
    Subject: RE: [ntdev] NdisRegisterDeviceEx problem
    Date: Mon, 8 Jul 2013 16:49:27 +0000








    Even if ndis delegated like you suggest, it wouldn't work when kmdf is initialized in miniport mode. Miniport allows you to use lower edge objects (Io targets, DMA, etc), it doesn't allow for Io queues



    d
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