NDIS LWF StartType

The NDIS filter driver in WDF set StartType to 1 (SERVICE_SYSTEM_START), which I think is dangerous when I just begin to modify it. So I change it to 3 (SERVICE_DEMAND_START), but the problem is then the driver block the network before I start it. Only if I start the filter driver, does the network connect. Do I have to modify other settings?

Change INF FilteRunype to Optional and network should not block.

Personally: I suggest debugging LWF in a virtual machine. Leave as system
start. Rollback to snapshot when you screw up.

Thomas F. Divine

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@gmail.com
Sent: Tuesday, May 14, 2013 9:20 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] NDIS LWF StartType

The NDIS filter driver in WDF set StartType to 1 (SERVICE_SYSTEM_START),
which I think is dangerous when I just begin to modify it. So I change it to
3 (SERVICE_DEMAND_START), but the problem is then the driver block the
network before I start it. Only if I start the filter driver, does the
network connect. Do I have to modify other settings?


NTDEV is sponsored by OSR

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

Hi Thomas

Tanks for your answer. That solved the problem.

Additionally, I found MSDN said the network stack is available if the mandatory filter is installed but not started because starting the stack, pausing it, and then restarting it when an filter eventually loads may cause other side effects to upper-layer components that are watching for network availability. (http://support.microsoft.com/kb/2019184)

Yue

Sorry, it should be “unavailable” instead of “available”.

> Additionally, I found MSDN said the network stack is available if the mandatory filter is installed but not started because starting the stack, pausing it, and then restarting it when an filter eventually loads may cause other side effects to upper-layer components that are watching for network availability.

That’s not quite what KB 2019184 is about. First off, there are two types of filters: Optional and Mandatory. KB 2019184 has no bearing on Mandatory filters. If a Mandatory filter is missing, then the network stack won’t start. No exceptions^1.

On the other hand, if an Optional filter is missing, then the network stack may eventually start without the missing Optional filter. I say “may” because NDIS has some heuristics to avoid churn during early boot. These heuristics are roughly:

  • Windows Vista, Windows 7: NDIS won’t start the stack until all Optional filters have loaded, or the miniport has been running for 90 seconds

  • Windows 8: NDIS won’t start the stack until all Optional filters have loaded, or the OS has at least 30 seconds of uptime

KB2019184 is basically pointing out the problem with the heuristic used in Windows Vista & Windows 7: if a NIC is installed long *after* the OS boots, then a missing Optional filter will make that NIC unavailable for 90 seconds.

So our guidance is this:

a. If you implement an Optional filter, and intend to ship on Windows Vista or Windows 7, you should either:
a.1. Start your service at boot (StartType=1, StartType=2) or soon after through some other means, or
a.2. Implement some sort of INetCfg notify object to disable your filter’s binding to miniports by default, and only enable it when your application needs it (think Wireshark). This option is much more complicated, and is not preferred.

b. If you implement an Optional filter that will only ship on Windows 8 or later, you don’t really need to worry as much. If the filter is demand-start (StartType=3) and unlikely to be started at boot, you can add this line to your INF to avoid even the 30-second wait at boot:
HKR, Ndi,NdisBootStart,0x00010001, 0 ; Don’t wait for this driver to start at boot
But it’s not the end of the world if you don’t do this.

^1: Ok, there is one exception: a Mandatory filter that sets NDIS_FILTER_ATTACH_FLAGS_IGNORE_MANDATORY in its filter attach parameters will temporarily be treated as Optional for that particular miniport stack.