Locking rule set (KMDF)

Use these rules to verify that your driver correctly manages shared resources.

In this section

Topic Description

ParentObjectCheckLock

The ParentObjectCheckLock rule specifies that the driver should call WdfWaitLockCreate and WdfSpinLockCreate setting a parent object.

ReqSendWhileSpinlock

The ReqSendWhileSpinlock rule specifies that no requests are sent while the driver holds a spinlock.

Spinlock

The Spinlock rule specifies that calls to KeAcquireSpinLock or KeAcquireSpinLockRaiseToDpc and KeReleaseSpinlock are used in strict alternation.

SpinlockDpc

The SpinlockDpc rule specifies that calls to KeAcquireSpinLock or KeAcquireSpinLockRaiseToDpc and KeReleaseSpinlock are used in strict alternation.

SpinlockRelease

The SpinlockRelease rule specifies that calls to KeAcquireSpinLock, KeAcquireSpinLockRaiseToDpc, and KeReleaseSpinLock are used in a balanced way within a KMDF callback. At the end of any KMDF callback routine, the driver should not hold the spin lock.

WdfInterruptLock

The WdfInterruptLock rule specifies that calls to the WdfInterruptAcquireLock method is used in strict alternation with calls to WdfInterruptReleaseLock. Moreover, at the end of any KMDF callback routine, the driver should not hold the framework spin lock object, obtained by a previous call to WdfInterruptAcquireLock.

WdfInterruptLockRelease

The WdfInterruptLockRelease rule specifies that calls to WdfInterruptAcquireLock and WdfInterruptReleaseLock are used in a balanced way within a KMDF callback routine. At the end of any KMDF callback routine, the driver should not hold the framework spin lock object that was obtained by a previous call to WdfInterruptAcquireLock.

WdfSpinlock

The WdfSpinlock rule specifies that calls to the WdfSpinLockAcquire method are used in strict alternation with WdfSpinlockRelease. At the end of any KMDF callback routine, the driver should not hold the framework spinlock object that was obtained by a previous call to WdfSpinLockAcquire.

WdfSpinlockRelease

The WdfSpinlockRelease rule specifies that calls to WdfSpinLockAcquire and WdfSpinlockRelease are used in a balanced way within a KMDF event callback function. When the KMDF event callback function returns, the driver should not hold the framework spin lock object that was obtained by a previous call to WdfSpinLockAcquire.

WdfWaitlock

The WdfWaitlock rule specifies that calls to WdfWaitLockAcquire are used in strict alternation with WdfWaitlockRelease. When the KMDF event callback function returns, the driver should not hold the framework spin lock object that was obtained by a previous call to WdfWaitLockAcquire.

WdfWaitlockRelease

The WdfWaitlockRelease rule specifies that calls to WdfWaitLockAcquire and WdfWaitLockRelease are used in a balanced way within a KMDF event callback function. When the KMDF event callback function returns, the driver should not hold the framework spin lock object that was obtained by a previous call to WdfWaitLockAcquire.

To select the Locking rule set

  1. Select your driver project (.vcxProj) in Microsoft Visual Studio. From the Driver menu, click Launch Static Driver Verifier….

  2. 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).