Post · 6 min read· pp. 2389–2392

EX_X.H

The public symbol file NTKRPAMP.PDB for the original release of Windows 10 tells that the kernel is built with the EX_X.H header at

d:\th\minkernel\ntos\inc

and draws from it the following type definitions:

Line NumberType
34enum _POOL_TYPE
259enum _EX_POOL_PRIORITY
997struct _LOOKASIDE_LIST_EX
1127struct _NPAGED_LOOKASIDE_LIST
1324struct _PAGED_LOOKASIDE_LIST
2582struct _WORK_QUEUE_ITEM
2946struct _OWNER_ENTRY
2959struct _ERESOURCE
3502struct _EX_PUSH_LOCK
3590struct _EX_PUSH_LOCK_AUTO_EXPAND_STATE
3601struct _EX_PUSH_LOCK_AUTO_EXPAND
3654struct _EX_RUNDOWN_REF
3758struct _EXHANDLE
4020struct _EXT_DELETE_PARAMETERS

The header EX_X.H is not known in any Device Driver Kit (DDK) or Windows Driver Kit (WDK).

That said, all the types that the kernel is known to pick up from EX_X.H are defined in the standard header WDM.H for kernel-mode programming or in one more header, named NTOSP.H, that Microsoft has mostly kept for its own kernel-mode programming but which is available from inspection because of its disclosure in the “minwin” directory of the Windows 10 WDK for the original release and for Version 1511.

Most of the types are extracted to both the widely available WDM.H and the private NTOSP.H, but both miss at least some lines and WDM.H consistently misses more. Some accounting is possible on the assumption that although each of these headers receives only a selection of lines from EX_X.H, their selections are contiguous. Put another way, assume that WDM.H lines 21560 to 23583 and NTOSP.H lines 16296 to 20137 are generated only as extractions from EX_X.H. Then some of the EX_X.H material that goes to NTOSP.H but not to WDM.H goes to NTDDK.H or NTIFS.H instead, but most is otherwise unknown in the WDK headers.

Reconstruction

This presumably accidental publication of NTOSP.H allows for high confidence in reconstructing the unseen EX_X.H almost completely. It may be that content is extracted from EX_X.H into the standard headers. It may be that all are extracted from yet some other source. Eithe way, the assumption seems reasonable that each line in the unseen EX_X.H is duplicated in zero or more of the published headers in an order-preserving way, leaving each of the published headers with a contiguous region of lines that can each be inferred as being also in the unseen EX_X.H.

In the table that follows, the line numbers on the left are deduced from type information in a statically linked library named CLFSMGMT.LIB which Microsoft publishes with the Software Development Kit (SDK) as if for user-mode programming. Of all sources of type information that cites EX_X.H as the header from which the compiler obtained the definitions, this is presently the one that is known to have it for the most types. The line numbers on the right are from headers as published in the WDK.

Line NumberTypeWDM.HNTDDK.HNTOSP.HNTOSIFS.H
34enum _POOL_TYPE2156016296
259enum _EX_POOL_PRIORITY2177316519
997struct _LOOKASIDE_LIST_EX2240117204
1127struct _NPAGED_LOOKASIDE_LIST2253117334
1324struct _PAGED_LOOKASIDE_LIST2272817531
2559enum _WORK_QUEUE_TYPE2296618750
2582struct _WORK_QUEUE_ITEM2298918773
2669struct _ZONE_SEGMENT_HEADER824418854
2674struct _ZONE_HEADER824918859
2946struct _OWNER_ENTRY2305819129
2948anonymous union in struct _OWNER_ENTRY2306019131
2949anonymous struct in anonymous union in struct _OWNER_ENTRY2306119132
2959struct _ERESOURCE2307119142
2971anonymous union in struct _ERESOURCE2308319154
2973anonymous struct in anonymous union in struct _ERESOURCE2308519156
3002anonymous union in struct _ERESOURCE2311419185
3020struct _RESOURCE_HASH_ENTRY2313219203
3027struct _RESOURCE_PERFORMANCE_DATA2313919210
3502struct _EX_PUSH_LOCK19630100
3537anonymous union in struct _EX_PUSH_LOCK19665135
3538anonymous struct in anonymous union in struct _EX_PUSH_LOCK19666136
3559struct _EX_PUSH_LOCK_CACHE_AWARE_LEGACY19687157
3567struct _EX_PUSH_LOCK_CACHE_AWARE_PADDED19695165
3569anonymous union in struct _EX_PUSH_LOCK_CACHE_AWARE_PADDED19697167
3571anonymous struct in anonymous union in struct _EX_PUSH_LOCK_CACHE_AWARE_PADDED19699169
3590struct _EX_PUSH_LOCK_AUTO_EXPAND_STATE19718188
3591anonymous union in struct _EX_PUSH_LOCK_AUTO_EXPAND_STATE19719189
3592anonymous struct in anonymous union in struct _EX_PUSH_LOCK_AUTO_EXPAND_STATE19720190
3601struct _EX_PUSH_LOCK_AUTO_EXPAND19729199
3654struct _EX_RUNDOWN_REF2346019780
3660anonymous union in struct _EX_RUNDOWN_REF2346619786
3689struct _EX_RUNDOWN_REF_CACHE_AWARE_STATE19815
3690anonymous union in struct _EX_RUNDOWN_REF_CACHE_AWARE_STATE19816
3691anonymous struct in anonymous union in struct _EX_RUNDOWN_REF_CACHE_AWARE_STATE19817
3712struct _EX_RUNDOWN_REF_CACHE_AWARE19838
3758struct _EXHANDLE19884
3760anonymous union in struct _EXHANDLE19886
3762anonymous struct in anonymous union in struct _EXHANDLE19888
4020struct _EXT_DELETE_PARAMETERS2358320137
5908enum _LICENSING_TAMPER_STATE21941
5974anonymous enum22007
6011struct _EX_EXTENSION_REGISTRATION_1220411345
6080struct EX_BOOT_DEVICE_HANDLE_
6088struct _EX_BOOT_DEVICE_REGISTRATION22114

For an example of what can be learnt from this skeleton for reconstruction, consider what might be in the 1,235 lines between the opening braces for definitions of _PAGED_LOOKASIDE_LIST and _WORK_QUEUE_TYPE. Only 223 are duplicated in WDM.H. This would be better than nothing, but NTOSP.H has 1,219 lines in this space. It’s all but certain that every one of them is in the corresponding space in EX_X.H. Thus is this part of the unseen EX_X.H reconstructed almost completely from published material.

A small but useful outcome of just this part of the reconstruction is to place the numerous small inline routines that are frequently encountered in any debugging or reverse engineering of Microsoft’s kernel-mode code—not only in the kernel itself—that works with user-mode addresses. Such addresses are well-known to require careful handling—or are not known nearly well enough, depending on perspective. The kernel exports functions named ProbeForRead and ProbeForWrite that help with one aspect of this care, but Microsoft’s own kernel-mode programmers have these as macros and have long benefited from the use of many inline elaborations that are specialised to probing for particular types and small structures. It must make their code more readable.

Debugging their code, including from outside Microsoft, is similarly much easier for recognising the macros and the inlining. Because of this, the inline routines must have attracted attention from very early in any study of kernel-mode Windows that’s worth calling a study. They will have been well-known long before the presumably accidental publication of NTOSP.H. Not only does their inline usage get them named in the kernel’s public symbol files starting with Windows 8, but they are named in older symbol files from having sometimes been instantiated instead of inlined. What was not known (without source-code access) until the NTOSP.H disclosure is which header provides the kernel with these macros and inline routines.

Is it vital to know that the kernel gets them from an unpublished header named EX_X.H? Not for itself, of course not. Does it help with an understanding of how Windows, still by far the world’s most sophisticated operating system in general use, is organised? In its small way, yes.