Locking rule set (WDM)
Use these rules to verify that your driver correctly manages shared resources.
In this section
Topic | Description |
---|---|
The CancelSpinLock rule specifies that the driver calls IoAcquireCancelSpinLock before calling IoReleaseCancelSpinLock and that the driver calls IoReleaseCancelSpinLock before any subsequent calls to IoAcquireCancelSpinLock. |
|
The CancelSpinlockRelease rule specifies that calls to IoAcquireCancelSpinLock and IoReleaseCancelSpinLock are used in strict alternation. That is, every call to IoAcquireCancelSpinLock must have a corresponding call to IoReleaseCancelSpinLock. |
|
The CriticalRegions rule specifies that the driver must call KeEnterCriticalRegion before calling KeLeaveCriticalRegion and that the driver calls KeLeaveCriticalRegion before any subsequent calls to KeEnterCriticalRegion. (Nested calls are permitted.) |
|
The ExclusiveResourceAccess rule specifies that the driver calls ExAcquireResourceExclusiveLite before calling ExReleaseResourceLite or ExReleaseResourceForThreadLite and specifies that the driver calls ExReleaseResourceLite or ExReleaseResourceForThreadLite before any subsequent calls to ExAcquireResourceExclusiveLite. |
|
The GuardedRegions rule verifies that calls to KeEnterGuardedRegion and KeLeaveGuardedRegion are used in strict alternation. |
|
The QueuedSpinLock rule specifies that the driver calls KeAcquireInStackQueuedSpinLock before calling KeReleaseInStackQueuedSpinLock and that the driver calls KeReleaseInStackQueuedSpinLock before any subsequent calls to KeAcquireInStackQueuedSpinLock. |
|
The QueuedSpinLockRelease rule specifies that calls to KeAcquireInStackQueuedSpinLock and KeReleaseInStackQueuedSpinLock are used in strict alternation. |
|
The SpinLock rule specifies that, after calling KeAcquireSpinLock, the driver calls KeReleaseSpinLock before subsequent calls to KeAcquireSpinLock or to KeAcquireSpinLockRaiseToDpc. |
|
The SpinLockDpc rule specifies that calls to KeAcquireSpinLock or KeAcquireSpinLockRaiseToDpc and KeReleaseSpinLock must be made in strict alternation. That is, after calling KeAcquireSpinLock or KeAcquireSpinLockRaiseToDpc, the driver must call KeReleaseSpinLock before subsequent calls to KeAcquireSpinLock or to KeAcquireSpinLockRaiseToDpc. |
|
The SpinlockRelease rule specifies that calls to KeReleaseSpinLock are made in strict alternation with KeAcquireSpinLock and KeAcquireSpinLockRaiseToDpc. That is, the driver must call KeReleaseSpinLock after calling KeAcquireSpinLock or KeAcquireSpinLockRaiseToDpc and before subsequent calls to KeAcquireSpinLock or to KeAcquireSpinLockRaiseToDpc. |
|
The SpinLockSafe rule specifies that IoStartNextPacket and IoCompleteRequest are not called while holding a spin lock. |
|
The WithinCriticalRegion rule specifies that the driver's calls to particular synchronization functions appear only after calling KeEnterCriticalRegion and before calling KeLeaveCriticalRegion. The affected synchronization functions are the following: |
To select the Locking rule set
Select your driver project (.vcxProj) in Microsoft Visual Studio. From the Driver menu, click Launch Static Driver Verifier….
Click the Rules tab. Under Rule Sets, select Locking.
To select the default rule set from a Visual Studio developer command prompt window, specify Locking.sdv with the /check option. For example:
msbuild /t:sdv /p:Inputs="/check:Locking.sdv" mydriver.VcxProj /p:Configuration="Win8 Release" /p:Platform=Win32
For more information, see Using Static Driver Verifier to Find Defects in Drivers and Static Driver Verifier commands (MSBuild).