KeInitializeSpinLock function (wdm.h)
The KeInitializeSpinLock routine initializes a variable of type KSPIN_LOCK.
Syntax
void KeInitializeSpinLock(
[out] PKSPIN_LOCK SpinLock
);
Parameters
[out] SpinLock
Pointer to a spin lock, for which the caller must provide the storage.
Return value
None
Remarks
This routine must be called before an initial call to KeAcquireSpinLock, to KeAcquireInStackQueuedSpinLock, or to any other support routine that requires a spin lock as an argument.
Storage for a spin lock object must be resident: in the device extension of a driver-created device object, in the controller extension of a driver-created controller object, or in nonpaged pool allocated by the caller.
This function is inlined for x64 systems from Windows XP till Windows 7. Starting in Windows 8, this function is exported from ntoskrnl.lib
. As a result, if you are using the Windows 10 WDK to build a binary that runs on Windows 7 (and therefore you need NX pool usage to pass Windows 10 HLK tests), you must define WIN9X_COMPAT_SPINLOCK
. Otherwise, you may see Windows cannot load the device driver for this hardware. The driver may be corrupted or missing. (Code 39)
.
For more information about spin locks, see Spin Locks.
Callers of this routine can be running at any IRQL. Usually, a caller is running at IRQL = PASSIVE_LEVEL in an AddDevice routine.
Requirements
Requirement | Value |
---|---|
Target Platform | Universal |
Header | wdm.h (include Wdm.h, Ntddk.h, Ntifs.h) |
Library | NtosKrnl.lib |
DLL | NtosKrnl.exe |
IRQL | Any level (see Remarks section) |
DDI compliance rules | HwStorPortProhibitedDDIs(storport) |
See also
KeAcquireInStackQueuedSpinLock
KeAcquireInStackQueuedSpinLockAtDpcLevel
KeReleaseInStackQueuedSpinLock