pcsc-lite 2.3.0
|
Handles smart card reader communications and forwarding requests over message queues. More...
Functions | |
PCSC_API const char * | pcsc_stringify_error (const LONG pcscError) |
Returns a human readable text for the given PC/SC error code. | |
LONG | SCardEstablishContext (DWORD dwScope, LPCVOID pvReserved1, LPCVOID pvReserved2, LPSCARDCONTEXT phContext) |
Creates an Application Context to the PC/SC Resource Manager. | |
LONG | SCardReleaseContext (SCARDCONTEXT hContext) |
Destroys a communication context to the PC/SC Resource Manager. | |
LONG | SCardConnect (SCARDCONTEXT hContext, LPCSTR szReader, DWORD dwShareMode, DWORD dwPreferredProtocols, LPSCARDHANDLE phCard, LPDWORD pdwActiveProtocol) |
Establishes a connection to the reader specified in * szReader. | |
LONG | SCardReconnect (SCARDHANDLE hCard, DWORD dwShareMode, DWORD dwPreferredProtocols, DWORD dwInitialization, LPDWORD pdwActiveProtocol) |
Reestablishes a connection to a reader that was previously connected to using SCardConnect(). | |
LONG | SCardDisconnect (SCARDHANDLE hCard, DWORD dwDisposition) |
Terminates a connection made through SCardConnect(). | |
LONG | SCardBeginTransaction (SCARDHANDLE hCard) |
Establishes a temporary exclusive access mode for doing a series of commands in a transaction. | |
LONG | SCardEndTransaction (SCARDHANDLE hCard, DWORD dwDisposition) |
Ends a previously begun transaction. | |
LONG | SCardStatus (SCARDHANDLE hCard, LPSTR szReaderName, LPDWORD pcchReaderLen, LPDWORD pdwState, LPDWORD pdwProtocol, LPBYTE pbAtr, LPDWORD pcbAtrLen) |
Returns the current status of the reader connected to by hCard . | |
LONG | SCardGetStatusChange (SCARDCONTEXT hContext, DWORD dwTimeout, SCARD_READERSTATE *rgReaderStates, DWORD cReaders) |
Blocks execution until the current availability of the cards in a specific set of readers changes. | |
LONG | SCardControl (SCARDHANDLE hCard, DWORD dwControlCode, LPCVOID pbSendBuffer, DWORD cbSendLength, LPVOID pbRecvBuffer, DWORD cbRecvLength, LPDWORD lpBytesReturned) |
Sends a command directly to the IFD Handler (reader driver) to be processed by the reader. | |
LONG | SCardGetAttrib (SCARDHANDLE hCard, DWORD dwAttrId, LPBYTE pbAttr, LPDWORD pcbAttrLen) |
Get an attribute from the IFD Handler (reader driver). | |
LONG | SCardSetAttrib (SCARDHANDLE hCard, DWORD dwAttrId, LPCBYTE pbAttr, DWORD cbAttrLen) |
Set an attribute of the IFD Handler. | |
LONG | SCardTransmit (SCARDHANDLE hCard, const SCARD_IO_REQUEST *pioSendPci, LPCBYTE pbSendBuffer, DWORD cbSendLength, SCARD_IO_REQUEST *pioRecvPci, LPBYTE pbRecvBuffer, LPDWORD pcbRecvLength) |
Sends an APDU to the smart card contained in the reader connected to by SCardConnect(). | |
LONG | SCardListReaders (SCARDCONTEXT hContext, LPCSTR mszGroups, LPSTR mszReaders, LPDWORD pcchReaders) |
Returns a list of currently available readers on the system. | |
LONG | SCardFreeMemory (SCARDCONTEXT hContext, LPCVOID pvMem) |
Releases memory that has been returned from the resource manager using the SCARD_AUTOALLOCATE length designator. | |
LONG | SCardListReaderGroups (SCARDCONTEXT hContext, LPSTR mszGroups, LPDWORD pcchGroups) |
Returns a list of currently available reader groups on the system. | |
LONG | SCardCancel (SCARDCONTEXT hContext) |
Cancels a specific blocking SCardGetStatusChange() function. | |
LONG | SCardIsValidContext (SCARDCONTEXT hContext) |
Check if a SCARDCONTEXT is valid. | |
Handles smart card reader communications and forwarding requests over message queues.
Here is exposed the API for client applications.
0x8010001F
in pcsc-lite but 0x80100022
in Windows WinSCard. You should not have any problem if you always use the symbolic name. 0x8010001F
is also used for SCARD_E_UNEXPECTED on pcsc-lite but SCARD_E_UNEXPECTED is never returned by pcsc-lite. So 0x8010001F
does always mean SCARD_E_UNSUPPORTED_FEATURE. PCSC_API const char * pcsc_stringify_error | ( | const LONG | pcscError | ) |
Returns a human readable text for the given PC/SC error code.
[in] | pcscError | Error code to be translated to text. |
LONG SCardBeginTransaction | ( | SCARDHANDLE | hCard | ) |
Establishes a temporary exclusive access mode for doing a series of commands in a transaction.
You might want to use this when you are selecting a few files and then writing a large file so you can make sure that another application will not change the current file. If another application has a lock on this reader or this application is in SCARD_SHARE_EXCLUSIVE the function will block until it can continue.
[in] | hCard | Connection made from SCardConnect(). |
SCARD_S_SUCCESS | Successful (SCARD_S_SUCCESS) |
SCARD_E_INVALID_HANDLE | Invalid hCard handle (SCARD_E_INVALID_HANDLE) |
SCARD_E_NO_SERVICE | The server is not running (SCARD_E_NO_SERVICE) |
SCARD_E_READER_UNAVAILABLE | The reader has been removed (SCARD_E_READER_UNAVAILABLE) |
SCARD_E_SHARING_VIOLATION | Someone else has exclusive rights (SCARD_E_SHARING_VIOLATION) |
SCARD_F_COMM_ERROR | An internal communications error has been detected (SCARD_F_COMM_ERROR) |
SCARD_E_INVALID_VALUE | An invalid value is used for hCard (for example the reader is no more present) (SCARD_E_INVALID_VALUE) |
Definition at line 1141 of file winscard_clnt.c.
LONG SCardCancel | ( | SCARDCONTEXT | hContext | ) |
Cancels a specific blocking SCardGetStatusChange() function.
MUST be called with the same SCARDCONTEXT as SCardGetStatusChange().
[in] | hContext | Connection context to the PC/SC Resource Manager. |
SCARD_S_SUCCESS | Successful (SCARD_S_SUCCESS) |
SCARD_E_INVALID_HANDLE | Invalid hContext handle (SCARD_E_INVALID_HANDLE) |
SCARD_E_NO_SERVICE | Server is not running (SCARD_E_NO_SERVICE) |
SCARD_F_COMM_ERROR | An internal communications error has been detected (SCARD_F_COMM_ERROR) |
Definition at line 3182 of file winscard_clnt.c.
LONG SCardConnect | ( | SCARDCONTEXT | hContext, |
LPCSTR | szReader, | ||
DWORD | dwShareMode, | ||
DWORD | dwPreferredProtocols, | ||
LPSCARDHANDLE | phCard, | ||
LPDWORD | pdwActiveProtocol ) |
Establishes a connection to the reader specified in *
szReader.
[in] | hContext | Connection context to the PC/SC Resource Manager. |
[in] | szReader | Reader name to connect to. |
[in] | dwShareMode | Mode of connection type: exclusive or shared.
|
[in] | dwPreferredProtocols | Desired protocol use.
|
[out] | phCard | Handle to this connection. |
[out] | pdwActiveProtocol | Established protocol to this connection. |
SCARD_S_SUCCESS | Successful (SCARD_S_SUCCESS) |
SCARD_E_INVALID_HANDLE | Invalid hContext handle (SCARD_E_INVALID_HANDLE) |
SCARD_E_INVALID_PARAMETER | phCard or pdwActiveProtocol is NULL (SCARD_E_INVALID_PARAMETER) |
SCARD_E_INVALID_VALUE | Invalid sharing mode, requested protocol, or reader name (SCARD_E_INVALID_VALUE) |
SCARD_E_NO_SERVICE | The server is not running (SCARD_E_NO_SERVICE) |
SCARD_E_NO_SMARTCARD | No smart card present (SCARD_E_NO_SMARTCARD) |
SCARD_E_PROTO_MISMATCH | Requested protocol is unknown (SCARD_E_PROTO_MISMATCH) |
SCARD_E_READER_UNAVAILABLE | Could not power up the reader or card (SCARD_E_READER_UNAVAILABLE) |
SCARD_E_SHARING_VIOLATION | Someone else has exclusive rights (SCARD_E_SHARING_VIOLATION) |
SCARD_E_UNKNOWN_READER | szReader is NULL (SCARD_E_UNKNOWN_READER) |
SCARD_E_UNSUPPORTED_FEATURE | Protocol not supported (SCARD_E_UNSUPPORTED_FEATURE) |
SCARD_F_COMM_ERROR | An internal communications error has been detected (SCARD_F_COMM_ERROR) |
SCARD_F_INTERNAL_ERROR | An internal consistency check failed (SCARD_F_INTERNAL_ERROR) |
SCARD_W_UNPOWERED_CARD | Card is not powered (SCARD_W_UNPOWERED_CARD) |
SCARD_W_UNRESPONSIVE_CARD | Card is mute (SCARD_W_UNRESPONSIVE_CARD) |
Definition at line 797 of file winscard_clnt.c.
LONG SCardControl | ( | SCARDHANDLE | hCard, |
DWORD | dwControlCode, | ||
LPCVOID | pbSendBuffer, | ||
DWORD | cbSendLength, | ||
LPVOID | pbRecvBuffer, | ||
DWORD | cbRecvLength, | ||
LPDWORD | lpBytesReturned ) |
Sends a command directly to the IFD Handler (reader driver) to be processed by the reader.
This is useful for creating client side reader drivers for functions like PIN pads, biometrics, or other extensions to the normal smart card reader that are not normally handled by PC/SC.
[in] | hCard | Connection made from SCardConnect(). |
[in] | dwControlCode | Control code for the operation. Click here for a list of supported commands by some drivers. |
[in] | pbSendBuffer | Command to send to the reader. |
[in] | cbSendLength | Length of the command. |
[out] | pbRecvBuffer | Response from the reader. |
[in] | cbRecvLength | Length of the response buffer. |
[out] | lpBytesReturned | Length of the response. |
SCARD_S_SUCCESS | Successful (SCARD_S_SUCCESS) |
SCARD_E_INSUFFICIENT_BUFFER | cbRecvLength was not large enough for the reader response. The expected size is now in lpBytesReturned (SCARD_E_INSUFFICIENT_BUFFER) |
SCARD_E_INVALID_HANDLE | Invalid hCard handle (SCARD_E_INVALID_HANDLE) |
SCARD_E_INVALID_PARAMETER | pbSendBuffer is NULL or cbSendLength is null and the IFDHandler is version 2.0 (without dwControlCode ) (SCARD_E_INVALID_PARAMETER) |
SCARD_E_INVALID_VALUE | Invalid value was presented (SCARD_E_INVALID_VALUE) |
SCARD_E_NO_SERVICE | The server is not running (SCARD_E_NO_SERVICE) |
SCARD_E_NOT_TRANSACTED | Data exchange not successful (SCARD_E_NOT_TRANSACTED) |
SCARD_E_READER_UNAVAILABLE | The reader has been removed(SCARD_E_READER_UNAVAILABLE) |
SCARD_E_UNSUPPORTED_FEATURE | Driver does not support (SCARD_E_UNSUPPORTED_FEATURE) |
SCARD_F_COMM_ERROR | An internal communications error has been detected (SCARD_F_COMM_ERROR) |
SCARD_W_REMOVED_CARD | The card has been removed from the reader(SCARD_W_REMOVED_CARD) |
SCARD_W_RESET_CARD | The card has been reset by another application (SCARD_W_RESET_CARD) |
Definition at line 2270 of file winscard_clnt.c.
LONG SCardDisconnect | ( | SCARDHANDLE | hCard, |
DWORD | dwDisposition ) |
Terminates a connection made through SCardConnect().
[in] | hCard | Connection made from SCardConnect(). |
[in] | dwDisposition | Reader function to execute.
|
SCARD_S_SUCCESS | Successful(SCARD_S_SUCCESS) |
SCARD_E_INVALID_HANDLE | Invalid hCard handle (SCARD_E_INVALID_HANDLE) |
SCARD_E_INVALID_VALUE | Invalid dwDisposition (SCARD_E_INVALID_VALUE) |
SCARD_E_NO_SERVICE | The server is not running (SCARD_E_NO_SERVICE) |
SCARD_E_NO_SMARTCARD | No smart card present (SCARD_E_NO_SMARTCARD) |
SCARD_F_COMM_ERROR | An internal communications error has been detected (SCARD_F_COMM_ERROR) |
Definition at line 1051 of file winscard_clnt.c.
LONG SCardEndTransaction | ( | SCARDHANDLE | hCard, |
DWORD | dwDisposition ) |
Ends a previously begun transaction.
The calling application must be the owner of the previously begun transaction or an error will occur.
[in] | hCard | Connection made from SCardConnect(). |
[in] | dwDisposition | Action to be taken on the reader.
|
SCARD_S_SUCCESS | Successful (SCARD_S_SUCCESS) |
SCARD_E_INVALID_HANDLE | Invalid hCard handle (SCARD_E_INVALID_HANDLE) |
SCARD_E_INVALID_VALUE | Invalid value for dwDisposition or hCard (SCARD_E_INVALID_VALUE) |
SCARD_E_NO_SERVICE | The server is not running (SCARD_E_NO_SERVICE) |
SCARD_E_READER_UNAVAILABLE | The reader has been removed (SCARD_E_READER_UNAVAILABLE) |
SCARD_E_SHARING_VIOLATION | Someone else has exclusive rights (SCARD_E_SHARING_VIOLATION) |
SCARD_F_COMM_ERROR | An internal communications error has been detected (SCARD_F_COMM_ERROR) |
Definition at line 1242 of file winscard_clnt.c.
LONG SCardEstablishContext | ( | DWORD | dwScope, |
LPCVOID | pvReserved1, | ||
LPCVOID | pvReserved2, | ||
LPSCARDCONTEXT | phContext ) |
Creates an Application Context to the PC/SC Resource Manager.
This must be the first WinSCard function called in a PC/SC application. Each thread of an application shall use its own SCARDCONTEXT, unless calling SCardCancel(), which MUST be called with the same context as the context used to call SCardGetStatusChange().
[in] | dwScope | Scope of the establishment. This can either be a local or remote connection.
|
[in] | pvReserved1 | Reserved for future use. |
[in] | pvReserved2 | Reserved for future use. |
[out] | phContext | Returned Application Context. |
SCARD_S_SUCCESS | Successful (SCARD_S_SUCCESS) |
SCARD_E_INVALID_PARAMETER | phContext is null (SCARD_E_INVALID_PARAMETER) |
SCARD_E_INVALID_VALUE | Invalid scope type passed (SCARD_E_INVALID_VALUE ) |
SCARD_E_NO_MEMORY | There is no free slot to store hContext (SCARD_E_NO_MEMORY) |
SCARD_E_NO_SERVICE | The server is not running (SCARD_E_NO_SERVICE) |
SCARD_F_COMM_ERROR | An internal communications error has been detected (SCARD_F_COMM_ERROR) |
SCARD_F_INTERNAL_ERROR | An internal consistency check failed (SCARD_F_INTERNAL_ERROR) |
Definition at line 461 of file winscard_clnt.c.
LONG SCardFreeMemory | ( | SCARDCONTEXT | hContext, |
LPCVOID | pvMem ) |
Releases memory that has been returned from the resource manager using the SCARD_AUTOALLOCATE length designator.
[in] | hContext | Connection context to the PC/SC Resource Manager. |
[in] | pvMem | pointer to allocated memory |
SCARD_S_SUCCESS | Successful (SCARD_S_SUCCESS) |
SCARD_E_INVALID_HANDLE | Invalid hContext handle (SCARD_E_INVALID_HANDLE) |
Definition at line 3022 of file winscard_clnt.c.
LONG SCardGetAttrib | ( | SCARDHANDLE | hCard, |
DWORD | dwAttrId, | ||
LPBYTE | pbAttr, | ||
LPDWORD | pcbAttrLen ) |
Get an attribute from the IFD Handler (reader driver).
The list of possible attributes is available in the file reader.h
.
If *pcbAttrLen
is equal to SCARD_AUTOALLOCATE then the function will allocate itself the needed memory. Use SCardFreeMemory() to release it.
SCARD_S_SUCCESS | Successful (SCARD_S_SUCCESS) |
SCARD_E_UNSUPPORTED_FEATURE | the dwAttrId attribute is not supported by the driver (SCARD_E_UNSUPPORTED_FEATURE) |
SCARD_E_NOT_TRANSACTED |
|
SCARD_E_INSUFFICIENT_BUFFER |
|
SCARD_E_INVALID_HANDLE | Invalid hCard handle (SCARD_E_INVALID_HANDLE) |
SCARD_E_INVALID_PARAMETER | A parameter is NULL and should not (SCARD_E_INVALID_PARAMETER) |
SCARD_E_NO_MEMORY | Memory allocation failed (SCARD_E_NO_MEMORY) |
SCARD_E_NO_SERVICE | The server is not running (SCARD_E_NO_SERVICE) |
SCARD_E_READER_UNAVAILABLE | The reader has been removed (SCARD_E_READER_UNAVAILABLE) |
SCARD_F_COMM_ERROR | An internal communications error has been detected (SCARD_F_COMM_ERROR) |
SCARD_E_INVALID_VALUE | An invalid value is used for hCard (for example the reader is no more present) (SCARD_E_INVALID_VALUE) |
Definition at line 2481 of file winscard_clnt.c.
LONG SCardGetStatusChange | ( | SCARDCONTEXT | hContext, |
DWORD | dwTimeout, | ||
SCARD_READERSTATE * | rgReaderStates, | ||
DWORD | cReaders ) |
Blocks execution until the current availability of the cards in a specific set of readers changes.
This function receives a structure or list of structures containing reader names. It then blocks waiting for a change in state to occur for a maximum blocking time of dwTimeout
or forever if INFINITE is used.
The new event state will be contained in dwEventState
. A status change might be a card insertion or removal event, a change in ATR, etc.
dwEventState
also contains a number of events in the upper 16 bits (dwEventState
& 0xFFFF0000). This number of events is incremented for each card insertion or removal in the specified reader. This can be used to detect a card removal/insertion between two calls to SCardGetStatusChange()
To wait for a reader event (reader added or removed) you may use the special reader name "\\?PnP?\Notification"
. If a reader event occurs the state of this reader will change and the bit SCARD_STATE_CHANGED will be set. To detect a reader event betweeen 2 calls to SCardGetStatusChange() you can use the upper 16 bits of dwCurrentState
. See https://blog.apdu.fr/posts/2024/08/improved-scardgetstatuschange-for-pnpnotification-special-reader/
To cancel the ongoing call, use SCardCancel() with the same SCARDCONTEXT.
Value of dwCurrentState
and dwEventState:
[in] | hContext | Connection context to the PC/SC Resource Manager. |
[in] | dwTimeout | Maximum waiting time (in milliseconds) for status change, INFINITE for infinite. |
[in,out] | rgReaderStates | Structures of readers with current states. |
[in] | cReaders | Number of structures. |
SCARD_S_SUCCESS | Successful (SCARD_S_SUCCESS) |
SCARD_E_NO_SERVICE | Server is not running (SCARD_E_NO_SERVICE) |
SCARD_E_INVALID_PARAMETER | rgReaderStates is NULL and cReaders > 0 (SCARD_E_INVALID_PARAMETER) |
SCARD_E_INVALID_VALUE | Invalid States, reader name, etc (SCARD_E_INVALID_VALUE) |
SCARD_E_INVALID_HANDLE | Invalid hContext handle (SCARD_E_INVALID_HANDLE) |
SCARD_E_READER_UNAVAILABLE | The reader is unavailable (SCARD_E_READER_UNAVAILABLE) |
SCARD_E_UNKNOWN_READER | The reader name is unknown (SCARD_E_UNKNOWN_READER) |
SCARD_E_TIMEOUT | The user-specified timeout value has expired (SCARD_E_TIMEOUT) |
SCARD_E_CANCELLED | The call has been cancelled by a call to SCardCancel() (SCARD_E_CANCELLED) |
Definition at line 1682 of file winscard_clnt.c.
LONG SCardIsValidContext | ( | SCARDCONTEXT | hContext | ) |
Check if a SCARDCONTEXT is valid.
Call this function to determine whether a smart card context handle is still valid. After a smart card context handle has been returned by SCardEstablishContext(), it may become invalid if the resource manager service has been shut down.
[in] | hContext | Connection context to the PC/SC Resource Manager. |
SCARD_S_SUCCESS | Successful (SCARD_S_SUCCESS) |
SCARD_E_INVALID_HANDLE | Invalid Handle (SCARD_E_INVALID_HANDLE) |
Definition at line 3272 of file winscard_clnt.c.
LONG SCardListReaderGroups | ( | SCARDCONTEXT | hContext, |
LPSTR | mszGroups, | ||
LPDWORD | pcchGroups ) |
Returns a list of currently available reader groups on the system.
mszGroups
is a pointer to a character string that is allocated by the application. If the application sends mszGroups
as NULL then this function will return the size of the buffer needed to allocate in pcchGroups
.
The group names is a multi-string and separated by a null character ('\0'
) and ended by a double null character like "SCard$DefaultReaders\0Group 2\0\0"
.
If *pcchGroups
is equal to SCARD_AUTOALLOCATE then the function will allocate itself the needed memory. Use SCardFreeMemory() to release it.
[in] | hContext | Connection context to the PC/SC Resource Manager. |
[out] | mszGroups | List of groups to list readers. |
[in,out] | pcchGroups | Size of multi-string buffer including NULL's. |
SCARD_S_SUCCESS | Successful (SCARD_S_SUCCESS) |
SCARD_E_INSUFFICIENT_BUFFER | Reader buffer not large enough (SCARD_E_INSUFFICIENT_BUFFER) |
SCARD_E_INVALID_HANDLE | Invalid Scope Handle (SCARD_E_INVALID_HANDLE) |
SCARD_E_INVALID_PARAMETER | mszGroups is NULL and *pcchGroups == SCARD_AUTOALLOCATE (SCARD_E_INVALID_PARAMETER) |
SCARD_E_NO_MEMORY | Memory allocation failed (SCARD_E_NO_MEMORY) |
SCARD_E_NO_SERVICE | The server is not running (SCARD_E_NO_SERVICE) |
Definition at line 3092 of file winscard_clnt.c.
LONG SCardListReaders | ( | SCARDCONTEXT | hContext, |
LPCSTR | mszGroups, | ||
LPSTR | mszReaders, | ||
LPDWORD | pcchReaders ) |
Returns a list of currently available readers on the system.
mszReaders
is a pointer to a character string that is allocated by the application. If the application sends mszGroups
and mszReaders
as NULL then this function will return the size of the buffer needed to allocate in pcchReaders
.
If *pcchReaders
is equal to SCARD_AUTOALLOCATE then the function will allocate itself the needed memory. Use SCardFreeMemory() to release it.
Encoding: The reader names and group names are encoded using UTF-8.
[in] | hContext | Connection context to the PC/SC Resource Manager. |
[in] | mszGroups | List of groups to list readers (not used). |
[out] | mszReaders | Multi-string with list of readers. |
[in,out] | pcchReaders | Size of multi-string buffer including NULL's. |
SCARD_S_SUCCESS | Successful (SCARD_S_SUCCESS) |
SCARD_E_INSUFFICIENT_BUFFER | Reader buffer not large enough (SCARD_E_INSUFFICIENT_BUFFER) |
SCARD_E_INVALID_HANDLE | Invalid Scope Handle (SCARD_E_INVALID_HANDLE) |
SCARD_E_INVALID_PARAMETER | pcchReaders is NULL (SCARD_E_INVALID_PARAMETER) |
SCARD_E_NO_MEMORY | Memory allocation failed (SCARD_E_NO_MEMORY) |
SCARD_E_NO_READERS_AVAILABLE | No readers available (SCARD_E_NO_READERS_AVAILABLE) |
SCARD_E_NO_SERVICE | The server is not running (SCARD_E_NO_SERVICE) |
or, with auto allocation:
Definition at line 2902 of file winscard_clnt.c.
LONG SCardReconnect | ( | SCARDHANDLE | hCard, |
DWORD | dwShareMode, | ||
DWORD | dwPreferredProtocols, | ||
DWORD | dwInitialization, | ||
LPDWORD | pdwActiveProtocol ) |
Reestablishes a connection to a reader that was previously connected to using SCardConnect().
In a multi application environment it is possible for an application to reset the card in shared mode. When this occurs any other application trying to access certain commands will be returned the value SCARD_W_RESET_CARD. When this occurs SCardReconnect() must be called in order to acknowledge that the card was reset and allow it to change its state accordingly.
[in] | hCard | Handle to a previous call to connect. |
[in] | dwShareMode | Mode of connection type: exclusive/shared.
|
[in] | dwPreferredProtocols | Desired protocol use.
|
[in] | dwInitialization | Desired action taken on the card/reader.
|
[out] | pdwActiveProtocol | Established protocol to this connection. |
SCARD_S_SUCCESS | Successful (SCARD_S_SUCCESS) |
SCARD_E_INVALID_HANDLE | Invalid hCard handle (SCARD_E_INVALID_HANDLE) |
SCARD_E_INVALID_PARAMETER | phContext is null. (SCARD_E_INVALID_PARAMETER) |
SCARD_E_INVALID_VALUE | Invalid hCard , sharing mode, requested protocol, or reader name (SCARD_E_INVALID_VALUE) |
SCARD_E_NO_SERVICE | The server is not running (SCARD_E_NO_SERVICE) |
SCARD_E_NO_SMARTCARD | No smart card present (SCARD_E_NO_SMARTCARD) |
SCARD_E_PROTO_MISMATCH | Requested protocol is unknown (SCARD_E_PROTO_MISMATCH) |
SCARD_E_READER_UNAVAILABLE | The reader has been removed (SCARD_E_READER_UNAVAILABLE) |
SCARD_E_SHARING_VIOLATION | Someone else has exclusive rights (SCARD_E_SHARING_VIOLATION) |
SCARD_E_UNSUPPORTED_FEATURE | Protocol not supported (SCARD_E_UNSUPPORTED_FEATURE) |
SCARD_F_COMM_ERROR | An internal communications error has been detected (SCARD_F_COMM_ERROR) |
SCARD_F_INTERNAL_ERROR | An internal consistency check failed (SCARD_F_INTERNAL_ERROR) |
SCARD_W_REMOVED_CARD | The smart card has been removed (SCARD_W_REMOVED_CARD) |
SCARD_W_UNRESPONSIVE_CARD | Card is mute (SCARD_W_UNRESPONSIVE_CARD) |
Definition at line 952 of file winscard_clnt.c.
LONG SCardReleaseContext | ( | SCARDCONTEXT | hContext | ) |
Destroys a communication context to the PC/SC Resource Manager.
This must be the last function called in a PC/SC application.
[in] | hContext | Connection context to be closed. |
SCARD_S_SUCCESS | Successful (SCARD_S_SUCCESS) |
SCARD_E_NO_SERVICE | The server is not running (SCARD_E_NO_SERVICE) |
SCARD_E_INVALID_HANDLE | Invalid hContext handle (SCARD_E_INVALID_HANDLE) |
SCARD_F_COMM_ERROR | An internal communications error has been detected (SCARD_F_COMM_ERROR) |
Definition at line 685 of file winscard_clnt.c.
LONG SCardSetAttrib | ( | SCARDHANDLE | hCard, |
DWORD | dwAttrId, | ||
LPCBYTE | pbAttr, | ||
DWORD | cbAttrLen ) |
Set an attribute of the IFD Handler.
The list of attributes you can set is dependent on the IFD Handler you are using.
[in] | hCard | Connection made from SCardConnect(). |
[in] | dwAttrId | Identifier for the attribute to set. |
[in] | pbAttr | Pointer to a buffer that receives the attribute. |
[in] | cbAttrLen | Length of the pbAttr buffer in bytes. |
SCARD_S_SUCCESS | Successful (SCARD_S_SUCCESS) |
SCARD_E_INSUFFICIENT_BUFFER | cbAttrLen is too big (SCARD_E_INSUFFICIENT_BUFFER) |
SCARD_E_INVALID_HANDLE | Invalid hCard handle (SCARD_E_INVALID_HANDLE) |
SCARD_E_INVALID_PARAMETER | A parameter is NULL and should not (SCARD_E_INVALID_PARAMETER) |
SCARD_E_NO_SERVICE | The server is not running (SCARD_E_NO_SERVICE) |
SCARD_E_NOT_TRANSACTED | Data exchange not successful (SCARD_E_NOT_TRANSACTED) |
SCARD_E_READER_UNAVAILABLE | The reader has been removed (SCARD_E_READER_UNAVAILABLE) |
SCARD_F_COMM_ERROR | An internal communications error has been detected (SCARD_F_COMM_ERROR) |
Definition at line 2564 of file winscard_clnt.c.
LONG SCardStatus | ( | SCARDHANDLE | hCard, |
LPSTR | szReaderName, | ||
LPDWORD | pcchReaderLen, | ||
LPDWORD | pdwState, | ||
LPDWORD | pdwProtocol, | ||
LPBYTE | pbAtr, | ||
LPDWORD | pcbAtrLen ) |
Returns the current status of the reader connected to by hCard
.
Its friendly name will be stored in szReaderName
. pcchReaderLen
will be the size of the allocated buffer for szReaderName
, while pcbAtrLen
will be the size of the allocated buffer for pbAtr
. If either of these is too small, the function will return with SCARD_E_INSUFFICIENT_BUFFER and the necessary size in pcchReaderLen
and pcbAtrLen
. The current state, and protocol will be stored in pdwState and pdwProtocol
respectively.
*pdwState also contains a number of events in the upper 16 bits (*pdwState & 0xFFFF0000). This number of events is incremented for each card insertion or removal in the specified reader. This can be used to detect a card removal/insertion between two calls to SCardStatus().
If *pcchReaderLen
is equal to SCARD_AUTOALLOCATE then the function will allocate itself the needed memory for szReaderName. Use SCardFreeMemory() to release it.
If *pcbAtrLen
is equal to SCARD_AUTOALLOCATE then the function will allocate itself the needed memory for pbAtr. Use SCardFreeMemory() to release it.
[in] | hCard | Connection made from SCardConnect(). |
[in,out] | szReaderName | Friendly name of this reader. |
[in,out] | pcchReaderLen | Size of the szReaderName . |
[out] | pdwState | Current state of this reader. pdwState is a DWORD possibly OR'd with the following values:
|
[out] | pdwProtocol | Current protocol of this reader.
|
[out] | pbAtr | Current ATR of a card in this reader. |
[out] | pcbAtrLen | Length of ATR. |
SCARD_S_SUCCESS | Successful (SCARD_S_SUCCESS) |
SCARD_E_INSUFFICIENT_BUFFER | Not enough allocated memory for szReaderName or for pbAtr (SCARD_E_INSUFFICIENT_BUFFER) |
SCARD_E_INVALID_HANDLE | Invalid hCard handle (SCARD_E_INVALID_HANDLE) |
SCARD_E_INVALID_PARAMETER | pcchReaderLen or pcbAtrLen is NULL (SCARD_E_INVALID_PARAMETER) |
SCARD_E_NO_MEMORY | Memory allocation failed (SCARD_E_NO_MEMORY) |
SCARD_E_NO_SERVICE | The server is not running (SCARD_E_NO_SERVICE) |
SCARD_E_READER_UNAVAILABLE | The reader has been removed (SCARD_E_READER_UNAVAILABLE) |
SCARD_F_COMM_ERROR | An internal communications error has been detected (SCARD_F_COMM_ERROR) |
SCARD_F_INTERNAL_ERROR | An internal consistency check failed (SCARD_F_INTERNAL_ERROR) |
SCARD_W_REMOVED_CARD | The smart card has been removed (SCARD_W_REMOVED_CARD) |
SCARD_W_RESET_CARD | The smart card has been reset (SCARD_W_RESET_CARD) |
Definition at line 1386 of file winscard_clnt.c.
LONG SCardTransmit | ( | SCARDHANDLE | hCard, |
const SCARD_IO_REQUEST * | pioSendPci, | ||
LPCBYTE | pbSendBuffer, | ||
DWORD | cbSendLength, | ||
SCARD_IO_REQUEST * | pioRecvPci, | ||
LPBYTE | pbRecvBuffer, | ||
LPDWORD | pcbRecvLength ) |
Sends an APDU to the smart card contained in the reader connected to by SCardConnect().
The card responds from the APDU and stores this response in pbRecvBuffer
and its length in pcbRecvLength
.
pioSendPci
and pioRecvPci
are structures containing the following:
[in] | hCard | Connection made from SCardConnect(). |
[in] | pioSendPci | Structure of Protocol Control Information.
|
[in] | pbSendBuffer | APDU to send to the card. |
[in] | cbSendLength | Length of the APDU. |
[in,out] | pioRecvPci | Structure of protocol information. This parameter can be NULL if no PCI is returned. |
[out] | pbRecvBuffer | Response from the card. |
[in,out] | pcbRecvLength | Length of the response. |
SCARD_S_SUCCESS | Successful (SCARD_S_SUCCESS) |
SCARD_E_INSUFFICIENT_BUFFER | cbRecvLength was not large enough for the card response. The expected size is now in cbRecvLength (SCARD_E_INSUFFICIENT_BUFFER) |
SCARD_E_INVALID_HANDLE | Invalid hCard handle (SCARD_E_INVALID_HANDLE) |
SCARD_E_INVALID_PARAMETER | pbSendBuffer or pbRecvBuffer or pcbRecvLength or pioSendPci is null (SCARD_E_INVALID_PARAMETER) |
SCARD_E_INVALID_VALUE | Invalid hCard , Protocol, reader name, etc (SCARD_E_INVALID_VALUE) |
SCARD_E_NO_SERVICE | The server is not running (SCARD_E_NO_SERVICE) |
SCARD_E_NOT_TRANSACTED | APDU exchange not successful (SCARD_E_NOT_TRANSACTED) |
SCARD_E_PROTO_MISMATCH | Connect protocol is different than desired (SCARD_E_PROTO_MISMATCH) |
SCARD_E_READER_UNAVAILABLE | The reader has been removed (SCARD_E_READER_UNAVAILABLE) |
SCARD_F_COMM_ERROR | An internal communications error has been detected (SCARD_F_COMM_ERROR) |
SCARD_W_RESET_CARD | The card has been reset by another application (SCARD_W_RESET_CARD) |
SCARD_W_REMOVED_CARD | The card has been removed from the reader (SCARD_W_REMOVED_CARD) |
Definition at line 2721 of file winscard_clnt.c.