EVT_WDF_DRIVER_DEVICE_ADD callback function (wdfdriver.h)

[Applies to KMDF and UMDF]

A driver's EvtDriverDeviceAdd event callback function performs device initialization operations when the Plug and Play (PnP) manager reports the existence of a device.



NTSTATUS EvtWdfDriverDeviceAdd(
  [in]      WDFDRIVER Driver,
  [in, out] PWDFDEVICE_INIT DeviceInit


[in] Driver

A handle to a framework driver object that represents the driver.

[in, out] DeviceInit

A pointer to a framework-allocated WDFDEVICE_INIT structure.

Return value

TheEvtDriverDeviceAdd callback function must return STATUS_SUCCESS if the operation succeeds. Otherwise, this callback function must return one of the error status values that are defined in Ntstatus.h. For more information, see the following Remarks section.


Each framework-based driver that supports PnP devices must provide the EvtDriverDeviceAdd callback function. The driver must place the callback function's address in its WDF_DRIVER_CONFIG structure before calling WdfDriverCreate.

The framework calls your driver's EvtDriverDeviceAdd callback function after a bus driver detects a device that has a hardware identifier (ID) that matches a hardware ID that your driver supports. You specify the hardware IDs that your driver supports by providing an INF file, which the operating system uses to install drivers the first time that one of your devices is connected to the computer. For more information about how the system uses INF files and hardware IDs, see How Setup Selects Drivers.

A driver's EvtDriverDeviceAdd callback function typically performs at least some of the following initialization operations:

Some drivers, especially filter drivers, might not create device objects for some devices. If an EvtDriverDeviceAdd callback function does not create a device object, it must still return STATUS_SUCCESS unless an error was encountered.

If a driver's EvtDriverDeviceAdd callback function creates a device object but does not return STATUS_SUCCESS, the framework deletes the device object and its child devices.

If a function driver's EvtDriverDeviceAdd callback function does not return STATUS_SUCCESS, the I/O manager does not build a device stack for the device.

If a filter driver's EvtDriverDeviceAdd callback function does not return STATUS_SUCCESS, the framework converts the return value to STATUS_SUCCESS, and the I/O manager builds the device stack without the filter driver.


Target Platform Universal
Minimum KMDF version 1.0
Minimum UMDF version 2.0
Header wdfdriver.h (include Wdf.h)

See also