2.17. ETW – Event Tracing for Windows¶
The EtwManager instance is accessible via windows.system.etw
Note
This code is the result of my research on ETW that lead to this presentation ETW for the lazy reverser (FR)
Note
See sample ETW (Event Tracing for Windows)
2.17.1. EtwManager¶
- class windows.winobject.event_trace.EtwManager[source]¶
An object to query ETW session/providers and open new trace
- property providers¶
The list of currently existing ETW providers.
- Type:
[
TraceProvider] – A list of ETW providers
- property sessions¶
The list of currently active ETW session.
- Type:
[
EventTraceProperties] – A list ofEventTraceProperties
2.17.2. Tracing Events¶
2.17.2.1. EtwTrace¶
- class windows.winobject.event_trace.EtwTrace(name, logfile=None, guid=None)[source]¶
Represent an ETW Trace for tracing/processing events
- enable_ex(guid, flags=255, level=255, any_keyword=4294967295, all_keyword=0)[source]¶
Enable the specified event trace provider.
- guid¶
The guid of the trace
- logfile¶
The logging file of the trace (
Nonemeans real time trace)
- name¶
The name of the trace
- process(callback, begin=None, end=None, context=None)[source]¶
Process the event retrieved by the trace. This function will call
callbackwith anyEventRecordin the trace.begin/endallow to filter and only process events in a given timeframe.Warning
If the trace if
REALTIME(no logfile) this function will hang/process new event until the trace is stopped.Using
logman -ets stop TRACE_NAMEfor exemple.
2.17.2.2. EventTraceProperties¶
- class windows.winobject.event_trace.EventTraceProperties[source]¶
Represent an Event Trace session that may exist or now. (https://docs.microsoft.com/en-us/windows/win32/api/evntrace/ns-evntrace-event_trace_properties)
This class is widly used by
EtwTrace- classmethod create()[source]¶
Initialize a new
EventTraceProperties
- property guid¶
The GUID of the Event Trace session (see
Wnode.Guid)
- property id¶
The LoggerId if the session (see
Wnode.HistoricalContext)
- property logfile¶
The logfile associated with the session
- property name¶
The name of the session