Post · 4 min read· pp. 1520–1523

Thread Flags in the KTHREAD

Reorganisation of the KTHREAD for the build of version 5.2 from Windows Server 2003 SP1, presumably in anticipation of 64-bit Windows, seems to have been very concerned about economy of space. A notable feature of that build is that it moves numerous small KTHREAD members into “spare” space in larger members. Perhaps as part of this exercise, this build also made bit fields of what had been two booleans. Later versions brought more booleans from the KTHREAD, and even a ULONG, and also moved bits to and from another set of flags.

The ThreadFlags member, which is an integral type for simultaneous access to all the bits described below, was first placed within the Timer member, using space that the KTIMER structure left undefined because of its 8-byte alignment in 64-bit builds. A reworking of the KTIMER for version 6.1 removed the saving and the ThreadFlags merely followed the Timer. Version 6.2 moved the ThreadFlags forward in the KTHREAD, and they have remained there since.

TypeVersionOffset (x86)Offset (x64)
LONGlate 5.2 and higher0xA00xF4
LONG volatile6.00xB00xF4
6.10xB80x0100
6.2 and higher0x5C0x78

Note that the ThreadFlags, as the integral type, are volatile in version 6.0 and higher. Versions 6.0 and 6.1 have the individual bit fields as volatile too.

Bit Fields

MaskDefinitionVersionsRemarks
0x00000003ULONG BamQosLevel : 2;1709 to 1903next as 8 bits in ThreadFlags3 (x86); next as 8 bits in ThreadFlags2 (x64)
ULONG ThreadFlagsSpare : 2;2004 and higher
0x00000001 (late 5.2 to 1703); 0x00000004LONG AutoAlignment : 1;late 5.2 onlypreviously BOOLEAN
ULONG AutoAlignment : 1;v. late 5.2 only
ULONG volatile AutoAlignment : 1;6.0 to 6.1
ULONG AutoAlignment : 1;6.2 and higher
0x00000002 (late 5.2 to 1703); 0x00000008LONG DisableBoost : 1;late 5.2 onlypreviously BOOLEAN
ULONG DisableBoost : 1;v. late 5.2 only
ULONG volatile DisableBoost : 1;6.0 to 6.1
ULONG DisableBoost : 1;6.2 and higher
0x00000004 (6.0 to 1703)ULONG volatile EtwStackTraceApc1Inserted : 1;6.0 to 6.1widened, see below
ULONG UserAffinitySet : 1;6.2 to 6.3
ULONG ThreadFlagsSpare0 : 1;10.0 to 1607
ULONG BamEppImportant : 1;1703 only
0x00000008 (6.0 to 1703); 0x00000010ULONG volatile EtwStackTraceApc2Inserted : 1;6.0 to 6.1widened, see below
ULONG AlertedByThreadId : 1;6.2 and higher
0x00000010 (6.0)ULONG volatile CycleChargePending : 1;6.0 only
0x00000020 (6.0); 0x00000010 (6.1 to 1703); 0x00000020ULONG volatile CalloutActive : 1;6.0 to 6.1previously BOOLEAN; next in MiscFlags
ULONG QuantumDonation : 1;6.2 and higher
0x00000040 (6.0); 0x00000020 (6.1)ULONG volatile ApcQueueable : 1;6.0 to 6.1previously BOOLEAN; next in MiscFlags
0x00000080 (6.0); 0x00000040 (6.1); 0x00000020 (6.2 to 1703); 0x00000040ULONG volatile EnableStackSwap : 1;6.0 to 6.1previously BOOLEAN
ULONG EnableStackSwap : 1;6.2 and higher
0x00000004 (v. late 5.2); 0x00000100 (6.0); 0x00000080 (6.1); 0x00000040 (6.2 to 1703); 0x00000080ULONG GuiThread : 1;v. late 5.2 only
ULONG volatile GuiThread : 1;6.0 to 6.1
ULONG GuiThread : 1;6.2 and higher
0x00000100 (6.1)ULONG volatile UmsPerformingSyscall : 1;6.1 onlynext in MiscFlags
0x00000080 (6.2 to 1703); 0x00000100ULONG DisableQuantum : 1;6.2 and higher
0x00000100 (6.2 to 1703); 0x00000200ULONG ChargeOnlyGroup : 1;6.2 only
ULONG ChargeOnlySchedulingGroup : 1;6.3 and higher
0x00000200 (6.2 to 1703); 0x00000400ULONG DeferPreemption : 1;6.2 and higher
0x00000400 (6.2 to 1703); 0x00000800ULONG QueueDeferPreemption : 1;6.2 and higher
0x00000800 (6.2 to 1703); 0x00001000ULONG ForceDeferSchedule : 1;6.2 and higherpreviously in MiscFlags
0x00001000 (6.2 to 1703); 0x00002000ULONG ExplicitIdealProcessor : 1;6.2 only
ULONG SharedReadyQueueAffinity : 1;6.3 and higher
0x00002000 (6.2 to 1703); 0x000040000ULONG FreezeCount : 1;6.2 and higherpreviously ULONG
0x00004000 (6.3 to 1703); 0x00008000ULONG TerminationApcRequest : 1;6.3 and higher
0x00008000 (6.3 to 1703); 0x00010000ULONG AutoBoostEntriesExhausted : 1;6.3 and higher
0x00010000 (10.0 to 1703); 0x00020000ULONG KernelStackResident : 1;10.0 and higherpreviously in MiscFlags
0x00020000 (10.0 to 1607); 0x00060000 (1703); 0x000C0000ULONG CommitFailTerminateRequest : 1;10.0 to 1607
ULONG TerminateRequestReason : 2;1703 and higher
0x00040000 (10.0 to 1607); 0x00080000 (1703); 0x00100000ULONG ProcessStackCountDecremented : 1;10.0 and higher
0x00080000 (1607); 0x00100000 (1703); 0x00200000ULONG RestrictedGuiThread : 1;1607 and higher
0x00400000ULONG VpBackingThread : 1;1709 and higher
ULONG ThreadFlagsSpare : 5;10.0 to 1511
ULONG ThreadFlagsSpare : 4;1607 only
ULONG ThreadFlagsSpare : 3;1703 only
ULONG ThreadFlagsSpare : 1;1709 to 1903
ULONG ThreadFlagsSpare2 : 1;2004 and higher
0x003FC000 (6.2); 0x00FF0000 (6.3); 0xFF000000ULONG EtwStackTraceApcInserted : 8;6.2 and highercollected from two single bits, see above
LONG ReservedFlags : 30;late 5.2 only
ULONG ReservedFlags : 29;v. late 5.2 only
ULONG volatile ReservedFlags : 23;6.0 to 6.1
ULONG ReservedFlags : 10;6.2 only
ULONG ReservedFlags : 8;6.3 only