Miscellaneous rule set (WDM)

Use these rules to verify that your driver correctly follows a general set of requirements for the proper handling of registry keys, strings and device object pointers.

In this section

Topic Description

AddDevice

The AddDevice rule specifies that the driver's AddDevice routine calls IoAttachDeviceToDeviceStack only after calling IoCreateDevice.

DanglingDeviceObjectReference

The DanglingDeviceObjectReference rule specifies that the driver calls ObDereferenceObject with the same device object pointer that IoGetAttachedDeviceReference returned.

PnpSameDeviceObject

The PnpSameDeviceObject rule specifies that the driver calls IoAttachDeviceToDeviceStack with a pointer to a valid target device object.

TargetRelationNeedsRef

The TargetRelationNeedsRef rule specifies that when processing a TargetDeviceRelation query, the driver's DispatchPnP routine calls one of the following functions to reference the child device's PDO:

UnSafeAllocatePool

UnSafeAllocatePool is an important security rule that checks that a driver is not using deprecated DDIs to allocate memory.

ZwRegistryCreate

The ZwRegistryCreate rule specifies that after calling ZwCreateKey, the driver can call the following registry functions only while holding an open handle to the registry key (that is, before any calls to ZwClose or ZwDeleteKey to close or delete the handle to the registry key):

ZwRegistryOpen

The ZwRegistryOpen rule specifies that after calling ZwOpenKey, the driver calls the following registry functions only while holding an open handle to a registry key (that is, before calling ZwClose or ZwDeleteKey):

To select the Miscellaneous 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 Miscellaneous.

    To select the default rule set from a Visual Studio developer command prompt window, specify Miscellaneous.sdv with the /check option. For example:

    msbuild /t:sdv /p:Inputs="/check:Miscellaneous.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).