[Winpcap-users] pcap_findalldevs_ex in thread behaviour ?

Bryan Kadzban bryan at kadzban.is-a-geek.net
Tue Dec 16 03:45:40 GMT 2008


Gianluca Varenni wrote:
> It's not just enumerating them... it's capturing on them.

Oh, right, duh.  Any interaction needs to be from the single thread.

> I've been thinking a lot about this issue, and the only safe patch to
> the problem is actually spawning a separate process capturing from 
> NetMon and piping the packets back.

Does NetMon provide a proxy/stub pair (or does it work with the standard
COM marshaller) that would work instead?  That's the standard fix when
you need to interact with an STA interface from an MTA thread, or any
thread that isn't the one that created that interface: marshal the calls
over to the correct thread, and marshal the return stuff back.  Most COM
wrappers seem to do this automatically, as well, so maybe it isn't
possible here.

Also, if the netmon coclass is STA-only, then this will only work if the
netmon interface pointer is already present and has been moved over to
the target thread (CoMarshalInterThreadInterfaceInStream followed by a
CoGetInterfaceAndReleaseStream in the other thread).  It will also only
work if the STA thread is pumping messages...

Maybe a separate process is safer.  ;-)

-------------- 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/20081216/c24d73ca/signature.pgp


More information about the Winpcap-users mailing list