Smart Card Driver Development Concepts (Windows CE 5.0)
Smart Card device drivers expose the stream interface. By convention, smart card reader drivers use the PSC prefix.
The Device Manager process calls the PSC_Init entry point when a new device is instantiated. The PSC_Init routine creates a device context that is used to talk to the reader. The PSC_Open entry point is called when a program, such as the Smart Card Resource Manager, attempts to open the reader using the CreateFile API. Because smart card reader drivers are not expected to support shared access by multiple applications, there is no need to create a separate open context. When the program releases the device by calling CloseHandle, the PSC_Close entry point is invoked. When it is time to remove the device from the system, the Device Manager calls PSC_Deinit.
PSC_IOControl is the main entry point for smart card requests. PSC_IOControl 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 typical driver's IOCTL function is shown in the following code example.
BOOL PSC_IOControl(
DWORD Handle,
DWORD dwIoControlCode,
PBYTE pInBuf,
DWORD nInBufSize,
PBYTE pOutBuf,
DWORD nOutBufSize,
PDWORD pBytesReturned
)
{
NTSTATUS status;
PSMARTCARD_EXTENSION pSmartcardExtension = (PSMARTCARD_EXTENSION) Handle;
if (pSmartcardExtension->ReaderExtension->d_uReaderState != STATE_OPENED)
{
SmartcardDebug(DEBUG_ERROR,(TEXT("%s: DeviceIOCTL - invalid state %d\n"), szDriverName,
pSmartcardExtension->ReaderExtension->d_uReaderState
));
status = ERROR_GEN_FAILURE;
}
else
status = SmartcardDeviceControl(
pSmartcardExtension, dwIoControlCode,
pInBuf, nInBufSize,
pOutBuf, nOutBufSize,
pBytesReturned);
return (status == STATUS_SUCCESS ? TRUE: FALSE);
}
See Also
Smart Card Driver Architecture | Smart Card Driver Samples | Smart Card Driver Registry Settings
Send Feedback on this topic to the authors