Redigera

Dela via


Memory usage rule set (NDIS)

Use these rules to verify that your driver correctly calls NDIS functions to allocate and free memory.

In this section

Topic Description

NdisAllocateGenericObject

The NdisAllocateGenericObject rule specifies that NdisAllocateGenericObject and NdisFreeGenericObject are called in alternate order. The ultimate goal is to make sure all generic objects are freed when MiniportHaltEx ends.

NdisAllocateMdl

The NdisAllocateMdl rule specifies that NdisAllocateMdl and NdisFreeMdl are called in alternate order. The ultimate goal is to make sure all MDLs are freed when MiniportHaltEx ends.

NdisAllocateMemoryWithTagPriority

The NdisAllocateMemoryWithTagPriority rule specifies that a driver must not call NdisAllocateMemoryWithTagPriority without providing a Tag.

Every memory allocation should use a unique pool tag to ensure that kernel debuggers and Driver Verifier can identify a distinct allocated block of memory.

NdisAllocateNetBuffer

The NdisAllocateNetBuffer rule specifies that NdisAllocateNetBuffer and NdisFreeNetBuffer are called in alternate order. The ultimate goal is to make sure all instances of NET_BUFFER are freed when MiniportHaltEx ends.

NdisMFreeSharedMemory

NdisMFreeSharedMemory cannot be called from a MiniportShutdownEx function.

NdisMIndicateStatusEx

The driver must not call NdisMIndicateStatusEx after it returns from the MiniportHaltEx function.

NdisMMapIoSpace

The NdisMMapIoSpace function should only be called in the context of MiniportInitializeEx.

NdisMRegisterIoPortRange

A miniport driver calls NdisMRegisterIoPortRange from its MiniportInitializeEx or MINIPORT_ADD_DEVICE functions. MiniportInitializeEx or MINIPORT_ADD_DEVICE must call NdisMSetMiniportAttributes before calling NdisMRegisterIoPortRange.

To select the Memory usage 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 MemoryUsage.

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

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