WDM 读取器驱动程序

Required routines

WDM 读取器驱动程序需要以下例程。

DriverEntry

初始化驱动程序对象和调度表。

AddDevice

为智能卡读卡器创建设备对象。 In addition, AddDevice can call any of the following driver library routines:

Unload

从系统中删除驱动程序。

DispatchCreate

-and-

DispatchClose

Supports IRP_MJ_CREATE and IRP_MJ_CLOSE<, respectively. To establish a connection to the reader, the resource manager sends IRP_MJ_CREATE to the reader driver. To sever the connection, the resource manager sends IRP_MJ_CLOSE.

DispatchCleanup

Supports IRP_MJ_CLEANUP, which the resource manager sends to the reader driver to cancel pending I/O requests.

DispatchPnP

Supports IRP_MJ_PNP

DispatchPower

Supports IRP_MJ_POWER.

DispatchDeviceControl

Supports IRP_MJ_DEVICE_CONTROL and is the main entry point for smart card requests. Upon receiving IRP_MJ_DEVICE_CONTROL, DispatchDeviceControl must immediately call SmartcardDeviceControl (WDM), which is the smart card driver library routine that handles device-control requests. 以下代码示例演示如何从 WDM 驱动程序调用此库例程:

NTSTATUS
DriverDeviceControl(
    PDEVICE_OBJECT DeviceObject,
    PIRP Irp
    )
{
    PDEVICE_EXTENSION deviceExtension = DeviceObject -&gt; DeviceExtension;

    return SmartcardDeviceControl(
        &(deviceExtension-&gt;SmartcardExtension),
        Irp
        );

If it is unable to handle the particular IOCTL that is indicated in the call, SmartcardDeviceControl will call the driver's callback for unknown IOCTL requests.