WDM Smart Card Driver Library

Every WDM driver needs the following routines:

The DriverEntry routine creates a device that is used to talk to the reader and uses the support functions SmartcardLogError_(WDM) and SmartcardCreateLink (WDM). The DriverUnload function removes the driver from the system. The resource manager calls Create to establish a connection to the reader, and Cleanup is used to cancel pending I/O requests.

DeviceControl is the main entry point for smart card requests. If the driver is a lowest-level driver, it should also have a StartIo routine.

DeviceControl should immediately call the smart card driver library. If the library is unable to handle the call because this IOCTL call is driver-specific, the driver's callback for unknown IOCTL codes is called.

A driver's IOCTL function usually looks like the following:

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

    return SmartcardDeviceControl(
        &(deviceExtension->SmartcardExtension),
        Irp
        );
}