#include "config.h"
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/un.h>
#include <smartcard/scf.h>
#include <time.h>
#include "pcsclite.h"
#include "winscard.h"
#include "debug.h"
#include "thread_generic.h"
#include "readerfactory.h"
#include "eventhandler.h"
#include "sys_generic.h"
Go to the source code of this file.
Data Structures | |
struct | _psTransmitMap |
struct | _psChannelMap |
Represents an Application Context Channel. More... | |
struct | _psContextMap |
Represents the an Application Context on the Client side. More... | |
struct | _psReaderMap |
Defines | |
#define | TRUE 1 |
#define | FALSE 0 |
#define | PCSCLITE_MAX_READERS_CONTEXTS 2 |
Functions | |
static LONG | isOCFServerRunning (void) |
LONG | SCardLockThread (void) |
LONG | SCardUnlockThread (void) |
LONG | SCardEventLock (void) |
LONG | SCardEventUnlock (void) |
static LONG | PCSC_SCF_Initialize (void) |
static void | EventCallback (SCF_Event_t eventType, SCF_Terminal_t hTerm, void *cbdata) |
static LONG | PCSC_SCF_getATR (SCF_Card_t hCard, LPBYTE pcbAtr, LPDWORD pcbAtrLen) |
static LONG | ConvertStatus (SCF_Status_t status) |
static LONG | SCardGetReaderIndice (LPCTSTR ReaderName) |
static LONG | getNewContext (SCARDCONTEXT *phContext) |
static LONG | SCardAddContext (SCARDCONTEXT hContext, SCF_Session_t hSession) |
static SCF_Session_t | getSessionForContext (SCARDCONTEXT hContext) |
static LONG | SCardRemoveContext (SCARDCONTEXT hContext) |
static LONG | SCardGetContextIndice (SCARDCONTEXT hContext) |
static LONG | getNewHandle (SCARDCONTEXT hContext, LPCTSTR szReader, SCARDHANDLE *phCard, DWORD) |
static LONG | getCardForHandle (SCARDHANDLE PSCS_hCard, SCF_Card_t *SCF_hCard) |
static LONG | SCardRemoveHandle (SCARDHANDLE hCard) |
static LONG | SCardAddHandle (SCARDHANDLE PCSC_hCard, SCARDCONTEXT hContext, SCF_Session_t hSession, SCF_Terminal_t hTerminal, SCF_Card_t SCF_hCard, int, DWORD) |
static LONG | SCardGetHandleIndice (SCARDHANDLE hCard) |
static LONG | isActiveContextPresent (void) |
static LONG | SCardEstablishContextTH (DWORD dwScope, LPCVOID pvReserved1, LPCVOID pvReserved2, LPSCARDCONTEXT phContext) |
LONG | SCardEstablishContext (DWORD dwScope, LPCVOID pvReserved1, LPCVOID pvReserved2, LPSCARDCONTEXT phContext) |
Creates an Application Context for a client. | |
static LONG | SCardReleaseContextTH (SCARDCONTEXT hContext) |
LONG | SCardReleaseContext (SCARDCONTEXT hContext) |
This function destroys a communication context to the PC/SC Resource Manager. | |
static LONG | SCardListReadersTH (SCARDCONTEXT hContext, LPCTSTR mszGroups, LPTSTR mszReaders, LPDWORD pcchReaders) |
LONG | SCardListReaders (SCARDCONTEXT hContext, LPCTSTR mszGroups, LPTSTR mszReaders, LPDWORD pcchReaders) |
This function returns a list of currently available readers on the system. | |
static LONG | SCardConnectTH (SCARDCONTEXT hContext, LPCTSTR szReader, DWORD dwShareMode, DWORD dwPreferredProtocols, LPSCARDHANDLE phCard, LPDWORD pdwActiveProtocol) |
LONG | SCardConnect (SCARDCONTEXT hContext, LPCTSTR szReader, DWORD dwShareMode, DWORD dwPreferredProtocols, LPSCARDHANDLE phCard, LPDWORD pdwActiveProtocol) |
This function establishes a connection to the friendly name of the reader specified in szReader. | |
static LONG | SCardDisconnectTH (SCARDHANDLE hCard, DWORD dwDisposition) |
static LONG | SCardReconnectTH (SCARDHANDLE hCard, DWORD dwShareMode, DWORD dwPreferredProtocols, DWORD dwInitialization, LPDWORD pdwActiveProtocol) |
LONG | SCardReconnect (SCARDHANDLE hCard, DWORD dwShareMode, DWORD dwPreferredProtocols, DWORD dwInitialization, LPDWORD pdwActiveProtocol) |
This function reestablishes a connection to a reader that was previously connected to using SCardConnect(). | |
LONG | SCardDisconnect (SCARDHANDLE hCard, DWORD dwDisposition) |
This function terminates a connection to the connection made through SCardConnect(). | |
LONG | SCardBeginTransaction (SCARDHANDLE hCard) |
This function establishes a temporary exclusive access mode for doing a series of commands or transaction. | |
static LONG | SCardEndTransactionTH (SCARDHANDLE hCard, DWORD dwDisposition) |
LONG | SCardEndTransaction (SCARDHANDLE hCard, DWORD dwDisposition) |
This function ends a previously begun transaction. | |
static LONG | SCardCancelTransactionTH (SCARDHANDLE hCard) |
LONG | SCardCancelTransaction (SCARDHANDLE hCard) |
static LONG | SCardStatusTH (SCARDHANDLE hCard, LPTSTR mszReaderNames, LPDWORD pcchReaderLen, LPDWORD pdwState, LPDWORD pdwProtocol, LPBYTE pbAtr, LPDWORD pcbAtrLen) |
LONG | SCardStatus (SCARDHANDLE hCard, LPTSTR mszReaderNames, LPDWORD pcchReaderLen, LPDWORD pdwState, LPDWORD pdwProtocol, LPBYTE pbAtr, LPDWORD pcbAtrLen) |
This function returns the current status of the reader connected to by hCard. | |
LONG | SCardGetStatusChange (SCARDCONTEXT hContext, DWORD dwTimeout, LPSCARD_READERSTATE_A rgReaderStates, DWORD cReaders) |
This function receives a structure or list of structures containing reader names. | |
LONG | SCardControl (SCARDHANDLE hCard, DWORD dwControlCode, LPCVOID pbSendBuffer, DWORD cbSendLength, LPVOID pbRecvBuffer, DWORD cbRecvLength, LPDWORD lpBytesReturned) |
This function sends a command directly to the IFD Handler to be processed by the reader. | |
static LONG | SCardTransmitTH (SCARDHANDLE hCard, LPCSCARD_IO_REQUEST pioSendPci, LPCBYTE pbSendBuffer, DWORD cbSendLength, LPSCARD_IO_REQUEST pioRecvPci, LPBYTE pbRecvBuffer, LPDWORD pcbRecvLength) |
LONG | SCardTransmit (SCARDHANDLE hCard, LPCSCARD_IO_REQUEST pioSendPci, LPCBYTE pbSendBuffer, DWORD cbSendLength, LPSCARD_IO_REQUEST pioRecvPci, LPBYTE pbRecvBuffer, LPDWORD pcbRecvLength) |
This function sends an APDU to the smart card contained in the reader connected to by SCardConnect(). | |
static LONG | SCardListReaderGroupsTH (SCARDCONTEXT hContext, LPTSTR mszGroups, LPDWORD pcchGroups) |
LONG | SCardListReaderGroups (SCARDCONTEXT hContext, LPTSTR mszGroups, LPDWORD pcchGroups) |
This function returns a list of currently available reader groups on the system. | |
static LONG | SCardCancelTH (SCARDCONTEXT hContext) |
LONG | SCardCancel (SCARDCONTEXT hContext) |
This function cancels all pending blocking requests on the SCardGetStatusChange() function. | |
LONG | SCardGetAttrib (SCARDHANDLE hCard, DWORD dwAttrId, LPBYTE pbAttr, LPDWORD pcbAttrLen) |
This function get an attribute from the IFD Handler. | |
LONG | SCardSetAttrib (SCARDHANDLE hCard, DWORD dwAttrId, LPCBYTE pbAttr, DWORD cbAttrLen) |
This function set an attribute of the IFD Handler. | |
LONG | SCardCheckReaderAvailability (LPTSTR readerName, LONG errorCode) |
void | SCardUnload (void) |
free resources allocated by the library You _shall_ call this function if you use dlopen/dlclose to load/unload the library. | |
LONG | SCardCheckDaemonAvailability (void) |
Checks if the Server is running. | |
Variables | |
static SCF_Session_t | g_hSession = NULL |
SCARD_IO_REQUEST | g_rgSCardT0Pci |
SCARD_IO_REQUEST | g_rgSCardT1Pci |
SCARD_IO_REQUEST | g_rgSCardRawPci |
static struct _psTransmitMap | psTransmitMap [PCSCLITE_MAX_APPLICATION_CONTEXTS] |
static struct _psChannelMap | psChannelMap [PCSCLITE_MAX_APPLICATION_CONTEXTS] |
static struct _psContextMap | psContextMap [PCSCLITE_MAX_APPLICATION_CONTEXTS] |
static struct _psReaderMap | psReaderMap [PCSCLITE_MAX_READERS_CONTEXTS] |
static PCSCLITE_MUTEX | clientMutex = PTHREAD_MUTEX_INITIALIZER |
static PCSCLITE_MUTEX | EventMutex = PTHREAD_MUTEX_INITIALIZER |
static PCSCLITE_MUTEX | SCFInitMutex = PTHREAD_MUTEX_INITIALIZER |
static pthread_cond_t | EventCondition = PTHREAD_COND_INITIALIZER |
static char | PCSC_Initialized = 0 |
Definition in file winscard_scf.c.
|
This function establishes a temporary exclusive access mode for doing a series of commands or 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
SCARDCONTEXT hContext; SCARDHANDLE hCard; DWORD dwActiveProtocol; LONG rv; ... rv = SCardEstablishContext(SCARD_SCOPE_SYSTEM, NULL, NULL, &hContext); rv = SCardConnect(hContext, "Reader X", SCARD_SHARE_SHARED, SCARD_PROTOCOL_T0, &hCard, &dwActiveProtocol); rv = SCardBeginTransaction(hCard); ... / * Do some transmit commands * / Definition at line 478 of file winscard_scf.c. References ConvertStatus(), getCardForHandle(), isOCFServerRunning(), SCARD_E_NO_SERVICE, SCARD_S_SUCCESS, SCardLockThread(), and SCardUnlockThread(). Referenced by MSGFunctionDemarshall(). |
|
This function cancels all pending blocking requests on the
SCARDCONTEXT hContext; DWORD cReaders; SCARD_READERSTATE rgReaderStates; LONG rv; ... rv = SCardEstablishContext(SCARD_SCOPE_SYSTEM, NULL, NULL, &hContext); rgReaderStates.szReader = strdup("Reader X"); rgReaderStates.dwCurrentState = SCARD_STATE_EMPTY; ... / * Spawn off thread for following function * / ... rv = SCardGetStatusChange(hContext, 0, rgReaderStates, cReaders); rv = SCardCancel(hContext); Definition at line 1185 of file winscard_scf.c. References SCardCancelTH(), SCardLockThread(), and SCardUnlockThread(). |
|
Definition at line 576 of file winscard_scf.c. References SCardCancelTransactionTH(), SCardLockThread(), and SCardUnlockThread(). Referenced by MSGFunctionDemarshall(). |
|
Checks if the Server is running.
Definition at line 1943 of file winscard_scf.c. References Log1, PCSCLITE_IPC_DIR, SCARD_E_NO_SERVICE, SCARD_S_SUCCESS, and SYS_Stat(). Referenced by SCardBeginTransaction(), SCardCancelTransaction(), SCardConnect(), SCardControl(), SCardDisconnect(), SCardEndTransaction(), SCardEstablishContextTH(), SCardGetSetAttrib(), SCardGetStatusChange(), SCardListReaderGroups(), SCardListReaders(), SCardReconnect(), SCardReleaseContext(), SCardStatus(), and SCardTransmit(). |
|
This function establishes a connection to the friendly name of the reader specified in szReader. The first connection will power up and perform a reset on the card.
SCARDCONTEXT hContext; SCARDHANDLE hCard; DWORD dwActiveProtocol; LONG rv; ... rv = SCardEstablishContext(SCARD_SCOPE_SYSTEM, NULL, NULL, &hContext); rv = SCardConnect(hContext, "Reader X", SCARD_SHARE_SHARED, SCARD_PROTOCOL_T0, &hCard, &dwActiveProtocol); Definition at line 344 of file winscard_scf.c. References SCardConnectTH(), SCardLockThread(), and SCardUnlockThread(). Referenced by MSGFunctionDemarshall(). |
|
This function sends a command directly to the IFD Handler 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.
LONG rv; SCARDCONTEXT hContext; SCARDHANDLE hCard; DWORD dwActiveProtocol, dwSendLength, dwRecvLength; BYTE pbRecvBuffer[10]; BYTE pbSendBuffer[] = { 0x06, 0x00, 0x0A, 0x01, 0x01, 0x10 0x00 }; ... rv = SCardEstablishContext(SCARD_SCOPE_SYSTEM, NULL, NULL, &hContext); rv = SCardConnect(hContext, "Reader X", SCARD_SHARE_SHARED, SCARD_PROTOCOL_RAW &hCard, &dwActiveProtocol); dwSendLength = sizeof(pbSendBuffer); dwRecvLength = sizeof(pbRecvBuffer); rv = SCardControl(hCard, 0x42000001, pbSendBuffer, dwSendLength, pbRecvBuffer, sizeof(pbRecvBuffer), &dwRecvLength); Definition at line 1013 of file winscard_scf.c. References SCARD_S_SUCCESS. Referenced by MSGFunctionDemarshall(). |
|
This function terminates a connection to the connection made through SCardConnect(). dwDisposition can have the following values:
SCARDCONTEXT hContext; SCARDHANDLE hCard; DWORD dwActiveProtocol; LONG rv; ... rv = SCardEstablishContext(SCARD_SCOPE_SYSTEM, NULL, NULL, &hContext); rv = SCardConnect(hContext, "Reader X", SCARD_SHARE_SHARED, SCARD_PROTOCOL_T0, &hCard, &dwActiveProtocol); rv = SCardDisconnect(hCard, SCARD_UNPOWER_CARD); Definition at line 467 of file winscard_scf.c. References SCardDisconnectTH(), SCardLockThread(), and SCardUnlockThread(). Referenced by MSGFunctionDemarshall(), and MSGRemoveContext(). |
|
This function ends a previously begun transaction. The calling application must be the owner of the previously begun transaction or an error will occur.
SCARDCONTEXT hContext; SCARDHANDLE hCard; DWORD dwActiveProtocol; LONG rv; ... rv = SCardEstablishContext(SCARD_SCOPE_SYSTEM, NULL, NULL, &hContext); rv = SCardConnect(hContext, "Reader X", SCARD_SHARE_SHARED, SCARD_PROTOCOL_T0, &hCard, &dwActiveProtocol); rv = SCardBeginTransaction(hCard); ... / * Do some transmit commands * / ... rv = SCardEndTransaction(hCard, SCARD_LEAVE_CARD); Definition at line 557 of file winscard_scf.c. References SCardEndTransactionTH(), SCardLockThread(), and SCardUnlockThread(). Referenced by MSGFunctionDemarshall(). |
|
Creates an Application Context for a client.
This must be the first function called in a PC/SC application. This is a thread-safe wrapper to the function
SCARDCONTEXT hContext; LONG rv; ... rv = SCardEstablishContext(SCARD_SCOPE_SYSTEM, NULL, NULL, &hContext); Definition at line 160 of file winscard_scf.c. References SCardEstablishContextTH(), SCardLockThread(), and SCardUnlockThread(). Referenced by main(), and MSGFunctionDemarshall(). |
|
This function get an attribute from the IFD Handler.
The list of possible attributes is available in the file
LONG rv; SCARDCONTEXT hContext; SCARDHANDLE hCard; DWORD dwActiveProtocol; unsigned char pbAtr[MAX_ATR_SIZE]; DWORD dwAtrLen; ... rv = SCardEstablishContext(SCARD_SCOPE_SYSTEM, NULL, NULL, &hContext); rv = SCardConnect(hContext, "Reader X", SCARD_SHARE_SHARED, SCARD_PROTOCOL_RAW &hCard, &dwActiveProtocol); rv = SCardGetAttrib(hCard, SCARD_ATTR_ATR_STRING, pbAtr, &dwAtrLen); Definition at line 1196 of file winscard_scf.c. References SCARD_E_NOT_TRANSACTED. Referenced by MSGFunctionDemarshall(). |
|
This function receives a structure or list of structures containing reader names. It then blocks for a change in state to occur on any of the OR'd values contained in dwCurrentState 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. This function will block for reader availability if cReaders is equal to zero and rgReaderStates is NULL.
typedef struct { LPCTSTR szReader; // Reader name LPVOID pvUserData; // User defined data DWORD dwCurrentState; // Current state of reader DWORD dwEventState; // Reader state after a state change DWORD cbAtr; // ATR Length, usually MAX_ATR_SIZE BYTE rgbAtr[MAX_ATR_SIZE]; // ATR Value } SCARD_READERSTATE; ... typedef SCARD_READERSTATE *PSCARD_READERSTATE, **LPSCARD_READERSTATE; ... Value of dwCurrentState and dwEventState:
SCARDCONTEXT hContext; SCARD_READERSTATE_A rgReaderStates[1]; LONG rv; ... rv = SCardEstablishContext(SCARD_SCOPE_SYSTEM, NULL, NULL, &hContext); ... rgReaderStates[0].szReader = "Reader X"; rgReaderStates[0].dwCurrentState = SCARD_STATE_UNAWARE; ... rv = SCardGetStatusChange(hContext, INFINITE, rgReaderStates, 1); printf("reader state: 0x%04X\n", rgReaderStates[0].dwEventState); Definition at line 688 of file winscard_scf.c. References isOCFServerRunning(), SCARD_E_INVALID_HANDLE, SCARD_E_INVALID_PARAMETER, SCARD_E_INVALID_VALUE, SCARD_E_NO_SERVICE, SCARD_E_READER_UNAVAILABLE, SCARD_S_SUCCESS, SCardGetContextIndice(), SCardLockThread(), and SCardUnlockThread(). Referenced by main(). |
|
This function returns a list of currently available reader groups on the system.
The group names is a multi-string and separated by a nul character ('\0') and ended by a double nul character. "SCard$DefaultReaders\\0Group 2\\0\\0".
SCARDCONTEXT hContext; LPTSTR mszGroups; DWORD dwGroups; LONG rv; ... rv = SCardEstablishContext(SCARD_SCOPE_SYSTEM, NULL, NULL, &hContext); rv = SCardListReaderGroups(hContext, NULL, &dwGroups); mszGroups = (LPTSTR)malloc(sizeof(char)*dwGroups); rv = SCardListReaderGroups(hContext, mszGroups, &dwGroups); Definition at line 1156 of file winscard_scf.c. References SCardListReaderGroupsTH(), SCardLockThread(), and SCardUnlockThread(). Referenced by main(). |
|
This function returns a list of currently available readers on the system.
SCARDCONTEXT hContext; LPTSTR mszReaders; DWORD dwReaders; LONG rv; ... rv = SCardEstablishContext(SCARD_SCOPE_SYSTEM, NULL, NULL, &hContext); rv = SCardListReaders(hContext, NULL, NULL, &dwReaders); mszReaders = (LPTSTR)malloc(sizeof(char)*dwReaders); rv = SCardListReaders(hContext, NULL, mszReaders, &dwReaders); Definition at line 273 of file winscard_scf.c. References SCardListReadersTH(), SCardLockThread(), and SCardUnlockThread(). Referenced by main(). |
|
This function 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 it's state accordingly.
SCARDCONTEXT hContext; SCARDHANDLE hCard; DWORD dwActiveProtocol, dwSendLength, dwRecvLength; LONG rv; BYTE pbRecvBuffer[10]; BYTE pbSendBuffer[] = {0xC0, 0xA4, 0x00, 0x00, 0x02, 0x3F, 0x00}; ... rv = SCardEstablishContext(SCARD_SCOPE_SYSTEM, NULL, NULL, &hContext); rv = SCardConnect(hContext, "Reader X", SCARD_SHARE_SHARED, SCARD_PROTOCOL_T0, &hCard, &dwActiveProtocol); ... dwSendLength = sizeof(pbSendBuffer); dwRecvLength = sizeof(pbRecvBuffer); rv = SCardTransmit(hCard, SCARD_PCI_T0, pbSendBuffer, dwSendLength, &pioRecvPci, pbRecvBuffer, &dwRecvLength); / * Card has been reset by another application * / if (rv == SCARD_W_RESET_CARD) { rv = SCardReconnect(hCard, SCARD_SHARE_SHARED, SCARD_PROTOCOL_T0, SCARD_RESET_CARD, &dwActiveProtocol); } Definition at line 454 of file winscard_scf.c. References SCardLockThread(), SCardReconnectTH(), and SCardUnlockThread(). Referenced by MSGFunctionDemarshall(). |
|
This function destroys a communication context to the PC/SC Resource Manager. This must be the last function called in a PC/SC application.
SCARDCONTEXT hContext; LONG rv; ... rv = SCardEstablishContext(SCARD_SCOPE_SYSTEM, NULL, NULL, &hContext); rv = SCardReleaseContext(hContext); Definition at line 189 of file winscard_scf.c. References SCardLockThread(), SCardReleaseContextTH(), and SCardUnlockThread(). Referenced by main(), MSGCleanupClient(), and MSGFunctionDemarshall(). |
|
This function set an attribute of the IFD Handler. The list of attributes you can set is dependent on the IFD Handler you are using.
LONG rv; SCARDCONTEXT hContext; SCARDHANDLE hCard; DWORD dwActiveProtocol; unsigned char pbAtr[MAX_ATR_SIZE]; DWORD dwAtrLen; ... rv = SCardEstablishContext(SCARD_SCOPE_SYSTEM, NULL, NULL, &hContext); rv = SCardConnect(hContext, "Reader X", SCARD_SHARE_SHARED, SCARD_PROTOCOL_RAW &hCard, &dwActiveProtocol); rv = SCardSetAttrib(hCard, 0x42000001, "\x12\x34\x56", 3); Definition at line 1202 of file winscard_scf.c. References SCARD_E_NOT_TRANSACTED. Referenced by MSGFunctionDemarshall(). |
|
This function returns the current status of the reader connected to by hCard. It's 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.
SCARDCONTEXT hContext; SCARDHANDLE hCard; DWORD dwActiveProtocol; DWORD dwState, dwProtocol, dwAtrLen, dwReaderLen; BYTE pbAtr[MAX_ATR_SIZE]; ... rv = SCardEstablishContext(SCARD_SCOPE_SYSTEM, NULL, NULL, &hContext); rv = SCardConnect(hContext, "Reader X", SCARD_SHARE_SHARED, SCARD_PROTOCOL_T0, &hCard, &dwActiveProtocol); ... dwAtrLen = sizeof(pbAtr); rv=SCardStatus(hCard, NULL, &dwReaderLen, &dwState, &dwProtocol, pbAtr, &dwAtrLen); Definition at line 675 of file winscard_scf.c. References SCardLockThread(), SCardStatusTH(), and SCardUnlockThread(). Referenced by MSGFunctionDemarshall(), and MSGRemoveContext(). |
|
This function 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 it's length in SpcbRecvLength. SSendPci and SRecvPci are structures containing the following: typedef struct { DWORD dwProtocol; // SCARD_PROTOCOL_T0 or SCARD_PROTOCOL_T1 DWORD cbPciLength; // Length of this structure - not used } SCARD_IO_REQUEST;
LONG rv; SCARDCONTEXT hContext; SCARDHANDLE hCard; DWORD dwActiveProtocol, dwSendLength, dwRecvLength; SCARD_IO_REQUEST pioRecvPci; BYTE pbRecvBuffer[10]; BYTE pbSendBuffer[] = { 0xC0, 0xA4, 0x00, 0x00, 0x02, 0x3F, 0x00 }; ... rv = SCardEstablishContext(SCARD_SCOPE_SYSTEM, NULL, NULL, &hContext); rv = SCardConnect(hContext, "Reader X", SCARD_SHARE_SHARED, SCARD_PROTOCOL_T0, &hCard, &dwActiveProtocol); dwSendLength = sizeof(pbSendBuffer); dwRecvLength = sizeof(pbRecvBuffer); rv = SCardTransmit(hCard, SCARD_PCI_T0, pbSendBuffer, dwSendLength, &pioRecvPci, pbRecvBuffer, &dwRecvLength); Definition at line 1111 of file winscard_scf.c. References SCardLockThread(), SCardTransmitTH(), and SCardUnlockThread(). Referenced by MSGFunctionDemarshall(). |
|
free resources allocated by the library You _shall_ call this function if you use dlopen/dlclose to load/unload the library. Otherwise you will exhaust the ressources available. Definition at line 1896 of file winscard_scf.c. References isActiveContextPresent(), isExecuted, mapAddr, PCSC_Initialized, SHMClientCloseSession(), and SYS_CloseFile(). |