Interacting with ETW
Introduction
ETW components are built-in to the Windows kernel. They are exposed to user mode applications through a set of WinAPI functions:
EventWrite and EventWriteEx - Write an event to the ETW event stream. These WinAPIs are also named
EtwEventWrite
andEtwEventWriteEx
, respectively.StartTraceA and StopTraceA - Start and stop an ETW tracing session.
QueryAllTraces - Retrieves the properties for all running ETW tracing sessions.
Kernel-level ETW
ntoskrnl.exe
is responsible for process handling, memory management, and hardware abstraction. It is the "Windows Operating System Kernel Executable"'
The kernel implementation is done with the EtwTi
function inside ntoskrnl.exe
The Ti
in EtwTi
represents "Threat Intelligence".
The name of the EtwTi
function will generally indicate what's being logged. A few examples are provided below to further clarify this point.
EtwTiLogSetContextThread
- Called fromPspSetContextThreadInternal
andPspWow64SetContextThread
kernel functions. ThisEtwTi
function is triggered when updating a thread's context.EtwTiLogSuspendResumeProcess
- Called from multiple kernel functions, from which thePsMultiResumeProcess
andPsSuspendProcess
functions are the most interesting. ThisEtwTi
function is triggered when suspending or resuming a process.EtwTiLogAllocExecVm
- Called fromMiAllocateVirtualMemory
kernel function. ThisEtwTi
function is triggered when allocating executable memory.EtwTiLogProtectExecVm
- Called fromNtProtectVirtualMemory
syscall (in the kernel). ThisEtwTi
function is triggered when updating memory permissions to executable.
Bypassing ETW
Bypassing ETW is not an easy task and typically requires access to the kernel.
Last updated