EvtDriverDeviceAdd

转:EvtDriverDeviceAdd


EvtDriverDeviceAdd

此主题尚未评级

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

语法

EVT_WDF_DRIVER_DEVICE_ADD EvtDriverDeviceAdd;

NTSTATUS EvtDriverDeviceAdd(
  __in  WDFDRIVER Driver,
  __in  PWDFDEVICE_INIT DeviceInit
)
{ ... }

参数

Driver [in]

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

DeviceInit [in]

A pointer to a framework-allocated WDFDEVICE_INIT structure.

返回值

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.

示例

The function type is declared in WdfDriver.h, as follows.

typedef NTSTATUS
  (EVT_WDF_DRIVER_DEVICE_ADD)(
    IN WDFDRIVER Driver,
    IN PWDFDEVICE_INIT DeviceInit
    );

To define an EvtDriverDeviceAdd callback function that is named MyDriverDeviceAdd, you must first provide a function declaration that driver verification tools require, as follows:

EVT_WDF_DRIVER_DEVICE_ADD MyDriverDeviceAdd;

Then, implement your callback function as follows:

NTSTATUS 
 MyDriverDeviceAdd (
    IN WDFDRIVER Driver,
    IN PWDFDEVICE_INIT DeviceInit
    )
  {...}

要求

版本

Supported by version 1.0 and later versions of KMDF.

标头

Wdfdriver.h (包括Wdf.h)

IRQL

PASSIVE_LEVEL

另请参见

WDF_DRIVER_CONFIG WDFDEVICE_INIT WdfDriverCreate

 


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值