I am now developing a PC/SC compatible virtual smart card reader driver.
I am developing by Windows DDK 2003 and XP. I want it plug and play, so I use the Toaster Bus which was provided by the DDK sample as its underlying bus device. I made it by combining the Toaster(incomplete1) function driver and the PSCR smart card reader driver which are both from the DDK samples.
Now, I have a problem. I build and install the virtual smart card reader driver. After that the Device Manager can display a “Virtual Smart Card Reader” working. But it seems that the Smart Card Resource Manager can’t recognize it, because when I use SCardListReaders to list the readers, the virtual reader hasn’t come up.
Above is the debug information when the device was pluged in.
VSCR: ===DriverEntry() on Oct 9 2007 at 13:49:30
VSCR: +++AddDevice()
VSCR: SmartcardInitialize() called with status=STATUS_SUCCESS
VSCR: —AddDevice() STATUS_SUCCESS
VSCR: +++Pnp() MinorFunction=IRP_MN_QUERY_LEGACY_BUS_INFORMATION
VSCR: —Pnp() STATUS_NOT_SUPPORTED
VSCR: +++Pnp() MinorFunction=IRP_MN_FILTER_RESOURCE_REQUIREMENTS
VSCR: —Pnp() STATUS_SUCCESS
VSCR: +++Pnp() MinorFunction=IRP_MN_QUERY_INTERFACE
VSCR: —Pnp() STATUS_NOT_SUPPORTED
VSCR: +++Pnp() MinorFunction=IRP_MN_START_DEVICE
VSCR: +++StartDevice()
VSCR: —StartDevice() STATUS_SUCCESS
VSCR: —Pnp() STATUS_SUCCESS
VSCR: +++Pnp() MinorFunction=IRP_MN_QUERY_CAPABILITIES
VSCR: —Pnp() STATUS_SUCCESS
VSCR: +++Pnp() MinorFunction=IRP_MN_QUERY_PNP_DEVICE_STATE
VSCR: —Pnp() STATUS_NOT_SUPPORTED
VSCR: +++Pnp() MinorFunction=IRP_MN_QUERY_DEVICE_RELATIONS
VSCR: —Pnp() STATUS_NOT_SUPPORTED
* All the driver has received were Pnp irps, why?
I have summarize all the requirments that a PC/SC smart card reader driver needs which I can think up:
In AddDevice():
(1) Define a SMARTCARD_EXTENSION member structure in the DEVICE_EXTENSION.
(2) Initialize Version, SmartcardRequest.BufferSize and SmartcardReply.BufferSize of SmartcardExtension and call SmartcardInitlize() to alloc buffer for SMLIB.
(3) Initlize VendorAttr and ReaderCapabilities member of SmartcardExtension. The VendorAttr.VendorName, VendorAttr.IfdType and VendorAttr.UnitNo must be set to proper values.
(4) Setup SMLIB callback functions, in which RDF_CARD_POWER, RDF_TRANSMIT, RDF_CARD_TRACKING and RDF_SET_PROTOCOL are mandatory.
(5) OsData->DeviceObject must be set to DeviceObject.
(6) Call IoRegisterDeviceInterface() to register a interface for the device with SmartCardReaderGuid.
In INF File:
(1) In [Version] section, “Class” must equal “SmartCardReader” and “ClassGuid” must be “{50DD5230-BA8A-11D1-BF5D-0000F805F530}”.
(2) Do I need to add an item into registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Cryptography\Calais\Readers with a device key named “VenderName IfdType UnitNo” which corresponding with the values in SmartcardExtension.VendorAttr.
In SMLIB callback functions:
(1) In CBCardPower() when SmartcardExtension->MinorIoControlCode equals SCARD_COLD_RESET or SCARD_WARM_RESET, fill the SmartcardExtension->IoRequest.ReplyBuffer with ATR which was fetched from card. Then copy ATR to SmartcardExtension->CardCapabilities.ATR and call SmartcardUpdateCardCapablities() to inform the SMLIB.
* Is there anything I have ignored or misunderstood?
I am beginner with driver developing. Any reply will be appreciated.