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?

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

Well, since CreateFile succeeds, the caller has enough priviliges.

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.

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. :slight_smile:

NDIS helpfully clears DO_DEVICE_INITIALIZING for you before NdisRegisterDeviceEx returns :slight_smile:

Ok. The problem was found actually in the test application code.

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.

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

@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.

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.

>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.

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.commailto:xxxxx
Sent: ‎7/‎3/‎2013 9:59 AM
To: Windows System Software Devs Interest Listmailto:xxxxx
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</mailto:xxxxx></mailto:xxxxx>

>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.

> 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

No, the NDIS5 and NDIS6 CDOs share the same NDIS implementation. Neither allows IRP_MJ_PNP to reach your handlers.

>Neither allows IRP_MJ_PNP to reach your handlers.

That’s a regrettable shortcoming.

> >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 :frowning:

Cheers,
Dave Cattley

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 Cattleymailto:xxxxx
Sent: ?7/?8/?2013 11:48 AM
To: Windows System Software Devs Interest Listmailto:xxxxx
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 :frowning:

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</mailto:xxxxx></mailto:xxxxx>

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