Post · 4 min read· pp. 1103–1105

THREADINFOCLASS

DRAFT: Take more than your usual care.

The THREADINFOCLASS is an enumeration whose values are intended as input to the ZwQueryInformationThread and ZwSetInformationThread functions. Different values select different types of information to query or set.

Documentation Status

A C-language definition of the THREADINFOCLASS enumeration has been publicly available in the NTDDK.H header since at least the Device Driver Kit (DDK) for Windows NT 3.51. It there supported the declaration of the ZwSetInformationThread function which is exported from both the kernel and NTDLL in version 3.10 and higher but was not formally documented even for kernel-mode programming until some time after the Windows Driver Kit (WDK) for Windows 7 in 2009. Such kernel-mode documentation as exists of either function presents only a handful of the defined values. In the WDK for Windows 10, even the definition in NTDDK.H has become selective.

Microsoft’s first formal documentation of either THREADINFOCLASS or of any function that uses it was in the Software Development Kit (SDK) for user-mode programming. A WINTERNL.H file was added to the SDK in 2002, apparently for Microsoft’s compliance with a settlement concerning unfair use of internal Windows APIs by “middleware” products such as, but in no way limited to, Internet Explorer. The file presents a greatly reduced C-language definition, just of the ThreadIsIoPending case, which contemporaneous documentation of the NtQueryInformationThread function quite rightly noted would better be accessed via the documented API function GetThreadPendingIoFlag. This documentation later added ThreadQuerySetWin32StartAddress to its description, though apparently without this case ever making it to the definition in the header.

As for the values that are added for Windows 10 but which the definition in the contemporaneous WDK skips, these are knowable from type information in symbol files. The surprise, however, is which symbol files—not for the kernel, where the enumeration is interpreted and the relevant functions are implemented, nor even NTDLL, but for various higher-level user-mode DLLs. The most conspicuous is URLMON.DLL, for it is a component of Internet Explorer, i.e., of the most prominent “middleware” that compelled even the grudgingly partial disclosure in 2002. The symbol files that have been publicly available for URLMON since 2012 show that it is built not with the reduced THREADINFOCLASS from WINTERNL.H but with the whole thing. However URLMON was built in the years when Microsoft’s compliance with the settlement was reviewed by—it might be hoped—competent regulators, it is now built with more knowledge of low-level Windows than Microsoft publishes even for kernel-mode device driver programmers. Do not tell me that there was not at Microsoft somewhere some time someone who enjoyed mocking the government and courts over this. (I say this as criticism of the latter very much more than of Microsoft.)

Enumeration

Of the many defined cases, some can be used successfully only to query or only to set. Some can’t usefully be called either way—at least, not in all versions. The present purpose however is not to show which values are implemented non-trivially in which versions, but which values are defined in which versions, as much as can be known.

Numeric ValueSymbolic NameVersions
0x00ThreadBasicInformationall
0x01ThreadTimesall
0x02ThreadPriorityall
0x03ThreadBasePriorityall
0x04ThreadAffinityMaskall
0x05ThreadImpersonationTokenall
0x06ThreadDescriptorTableEntryall
0x07ThreadEnableAlignmentFaultFixupall
0x08ThreadEventPair3.10 to 4.0
ThreadEventPair_Reusable5.0 and higher
0x09ThreadQuerySetWin32StartAddressall
0x0Aunknown3.10 only
0x0B (3.10); 0x0AThreadZeroTlsCellall
0x0BThreadPerformanceCount3.51 and higher
0x0CThreadAmILastThread3.51 and higher
0x0DThreadIdealProcessor4.0 and higher
0x0EThreadPriorityBoost4.0 and higher
0x0FThreadSetTlsArrayAddress4.0 and higher
0x10ThreadIsIoPending5.0 and higher
0x11ThreadHideFromDebugger5.0 and higher
0x12ThreadBreakOnTermination5.2 and higher
0x13ThreadSwitchLegacyState5.2 from Windows Server 2003 SP1, and higher
0x14ThreadIsTerminated5.2 from Windows Server 2003 SP1, and higher
0x15ThreadLastSystemCall6.0 and higher
0x16ThreadIoPriority6.0 and higher
0x17ThreadCycleTime6.0 and higher
0x18ThreadPagePriority6.0 and higher
0x19ThreadActualBasePriority6.0 and higher
0x1AThreadTebInformation6.0 and higher
0x1BThreadCSwitchMon6.0 and higher
0x1CThreadCSwitchPmu6.1 and higher
0x1DThreadWow64Context6.1 and higher
0x1EThreadGroupInformation6.1 and higher
0x1FThreadUmsInformation6.1 and higher
0x20ThreadCounterProfiling6.1 and higher
0x21ThreadIdealProcessorEx6.1 and higher
0x22ThreadCpuAccountingInformation6.2 and higher
0x23ThreadSuspendCount6.3 and higher
0x24ThreadHeterogeneousCpuPolicy10.0 and higher
0x25ThreadContainerId10.0 and higher
0x26ThreadNameInformation10.0 and higher
0x27ThreadSelectedCpuSets10.0 and higher
0x28ThreadSystemThreadInformation10.0 and higher
0x29ThreadActualGroupAffinity10.0 and higher
MaxThreadInfoClassall