[Winpcap-users] why pcap_findalldevs run about 30 seconds

Bryan Kadzban bryan at kadzban.is-a-geek.net
Mon Dec 10 12:08:44 GMT 2007


-----BEGIN PGP SIGNED MESSAGE-----
Hash: RIPEMD160

工商银行 wrote:
> I found that  the pcap_findalldevs function consume about 34 seconds.
> My question is how long does the winpcap driver loaded ?

The driver loads in a few milliseconds, usually.

> Does it loaded earlier than the network interface loaded?

If it does load before the network card does, winpcap handles the
dynamic addition of the card.  As long as your program does a
pcap_findalldevs* after that new card is present, and you're using a
new-enough winpcap (4.0 should be fine), that will work fine.  (It also
won't cause an extra delay.)

> My program is put into the windows system service.auto started.

Oh, you're writing a service.  Well that's different then.  I'm guessing
that you're calling pcap_findalldevs in either ServiceMain or in your
service's START control handler?  Whenever you make your first winpcap
driver call (and pcap_findalldevs is one of those), the DLL tries to
start the "npf" driver.  But if the service control manager is in the
middle of starting your service, it won't go start another one.  (The
winpcap DLL also used to require the "nm" service to be running; I don't
know if this is true anymore, but I believe it still is.)

What you need to do is use service dependencies to make the service
control manager start the "npf" and "nm" services *before* it starts
yours.  When you call the API that installs your service, there should
be a parameter for dependencies (or you can add a REG_MULTI_SZ named
"DependOnService" to your service's registry key, but you have to reboot
for that to take effect).  Add both "npf" and "nm" as dependencies.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHXSxKS5vET1Wea5wRA4rFAJ4t/BmfYGXG2RDQyVOz6L3zPx8ZfgCgxsL/
UacLZ64+/wipzWv/sjA6ZB0=
=rKwm
-----END PGP SIGNATURE-----


More information about the Winpcap-users mailing list