Post · 9 min read· pp. 2077–2084

PERFINFO_GROUPMASK

The PERFINFO_GROUPMASK describes the types of event that are enabled or are to be enabled in an NT Kernel Logger session.

Usage

Historically, and as far as anyone still might know from Microsoft’s documentation, the choice of events to enable in NT Kernel Logger sessions is managed from user mode through the EnableFlags member of the EVENT_TRACE_PROPERTIES structure. This is most of the input and output for such documented API functions as StartTrace and ControlTrace. Bits within the EnableFlags select types of event. The PERFINFO_GROUPMASK greatly extends this choice, by allowing for very many more bits, and thus types of event.

The modern and arguably cleanest way to use a PERFINFO_GROUPMASK is through the TraceQueryInformation and TraceSetInformation functions. The PERFINFO_GROUPMASK structure is what these functions produce as output or expect as input in their information buffer when given the information class TraceSystemTraceEnableFlagsInfo (0x04).

Beneath these user-mode API functions, the PERFINFO_GROUPMASK is part of the EVENT_TRACE_GROUPMASK_INFORMATION structure that is expected by the ZwQuerySystemInformation or NtQuerySystemInformation functions and the ZwSetSystemInformation or NtSetSystemInformation functions when given their information class SystemPerformanceTraceInformation (0x1F) if the first dword in the information buffer on input is EventTraceGroupMaskInformation (0x01).

Internally, the kernel keeps an array of PERFINFO_GROUPMASK structures, one for each possible NT Kernel Logger session (the present capacity being eight), and a single structure that acts as a union of the others for quickly reckoning which types of event are enabled in at least one session.

Documentation Status

The PERFINFO_GROUPMASK structure is not documented. Until relatively recently, it was known only from type information in public symbol files (in Windows Vista and higher). A C-language definition has been published by Microsoft in NTWMI.H from the Windows Driver Kit (WDK) for the original release of Windows 10 and for Version 1511. This disclosure is not repeated in subsequent editions and is here thought to be an oversight. Still, published it is, which means that this note uses Microsoft’s names throughout, notably for the many bits that Microsoft has yet defined for types of event that can be monitored through an NT Kernel Logger.

Layout

The PERFINFO_GROUPMASK structure is 0x20 bytes in both 32-bit and 64-bit Windows for all versions 5.2 and higher, but is 0x24 bytes in version 5.1. Symbol files for version 6.0 and higher show just the one member:

OffsetDefinitionVersions
0x00ULONG Masks [8];5.2 and higher
0x20unknown dword5.1 only

The PERFINFO_GROUPMASK in version 5.1 certainly is nine dwords but the purpose of the last is not understood much beyond knowing that it is not treated just as an extra mask as if to allow for more types of event. That the last dword is formally separated from the Masks is mere supposition.

Masks

The first point to the PERFINFO_GROUPMASK is simply that its eight array elements allow 256 bits instead of the 32 that can be passed to and fro in the EnableFlags. A second point to the PERFINFO_GROUPMASK is that each ULONG is a group of bits for enabling similar types of events. It will often be wanted that multiple types of event in the one group are enabled concurrently. This is helped by adopting a conventional representation of each supported type of event by one 32-bit value in which the high 3 bits encode the group’s index within the array.

For instance, to enable the somewhat quirky tracing of what may be going wrong with the ERESOURCE structures that provide for synchronising exclusive and shared ownership of abstracted kernel-mode resources, the kernel needs to see that the 0x00020000 bit is set in Masks [1]. The conventional representation is the one symbol PERF_SYNC_OBJECTS whose numerical value is 0x20020000.

The merit of this convention is that values that have the same index—corresponding to types of events that are in the same group—are easily combined. For instance, two types of events for instrumenting spin locks are in the same group. Their numerical representations PERF_SPINLOCK (0x20010000) and PERF_SPINLOCK_CNTRS (0x20200000) can be combined as 0x20210000, for which Microsoft helpfully defines the symbol PERF_SPININSTR.

Macros in the semi-secret NTWMI.H provide the programmers of ETW clients with the easy means to set or clear the desired bit in the desired Masks element of their PERFINFO_GROUPMASK by supplying the address, of course, and just one symbol to select the bit. For the kernel’s programmers, the same header defines an inline routine that tests for the bit, again just from one symbol and the address.

Masks [0]

The first element arguably is the EnableFlags:

ValueNameEquivalent in EnableFlagsVersions
0x00000001PERF_PROCESSEVENT_TRACE_FLAG_PROCESS5.0 and higher
0x00000002PERF_THREADEVENT_TRACE_FLAG_THREAD5.0 and higher
0x00000003PERF_PROC_THREAD
0x00000004PERF_LOADEREVENT_TRACE_FLAG_IMAGE_LOAD5.0 and higher
0x00000008PERF_PERF_COUNTEREVENT_TRACE_FLAG_PROCESS_COUNTERS6.0 and higher
0x00000010maps to PERF_CONTEXT_SWITCH in Mask [1]EVENT_TRACE_FLAG_CSWITCH6.0 and higher
0x00000020maps to PERF_DPC in Mask [1]EVENT_TRACE_FLAG_DPC6.0 and higher
0x00000040maps to PERF_INTERRUPT in Mask [1]EVENT_TRACE_FLAG_INTERRUPT6.0 and higher
0x00000080maps to PERF_SYSCALL in Mask [2]EVENT_TRACE_FLAG_SYSTEMCALL6.0 and higher
0x00000100EVENT_TRACE_FLAG_DISK_IO5.0 and higher
0x00000200PERF_FILENAMEEVENT_TRACE_FLAG_DISK_FILE_IO5.0 and higher
0x00000300PERF_DISK_IO
0x00000400PERF_DISK_IO_INITEVENT_TRACE_FLAG_DISK_IO_INIT6.0 and higher
0x00000800maps to PERF_DISPATCHER in Mask [1]EVENT_TRACE_FLAG_DISPATCHER6.1 and higher
0x00001000PERF_ALL_FAULTSEVENT_TRACE_FLAG_MEMORY_PAGE_FAULTS5.0 and higher
0x00002000PERF_HARD_FAULTSEVENT_TRACE_FLAG_MEMORY_HARD_FAULTS5.0 and higher
0x00004000maps to PERF_VIRTUAL_ALLOC in Mask [1]EVENT_TRACE_FLAG_VIRTUAL_ALLOC6.1 and higher
0x00008000PERF_VAMAPEVENT_TRACE_FLAG_VAMAP6.2 and higher
0x00010000PERF_NETWORKEVENT_TRACE_FLAG_NETWORK_TCPIP5.0 and higher
0x00020000PERF_REGISTRYEVENT_TRACE_FLAG_REGISTRY5.0 and higher
0x00040000PERF_DBGPRINTEVENT_TRACE_FLAG_DBGPRINT5.1 and higher
0x00080000PERF_JOBEVENT_TRACE_FLAG_JOB10.0 and higher
0x00100000PERF_ALPCEVENT_TRACE_FLAG_ALPC6.0 and higher
0x00200000PERF_SPLIT_IOEVENT_TRACE_FLAG_VOLMGRlate 5.2 only
EVENT_TRACE_FLAG_SPLIT_IO6.0 and higher
0x00400000PERF_DEBUG_EVENTSEVENT_TRACE_FLAG_DEBUG_EVENTS10.0 and higher
0x00800000maps to PERF_DRIVERS in Mask [1]EVENT_TRACE_FLAG_DRIVER6.0 and higher
0x01000000maps to PERF_PROFILE in Mask [1]EVENT_TRACE_FLAG_PROFILE6.0 and higher
0x02000000PERF_FILE_IOEVENT_TRACE_FLAG_FILE_IO6.0 and higher
0x04000000PERF_FILE_IO_INITEVENT_TRACE_FLAG_FILE_IO_INIT6.0 and higher
0x08000000apparently unused
0x10000000PERF_NO_SYSCONFIGEVENT_TRACE_FLAG_NO_SYSCONFIG6.2 and higher
0x20000000EVENT_TRACE_FLAG_ENABLE_RESERVE5.0 and higher
0x40000000EVENT_TRACE_FLAG_FORWARD_WMI5.0 and higher
0x80000000EVENT_TRACE_FLAG_EXTENSION5.0 and higher

Indication of support for version 5.0 applies only to the bit in the EnableFlags. as the precursor to the PERFINFO_GROUPMASK.

Please note a general caution about versions that are indicated for any of these masks, above and below. This analysis is preliminary at best. That a version is indicated does mean that use is known in those versions. It does not mean that earlier versions have no support, just that I don’t know of it or that I haven’t yet recorded it here. It’s a rough indication only. If it ever seems that presenting it is not better than nothing, it will be withdrawn.

Masks [1]

ValueNameVersions
0x20000001PERF_MEMORY5.1 and higher
0x20000002PERF_PROFILE5.1 and higher
0x20000004PERF_CONTEXT_SWITCH5.1 and higher
0x20000008PERF_FOOTPRINT5.1 and higher
0x20000010PERF_DRIVERS5.1 and higher
0x20000020
PERF_REFSET
0x20000040
PERF_POOL6.1 and higher
0x20000041PERF_POOLTRACE6.1 and higher
0x20000080PERF_DPC5.1 and higher
0x20000100
PERF_COMPACT_CSWITCH6.0 and higher
0x20000200PERF_DISPATCHER6.0 and higher
0x20000400PERF_PMC_PROFILE6.2 and higher
0x20000402PERF_PROFILING6.2 and higher
0x20000800PERF_PROCESS_INSWAP6.1 and higher
0x20001000unknown5.1 to 5.2
PERF_AFFINITY6.1 and higher
0x20002000PERF_PRIORITY6.0 and higher
0x20004000PERF_INTERRUPT5.1 and higher
0x20008000PERF_VIRTUAL_ALLOC6.0 and higher
0x20010000PERF_SPINLOCK6.1 and higher (x64); 6.2 and higher (x86)
0x20020000PERF_SYNC_OBJECTS6.1 and higher
0x20040000PERF_DPC_QUEUE6.2 and higher
0x20080000PERF_MEMINFO6.0 and higher
0x20100000PERF_CONTMEM_GEN6.0 and higher
0x20200000PERF_SPINLOCK_CNTRS6.2 and higher
0x20210000PERF_SPININSTR6.2 and higher
0x20400000PERF_SESSION PERF_PFSECTION6.2 and higher
0x20800000PERF_MEMINFO_WS
0x21000000PERF_KERNEL_QUEUE6.2 and higher
0x22000000PERF_INTERRUPT_STEER
0x24000000PERF_SHOULD_YIELD
0x28000000PERF_WS6.2 and higher

Masks [2]

ValueNameVersions
0x40000001PERF_ANTI_STARVATION6.2 and higher
0x40000002PERF_PROCESS_FREEZE6.2 and higher
0x40000004PERF_PFN_LIST
0x40000008PERF_WS_DETAIL
0x40000010PERF_WS_ENTRY
0x40000020PERF_HEAP6.2 and higher
0x40000040PERF_SYSCALL6.0 and higher
0x40000080PERF_UMS
0x40000100PERF_BACKTRACE
0x40000200PERF_VULCAN
0x40000400PERF_OBJECTS
0x40000800PERF_EVENTS
0x40001000PERF_FULLTRACE
0x40002000PERF_DFSS6.1 and higher
0x40004000PERF_PREFETCH
0x40008000PERF_PROCESSOR_IDLE6.1 and higher
0x40010000PERF_CPU_CONFIG
0x40020000PERF_TIMER6.2 and higher
0x40040000PERF_CLOCK_INTERRUPT6.2 and higher
0x40080000PERF_LOAD_BALANCER6.2 and higher
0x40100000PERF_CLOCK_TIMER6.2 and higher
0x40200000PERF_IDLE_SELECTION
0x40400000PERF_IPI6.2 and higher
0x40800000PERF_IO_TIMER6.2 and higher
0x41000000PERF_REG_HIVE6.2 and higher
0x42000000PERF_REG_NOTIF6.2 and higher
0x44000000PERF_PPM_EXIT_LATENCY6.2 and higher
0x48000000PERF_WORKER_THREAD

Masks [3]

Apparently, no flags are yet defined for mask number 3.

Masks [4]

ValueNameVersions
0x80000001PERF_OPTICAL_IO6.2 and higher
0x80000002PERF_OPTICAL_IO_INIT6.2 and higher
0x80000004apparently unused
0x80000008PERF_DLL_INFO
0x80000010PERF_DLL_FLUSH_WS
0x80000020apparently unused
0x80000040PERF_OB_HANDLE6.2 and higher
0x80000080PERF_OB_OBJECT6.2 and higher
0x80000100apparently unused
0x80000200PERF_WAKE_DROP6.2 and higher
0x80000400PERF_WAKE_EVENT6.2 and higher
0x80000800PERF_DEBUGGER
0x80001000PERF_PROC_ATTACH
0x80002000PERF_WAKE_COUNTER
0x80004000apparently unused
0x80008000PERF_POWER5.1 and higher
0x80010000PERF_SOFT_TRIM
0x80020000PERF_CC6.2 and higher
0x80040000apparently unused
0x80080000PERF_FLT_IO_INIT
0x80100000PERF_FLT_IO
0x80200000PERF_FLT_FASTIO
0x80400000PERF_FLT_IO_FAILURE
0x80800000PERF_HV_PROFILE
0x81000000PERF_WDF_DPC
0x82000000PERF_WDF_INTERRUPT
0x84000000PERF_CACHE_FLUSH

Masks [5]

ValueName
0xA0000001PERF_HIBER_RUNDOWN

Masks [6]

ValueName
0xC0000001PERF_SYSCFG_SYSTEM
0xC0000002PERF_SYSCFG_GRAPHICS
0xC0000004PERF_SYSCFG_STORAGE
0xC0000008PERF_SYSCFG_NETWORK
0xC0000010PERF_SYSCFG_SERVICES
0xC0000020PERF_SYSCFG_PNP
0xC0000040PERF_SYSCFG_OPTICAL
0xDFFFFFFFPERF_SYSCFG_ALL

Masks [7]

ValueNameVersions
0xE0000001PERF_CLUSTER_OFF
0xE0000002PERF_MEMORY_CONTROL6.2 and higher