KAFFINITY_EX

The KAFFINITY_EX structure is used by the kernel to represent an arbitrary boolean property per processor. It is essentially a dressing-up of a bitmap that allows one bit per processor. Outside the kernel, the structure is opaque. The kernel exports functions that support a range of operations such as setting, clearing and counting bits.

Documentation Status

The KAFFINITY_EX structure is not documented. Neither are the functions, though they are declared in the NTOSP.H from the Windows Driver Kit (WDK) for Windows 10.

Layout

The KAFFINITY_EX expands as successive Windows versions allow more processor groups:

Version Size (x86) Size (x64)
6.1 0x0C 0x28
6.2 to 10.0 0x0C 0xA8

Sizes, offsets, types and names in the table that follows are from Microsoft’s symbol files for the kernel.

Offset (x86) Offset (x64) Definition
0x00 0x00
USHORT Count;
0x02 0x02
USHORT Size;
0x04 0x04
ULONG Reserved;
0x08 0x08
KAFFINITY Bitmap [MAX_PROC_GROUPS];

Here, a macro, MAX_PROC_GROUPS, is presumed for the maximum number of processor groups:

The Count and Size count processor groups. They are initially 1 and MAX_PROC_GROUPS. The Count grows, up to the Size, as bits get set further into the bitmap.