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 |
|
EVT_WDF_CHILD_LIST_ADDRESS_DESCRIPTION_COPY |
|
EVT_WDF_CHILD_LIST_ADDRESS_DESCRIPTION_DUPLICATE |
|
EVT_WDF_CHILD_LIST_CREATE_DEVICE |
|
EVT_WDF_CHILD_LIST_DEVICE_REENUMERATED |
|
EVT_WDF_CHILD_LIST_IDENTIFICATION_DESCRIPTION_CLEANUP |
|
EVT_WDF_CHILD_LIST_IDENTIFICATION_DESCRIPTION_COMPARE |
|
EVT_WDF_CHILD_LIST_IDENTIFICATION_DESCRIPTION_COPY |
|
EVT_WDF_CHILD_LIST_IDENTIFICATION_DESCRIPTION_DUPLICATE |
|
EVT_WDF_CHILD_LIST_SCAN_FOR_CHILDREN |
|
EVT_WDF_DEVICE_ARM_WAKE_FROM_S0 |
|
EVT_WDF_DEVICE_ARM_WAKE_FROM_SX |
|
EVT_WDF_DEVICE_CONTEXT_CLEANUP |
|
EVT_WDF_DEVICE_CONTEXT_DESTROY |
|
EVT_WDF_DEVICE_D0_ENTRY |
|
EVT_WDF_DEVICE_D0_ENTRY_POST_INTERRUPTS_ENABLED |
|
EVT_WDF_DEVICE_D0_EXIT |
|
EVT_WDF_DEVICE_D0_EXIT_PRE_INTERRUPTS_DISABLED |
|
EVT_WDF_DEVICE_DISABLE_WAKE_AT_BUS |
|
EVT_WDF_DEVICE_DISARM_WAKE_FROM_S0 |
|
EVT_WDF_DEVICE_DISARM_WAKE_FROM_SX |
|
EVT_WDF_DEVICE_EJECT |
|
EVT_WDF_DEVICE_ENABLE_WAKE_AT_BUS |
|
EVT_WDF_DEVICE_FILE_CREATE |
|
EVT_WDF_DEVICE_FILTER_RESOURCE_REQUIREMENTS |
|
EVT_WDF_DEVICE_PNP_STATE_CHANGE_NOTIFICATION |
|
EVT_WDF_DEVICE_POWER_POLICY_STATE_CHANGE_NOTIFICATION |
|
EVT_WDF_DEVICE_POWER_STATE_CHANGE_NOTIFICATION |
|
EVT_WDF_DEVICE_PREPARE_HARDWARE |
|
EVT_WDF_DEVICE_PROCESS_QUERY_INTERFACE_REQUEST |
|
EVT_WDF_DEVICE_QUERY_REMOVE |
|
EVT_WDF_DEVICE_QUERY_STOP |
|
EVT_WDF_DEVICE_RELATIONS_QUERY |
|
EVT_WDF_DEVICE_RELEASE_HARDWARE |
|
EVT_WDF_DEVICE_REMOVE_ADDED_RESOURCES |
|
EVT_WDF_DEVICE_RESOURCE_REQUIREMENTS_QUERY |
|
EVT_WDF_DEVICE_RESOURCES_QUERY |
|
EVT_WDF_DEVICE_SELF_MANAGED_IO_CLEANUP |
|
EVT_WDF_DEVICE_SELF_MANAGED_IO_FLUSH |
|
EVT_WDF_DEVICE_SELF_MANAGED_IO_INIT |
|
EVT_WDF_DEVICE_SELF_MANAGED_IO_RESTART |
|
EVT_WDF_DEVICE_SELF_MANAGED_IO_SUSPEND |
|
EVT_WDF_DEVICE_SET_LOCK |
|
EVT_WDF_DEVICE_SHUTDOWN_NOTIFICATION |
|
EVT_WDF_DEVICE_SURPRISE_REMOVAL |
|
EVT_WDF_DEVICE_USAGE_NOTIFICATION |
|
EVT_WDF_DEVICE_WAKE_FROM_S0_TRIGGERED |
|
EVT_WDF_DEVICE_WAKE_FROM_SX_TRIGGERED |
|
EVT_WDF_DMA_ENABLER_DISABLE |
|
EVT_WDF_DMA_ENABLER_ENABLE |
|
EVT_WDF_DMA_ENABLER_FILL |
|
EVT_WDF_DMA_ENABLER_FLUSH |
|
EVT_WDF_DMA_ENABLER_SELFMANAGED_IO_START |
|
EVT_WDF_DMA_ENABLER_SELFMANAGED_IO_STOP |
|
EVT_WDF_DPC |
|
EVT_WDF_DRIVER_DEVICE_ADD |
|
EVT_WDF_DRIVER_UNLOAD |
|
EVT_WDF_FILE_CLEANUP |
|
EVT_WDF_FILE_CLOSE |
|
EVT_WDF_FILE_CONTEXT_CLEANUP_CALLBACK |
|
EVT_WDF_FILE_CONTEXT_DESTROY_CALLBACK |
|
EVT_WDF_INTERRUPT_DISABLE |
|
EVT_WDF_INTERRUPT_DPC |
|
EVT_WDF_INTERRUPT_ENABLE |
|
EVT_WDF_INTERRUPT_ISR |
|
EVT_WDF_INTERRUPT_SYNCHRONIZE |
|
EVT_WDF_IO_IN_CALLER_CONTEXT |
|
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 |
|
EVT_WDF_IO_TARGET_QUERY_REMOVE |
|
EVT_WDF_IO_TARGET_REMOVE_CANCELED |
|
EVT_WDF_IO_TARGET_REMOVE_COMPLETE |
|
EVT_WDF_OBJECT_CONTEXT_CLEANUP |
|
EVT_WDF_OBJECT_CONTEXT_DESTROY |
|
EVT_WDF_PROGRAM_DMA |
|
EVT_WDF_REQUEST_CANCEL |
|
EVT_WDF_REQUEST_COMPLETION_ROUTINE |
|
EVT_WDF_TIMER |
|
EVT_WDF_TRACE_CALLBACK |
|
EVT_WDF_WMI_INSTANCE_EXECUTE_METHOD |
|
EVT_WDF_WMI_INSTANCE_QUERY_INSTANCE |
|
EVT_WDF_WMI_INSTANCE_SET_INSTANCE |
|
EVT_WDF_WMI_INSTANCE_SET_ITEM |
|
EVT_WDF_WMI_PROVIDER_FUNCTION_CONTROL |
|
EVT_WDF_WORKITEM |
|
EVT_WDFDEVICE_WDM_IRP_PREPROCESS |
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 |