Static Driver Verifier KMDF Function Declarations

To enable SDV to verify your KMDF driver, you must declare each callback function, using a callback function role type. The callback function role types are defined in the various WDF header files and are included when you build your driver with the Wdf.h header file. The following table shows the function role types and the event callback functions that they are associated with.

You must declare the driver's callback functions before the callback function definitions. The following example shows the function role type declaration for the EvtDriverDeviceAdd callback function. In this example, the callback function is called EvtDriverDeviceAdd.

#include <NTDDK.h>  
#include <wdf.h>
EVT_WDF_DRIVER_DEVICE_ADD EvtDriverDeviceAdd

If a callback function has a function prototype declaration, you must replace the function prototype with the function role type declaration. For more information about the function role type declarations, see Using Function Role Type Declarations.

The following table shows the callback function types and the event callback functions that they are associated with.

Function role type Event callback function

EVT_WDF_CHILD_LIST_ADDRESS_DESCRIPTION_CLEANUP

EvtChildListAddressDescriptionCleanup

EVT_WDF_CHILD_LIST_ADDRESS_DESCRIPTION_COPY

EvtChildListAddressDescriptionCopy

EVT_WDF_CHILD_LIST_ADDRESS_DESCRIPTION_DUPLICATE

EvtChildListIdentificationDescriptionDuplicate

EVT_WDF_CHILD_LIST_CREATE_DEVICE

EvtChildListCreateDevice

EVT_WDF_CHILD_LIST_DEVICE_REENUMERATED

EvtChildListDeviceReenumerated

EVT_WDF_CHILD_LIST_IDENTIFICATION_DESCRIPTION_CLEANUP

EvtChildListIdentificationDescriptionCleanup

EVT_WDF_CHILD_LIST_IDENTIFICATION_DESCRIPTION_COMPARE

EvtChildListIdentificationDescriptionCompare

EVT_WDF_CHILD_LIST_IDENTIFICATION_DESCRIPTION_COPY

EvtChildListIdentificationDescriptionCopy

EVT_WDF_CHILD_LIST_IDENTIFICATION_DESCRIPTION_DUPLICATE

EvtChildListIdentificationDescriptionDuplicate

EVT_WDF_CHILD_LIST_SCAN_FOR_CHILDREN

EvtChildListScanForChildren

EVT_WDF_DEVICE_ARM_WAKE_FROM_S0

EvtDeviceArmWakeFromS0

EVT_WDF_DEVICE_ARM_WAKE_FROM_SX

EvtDeviceArmWakeFromSx

EVT_WDF_DEVICE_CONTEXT_CLEANUP

EvtCleanupCallback

EVT_WDF_DEVICE_CONTEXT_DESTROY

EvtDestroyCallback

EVT_WDF_DEVICE_D0_ENTRY

EvtDeviceD0Entry

EVT_WDF_DEVICE_D0_ENTRY_POST_INTERRUPTS_ENABLED

EvtDeviceD0EntryPostInterruptsEnabled

EVT_WDF_DEVICE_D0_EXIT

EvtDeviceD0Exit

EVT_WDF_DEVICE_D0_EXIT_PRE_INTERRUPTS_DISABLED

EvtDeviceD0ExitPreInterruptsDisabled

EVT_WDF_DEVICE_DISABLE_WAKE_AT_BUS

EvtDeviceDisableWakeAtBus

EVT_WDF_DEVICE_DISARM_WAKE_FROM_S0

EvtDeviceDisarmWakeFromS0

EVT_WDF_DEVICE_DISARM_WAKE_FROM_SX

EvtDeviceDisarmWakeFromSx

EVT_WDF_DEVICE_EJECT

EvtDeviceEject

EVT_WDF_DEVICE_ENABLE_WAKE_AT_BUS

EvtDeviceEnableWakeAtBus

EVT_WDF_DEVICE_FILE_CREATE

EvtDeviceFileCreate

EVT_WDF_DEVICE_FILTER_RESOURCE_REQUIREMENTS

EvtDeviceFilterAddResourceRequirements

EVT_WDF_DEVICE_PNP_STATE_CHANGE_NOTIFICATION

EvtDevicePnpStateChange

EVT_WDF_DEVICE_POWER_POLICY_STATE_CHANGE_NOTIFICATION

EvtDevicePnpStateChange

EVT_WDF_DEVICE_POWER_STATE_CHANGE_NOTIFICATION

EvtDevicePowerStateChange

EVT_WDF_DEVICE_PREPARE_HARDWARE

EvtDevicePrepareHardware

EVT_WDF_DEVICE_PROCESS_QUERY_INTERFACE_REQUEST

EvtDeviceProcessQueryInterfaceRequest

EVT_WDF_DEVICE_QUERY_REMOVE

EvtDeviceQueryRemove

EVT_WDF_DEVICE_QUERY_STOP

EvtDeviceQueryStop

EVT_WDF_DEVICE_RELATIONS_QUERY

EvtDeviceRelationsQuery

EVT_WDF_DEVICE_RELEASE_HARDWARE

EvtDeviceReleaseHardware

EVT_WDF_DEVICE_REMOVE_ADDED_RESOURCES

EvtDeviceRemoveAddedResources

EVT_WDF_DEVICE_RESOURCE_REQUIREMENTS_QUERY

EvtDeviceResourceRequirementsQuery

EVT_WDF_DEVICE_RESOURCES_QUERY

EvtDeviceResourcesQuery

EVT_WDF_DEVICE_SELF_MANAGED_IO_CLEANUP

EvtDeviceSelfManagedIoCleanup

EVT_WDF_DEVICE_SELF_MANAGED_IO_FLUSH

EvtDeviceSelfManagedIoFlush

EVT_WDF_DEVICE_SELF_MANAGED_IO_INIT

EvtDeviceSelfManagedIoInit

EVT_WDF_DEVICE_SELF_MANAGED_IO_RESTART

EvtDeviceSelfManagedIoRestart

EVT_WDF_DEVICE_SELF_MANAGED_IO_SUSPEND

EvtDeviceSelfManagedIoSuspend

EVT_WDF_DEVICE_SET_LOCK

EvtDeviceSetLock

EVT_WDF_DEVICE_SHUTDOWN_NOTIFICATION

EvtDeviceShutdownNotification

EVT_WDF_DEVICE_SURPRISE_REMOVAL

EvtDeviceSurpriseRemoval

EVT_WDF_DEVICE_USAGE_NOTIFICATION

EvtDeviceUsageNotification

EVT_WDF_DEVICE_WAKE_FROM_S0_TRIGGERED

EvtDeviceWakeFromS0Triggered

EVT_WDF_DEVICE_WAKE_FROM_SX_TRIGGERED

EvtDeviceWakeFromSxTriggered

EVT_WDF_DMA_ENABLER_DISABLE

EvtDmaEnablerDisable

EVT_WDF_DMA_ENABLER_ENABLE

EvtDmaEnablerEnable

EVT_WDF_DMA_ENABLER_FILL

EvtDmaEnablerFill

EVT_WDF_DMA_ENABLER_FLUSH

EvtDmaEnablerFlush

EVT_WDF_DMA_ENABLER_SELFMANAGED_IO_START

EvtDmaEnablerSelfManagedIoStart

EVT_WDF_DMA_ENABLER_SELFMANAGED_IO_STOP

EvtDmaEnablerSelfManagedIoStop

EVT_WDF_DPC

EvtDpcFunc

EVT_WDF_DRIVER_DEVICE_ADD

EvtDriverDeviceAdd

EVT_WDF_DRIVER_UNLOAD

EvtDriverUnload

EVT_WDF_FILE_CLEANUP

EvtFileCleanup

EVT_WDF_FILE_CLOSE

EvtFileClose

EVT_WDF_FILE_CONTEXT_CLEANUP_CALLBACK

EvtCleanupCallback

EVT_WDF_FILE_CONTEXT_DESTROY_CALLBACK

EvtDestroyCallback

EVT_WDF_INTERRUPT_DISABLE

EvtInterruptDisable

EVT_WDF_INTERRUPT_DPC

EvtInterruptDpc

EVT_WDF_INTERRUPT_ENABLE

EvtInterruptEnable

EVT_WDF_INTERRUPT_ISR

EvtInterruptIsr

EVT_WDF_INTERRUPT_SYNCHRONIZE

EvtInterruptSynchronize

EVT_WDF_IO_IN_CALLER_CONTEXT

EvtIoInCallerContext

EVT_WDF_IO_QUEUE_CONTEXT_CLEANUP_CALLBACK

EvtCleanupCallback

EVT_WDF_IO_QUEUE_CONTEXT_DESTROY_CALLBACK

EvtDestroyCallback

EVT_WDF_IO_QUEUE_IO_CANCELED_ON_QUEUE

EvtIoCanceledOnQueue

EVT_WDF_IO_QUEUE_IO_DEFAULT

EvtIoDefault

EVT_WDF_IO_QUEUE_IO_DEVICE_CONTROL

EvtIoDeviceControl

EVT_WDF_IO_QUEUE_IO_INTERNAL_DEVICE_CONTROL

EvtIoInternalDeviceControl

EVT_WDF_IO_QUEUE_IO_READ

EvtIoRead

EVT_WDF_IO_QUEUE_IO_RESUME

EvtIoResume

EVT_WDF_IO_QUEUE_IO_STOP

EvtIoStop

EVT_WDF_IO_QUEUE_IO_WRITE

EvtIoWrite

EVT_WDF_IO_QUEUE_STATE

EvtIoQueueState

EVT_WDF_IO_TARGET_QUERY_REMOVE

EvtIoTargetQueryRemove

EVT_WDF_IO_TARGET_REMOVE_CANCELED

EvtIoTargetRemoveCanceled

EVT_WDF_IO_TARGET_REMOVE_COMPLETE

EvtIoTargetRemoveComplete

EVT_WDF_OBJECT_CONTEXT_CLEANUP

EvtCleanupCallback

EVT_WDF_OBJECT_CONTEXT_DESTROY

EVT_WDF_PROGRAM_DMA

EvtProgramDma

EVT_WDF_REQUEST_CANCEL

EvtRequestCancel

EVT_WDF_REQUEST_COMPLETION_ROUTINE

CompletionRoutine

EVT_WDF_TIMER

EvtTimerFunc

EVT_WDF_TRACE_CALLBACK

EVT_WDF_WMI_INSTANCE_EXECUTE_METHOD

EvtWmiInstanceExecuteMethod

EVT_WDF_WMI_INSTANCE_QUERY_INSTANCE

EvtWmiInstanceQueryInstance

EVT_WDF_WMI_INSTANCE_SET_INSTANCE

EvtWmiInstanceSetInstance

EVT_WDF_WMI_INSTANCE_SET_ITEM

EvtWmiInstanceSetItem

EVT_WDF_WMI_PROVIDER_FUNCTION_CONTROL

EvtWmiProviderFunctionControl

EVT_WDF_WORKITEM

EvtWorkItem

EVT_WDFDEVICE_WDM_IRP_PREPROCESS

EvtDeviceWdmIrpPreprocess

Function role types that allow multiple callback functions

There are some function role types that can have multiple event callback functions associated with them. For example, a driver might have multiple EvtTimerFunc or EvtDpcFunc callback functions. The following table show the maximum number of callbacks that SDV supports for each function role type. While it is not incorrect for a driver to have more than the maximum number of callback functions listed in the table, it does complicate the verification process when using SDV. For information about changes you might need to make to the Sdv-map.h file to accommodate the additional callback functions, see Duplicate entry points for a function role type.

Function role type Maximum number of callback functions

EVT_WDF_DPC

7

EVT_WDF_INTERRUPT_SYNCHRONIZE

11

EVT_WDF_TIMER

6

EVT_WDF_WMI_INSTANCE_EXECUTE_METHOD

5

EVT_WDF_WMI_INSTANCE_QUERY_INSTANCE

5

EVT_WDF_WMI_INSTANCE_SET_INSTANCE

5

EVT_WDF_WMI_INSTANCE_SET_ITEM

5

Function role types and I/O queues

Use the following function role types when you declare the Request Handlers and callback functions that rely on the KMDF framework to deliver the I/O requests to the driver (for sequential or parallel dispatching). Do not use these function role types for the functions that manually forward requests from the default queue to other queues (manual dispatching). SDV does not support a memory model that allows it to track requests from one queue to another.

For more information about I/O queues, see Creating I/O Queues.

Function role types used for I/O queue configured for manual dispatching

EVT_WDF_IO_QUEUE_CONTEXT_CLEANUP_CALLBACK

EVT_WDF_IO_QUEUE_CONTEXT_DESTROY_CALLBACK

EVT_WDF_IO_QUEUE_IO_CANCELED_ON_QUEUE

EVT_WDF_IO_QUEUE_IO_DEFAULT

EVT_WDF_IO_QUEUE_IO_DEVICE_CONTROL

EVT_WDF_IO_QUEUE_IO_INTERNAL_DEVICE_CONTROL

EVT_WDF_IO_QUEUE_IO_READ

EVT_WDF_IO_QUEUE_IO_RESUME

EVT_WDF_IO_QUEUE_IO_STOP

EVT_WDF_IO_QUEUE_IO_WRITE

EVT_WDF_IO_QUEUE_STATE

Function role types for the EvtCleanupCallback and EvtDestroyCallback functions

You must declare the EvtCleanupCallback and EvtDestroyCallback function with object-specific, function role types. SDV requires these object-specific role types to determine whether the driver is properly using the callback function. Use the following tables to determine which function type to use.

Object type Function role type for EvtCleanupCallback

Device object

EVT_WDF_DEVICE_CONTEXT_CLEANUP

I/O queue object

EVT_WDF_IO_QUEUE_CONTEXT_CLEANUP_CALLBACK

File object

EVT_WDF_FILE_CONTEXT_CLEANUP_CALLBACK

All other objects

EVT_WDF_OBJECT_CONTEXT_CLEANUP

Object type Function role type for EvDestroyCallback

Device object

EVT_WDF_DEVICE_CONTEXT_DESTROY

I/O queue object

EVT_WDF_IO_QUEUE_CONTEXT_DESTROY_CALLBACK

File object

EVT_WDF_FILE_CONTEXT_DESTROY_CALLBACK

All other objects

EVT_WDF_OBJECT_CONTEXT_DESTROY