Interaction with the Smart Card Driver Library
The following figure shows how a reader driver interacts with the smart card driver library in order to process IOCTL requests that it receives from the resource manager:

Interaction Between Reader Driver and Driver Library While Processing IOCTLs
Starting in the upper left-hand corner with number (1) this diagram illustrates the steps that a reader driver must take together with the system-supplied driver library to process an IOCTL request:
- The reader driver should pass all IOCTL requests to the SmartcardDeviceControl (WDM) driver library routine.
- If the parameters that the reader driver passes to SmartcardDeviceControl are incorrect, SmartcardDeviceControl returns with an error message. In the WDM version of the driver library, SmartcardDeviceControl returns without completing the IRP, and it is the reader driver's responsibility to complete the IRP.
- If the parameters are legal, SmartcardDeviceControl processes the IOCTL if it can.
- SmartcardDeviceControl checks to see if the reader driver has a callback defined for the IOCTL request that it is processing. If the callback exists, SmartcardDeviceControl calls it.
- The callback routine calls all the driver library routines required to complete the processing of the IOCTL.
- After processing the IOCTL, the callback routine returns to SmartcardDeviceControl.
- In the WDM version of the library, SmartcardDeviceControl completes the IRP that carried the IOCTL.
- SmartcardDeviceControl returns control to the reader driver dispatch routine.
The smart card library synchronizes access to the reader driver. No two callback functions will be called at the same time. However, card insertion and removal event handling must be processed asynchronously.