[Winpcap-users] pcap_findalldevs_ex in thread behaviour ?
Bryan Kadzban
bryan at kadzban.is-a-geek.net
Mon Dec 15 16:22:37 GMT 2008
psachet.ext at orange-ftgroup.com wrote:
> I have a multithreaded application, if I enumerate the devices with
> pcap_findalldevs_ex in the main thread everything is OK (I see
> network adapter, genericDialupAdapter and all the connected dialup
> adapter). But if I create a thread and then enumerate the net devices
> in this new thread I see only non-dialup network adapters.
>
> Is there any permissions tips that I didn't know ?
No.
This is a FAQ, though. (But I don't know where to find it. I've just
seen this answer on this list several times.)
The issue is Windows and COM. It has to do with apartments and
threading -- you can't create STA objects on an MTA thread (or a free
thread). The dialup stuff in WinPcap is done by calling out to a COM
object -- which can't be created unless you're in an STA thread. There
is only one STA thread per process (IIRC anyway), and it's the main GUI
thread in anything running under .net.
Just enumerate the devices in the main thread. ;-)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 260 bytes
Desc: OpenPGP digital signature
Url : http://www.winpcap.org/pipermail/winpcap-users/attachments/20081215/35d452ee/signature.pgp
More information about the Winpcap-users
mailing list