PyEtwMonitor (version 0.0.1)
index
pyetwmonitor.py

Real-time Windows ETW monitoring module.
 
This module provides a real-time Event Tracing for Windows (ETW)
monitoring solution implemented entirely with Python's standard
library and
 
It enables the collection, decoding, filtering, and display of
events generated by modern Windows kernel providers.
 
Supported providers:
    file:
        Microsoft-Windows-Kernel-File
        {EDD08927-9CC4-4E65-B970-C2560FB5C289}
 
    process:
        Microsoft-Windows-Kernel-Process
        {22FB2CD6-0E7B-422B-A0C7-2FAD1FD0E716}
 
    network:
        Microsoft-Windows-Kernel-Network
        {7DD42A49-5329-4832-8DFD-43D979153A88}
 
    registry:
        Microsoft-Windows-Kernel-Registry
        {70EB4F03-C1DE-4F73-A051-33D13D5413BD}
 
    memory:
        Microsoft-Windows-Kernel-Memory
        {D1D93EF7-E1F2-4F45-9943-03D245FE6C00}
 
Main features:
    - Real-time ETW session creation and management.
    - Multiple simultaneous kernel provider activation.
    - Event consumption through OpenTraceW and ProcessTrace.
    - Event metadata retrieval using the Windows TDH API.
    - Automatic decoding of supported ETW property types.
    - Filtering by process ID, event ID, and provider name.
    - Configurable trace verbosity.
    - Graceful shutdown and session cleanup.
 
Architecture:
    1. Parse command-line arguments and configure filters.
    2. Validate administrator privileges.
    3. Create a private real-time ETW tracing session.
    4. Enable the selected ETW providers.
    5. Open an event consumer and register the callback.
    6. Process incoming events in a dedicated worker thread.
    7. Decode and display event metadata and properties.
    8. Close the consumer and stop the tracing session.
 
Requirements:
    - Windows operating system.
    - Python 3.9 or later.
    - Administrator privileges for kernel provider access.
    - No third-party Python dependencies.
 
Usage:
    python PyEtwMonitor.py
 
    python PyEtwMonitor.py --providers file,process
 
    python PyEtwMonitor.py --pid 4821 9100 --event-id 12 15
 
    python PyEtwMonitor.py --providers network,registry --level verbose
 
    python PyEtwMonitor.py --list-providers
 
Command-line arguments:
    --providers:
        Comma-separated list of providers to enable.
        Accepts 'all' to enable every registered provider.
 
    --pid:
        Restrict displayed events to the specified process IDs.
 
    --event-id:
        Restrict displayed events to the specified event IDs.
 
    --provider-filter:
        Restrict displayed events to selected provider names.
 
    --level:
        Set the provider trace level ('info' or 'verbose').
 
    --list-providers:
        Display registered providers and exit.
 
Notes:
    - ETW sessions are managed through Windows APIs.
    - Event decoding depends on provider metadata availability.
    - Some providers or events may require additional privileges.
    - The module is designed for diagnostic and system monitoring
      purposes.
 
Usage examples:
 
    Monitor process creation:
        python PyEtwMonitor.py --providers process --event-id 1
 
    Monitor a specific process:
        python PyEtwMonitor.py --pid <id>
 
    Monitor network activity:
        python PyEtwMonitor.py --providers network
 
    Monitor file open events:
        python PyEtwMonitor.py --providers file --event-id 12
 
    Monitor file creation events:
        python PyEtwMonitor.py --providers file --event-id 10
 
    Monitor file deletion events:
        python PyEtwMonitor.py --providers file --event-id 11 18
 
    Monitor image loading by a specific process:
        python PyEtwMonitor.py --pid <id> --providers process --event-id 5
 
    Monitor registry key open events:
        python PyEtwMonitor.py --providers registry --event-id 2
 
    Monitor registry key creation events:
        python PyEtwMonitor.py --providers registry --event-id 1
 
    Monitor registry value modification events:
        python PyEtwMonitor.py --providers registry --event-id 5
 
File:
• 10 : NameCreate
• 11 : NameDelete
• 12 : Create / Create_V1
• 13 : Cleanup / Cleanup_V1
• 14 : Close / Close_V1
• 15 : Read / Read_V1
• 16 : Write / Write_V1
• 17 : SetInformation / SetInformation_V1
• 18 : SetDelete / SetDelete_V1
• 19 : Rename / Rename_V1
• 20 : DirEnum / DirEnum_V1
• 21 : Flush / Flush_V1
• 22 : QueryInformation / QueryInformation_V1
• 23 : FSCTL / FSCTL_V1
• 24 : OperationEnd
• 25 : DirNotify / DirNotify_V1
• 26 : DeletePath / DeletePath_V1
• 27 : RenamePath / RenamePath_V1
• 28 : SetLinkPath / SetLinkPath_V1
• 29 : Rename29 / Rename29_V1
• 30 : CreateNewFile / CreateNewFile_V1
• 31 : SetSecurity_V1
• 32 : QuerySecurity_V1
• 33 : SetEA_V1
• 34 : QueryEA_V1
 
Memory:
• 1 : MemInfo_V1
• 2 : MemInfoWS / MemInfoWS_V1 / MemInfoWS_V2
• 3 : MemInfoSessionWS / MemInfoSessionWS_V1 / MemInfoSessionWS_V2
• 4 : WorkingSetOutSwapStart / WorkingSetOutSwapStart_V1
• 5 : WorkingSetOutSwapStop / WorkingSetOutSwapStop_V1
• 6 : WorkingSetInSwapStart / WorkingSetInSwapStart_V1
• 7 : WorkingSetInSwapStop
• 8 : Acg
• 9 : WorkingSetInSwap
• 10 : MdlAllocation
• 11 : ContAllocation
• 12 : MemInfoNode
 
Network:
• 10 : KERNEL_NETWORK_TASK_TCPIPDatasent.
• 11 : KERNEL_NETWORK_TASK_TCPIPDatareceived.
• 12 : KERNEL_NETWORK_TASK_TCPIPConnectionattempted.
• 13 : KERNEL_NETWORK_TASK_TCPIPDisconnectissued.
• 14 : KERNEL_NETWORK_TASK_TCPIPDataretransmitted.
• 15 : KERNEL_NETWORK_TASK_TCPIPConnectionaccepted.
• 16 : KERNEL_NETWORK_TASK_TCPIPReconnectattempted.
• 17 : KERNEL_NETWORK_TASK_TCPIPTCPconnectionattemptfailed.
• 18 : KERNEL_NETWORK_TASK_TCPIPProtocolcopieddataonbehalfofuser.
• 26 : KERNEL_NETWORK_TASK_TCPIPDatasent.26
• 27 : KERNEL_NETWORK_TASK_TCPIPDatareceived.27
• 28 : KERNEL_NETWORK_TASK_TCPIPConnectionattempted.28
• 29 : KERNEL_NETWORK_TASK_TCPIPDisconnectissued.29
• 30 : KERNEL_NETWORK_TASK_TCPIPDataretransmitted.30
• 31 : KERNEL_NETWORK_TASK_TCPIPConnectionaccepted.31
• 32 : KERNEL_NETWORK_TASK_TCPIPReconnectattempted.32
• 34 : KERNEL_NETWORK_TASK_TCPIPProtocolcopieddataonbehalfofuser.34
• 42 : KERNEL_NETWORK_TASK_UDPIPDatasentoverUDPprotocol.
• 43 : KERNEL_NETWORK_TASK_UDPIPDatareceivedoverUDPprotocol.
• 49 : KERNEL_NETWORK_TASK_UDPIPUDPconnectionattemptfailed.
• 58 : KERNEL_NETWORK_TASK_UDPIPDatasentoverUDPprotocol.58
• 59 : KERNEL_NETWORK_TASK_UDPIPDatareceivedoverUDPprotocol.59
 
Process:
• 1 : ProcessStart / ProcessStart_V1 / ProcessStart_V2 / ProcessStart_V3
• 2 : ProcessStop / ProcessStop_V1 / ProcessStop_V2
• 3 : ThreadStart / ThreadStart_V1
• 4 : ThreadStop / ThreadStop_V1
• 5 : ImageLoad
• 6 : ImageUnload
• 7 : CpuBasePriorityChange
• 8 : CpuPriorityChange
• 9 : PagePriorityChange
• 10 : IoPriorityChange
• 11 : ProcessFreezeStart / ProcessFreezeStart_V1
• 12 : ProcessFreezeStop / ProcessFreezeStop_V1
• 13 : JobStart
• 14 : JobTerminateStop
• 15 : ProcessRundown / ProcessRundown_V1
• 16 : task_0
• 17 : PsDiskIoAttributionStart
• 18 : PsDiskIoAttributionStop
• 19 : PsIoRateControlStart / PsIoRateControlStart_V1 / PsIoRateControlStart_V2
• 20 : PsIoRateControlStop / PsIoRateControlStop_V1 / PsIoRateControlStop_V2
• 21 : ThreadWorkOnBehalfUpdate
• 22 : JobServerSiloStart
• 23 : JobServerSiloStart23
• 24 : JobServerSiloStartStop
• 25 : JobServerSiloStart25
• 26 : JobServerSiloStartStop26
 
Registry:
• 1 : task_0CreateKey
• 2 : task_0OpenKey
• 3 : task_0DeleteKey
• 4 : task_0QueryKey
• 5 : task_0SetValueKey
• 6 : task_0DeleteValueKey
• 7 : task_0QueryValueKey
• 8 : task_0EnumerateKey
• 9 : task_0EnumerateValueKey
• 10 : task_0QueryMultipleValueKey
• 11 : task_0SetInformationKey
• 12 : task_0FlushKey
• 13 : task_0CloseKey
• 14 : task_0QuerySecurityKey
• 15 : task_0SetSecurityKey
• 16 : Thisgroupofeventstrackstheperformanceofmountinghivesfromexistingfiles.Start
• 17 : Thisgroupofeventstrackstheperformanceofmountinghivesfromexistingfiles.RegPerfOpHiveMountBaseFileMounted
• 18 : Thisgroupofeventstrackstheperformanceofmountinghivesfromexistingfiles.RegPerfOpHiveMountLogEntryApplied
• 19 : Thisgroupofeventstrackstheperformanceofmountinghivesfromexistingfiles.Stop
• 20 : Thisgroupofeventstrackstheperformanceofunloadinghives.Start
• 21 : Thisgroupofeventstrackstheperformanceofunloadinghives.Stop
• 22 : Thisgroupofeventstrackstheperformanceofflushinghives.Start
• 23 : Thisgroupofeventstrackstheperformanceofflushinghives.RegPerfOpHiveFlushBecameActiveFlusher
• 24 : Thisgroupofeventstrackstheperformanceofflushinghives.RegPerfOpHiveFlushGatheredLogData
• 25 : Thisgroupofeventstrackstheperformanceofflushinghives.RegPerfOpHiveFlushGatheredPrimaryData
• 26 : Thisgroupofeventstrackstheperformanceofflushinghives.RegPerfOpHiveFlushWroteLogFile
• 27 : Thisgroupofeventstrackstheperformanceofflushinghives.RegPerfOpHiveFlushWrotePrimaryFile
• 28 : Thisgroupofeventstrackstheperformanceofflushinghives.RegPerfOpHiveFlushBoostedActiveFlusher
• 29 : Thisgroupofeventstrackstheperformanceofflushinghives.RegPerfOpHiveFlushStartWaitForActive
• 30 : Thisgroupofeventstrackstheperformanceofflushinghives.RegPerfOpHiveFlushFinishWaitForActive
• 31 : Thisgroupofeventstrackstheperformanceofflushinghives.Stop
• 32 : Thisgroupofeventstrackstheperformanceofregistryshutdown.Start
• 33 : Thisgroupofeventstrackstheperformanceofregistryshutdown.Start33
• 34 : Thisgroupofeventstrackstheperformanceofregistryshutdown.RegPerfOpShutdownFlushStart
• 35 : Thisgroupofeventstrackstheperformanceofregistryshutdown.RegPerfOpShutdownFlushStop
• 36 : Thisgroupofeventstrackstheperformanceofregistryshutdown.Stop
• 37 : Thisgroupofeventstrackstheperformanceofloadinghives.Start
• 38 : Thisgroupofeventstrackstheperformanceofloadinghives.Stop
• 39 : Thisgroupofeventstrackstheperformanceofrestoringhives.Start
• 40 : Thisgroupofeventstrackstheperformanceofrestoringhives.Stop
• 41 : Thisgroupofeventstrackstheperformanceofexportinghives.Start
• 42 : Thisgroupofeventstrackstheperformanceofexportinghives.RegPerfOpSaveFileCopied
• 43 : Thisgroupofeventstrackstheperformanceofexportinghives.RegPerfOpSaveTreeCopied
• 44 : Thisgroupofeventstrackstheperformanceofexportinghives.RegPerfOpSaveFileWritten
• 45 : Thisgroupofeventstrackstheperformanceofexportinghives.Stop

 
Classes
       
_ctypes.CFuncPtr(_ctypes._CData)
ctypes.WinFunctionType
_ctypes.Structure(_ctypes._CData)
ENABLE_TRACE_PARAMETERS
ETW_BUFFER_CONTEXT
EVENT_DESCRIPTOR
EVENT_HEADER
EVENT_PROPERTY_INFO
EVENT_RECORD
EVENT_TRACE
EVENT_TRACE_HEADER
EVENT_TRACE_LOGFILEW
EVENT_TRACE_PROPERTIES
GUID
PROPERTY_DATA_DESCRIPTOR
SYSTEMTIME
TIME_ZONE_INFORMATION
TRACE_EVENT_INFO_HEADER
TRACE_LOGFILE_HEADER
WNODE_HEADER

 
class ENABLE_TRACE_PARAMETERS(_ctypes.Structure)
    Represent ETW provider activation parameters.
 
 
Method resolution order:
ENABLE_TRACE_PARAMETERS
_ctypes.Structure
_ctypes._CData
builtins.object

Data descriptors defined here:
ControlFlags
EnableFilterDesc
EnableProperty
FilterDescCount
SourceId
Version
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

Methods inherited from _ctypes.Structure:
__buffer__(self, flags, /)
Return a buffer object that exposes the underlying memory of the object.
__init__(self, /, *args, **kwargs)
Initialize self.  See help(type(self)) for accurate signature.

Static methods inherited from _ctypes.Structure:
__new__(*args, **kwargs) class method of _ctypes.Structure
Create and return a new object.  See help(type) for accurate signature.

Methods inherited from _ctypes._CData:
__ctypes_from_outparam__(self, /)
default __ctypes_from_outparam__ method returns self.
__hash__(self, /)
Return hash(self).
__reduce__(self, /)
Helper for pickle.
__setstate__(self, dict, data, /)

 
class ETW_BUFFER_CONTEXT(_ctypes.Structure)
    Represent the ETW buffer context.
 
 
Method resolution order:
ETW_BUFFER_CONTEXT
_ctypes.Structure
_ctypes._CData
builtins.object

Data descriptors defined here:
LoggerId
ProcessorIndex
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

Methods inherited from _ctypes.Structure:
__buffer__(self, flags, /)
Return a buffer object that exposes the underlying memory of the object.
__init__(self, /, *args, **kwargs)
Initialize self.  See help(type(self)) for accurate signature.

Static methods inherited from _ctypes.Structure:
__new__(*args, **kwargs) class method of _ctypes.Structure
Create and return a new object.  See help(type) for accurate signature.

Methods inherited from _ctypes._CData:
__ctypes_from_outparam__(self, /)
default __ctypes_from_outparam__ method returns self.
__hash__(self, /)
Return hash(self).
__reduce__(self, /)
Helper for pickle.
__setstate__(self, dict, data, /)

 
class EVENT_DESCRIPTOR(_ctypes.Structure)
    Represent an ETW event descriptor.
 
 
Method resolution order:
EVENT_DESCRIPTOR
_ctypes.Structure
_ctypes._CData
builtins.object

Data descriptors defined here:
Channel
Id
Keyword
Level
Opcode
Task
Version
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

Methods inherited from _ctypes.Structure:
__buffer__(self, flags, /)
Return a buffer object that exposes the underlying memory of the object.
__init__(self, /, *args, **kwargs)
Initialize self.  See help(type(self)) for accurate signature.

Static methods inherited from _ctypes.Structure:
__new__(*args, **kwargs) class method of _ctypes.Structure
Create and return a new object.  See help(type) for accurate signature.

Methods inherited from _ctypes._CData:
__ctypes_from_outparam__(self, /)
default __ctypes_from_outparam__ method returns self.
__hash__(self, /)
Return hash(self).
__reduce__(self, /)
Helper for pickle.
__setstate__(self, dict, data, /)

 
class EVENT_HEADER(_ctypes.Structure)
    Represent an ETW event header.
 
 
Method resolution order:
EVENT_HEADER
_ctypes.Structure
_ctypes._CData
builtins.object

Data descriptors defined here:
ActivityId
EventDescriptor
EventProperty
Flags
HeaderType
KernelTime
ProcessId
ProviderId
Size
ThreadId
TimeStamp
UserTime
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

Methods inherited from _ctypes.Structure:
__buffer__(self, flags, /)
Return a buffer object that exposes the underlying memory of the object.
__init__(self, /, *args, **kwargs)
Initialize self.  See help(type(self)) for accurate signature.

Static methods inherited from _ctypes.Structure:
__new__(*args, **kwargs) class method of _ctypes.Structure
Create and return a new object.  See help(type) for accurate signature.

Methods inherited from _ctypes._CData:
__ctypes_from_outparam__(self, /)
default __ctypes_from_outparam__ method returns self.
__hash__(self, /)
Return hash(self).
__reduce__(self, /)
Helper for pickle.
__setstate__(self, dict, data, /)

 
class EVENT_PROPERTY_INFO(_ctypes.Structure)
    Represent an ETW event property descriptor.
 
 
Method resolution order:
EVENT_PROPERTY_INFO
_ctypes.Structure
_ctypes._CData
builtins.object

Data descriptors defined here:
Count
Flags
InType
Length
MapNameOffset
NameOffset
OutType
Reserved
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

Methods inherited from _ctypes.Structure:
__buffer__(self, flags, /)
Return a buffer object that exposes the underlying memory of the object.
__init__(self, /, *args, **kwargs)
Initialize self.  See help(type(self)) for accurate signature.

Static methods inherited from _ctypes.Structure:
__new__(*args, **kwargs) class method of _ctypes.Structure
Create and return a new object.  See help(type) for accurate signature.

Methods inherited from _ctypes._CData:
__ctypes_from_outparam__(self, /)
default __ctypes_from_outparam__ method returns self.
__hash__(self, /)
Return hash(self).
__reduce__(self, /)
Helper for pickle.
__setstate__(self, dict, data, /)

 
class EVENT_RECORD(_ctypes.Structure)
    Represent an ETW event record.
 
 
Method resolution order:
EVENT_RECORD
_ctypes.Structure
_ctypes._CData
builtins.object

Data descriptors defined here:
BufferContext
EventHeader
ExtendedData
ExtendedDataCount
UserContext
UserData
UserDataLength
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

Methods inherited from _ctypes.Structure:
__buffer__(self, flags, /)
Return a buffer object that exposes the underlying memory of the object.
__init__(self, /, *args, **kwargs)
Initialize self.  See help(type(self)) for accurate signature.

Static methods inherited from _ctypes.Structure:
__new__(*args, **kwargs) class method of _ctypes.Structure
Create and return a new object.  See help(type) for accurate signature.

Methods inherited from _ctypes._CData:
__ctypes_from_outparam__(self, /)
default __ctypes_from_outparam__ method returns self.
__hash__(self, /)
Return hash(self).
__reduce__(self, /)
Helper for pickle.
__setstate__(self, dict, data, /)

 
EVENT_RECORD_CALLBACK = class WinFunctionType(_ctypes.CFuncPtr)
    
Method resolution order:
WinFunctionType
_ctypes.CFuncPtr
_ctypes._CData
builtins.object

Data descriptors defined here:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

Methods inherited from _ctypes.CFuncPtr:
__bool__(self, /)
True if self else False
__buffer__(self, flags, /)
Return a buffer object that exposes the underlying memory of the object.
__call__(self, /, *args, **kwargs)
Call self as a function.
__repr__(self, /)
Return repr(self).

Static methods inherited from _ctypes.CFuncPtr:
__new__(*args, **kwargs) class method of _ctypes.CFuncPtr
Create and return a new object.  See help(type) for accurate signature.

Data descriptors inherited from _ctypes.CFuncPtr:
argtypes
specify the argument types
errcheck
a function to check for errors
restype
specify the result type

Methods inherited from _ctypes._CData:
__ctypes_from_outparam__(self, /)
default __ctypes_from_outparam__ method returns self.
__hash__(self, /)
Return hash(self).
__reduce__(self, /)
Helper for pickle.
__setstate__(self, dict, data, /)

 
class EVENT_TRACE(_ctypes.Structure)
    Represent a legacy ETW event.
 
 
Method resolution order:
EVENT_TRACE
_ctypes.Structure
_ctypes._CData
builtins.object

Data descriptors defined here:
ClientContextUnion
Header
InstanceId
MofData
MofLength
ParentGuid
ParentInstanceId
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

Methods inherited from _ctypes.Structure:
__buffer__(self, flags, /)
Return a buffer object that exposes the underlying memory of the object.
__init__(self, /, *args, **kwargs)
Initialize self.  See help(type(self)) for accurate signature.

Static methods inherited from _ctypes.Structure:
__new__(*args, **kwargs) class method of _ctypes.Structure
Create and return a new object.  See help(type) for accurate signature.

Methods inherited from _ctypes._CData:
__ctypes_from_outparam__(self, /)
default __ctypes_from_outparam__ method returns self.
__hash__(self, /)
Return hash(self).
__reduce__(self, /)
Helper for pickle.
__setstate__(self, dict, data, /)

 
class EVENT_TRACE_HEADER(_ctypes.Structure)
    Represent the legacy ETW event header.
 
 
Method resolution order:
EVENT_TRACE_HEADER
_ctypes.Structure
_ctypes._CData
builtins.object

Data descriptors defined here:
FieldTypeFlags
Guid
ProcessId
Size
ThreadId
TimeStamp
UnionTail
VersionUnion
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

Methods inherited from _ctypes.Structure:
__buffer__(self, flags, /)
Return a buffer object that exposes the underlying memory of the object.
__init__(self, /, *args, **kwargs)
Initialize self.  See help(type(self)) for accurate signature.

Static methods inherited from _ctypes.Structure:
__new__(*args, **kwargs) class method of _ctypes.Structure
Create and return a new object.  See help(type) for accurate signature.

Methods inherited from _ctypes._CData:
__ctypes_from_outparam__(self, /)
default __ctypes_from_outparam__ method returns self.
__hash__(self, /)
Return hash(self).
__reduce__(self, /)
Helper for pickle.
__setstate__(self, dict, data, /)

 
class EVENT_TRACE_LOGFILEW(_ctypes.Structure)
    Represent a real-time ETW consumer logfile.
 
 
Method resolution order:
EVENT_TRACE_LOGFILEW
_ctypes.Structure
_ctypes._CData
builtins.object

Data descriptors defined here:
BufferCallback
BufferSize
BuffersRead
Context
CurrentEvent
CurrentTime
EventRecordCallback
EventsLost
Filled
IsKernelTrace
LogFileName
LogfileHeader
LoggerName
ProcessTraceMode
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

Methods inherited from _ctypes.Structure:
__buffer__(self, flags, /)
Return a buffer object that exposes the underlying memory of the object.
__init__(self, /, *args, **kwargs)
Initialize self.  See help(type(self)) for accurate signature.

Static methods inherited from _ctypes.Structure:
__new__(*args, **kwargs) class method of _ctypes.Structure
Create and return a new object.  See help(type) for accurate signature.

Methods inherited from _ctypes._CData:
__ctypes_from_outparam__(self, /)
default __ctypes_from_outparam__ method returns self.
__hash__(self, /)
Return hash(self).
__reduce__(self, /)
Helper for pickle.
__setstate__(self, dict, data, /)

 
class EVENT_TRACE_PROPERTIES(_ctypes.Structure)
    Represent the properties of an ETW tracing session.
 
 
Method resolution order:
EVENT_TRACE_PROPERTIES
_ctypes.Structure
_ctypes._CData
builtins.object

Data descriptors defined here:
AgeLimit
BufferSize
BuffersWritten
EnableFlags
EventsLost
FlushTimer
FreeBuffers
LogBuffersLost
LogFileMode
LogFileNameOffset
LoggerNameOffset
LoggerThreadId
MaximumBuffers
MaximumFileSize
MinimumBuffers
NumberOfBuffers
RealTimeBuffersLost
Wnode
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

Methods inherited from _ctypes.Structure:
__buffer__(self, flags, /)
Return a buffer object that exposes the underlying memory of the object.
__init__(self, /, *args, **kwargs)
Initialize self.  See help(type(self)) for accurate signature.

Static methods inherited from _ctypes.Structure:
__new__(*args, **kwargs) class method of _ctypes.Structure
Create and return a new object.  See help(type) for accurate signature.

Methods inherited from _ctypes._CData:
__ctypes_from_outparam__(self, /)
default __ctypes_from_outparam__ method returns self.
__hash__(self, /)
Return hash(self).
__reduce__(self, /)
Helper for pickle.
__setstate__(self, dict, data, /)

 
class GUID(_ctypes.Structure)
    Represent a Windows globally unique identifier.
 
 
Method resolution order:
GUID
_ctypes.Structure
_ctypes._CData
builtins.object

Data descriptors defined here:
Data1
Data2
Data3
Data4
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

Methods inherited from _ctypes.Structure:
__buffer__(self, flags, /)
Return a buffer object that exposes the underlying memory of the object.
__init__(self, /, *args, **kwargs)
Initialize self.  See help(type(self)) for accurate signature.

Static methods inherited from _ctypes.Structure:
__new__(*args, **kwargs) class method of _ctypes.Structure
Create and return a new object.  See help(type) for accurate signature.

Methods inherited from _ctypes._CData:
__ctypes_from_outparam__(self, /)
default __ctypes_from_outparam__ method returns self.
__hash__(self, /)
Return hash(self).
__reduce__(self, /)
Helper for pickle.
__setstate__(self, dict, data, /)

 
class PROPERTY_DATA_DESCRIPTOR(_ctypes.Structure)
    Represent a TDH property data descriptor.
 
 
Method resolution order:
PROPERTY_DATA_DESCRIPTOR
_ctypes.Structure
_ctypes._CData
builtins.object

Data descriptors defined here:
ArrayIndex
PropertyName
Reserved
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

Methods inherited from _ctypes.Structure:
__buffer__(self, flags, /)
Return a buffer object that exposes the underlying memory of the object.
__init__(self, /, *args, **kwargs)
Initialize self.  See help(type(self)) for accurate signature.

Static methods inherited from _ctypes.Structure:
__new__(*args, **kwargs) class method of _ctypes.Structure
Create and return a new object.  See help(type) for accurate signature.

Methods inherited from _ctypes._CData:
__ctypes_from_outparam__(self, /)
default __ctypes_from_outparam__ method returns self.
__hash__(self, /)
Return hash(self).
__reduce__(self, /)
Helper for pickle.
__setstate__(self, dict, data, /)

 
class SYSTEMTIME(_ctypes.Structure)
    Represent the Windows SYSTEMTIME structure.
 
 
Method resolution order:
SYSTEMTIME
_ctypes.Structure
_ctypes._CData
builtins.object

Data descriptors defined here:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object
wDay
wDayOfWeek
wHour
wMilliseconds
wMinute
wMonth
wSecond
wYear

Methods inherited from _ctypes.Structure:
__buffer__(self, flags, /)
Return a buffer object that exposes the underlying memory of the object.
__init__(self, /, *args, **kwargs)
Initialize self.  See help(type(self)) for accurate signature.

Static methods inherited from _ctypes.Structure:
__new__(*args, **kwargs) class method of _ctypes.Structure
Create and return a new object.  See help(type) for accurate signature.

Methods inherited from _ctypes._CData:
__ctypes_from_outparam__(self, /)
default __ctypes_from_outparam__ method returns self.
__hash__(self, /)
Return hash(self).
__reduce__(self, /)
Helper for pickle.
__setstate__(self, dict, data, /)

 
class TIME_ZONE_INFORMATION(_ctypes.Structure)
    Represent Windows time zone information.
 
 
Method resolution order:
TIME_ZONE_INFORMATION
_ctypes.Structure
_ctypes._CData
builtins.object

Data descriptors defined here:
Bias
DaylightBias
DaylightDate
DaylightName
StandardBias
StandardDate
StandardName
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

Methods inherited from _ctypes.Structure:
__buffer__(self, flags, /)
Return a buffer object that exposes the underlying memory of the object.
__init__(self, /, *args, **kwargs)
Initialize self.  See help(type(self)) for accurate signature.

Static methods inherited from _ctypes.Structure:
__new__(*args, **kwargs) class method of _ctypes.Structure
Create and return a new object.  See help(type) for accurate signature.

Methods inherited from _ctypes._CData:
__ctypes_from_outparam__(self, /)
default __ctypes_from_outparam__ method returns self.
__hash__(self, /)
Return hash(self).
__reduce__(self, /)
Helper for pickle.
__setstate__(self, dict, data, /)

 
class TRACE_EVENT_INFO_HEADER(_ctypes.Structure)
    Represent the TDH event information header.
 
 
Method resolution order:
TRACE_EVENT_INFO_HEADER
_ctypes.Structure
_ctypes._CData
builtins.object

Data descriptors defined here:
BinaryXMLOffset
BinaryXMLSize
ChannelNameOffset
DecodingSource
EventAttributesOffset
EventDescriptor
EventGuid
EventMessageOffset
EventNameOffset
Flags
KeywordsNameOffset
LevelNameOffset
OpcodeNameOffset
PropertyCount
ProviderGuid
ProviderMessageOffset
ProviderNameOffset
TaskNameOffset
TopLevelPropertyCount
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

Methods inherited from _ctypes.Structure:
__buffer__(self, flags, /)
Return a buffer object that exposes the underlying memory of the object.
__init__(self, /, *args, **kwargs)
Initialize self.  See help(type(self)) for accurate signature.

Static methods inherited from _ctypes.Structure:
__new__(*args, **kwargs) class method of _ctypes.Structure
Create and return a new object.  See help(type) for accurate signature.

Methods inherited from _ctypes._CData:
__ctypes_from_outparam__(self, /)
default __ctypes_from_outparam__ method returns self.
__hash__(self, /)
Return hash(self).
__reduce__(self, /)
Helper for pickle.
__setstate__(self, dict, data, /)

 
class TRACE_LOGFILE_HEADER(_ctypes.Structure)
    Represent the ETW logfile header.
 
 
Method resolution order:
TRACE_LOGFILE_HEADER
_ctypes.Structure
_ctypes._CData
builtins.object

Data descriptors defined here:
BootTime
BufferSize
BuffersLost
BuffersWritten
EndTime
LogFileMode
LogFileName
LogInstanceGuidUnion
LoggerName
MaximumFileSize
NumberOfProcessors
PerfFreq
ProviderVersion
ReservedFlags
StartTime
TimeZone
TimerResolution
VersionUnion
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

Methods inherited from _ctypes.Structure:
__buffer__(self, flags, /)
Return a buffer object that exposes the underlying memory of the object.
__init__(self, /, *args, **kwargs)
Initialize self.  See help(type(self)) for accurate signature.

Static methods inherited from _ctypes.Structure:
__new__(*args, **kwargs) class method of _ctypes.Structure
Create and return a new object.  See help(type) for accurate signature.

Methods inherited from _ctypes._CData:
__ctypes_from_outparam__(self, /)
default __ctypes_from_outparam__ method returns self.
__hash__(self, /)
Return hash(self).
__reduce__(self, /)
Helper for pickle.
__setstate__(self, dict, data, /)

 
class WNODE_HEADER(_ctypes.Structure)
    Represent the ETW WNODE header.
 
 
Method resolution order:
WNODE_HEADER
_ctypes.Structure
_ctypes._CData
builtins.object

Data descriptors defined here:
BufferSize
ClientContext
Flags
Guid
HistoricalContext
ProviderId
TimeStamp
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

Methods inherited from _ctypes.Structure:
__buffer__(self, flags, /)
Return a buffer object that exposes the underlying memory of the object.
__init__(self, /, *args, **kwargs)
Initialize self.  See help(type(self)) for accurate signature.

Static methods inherited from _ctypes.Structure:
__new__(*args, **kwargs) class method of _ctypes.Structure
Create and return a new object.  See help(type) for accurate signature.

Methods inherited from _ctypes._CData:
__ctypes_from_outparam__(self, /)
default __ctypes_from_outparam__ method returns self.
__hash__(self, /)
Return hash(self).
__reduce__(self, /)
Helper for pickle.
__setstate__(self, dict, data, /)

 
Functions
       
cleanup_session( consumer_handle: TRACEHANDLE, worker: Thread, session_handle: TRACEHANDLE ) -> None
Close the consumer and stop the ETW tracing session.
configure_provider_names(selected: list[str]) -> None
Register GUID-to-name mappings for selected providers.
create_session_properties(logger_name: str, include_flags: bool = False) -> tuple
Create and initialize an ETW session properties buffer.
decode_guid(raw: bytes) -> str
Decode binary GUID data into its textual representation.
decode_hexadecimal(raw: bytes, size: int) -> str
Decode binary data into a hexadecimal integer string.
decode_integer(raw: bytes, size: int, signed: bool = False) -> str
Decode a little-endian integer into a string.
decode_property( record: EVENT_RECORD, info_buffer: Any, prop: EVENT_PROPERTY_INFO ) -> Tuple[str, str]
Retrieve and decode an individual ETW event property.
decode_raw_value(raw: bytes, input_type: int) -> str
Decode an ETW property according to its TDH input type.
decode_string(raw: bytes, encoding: str) -> str
Decode null-terminated string data using the specified encoding.
display_event( record: EVENT_RECORD, provider_name: str, info_buffer: Optional[Any] ) -> None
Display an event header and its decoded properties.
display_event_header(record: EVENT_RECORD, provider_name: str) -> None
Display the metadata contained in an ETW event header.
display_event_properties(record: EVENT_RECORD, info_buffer: Any) -> None
Display the decoded properties of an ETW event.
display_providers() -> None
Display all registered ETW providers and their GUIDs.
enable_provider(session_handle: TRACEHANDLE, guid_string: str, level: int) -> None
Enable an ETW provider for the specified tracing session.
get_event_info(record: EVENT_RECORD) -> Optional[Any]
Retrieve the TDH metadata buffer associated with an event.
get_event_name(info_buffer: Any, info: TRACE_EVENT_INFO_HEADER) -> str
Retrieve the most descriptive available event name.
get_property_data( record: EVENT_RECORD, descriptor: PROPERTY_DATA_DESCRIPTOR, size: int ) -> Optional[bytes]
Retrieve the raw binary data of an ETW property.
get_property_descriptor(name: str) -> Any
Create a TDH property descriptor for a named property.
get_property_size(record: EVENT_RECORD, descriptor: PROPERTY_DATA_DESCRIPTOR) -> int
Retrieve the size of an ETW event property.
get_provider_name(record: EVENT_RECORD) -> str
Resolve an event provider GUID into its configured short name.
get_trace_level(level_name: str) -> int
Convert a trace level name into its ETW numeric value.
guid_from_string(value: str) -> GUID
Convert a string representation into a Windows GUID.
guid_to_string(guid: GUID) -> str
Convert a Windows GUID structure into a string.
matches_event_filters(pid: int, event_id: int, provider_name: str) -> bool
Check whether an event matches the configured filters.
open_event_consumer() -> TRACEHANDLE
Open a real-time ETW event consumer.
process_trace_thread(consumer_handle_ref: TRACEHANDLE) -> None
Process incoming ETW events in the consumer thread.
run_monitoring(selected: list[str], level: int) -> None
Initialize and run the ETW monitoring session.
safe_string(buffer: Any, offset: int) -> str
Read a null-terminated Unicode string from a memory buffer.
start_consumer_thread(consumer_handle: TRACEHANDLE) -> Thread
Start the ETW event processing worker thread.
start_session() -> TRACEHANDLE
Create and start a real-time ETW tracing session.
stop_leftover_session() -> None
Stop a previously abandoned ETW session if one exists.
stop_session(session_handle: TRACEHANDLE) -> None
Stop the specified ETW tracing session.
validate_providers(provider_argument: str) -> list[str]
Validate and return the selected provider names.
wait_for_consumer(worker: Thread) -> None
Wait for the consumer thread until interrupted.

 
Data
        PROVIDERS = {'file': 'EDD08927-9CC4-4E65-B970-C2560FB5C289', 'memory': 'D1D93EF7-E1F2-4F45-9943-03D245FE6C00', 'network': '7DD42A49-5329-4832-8DFD-43D979153A88', 'process': '22FB2CD6-0E7B-422B-A0C7-2FAD1FD0E716', 'registry': '70EB4F03-C1DE-4F73-A051-33D13D5413BD'}
PROVIDER_GUID_TO_NAME = {}
SESSION_NAME = 'PyEtwMonitor'
__all__ = ['PROVIDERS', 'PROVIDER_GUID_TO_NAME', 'EVENT_RECORD_CALLBACK', 'SESSION_NAME', 'ENABLE_TRACE_PARAMETERS', 'ETW_BUFFER_CONTEXT', 'EVENT_DESCRIPTOR', 'EVENT_HEADER', 'EVENT_PROPERTY_INFO', 'EVENT_RECORD', 'EVENT_TRACE', 'EVENT_TRACE_HEADER', 'EVENT_TRACE_LOGFILEW', 'EVENT_TRACE_PROPERTIES', 'GUID', 'PROPERTY_DATA_DESCRIPTOR', 'SYSTEMTIME', 'TIME_ZONE_INFORMATION', 'TRACE_EVENT_INFO_HEADER', 'TRACE_LOGFILE_HEADER', ...]
__author_email__ = 'mauricelambert434@gmail.com'
__copyright__ = '\nPyEtwMonitor Copyright (C) 2026 Maurice Lambe...ome to redistribute it\nunder certain conditions.\n'
__description__ = '\nReal-time Windows ETW monitoring module.\n'
__license__ = 'GPL-3.0 License'
__maintainer__ = 'Maurice Lambert'
__maintainer_email__ = 'mauricelambert434@gmail.com'
__url__ = 'https://github.com/mauricelambert/PyEtwMonitor'

 
Author
        Maurice Lambert