How to consume real-time ETW events from the Microsoft-Windows-NDIS-PacketCapture provider?

痴心易碎 提交于 2019-12-03 01:20:27

If you look into what the "netsh trace" commands do internally you'll see they attach an NDIS lightweight filter driver to the various network interfaces. Only with this filter attached and activated will you get events from this provider. The details of this facility are undocumented and subject to change. All the logic of the netsh trace commands is implemented in nettrace.dll which you can reverse engineer with the assistance of Microsoft's public symbols. Specifically, the CInboxCapture class has code which determines whether the driver has been started, binds it to appropriate network interfaces and starts it. If you start the capturing filter driver the way nettrace.dll does, you'll get your packet capture events.

Good luck.

For what it's worth, I did find one example of a real-time ETW consumer (the example is for IIS web server): http://blogs.iis.net/eokim/archive/2009/05/15/consume-iis-etw-tracing.aspx

Here's a commented c++ example application that demonstrates simultaneous real-time ETW sessions for packet capture and kernel events.

https://github.com/packetzero/etwrealtime

Stephen Vickers

Instead of running netsh trace start etc. you could try this:

net start ndiscap

When running netsh trace etc. it will do this for you, and I think that's the missing part here, that the lightweight filter driver which is injected into ndis to capture packets (i.e. the etw provider) is not running and emitting events.

When you are finished you can stop it using:

net stop ndiscap
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!