Ndis 6 filter

Hi,

When ndis calls FilterAttach callback, how can a filter indicate that it is not interested in sugguested miniport.
Currently I return NDIS_STATUS_INVALID_PARAMETER (as the sample does), but I think I’m missing something because the miniport does not function normally. It does function normally if I attach to it.

What am I missing?

Thanks,
Anatoly.

During setup, your filter is bound to the miniport. This binding is permanently stored in the registry.

When your filter starts and registers with NDIS, NDIS tries to attach you to the miniport. If you return some error code (it doesn’t really matter which code), then NDIS figures that the filter *should* be attached (since the binding is still saved in the registry), but it *isn’t* bound (since you failed FilterAttach). What happens next depends on the FilterRunType:

* If you are a Mandatory filter (INF file says FilterRunType 0x00000001), NDIS will not allow protocols to bind until your filter attaches successfully. This is almost certainly what you are seeing, since the sample filter driver is marked as a Mandatory filter by default.

* If you are an optional filters (INF file says FilterRunType 0x00000002), NDIS will ignore the error in your FilterAttach and keep going.

So you have two possible solutions:

  1. The easiest (by far!) is to change yourself to be an Optional filter. All you have to do is change the ‘1’ to a ‘2’ in your INF’s FilterRunType directive. Note that you’ll still be bound to the miniport (e.g., the ncpa.cpl GUI will still list you in the Connection Properties box), but you just won’t be attached.

See also: http://msdn.microsoft.com/en-us/library/ff557135(v=VS.85).aspx

  1. If you must be a mandatory filter driver, or if you don’t want your filter to be shown in the GUI for adapters it won’t attach to, then you need to remove the bindings themselves. Bindings are created at setup-time in usermode, so you need to run code there. The way to do this is to create a Notify Object. The Notify Object will be notified when your filter is installed/removed, and also every time another NIC is installed/removed. From there, you can decide whether the filter driver is bound to each NIC. If the filter is not bound to a particular NIC, then your FilterAttach is never called, and so you don’t have to fail a FilterAttach. Beware that Notify Objects aren’t trivial, so you will have to budget some time if you go this route.

See also: http://msdn.microsoft.com/en-us/library/ff568810(v=VS.85).aspx

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@gmail.com
Sent: Friday, December 17, 2010 4:43 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] Ndis 6 filter

Hi,

When ndis calls FilterAttach callback, how can a filter indicate that it is not interested in sugguested miniport.
Currently I return NDIS_STATUS_INVALID_PARAMETER (as the sample does), but I think I’m missing something because the miniport does not function normally. It does function normally if I attach to it.

What am I missing?

Thanks,
Anatoly.


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