Post · 2 min read· p. 88

Spin Locks

The spin lock is the kernel’s simplest synchronisation object, but the main functions for working with spin locks started as HAL exports. This is because acquiring a spin lock in ordinary execution starts with raising the Interrupt Request Level (IRQL) to DISPATCH_LEVEL and changing the IRQL is the HAL’s work in x86 builds. Functions that work with spin locks but take as granted that the IRQL is already DISPATCH_LEVEL or higher have always been the kernel’s to export. For 64-bit Windows, this division between the HAL and the kernel was put aside: presumably because the IRQL is managed inline by reading and writing the cr8 register, all work with spin locks is the kernel’s.

FunctionVersions (x86 Only)Remarks
KeAcquireSpinLockallexport in 3.50 to 6.1 is a thunk to KfAcquireSpinLock; export in 6.2 and higher is forward to kernel
KeAcquireSpinLockRaiseToSynch4.0 and higherexport in 6.2 and higher is forward to kernel
KeReleaseSpinLockallexport in 3.50 to 6.1 is a thunk to KfReleaseSpinLock; export in 6.2 and higher is forward to kernel
KfAcquireSpinLock3.50 and higherexport in 6.2 and higher is forward to kernel
KfReleaseSpinLock3.50 and higherexport in 6.2 and higher is forward to kernel

The separation of functionality for x86 builds was kept when version 5.0 introduced queued spin locks:

FunctionVersions (x86 Only)Remarks
KeAcquireInStackQueuedSpinLock5.1 and higherexport in 6.2 and higher is forward to kernel
KeAcquireInStackQueuedSpinLockRaiseToSynch5.1 and higherexport in 6.2 and higher is forward to kernel
KeAcquireQueuedSpinLock5.0 and higherexport in 6.2 and higher is forward to kernel
KeAcquireQueuedSpinLockRaiseToSynch5.0 and higherexport in 6.2 and higher is forward to kernel
KeReleaseInStackQueuedSpinLock5.1 and higherexport in 6.2 and higher is forward to kernel
KeReleaseQueuedSpinLock5.0 and higherexport in 6.2 and higher is forward to kernel
KeTryToAcquireQueuedSpinLock5.0 and higherexport in 6.2 and higher is forward to kernel
KeTryToAcquireQueuedSpinLockRaiseToSynch5.0 and higherexport in 6.2 and higher is forward to kernel