FreeRDP
smartcard_pcsc.c File Reference
#include <winpr/config.h>
#include <stdio.h>
#include <stdlib.h>
#include <winpr/crt.h>
#include <winpr/assert.h>
#include <winpr/synch.h>
#include <winpr/library.h>
#include <winpr/smartcard.h>
#include <winpr/collections.h>
#include <winpr/environment.h>
#include "smartcard_pcsc.h"
#include "../log.h"

Macros

#define TAG   WINPR_TAG("smartcard")
 
#define WINSCARD_LOAD_PROC_EX(module, pcsc, _fname, _name, ...)
 
#define WINSCARD_LOAD_PROC(module, pcsc, _name, ...)    WINSCARD_LOAD_PROC_EX(module, pcsc, _name, _name, ##__VA_ARGS__)
 
#define PCSC_SCARD_PCI_T0   (&g_PCSC_rgSCardT0Pci)
 
#define PCSC_SCARD_PCI_T1   (&g_PCSC_rgSCardT1Pci)
 
#define PCSC_SCARD_PCI_RAW   (&g_PCSC_rgSCardRawPci)
 
#define ARRAY_LENGTH(a)   (sizeof(a) / sizeof(a)[0])
 

Typedefs

typedef PCSC_LONG(* fnPCSCSCardEstablishContext) (PCSC_DWORD dwScope, LPCVOID pvReserved1, LPCVOID pvReserved2, LPSCARDCONTEXT phContext)
 
typedef PCSC_LONG(* fnPCSCSCardReleaseContext) (SCARDCONTEXT hContext)
 
typedef PCSC_LONG(* fnPCSCSCardIsValidContext) (SCARDCONTEXT hContext)
 
typedef PCSC_LONG(* fnPCSCSCardConnect) (SCARDCONTEXT hContext, LPCSTR szReader, PCSC_DWORD dwShareMode, PCSC_DWORD dwPreferredProtocols, LPSCARDHANDLE phCard, PCSC_LPDWORD pdwActiveProtocol)
 
typedef PCSC_LONG(* fnPCSCSCardReconnect) (SCARDHANDLE hCard, PCSC_DWORD dwShareMode, PCSC_DWORD dwPreferredProtocols, PCSC_DWORD dwInitialization, PCSC_LPDWORD pdwActiveProtocol)
 
typedef PCSC_LONG(* fnPCSCSCardDisconnect) (SCARDHANDLE hCard, PCSC_DWORD dwDisposition)
 
typedef PCSC_LONG(* fnPCSCSCardBeginTransaction) (SCARDHANDLE hCard)
 
typedef PCSC_LONG(* fnPCSCSCardEndTransaction) (SCARDHANDLE hCard, PCSC_DWORD dwDisposition)
 
typedef PCSC_LONG(* fnPCSCSCardStatus) (SCARDHANDLE hCard, LPSTR mszReaderName, PCSC_LPDWORD pcchReaderLen, PCSC_LPDWORD pdwState, PCSC_LPDWORD pdwProtocol, LPBYTE pbAtr, PCSC_LPDWORD pcbAtrLen)
 
typedef PCSC_LONG(* fnPCSCSCardGetStatusChange) (SCARDCONTEXT hContext, PCSC_DWORD dwTimeout, PCSC_SCARD_READERSTATE *rgReaderStates, PCSC_DWORD cReaders)
 
typedef PCSC_LONG(* fnPCSCSCardControl) (SCARDHANDLE hCard, PCSC_DWORD dwControlCode, LPCVOID pbSendBuffer, PCSC_DWORD cbSendLength, LPVOID pbRecvBuffer, PCSC_DWORD cbRecvLength, PCSC_LPDWORD lpBytesReturned)
 
typedef PCSC_LONG(* fnPCSCSCardTransmit) (SCARDHANDLE hCard, const PCSC_SCARD_IO_REQUEST *pioSendPci, LPCBYTE pbSendBuffer, PCSC_DWORD cbSendLength, PCSC_SCARD_IO_REQUEST *pioRecvPci, LPBYTE pbRecvBuffer, PCSC_LPDWORD pcbRecvLength)
 
typedef PCSC_LONG(* fnPCSCSCardListReaderGroups) (SCARDCONTEXT hContext, LPSTR mszGroups, PCSC_LPDWORD pcchGroups)
 
typedef PCSC_LONG(* fnPCSCSCardListReaders) (SCARDCONTEXT hContext, LPCSTR mszGroups, LPSTR mszReaders, PCSC_LPDWORD pcchReaders)
 
typedef PCSC_LONG(* fnPCSCSCardFreeMemory) (SCARDCONTEXT hContext, LPCVOID pvMem)
 
typedef PCSC_LONG(* fnPCSCSCardCancel) (SCARDCONTEXT hContext)
 
typedef PCSC_LONG(* fnPCSCSCardGetAttrib) (SCARDHANDLE hCard, PCSC_DWORD dwAttrId, LPBYTE pbAttr, PCSC_LPDWORD pcbAttrLen)
 
typedef PCSC_LONG(* fnPCSCSCardSetAttrib) (SCARDHANDLE hCard, PCSC_DWORD dwAttrId, LPCBYTE pbAttr, PCSC_DWORD cbAttrLen)
 

Functions

static LONG WINAPI PCSC_SCardFreeMemory_Internal (SCARDCONTEXT hContext, LPVOID pvMem)
 
static LONG WINAPI PCSC_SCardEstablishContext_Internal (DWORD dwScope, LPCVOID pvReserved1, LPCVOID pvReserved2, LPSCARDCONTEXT phContext)
 
static LONG WINAPI PCSC_SCardReleaseContext_Internal (SCARDCONTEXT hContext)
 
static LONG PCSC_SCard_LogError (const char *what)
 
static LONG PCSC_MapErrorCodeToWinSCard (PCSC_LONG errorCode)
 
static DWORD PCSC_ConvertCardStateToWinSCard (DWORD dwCardState, PCSC_LONG status)
 
static DWORD PCSC_ConvertProtocolsToWinSCard (PCSC_DWORD dwProtocols)
 
static DWORD PCSC_ConvertProtocolsFromWinSCard (DWORD dwProtocols)
 
static PCSC_SCARDCONTEXT * PCSC_GetCardContextData (SCARDCONTEXT hContext)
 
static void pcsc_cache_item_free (void *ptr)
 
static PCSC_SCARDCONTEXT * PCSC_EstablishCardContext (SCARDCONTEXT hContext)
 
static void PCSC_ReleaseCardContext (SCARDCONTEXT hContext)
 
static BOOL PCSC_LockCardContext (SCARDCONTEXT hContext)
 
static BOOL PCSC_UnlockCardContext (SCARDCONTEXT hContext)
 
static PCSC_SCARDHANDLE * PCSC_GetCardHandleData (SCARDHANDLE hCard)
 
static SCARDCONTEXT PCSC_GetCardContextFromHandle (SCARDHANDLE hCard)
 
static BOOL PCSC_WaitForCardAccess (SCARDCONTEXT hContext, SCARDHANDLE hCard, BOOL shared)
 
static BOOL PCSC_ReleaseCardAccess (SCARDCONTEXT hContext, SCARDHANDLE hCard)
 
static PCSC_SCARDHANDLE * PCSC_ConnectCardHandle (SCARDCONTEXT hSharedContext, SCARDHANDLE hCard)
 
static void PCSC_DisconnectCardHandle (SCARDHANDLE hCard)
 
static BOOL PCSC_AddMemoryBlock (SCARDCONTEXT hContext, void *pvMem)
 
static void * PCSC_RemoveMemoryBlock (SCARDCONTEXT hContext, void *pvMem)
 
static LONG WINAPI PCSC_SCardEstablishContext (DWORD dwScope, LPCVOID pvReserved1, LPCVOID pvReserved2, LPSCARDCONTEXT phContext)
 
static LONG WINAPI PCSC_SCardReleaseContext (SCARDCONTEXT hContext)
 
static LONG WINAPI PCSC_SCardIsValidContext (SCARDCONTEXT hContext)
 
static LONG WINAPI PCSC_SCardListReaderGroups_Internal (SCARDCONTEXT hContext, LPSTR mszGroups, LPDWORD pcchGroups)
 
static LONG WINAPI PCSC_SCardListReaderGroupsA (SCARDCONTEXT hContext, LPSTR mszGroups, LPDWORD pcchGroups)
 
static LONG WINAPI PCSC_SCardListReaderGroupsW (SCARDCONTEXT hContext, LPWSTR mszGroups, LPDWORD pcchGroups)
 
static LONG WINAPI PCSC_SCardListReaders_Internal (SCARDCONTEXT hContext, LPCSTR mszGroups, LPSTR mszReaders, LPDWORD pcchReaders)
 
static LONG WINAPI PCSC_SCardListReadersA (SCARDCONTEXT hContext, LPCSTR mszGroups, LPSTR mszReaders, LPDWORD pcchReaders)
 
static LONG WINAPI PCSC_SCardListReadersW (SCARDCONTEXT hContext, LPCWSTR mszGroups, LPWSTR mszReaders, LPDWORD pcchReaders)
 
static const char * findCardByAtr (LPCBYTE pbAtr)
 
static LONG WINAPI PCSC_SCardListCardsA (SCARDCONTEXT hContext, LPCBYTE pbAtr, LPCGUID rgquidInterfaces, DWORD cguidInterfaceCount, CHAR *mszCards, LPDWORD pcchCards)
 
static LONG WINAPI PCSC_SCardListCardsW (SCARDCONTEXT hContext, LPCBYTE pbAtr, LPCGUID rgquidInterfaces, DWORD cguidInterfaceCount, WCHAR *mszCards, LPDWORD pcchCards)
 
static LONG WINAPI PCSC_SCardListInterfacesA (SCARDCONTEXT hContext, LPCSTR szCard, LPGUID pguidInterfaces, LPDWORD pcguidInterfaces)
 
static LONG WINAPI PCSC_SCardListInterfacesW (SCARDCONTEXT hContext, LPCWSTR szCard, LPGUID pguidInterfaces, LPDWORD pcguidInterfaces)
 
static LONG WINAPI PCSC_SCardGetProviderIdA (SCARDCONTEXT hContext, LPCSTR szCard, LPGUID pguidProviderId)
 
static LONG WINAPI PCSC_SCardGetProviderIdW (SCARDCONTEXT hContext, LPCWSTR szCard, LPGUID pguidProviderId)
 
static LONG WINAPI PCSC_SCardGetCardTypeProviderNameA (SCARDCONTEXT hContext, LPCSTR szCardName, DWORD dwProviderId, CHAR *szProvider, LPDWORD pcchProvider)
 
static LONG WINAPI PCSC_SCardGetCardTypeProviderNameW (SCARDCONTEXT hContext, LPCWSTR szCardName, DWORD dwProviderId, WCHAR *szProvider, LPDWORD pcchProvider)
 
static LONG WINAPI PCSC_SCardIntroduceReaderGroupA (SCARDCONTEXT hContext, LPCSTR szGroupName)
 
static LONG WINAPI PCSC_SCardIntroduceReaderGroupW (SCARDCONTEXT hContext, LPCWSTR szGroupName)
 
static LONG WINAPI PCSC_SCardForgetReaderGroupA (SCARDCONTEXT hContext, LPCSTR szGroupName)
 
static LONG WINAPI PCSC_SCardForgetReaderGroupW (SCARDCONTEXT hContext, LPCWSTR szGroupName)
 
static LONG WINAPI PCSC_SCardIntroduceReaderA (SCARDCONTEXT hContext, LPCSTR szReaderName, LPCSTR szDeviceName)
 
static LONG WINAPI PCSC_SCardIntroduceReaderW (SCARDCONTEXT hContext, LPCWSTR szReaderName, LPCWSTR szDeviceName)
 
static LONG WINAPI PCSC_SCardForgetReaderA (SCARDCONTEXT hContext, LPCSTR szReaderName)
 
static LONG WINAPI PCSC_SCardForgetReaderW (SCARDCONTEXT hContext, LPCWSTR szReaderName)
 
static LONG WINAPI PCSC_SCardAddReaderToGroupA (SCARDCONTEXT hContext, LPCSTR szReaderName, LPCSTR szGroupName)
 
static LONG WINAPI PCSC_SCardAddReaderToGroupW (SCARDCONTEXT hContext, LPCWSTR szReaderName, LPCWSTR szGroupName)
 
static LONG WINAPI PCSC_SCardRemoveReaderFromGroupA (SCARDCONTEXT hContext, LPCSTR szReaderName, LPCSTR szGroupName)
 
static LONG WINAPI PCSC_SCardRemoveReaderFromGroupW (SCARDCONTEXT hContext, LPCWSTR szReaderName, LPCWSTR szGroupName)
 
static LONG WINAPI PCSC_SCardIntroduceCardTypeA (SCARDCONTEXT hContext, LPCSTR szCardName, LPCGUID pguidPrimaryProvider, LPCGUID rgguidInterfaces, DWORD dwInterfaceCount, LPCBYTE pbAtr, LPCBYTE pbAtrMask, DWORD cbAtrLen)
 
static LONG WINAPI PCSC_SCardIntroduceCardTypeW (SCARDCONTEXT hContext, LPCWSTR szCardName, LPCGUID pguidPrimaryProvider, LPCGUID rgguidInterfaces, DWORD dwInterfaceCount, LPCBYTE pbAtr, LPCBYTE pbAtrMask, DWORD cbAtrLen)
 
static LONG WINAPI PCSC_SCardSetCardTypeProviderNameA (SCARDCONTEXT hContext, LPCSTR szCardName, DWORD dwProviderId, LPCSTR szProvider)
 
static LONG WINAPI PCSC_SCardSetCardTypeProviderNameW (SCARDCONTEXT hContext, LPCWSTR szCardName, DWORD dwProviderId, LPCWSTR szProvider)
 
static LONG WINAPI PCSC_SCardForgetCardTypeA (SCARDCONTEXT hContext, LPCSTR szCardName)
 
static LONG WINAPI PCSC_SCardForgetCardTypeW (SCARDCONTEXT hContext, LPCWSTR szCardName)
 
static LONG WINAPI PCSC_SCardFreeMemory (SCARDCONTEXT hContext, LPVOID pvMem)
 
static HANDLE WINAPI PCSC_SCardAccessStartedEvent (void)
 
static void WINAPI PCSC_SCardReleaseStartedEvent (void)
 
static LONG WINAPI PCSC_SCardLocateCardsA (SCARDCONTEXT hContext, LPCSTR mszCards, LPSCARD_READERSTATEA rgReaderStates, DWORD cReaders)
 
static LONG WINAPI PCSC_SCardLocateCardsW (SCARDCONTEXT hContext, LPCWSTR mszCards, LPSCARD_READERSTATEW rgReaderStates, DWORD cReaders)
 
static LONG WINAPI PCSC_SCardLocateCardsByATRA (SCARDCONTEXT hContext, LPSCARD_ATRMASK rgAtrMasks, DWORD cAtrs, LPSCARD_READERSTATEA rgReaderStates, DWORD cReaders)
 
static LONG WINAPI PCSC_SCardLocateCardsByATRW (SCARDCONTEXT hContext, LPSCARD_ATRMASK rgAtrMasks, DWORD cAtrs, LPSCARD_READERSTATEW rgReaderStates, DWORD cReaders)
 
static LONG WINAPI PCSC_SCardGetStatusChange_Internal (SCARDCONTEXT hContext, DWORD dwTimeout, LPSCARD_READERSTATEA rgReaderStates, DWORD cReaders)
 
static LONG WINAPI PCSC_SCardGetStatusChangeA (SCARDCONTEXT hContext, DWORD dwTimeout, LPSCARD_READERSTATEA rgReaderStates, DWORD cReaders)
 
static LONG WINAPI PCSC_SCardGetStatusChangeW (SCARDCONTEXT hContext, DWORD dwTimeout, LPSCARD_READERSTATEW rgReaderStates, DWORD cReaders)
 
static LONG WINAPI PCSC_SCardCancel (SCARDCONTEXT hContext)
 
static LONG WINAPI PCSC_SCardConnect_Internal (SCARDCONTEXT hContext, LPCSTR szReader, DWORD dwShareMode, DWORD dwPreferredProtocols, LPSCARDHANDLE phCard, LPDWORD pdwActiveProtocol)
 
static LONG WINAPI PCSC_SCardConnectA (SCARDCONTEXT hContext, LPCSTR szReader, DWORD dwShareMode, DWORD dwPreferredProtocols, LPSCARDHANDLE phCard, LPDWORD pdwActiveProtocol)
 
static LONG WINAPI PCSC_SCardConnectW (SCARDCONTEXT hContext, LPCWSTR szReader, DWORD dwShareMode, DWORD dwPreferredProtocols, LPSCARDHANDLE phCard, LPDWORD pdwActiveProtocol)
 
static LONG WINAPI PCSC_SCardReconnect (SCARDHANDLE hCard, DWORD dwShareMode, DWORD dwPreferredProtocols, DWORD dwInitialization, LPDWORD pdwActiveProtocol)
 
static LONG WINAPI PCSC_SCardDisconnect (SCARDHANDLE hCard, DWORD dwDisposition)
 
static LONG WINAPI PCSC_SCardBeginTransaction (SCARDHANDLE hCard)
 
static LONG WINAPI PCSC_SCardEndTransaction (SCARDHANDLE hCard, DWORD dwDisposition)
 
static LONG WINAPI PCSC_SCardCancelTransaction (SCARDHANDLE hCard)
 
static LONG WINAPI PCSC_SCardStatus_Internal (SCARDHANDLE hCard, LPSTR mszReaderNames, LPDWORD pcchReaderLen, LPDWORD pdwState, LPDWORD pdwProtocol, LPBYTE pbAtr, LPDWORD pcbAtrLen, BOOL unicode)
 
static LONG WINAPI PCSC_SCardState (SCARDHANDLE hCard, LPDWORD pdwState, LPDWORD pdwProtocol, LPBYTE pbAtr, LPDWORD pcbAtrLen)
 
static LONG WINAPI PCSC_SCardStatusA (SCARDHANDLE hCard, LPSTR mszReaderNames, LPDWORD pcchReaderLen, LPDWORD pdwState, LPDWORD pdwProtocol, LPBYTE pbAtr, LPDWORD pcbAtrLen)
 
static LONG WINAPI PCSC_SCardStatusW (SCARDHANDLE hCard, LPWSTR mszReaderNames, LPDWORD pcchReaderLen, LPDWORD pdwState, LPDWORD pdwProtocol, LPBYTE pbAtr, LPDWORD pcbAtrLen)
 
static LONG WINAPI PCSC_SCardTransmit (SCARDHANDLE hCard, LPCSCARD_IO_REQUEST pioSendPci, LPCBYTE pbSendBuffer, DWORD cbSendLength, LPSCARD_IO_REQUEST pioRecvPci, LPBYTE pbRecvBuffer, LPDWORD pcbRecvLength)
 
static LONG WINAPI PCSC_SCardGetTransmitCount (SCARDHANDLE hCard, LPDWORD pcTransmitCount)
 
static LONG WINAPI PCSC_SCardControl (SCARDHANDLE hCard, DWORD dwControlCode, LPCVOID lpInBuffer, DWORD cbInBufferSize, LPVOID lpOutBuffer, DWORD cbOutBufferSize, LPDWORD lpBytesReturned)
 
static LONG WINAPI PCSC_SCardGetAttrib_Internal (SCARDHANDLE hCard, DWORD dwAttrId, LPBYTE pbAttr, LPDWORD pcbAttrLen)
 
static LONG WINAPI PCSC_SCardGetAttrib_FriendlyName (SCARDHANDLE hCard, DWORD dwAttrId, LPBYTE pbAttr, LPDWORD pcbAttrLen)
 
static LONG WINAPI PCSC_SCardGetAttrib (SCARDHANDLE hCard, DWORD dwAttrId, LPBYTE pbAttr, LPDWORD pcbAttrLen)
 
static LONG WINAPI PCSC_SCardSetAttrib (SCARDHANDLE hCard, DWORD dwAttrId, LPCBYTE pbAttr, DWORD cbAttrLen)
 
static LONG WINAPI PCSC_SCardUIDlgSelectCardA (LPOPENCARDNAMEA_EX pDlgStruc)
 
static LONG WINAPI PCSC_SCardUIDlgSelectCardW (LPOPENCARDNAMEW_EX pDlgStruc)
 
static LONG WINAPI PCSC_GetOpenCardNameA (LPOPENCARDNAMEA pDlgStruc)
 
static LONG WINAPI PCSC_GetOpenCardNameW (LPOPENCARDNAMEW pDlgStruc)
 
static LONG WINAPI PCSC_SCardDlgExtendedError (void)
 
static char * card_id_and_name_a (const UUID *CardIdentifier, LPCSTR LookupName)
 
static char * card_id_and_name_w (const UUID *CardIdentifier, LPCWSTR LookupName)
 
static LONG WINAPI PCSC_SCardReadCacheA (SCARDCONTEXT hContext, UUID *CardIdentifier, DWORD FreshnessCounter, LPSTR LookupName, PBYTE Data, DWORD *DataLen)
 
static LONG WINAPI PCSC_SCardReadCacheW (SCARDCONTEXT hContext, UUID *CardIdentifier, DWORD FreshnessCounter, LPWSTR LookupName, PBYTE Data, DWORD *DataLen)
 
static LONG WINAPI PCSC_SCardWriteCacheA (SCARDCONTEXT hContext, UUID *CardIdentifier, DWORD FreshnessCounter, LPSTR LookupName, PBYTE Data, DWORD DataLen)
 
static LONG WINAPI PCSC_SCardWriteCacheW (SCARDCONTEXT hContext, UUID *CardIdentifier, DWORD FreshnessCounter, LPWSTR LookupName, PBYTE Data, DWORD DataLen)
 
static LONG WINAPI PCSC_SCardGetReaderIconA (SCARDCONTEXT hContext, LPCSTR szReaderName, LPBYTE pbIcon, LPDWORD pcbIcon)
 
static LONG WINAPI PCSC_SCardGetReaderIconW (SCARDCONTEXT hContext, LPCWSTR szReaderName, LPBYTE pbIcon, LPDWORD pcbIcon)
 
static LONG WINAPI PCSC_SCardGetDeviceTypeIdA (SCARDCONTEXT hContext, LPCSTR szReaderName, LPDWORD pdwDeviceTypeId)
 
static LONG WINAPI PCSC_SCardGetDeviceTypeIdW (SCARDCONTEXT hContext, LPCWSTR szReaderName, LPDWORD pdwDeviceTypeId)
 
static LONG WINAPI PCSC_SCardGetReaderDeviceInstanceIdA (SCARDCONTEXT hContext, LPCSTR szReaderName, LPSTR szDeviceInstanceId, LPDWORD pcchDeviceInstanceId)
 
static LONG WINAPI PCSC_SCardGetReaderDeviceInstanceIdW (SCARDCONTEXT hContext, LPCWSTR szReaderName, LPWSTR szDeviceInstanceId, LPDWORD pcchDeviceInstanceId)
 
static LONG WINAPI PCSC_SCardListReadersWithDeviceInstanceIdA (SCARDCONTEXT hContext, LPCSTR szDeviceInstanceId, LPSTR mszReaders, LPDWORD pcchReaders)
 
static LONG WINAPI PCSC_SCardListReadersWithDeviceInstanceIdW (SCARDCONTEXT hContext, LPCWSTR szDeviceInstanceId, LPWSTR mszReaders, LPDWORD pcchReaders)
 
static LONG WINAPI PCSC_SCardAudit (SCARDCONTEXT hContext, DWORD dwEvent)
 
const SCardApiFunctionTablePCSC_GetSCardApiFunctionTable (void)
 
int PCSC_InitializeSCardApi (void)
 

Variables

static HMODULE g_PCSCModule = NULL
 
static PCSCFunctionTable g_PCSC = { 0 }
 
static HANDLE g_StartedEvent = NULL
 
static int g_StartedEventRefCount = 0
 
static BOOL g_SCardAutoAllocate = FALSE
 
static BOOL g_PnP_Notification = TRUE
 
static wListDictionary * g_CardHandles = NULL
 
static wListDictionary * g_CardContexts = NULL
 
static wListDictionary * g_MemoryBlocks = NULL
 
static const char SMARTCARD_PNP_NOTIFICATION_A [] = "\\\\?PnP?\\Notification"
 
static const PCSC_SCARD_IO_REQUEST g_PCSC_rgSCardT0Pci
 
static const PCSC_SCARD_IO_REQUEST g_PCSC_rgSCardT1Pci
 
static const PCSC_SCARD_IO_REQUEST g_PCSC_rgSCardRawPci
 
static PcscKnownAtr knownAtrs []
 
static const SCardApiFunctionTable PCSC_SCardApiFunctionTable
 

Macro Definition Documentation

◆ ARRAY_LENGTH

#define ARRAY_LENGTH (   a)    (sizeof(a) / sizeof(a)[0])

◆ PCSC_SCARD_PCI_RAW

#define PCSC_SCARD_PCI_RAW   (&g_PCSC_rgSCardRawPci)

◆ PCSC_SCARD_PCI_T0

#define PCSC_SCARD_PCI_T0   (&g_PCSC_rgSCardT0Pci)

PC/SC transactions: http://developersblog.wwpass.com/?p=180 Smart Card Logon on Windows Vista: http://blogs.msdn.com/b/shivaram/archive/2007/02/26/smart-card-logon-on-windows-vista.aspx The Smart Card Cryptographic Service Provider Cookbook: http://msdn.microsoft.com/en-us/library/ms953432.aspx

SCARDCONTEXT

The context is a communication channel with the smart card resource manager and all calls to the resource manager must go through this link.

All functions that take a context as a parameter or a card handle as parameter, which is indirectly associated with a particular context, may be blocking calls. Examples of these are SCardGetStatusChange and SCardBeginTransaction, which takes a card handle as a parameter. If such a function blocks then all operations wanting to use the context are blocked as well. So, it is recommended that a CSP using monitoring establishes at least two contexts with the resource manager; one for monitoring (with SCardGetStatusChange) and one for other operations.

If multiple cards are present, it is recommended that a separate context or pair of contexts be established for each card to prevent operations on one card from blocking operations on another.

Example one

The example below shows what can happen if a CSP using SCardGetStatusChange for monitoring does not establish two contexts with the resource manager. The context becomes unusable until SCardGetStatusChange unblocks.

In this example, there is one process running called P1. P1 calls SCardEstablishContext, which returns the context hCtx. P1 calls SCardConnect (with the hCtx context) which returns a handle to the card, hCard. P1 calls SCardGetStatusChange (with the hCtx context) which blocks because there are no status changes to report. Until the thread running SCardGetStatusChange unblocks, another thread in P1 trying to perform an operation using the context hCtx (or the card hCard) will also be blocked.

Example two

The example below shows how transaction control ensures that operations meant to be performed without interruption can do so safely within a transaction.

In this example, there are two different processes running; P1 and P2. P1 calls SCardEstablishContext, which returns the context hCtx1. P2 calls SCardEstablishContext, which returns the context hCtx2. P1 calls SCardConnect (with the hCtx1 context) which returns a handle to the card, hCard1. P2 calls SCardConnect (with the hCtx2 context) which returns a handle to the same card, hCard2. P1 calls SCardBeginTransaction (with the hCard 1 context). Until P1 calls SCardEndTransaction (with the hCard1 context), any operation using hCard2 will be blocked. Once an operation using hCard2 is blocked and until it's returning, any operation using hCtx2 (and hCard2) will also be blocked.

◆ PCSC_SCARD_PCI_T1

#define PCSC_SCARD_PCI_T1   (&g_PCSC_rgSCardT1Pci)

◆ TAG

#define TAG   WINPR_TAG("smartcard")

WinPR: Windows Portable Runtime Smart Card API

Copyright 2014 Marc-Andre Moreau marca.nosp@m.ndre.nosp@m..more.nosp@m.au@g.nosp@m.mail..nosp@m.com Copyright 2020 Armin Novak armin.nosp@m..nov.nosp@m.ak@th.nosp@m.inca.nosp@m.st.co.nosp@m.m Copyright 2020 Thincast Technologies GmbH

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

◆ WINSCARD_LOAD_PROC

#define WINSCARD_LOAD_PROC (   module,
  pcsc,
  _name,
  ... 
)     WINSCARD_LOAD_PROC_EX(module, pcsc, _name, _name, ##__VA_ARGS__)

◆ WINSCARD_LOAD_PROC_EX

#define WINSCARD_LOAD_PROC_EX (   module,
  pcsc,
  _fname,
  _name,
  ... 
)
Value:
do \
{ \
WINPR_PRAGMA_DIAG_PUSH \
WINPR_PRAGMA_DIAG_IGNORED_PEDANTIC \
pcsc.pfn##_fname = (fnPCSC##_fname)GetProcAddress(module, #_name); \
WINPR_PRAGMA_DIAG_POP \
} while (0)
WINPR_API FARPROC GetProcAddress(HMODULE hModule, LPCSTR lpProcName)
Definition: library.c:182

Typedef Documentation

◆ fnPCSCSCardBeginTransaction

typedef PCSC_LONG(* fnPCSCSCardBeginTransaction) (SCARDHANDLE hCard)

◆ fnPCSCSCardCancel

typedef PCSC_LONG(* fnPCSCSCardCancel) (SCARDCONTEXT hContext)

◆ fnPCSCSCardConnect

typedef PCSC_LONG(* fnPCSCSCardConnect) (SCARDCONTEXT hContext, LPCSTR szReader, PCSC_DWORD dwShareMode, PCSC_DWORD dwPreferredProtocols, LPSCARDHANDLE phCard, PCSC_LPDWORD pdwActiveProtocol)

◆ fnPCSCSCardControl

typedef PCSC_LONG(* fnPCSCSCardControl) (SCARDHANDLE hCard, PCSC_DWORD dwControlCode, LPCVOID pbSendBuffer, PCSC_DWORD cbSendLength, LPVOID pbRecvBuffer, PCSC_DWORD cbRecvLength, PCSC_LPDWORD lpBytesReturned)

◆ fnPCSCSCardDisconnect

typedef PCSC_LONG(* fnPCSCSCardDisconnect) (SCARDHANDLE hCard, PCSC_DWORD dwDisposition)

◆ fnPCSCSCardEndTransaction

typedef PCSC_LONG(* fnPCSCSCardEndTransaction) (SCARDHANDLE hCard, PCSC_DWORD dwDisposition)

◆ fnPCSCSCardEstablishContext

typedef PCSC_LONG(* fnPCSCSCardEstablishContext) (PCSC_DWORD dwScope, LPCVOID pvReserved1, LPCVOID pvReserved2, LPSCARDCONTEXT phContext)

◆ fnPCSCSCardFreeMemory

typedef PCSC_LONG(* fnPCSCSCardFreeMemory) (SCARDCONTEXT hContext, LPCVOID pvMem)

◆ fnPCSCSCardGetAttrib

typedef PCSC_LONG(* fnPCSCSCardGetAttrib) (SCARDHANDLE hCard, PCSC_DWORD dwAttrId, LPBYTE pbAttr, PCSC_LPDWORD pcbAttrLen)

◆ fnPCSCSCardGetStatusChange

typedef PCSC_LONG(* fnPCSCSCardGetStatusChange) (SCARDCONTEXT hContext, PCSC_DWORD dwTimeout, PCSC_SCARD_READERSTATE *rgReaderStates, PCSC_DWORD cReaders)

◆ fnPCSCSCardIsValidContext

typedef PCSC_LONG(* fnPCSCSCardIsValidContext) (SCARDCONTEXT hContext)

◆ fnPCSCSCardListReaderGroups

typedef PCSC_LONG(* fnPCSCSCardListReaderGroups) (SCARDCONTEXT hContext, LPSTR mszGroups, PCSC_LPDWORD pcchGroups)

◆ fnPCSCSCardListReaders

typedef PCSC_LONG(* fnPCSCSCardListReaders) (SCARDCONTEXT hContext, LPCSTR mszGroups, LPSTR mszReaders, PCSC_LPDWORD pcchReaders)

◆ fnPCSCSCardReconnect

typedef PCSC_LONG(* fnPCSCSCardReconnect) (SCARDHANDLE hCard, PCSC_DWORD dwShareMode, PCSC_DWORD dwPreferredProtocols, PCSC_DWORD dwInitialization, PCSC_LPDWORD pdwActiveProtocol)

◆ fnPCSCSCardReleaseContext

typedef PCSC_LONG(* fnPCSCSCardReleaseContext) (SCARDCONTEXT hContext)

◆ fnPCSCSCardSetAttrib

typedef PCSC_LONG(* fnPCSCSCardSetAttrib) (SCARDHANDLE hCard, PCSC_DWORD dwAttrId, LPCBYTE pbAttr, PCSC_DWORD cbAttrLen)

◆ fnPCSCSCardStatus

typedef PCSC_LONG(* fnPCSCSCardStatus) (SCARDHANDLE hCard, LPSTR mszReaderName, PCSC_LPDWORD pcchReaderLen, PCSC_LPDWORD pdwState, PCSC_LPDWORD pdwProtocol, LPBYTE pbAtr, PCSC_LPDWORD pcbAtrLen)

◆ fnPCSCSCardTransmit

typedef PCSC_LONG(* fnPCSCSCardTransmit) (SCARDHANDLE hCard, const PCSC_SCARD_IO_REQUEST *pioSendPci, LPCBYTE pbSendBuffer, PCSC_DWORD cbSendLength, PCSC_SCARD_IO_REQUEST *pioRecvPci, LPBYTE pbRecvBuffer, PCSC_LPDWORD pcbRecvLength)

Function Documentation

◆ card_id_and_name_a()

static char* card_id_and_name_a ( const UUID *  CardIdentifier,
LPCSTR  LookupName 
)
static
Here is the caller graph for this function:

◆ card_id_and_name_w()

static char* card_id_and_name_w ( const UUID *  CardIdentifier,
LPCWSTR  LookupName 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ findCardByAtr()

static const char* findCardByAtr ( LPCBYTE  pbAtr)
static
Here is the caller graph for this function:

◆ PCSC_AddMemoryBlock()

static BOOL PCSC_AddMemoryBlock ( SCARDCONTEXT  hContext,
void *  pvMem 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pcsc_cache_item_free()

static void pcsc_cache_item_free ( void *  ptr)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ PCSC_ConnectCardHandle()

static PCSC_SCARDHANDLE* PCSC_ConnectCardHandle ( SCARDCONTEXT  hSharedContext,
SCARDHANDLE  hCard 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ PCSC_ConvertCardStateToWinSCard()

static DWORD PCSC_ConvertCardStateToWinSCard ( DWORD  dwCardState,
PCSC_LONG  status 
)
static

pcsc-lite's SCardStatus returns a bit-field, not an enumerated value.

    State             WinSCard           pcsc-lite

 SCARD_UNKNOWN           0                0x0001
 SCARD_ABSENT            1                0x0002
 SCARD_PRESENT           2                0x0004
 SCARD_SWALLOWED         3                0x0008
 SCARD_POWERED           4                0x0010
 SCARD_NEGOTIABLE        5                0x0020
 SCARD_SPECIFIC          6                0x0040

pcsc-lite also never sets SCARD_SPECIFIC, which is expected by some windows applications.

Here is the caller graph for this function:

◆ PCSC_ConvertProtocolsFromWinSCard()

static DWORD PCSC_ConvertProtocolsFromWinSCard ( DWORD  dwProtocols)
static

pcsc-lite uses a different value for SCARD_PROTOCOL_RAW, and it does not define WinSCard's SCARD_PROTOCOL_DEFAULT.

Here is the caller graph for this function:

◆ PCSC_ConvertProtocolsToWinSCard()

static DWORD PCSC_ConvertProtocolsToWinSCard ( PCSC_DWORD  dwProtocols)
static

pcsc-lite uses a different value for SCARD_PROTOCOL_RAW, and also has SCARD_PROTOCOL_T15 which is not in WinSCard.

Here is the caller graph for this function:

◆ PCSC_DisconnectCardHandle()

static void PCSC_DisconnectCardHandle ( SCARDHANDLE  hCard)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ PCSC_EstablishCardContext()

static PCSC_SCARDCONTEXT* PCSC_EstablishCardContext ( SCARDCONTEXT  hContext)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ PCSC_GetCardContextData()

static PCSC_SCARDCONTEXT* PCSC_GetCardContextData ( SCARDCONTEXT  hContext)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ PCSC_GetCardContextFromHandle()

static SCARDCONTEXT PCSC_GetCardContextFromHandle ( SCARDHANDLE  hCard)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ PCSC_GetCardHandleData()

static PCSC_SCARDHANDLE* PCSC_GetCardHandleData ( SCARDHANDLE  hCard)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ PCSC_GetOpenCardNameA()

static LONG WINAPI PCSC_GetOpenCardNameA ( LPOPENCARDNAMEA  pDlgStruc)
static

◆ PCSC_GetOpenCardNameW()

static LONG WINAPI PCSC_GetOpenCardNameW ( LPOPENCARDNAMEW  pDlgStruc)
static

◆ PCSC_GetSCardApiFunctionTable()

const SCardApiFunctionTable* PCSC_GetSCardApiFunctionTable ( void  )
Here is the caller graph for this function:

◆ PCSC_InitializeSCardApi()

int PCSC_InitializeSCardApi ( void  )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ PCSC_LockCardContext()

static BOOL PCSC_LockCardContext ( SCARDCONTEXT  hContext)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ PCSC_MapErrorCodeToWinSCard()

static LONG PCSC_MapErrorCodeToWinSCard ( PCSC_LONG  errorCode)
static

pcsc-lite returns SCARD_E_UNEXPECTED when it should return SCARD_E_UNSUPPORTED_FEATURE.

Additionally, the pcsc-lite headers incorrectly define SCARD_E_UNSUPPORTED_FEATURE to 0x8010001F, when the real value should be 0x80100022.

Here is the caller graph for this function:

◆ PCSC_ReleaseCardAccess()

static BOOL PCSC_ReleaseCardAccess ( SCARDCONTEXT  hContext,
SCARDHANDLE  hCard 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ PCSC_ReleaseCardContext()

static void PCSC_ReleaseCardContext ( SCARDCONTEXT  hContext)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ PCSC_RemoveMemoryBlock()

static void* PCSC_RemoveMemoryBlock ( SCARDCONTEXT  hContext,
void *  pvMem 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ PCSC_SCard_LogError()

static LONG PCSC_SCard_LogError ( const char *  what)
static
Here is the caller graph for this function:

◆ PCSC_SCardAccessStartedEvent()

static HANDLE WINAPI PCSC_SCardAccessStartedEvent ( void  )
static
Here is the call graph for this function:

◆ PCSC_SCardAddReaderToGroupA()

static LONG WINAPI PCSC_SCardAddReaderToGroupA ( SCARDCONTEXT  hContext,
LPCSTR  szReaderName,
LPCSTR  szGroupName 
)
static

◆ PCSC_SCardAddReaderToGroupW()

static LONG WINAPI PCSC_SCardAddReaderToGroupW ( SCARDCONTEXT  hContext,
LPCWSTR  szReaderName,
LPCWSTR  szGroupName 
)
static

◆ PCSC_SCardAudit()

static LONG WINAPI PCSC_SCardAudit ( SCARDCONTEXT  hContext,
DWORD  dwEvent 
)
static

◆ PCSC_SCardBeginTransaction()

static LONG WINAPI PCSC_SCardBeginTransaction ( SCARDHANDLE  hCard)
static
Here is the call graph for this function:

◆ PCSC_SCardCancel()

static LONG WINAPI PCSC_SCardCancel ( SCARDCONTEXT  hContext)
static
Here is the call graph for this function:

◆ PCSC_SCardCancelTransaction()

static LONG WINAPI PCSC_SCardCancelTransaction ( SCARDHANDLE  hCard)
static

◆ PCSC_SCardConnect_Internal()

static LONG WINAPI PCSC_SCardConnect_Internal ( SCARDCONTEXT  hContext,
LPCSTR  szReader,
DWORD  dwShareMode,
DWORD  dwPreferredProtocols,
LPSCARDHANDLE  phCard,
LPDWORD  pdwActiveProtocol 
)
static

As stated here : https://pcsclite.alioth.debian.org/api/group__API.html#ga4e515829752e0a8dbc4d630696a8d6a5 SCARD_PROTOCOL_UNDEFINED is valid for dwPreferredProtocols (only) if dwShareMode == SCARD_SHARE_DIRECT and allows to send control commands to the reader (with SCardControl()) even if a card is not present in the reader

Here is the call graph for this function:
Here is the caller graph for this function:

◆ PCSC_SCardConnectA()

static LONG WINAPI PCSC_SCardConnectA ( SCARDCONTEXT  hContext,
LPCSTR  szReader,
DWORD  dwShareMode,
DWORD  dwPreferredProtocols,
LPSCARDHANDLE  phCard,
LPDWORD  pdwActiveProtocol 
)
static
Here is the call graph for this function:

◆ PCSC_SCardConnectW()

static LONG WINAPI PCSC_SCardConnectW ( SCARDCONTEXT  hContext,
LPCWSTR  szReader,
DWORD  dwShareMode,
DWORD  dwPreferredProtocols,
LPSCARDHANDLE  phCard,
LPDWORD  pdwActiveProtocol 
)
static
Here is the call graph for this function:

◆ PCSC_SCardControl()

static LONG WINAPI PCSC_SCardControl ( SCARDHANDLE  hCard,
DWORD  dwControlCode,
LPCVOID  lpInBuffer,
DWORD  cbInBufferSize,
LPVOID  lpOutBuffer,
DWORD  cbOutBufferSize,
LPDWORD  lpBytesReturned 
)
static

◆ PCSC_SCardDisconnect()

static LONG WINAPI PCSC_SCardDisconnect ( SCARDHANDLE  hCard,
DWORD  dwDisposition 
)
static
Here is the call graph for this function:

◆ PCSC_SCardDlgExtendedError()

static LONG WINAPI PCSC_SCardDlgExtendedError ( void  )
static

◆ PCSC_SCardEndTransaction()

static LONG WINAPI PCSC_SCardEndTransaction ( SCARDHANDLE  hCard,
DWORD  dwDisposition 
)
static
Here is the call graph for this function:

◆ PCSC_SCardEstablishContext()

static LONG WINAPI PCSC_SCardEstablishContext ( DWORD  dwScope,
LPCVOID  pvReserved1,
LPCVOID  pvReserved2,
LPSCARDCONTEXT  phContext 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ PCSC_SCardEstablishContext_Internal()

static LONG WINAPI PCSC_SCardEstablishContext_Internal ( DWORD  dwScope,
LPCVOID  pvReserved1,
LPCVOID  pvReserved2,
LPSCARDCONTEXT  phContext 
)
static

Standard Windows Smart Card API (PCSC)

Here is the call graph for this function:
Here is the caller graph for this function:

◆ PCSC_SCardForgetCardTypeA()

static LONG WINAPI PCSC_SCardForgetCardTypeA ( SCARDCONTEXT  hContext,
LPCSTR  szCardName 
)
static

◆ PCSC_SCardForgetCardTypeW()

static LONG WINAPI PCSC_SCardForgetCardTypeW ( SCARDCONTEXT  hContext,
LPCWSTR  szCardName 
)
static

◆ PCSC_SCardForgetReaderA()

static LONG WINAPI PCSC_SCardForgetReaderA ( SCARDCONTEXT  hContext,
LPCSTR  szReaderName 
)
static

◆ PCSC_SCardForgetReaderGroupA()

static LONG WINAPI PCSC_SCardForgetReaderGroupA ( SCARDCONTEXT  hContext,
LPCSTR  szGroupName 
)
static

◆ PCSC_SCardForgetReaderGroupW()

static LONG WINAPI PCSC_SCardForgetReaderGroupW ( SCARDCONTEXT  hContext,
LPCWSTR  szGroupName 
)
static

◆ PCSC_SCardForgetReaderW()

static LONG WINAPI PCSC_SCardForgetReaderW ( SCARDCONTEXT  hContext,
LPCWSTR  szReaderName 
)
static

◆ PCSC_SCardFreeMemory()

static LONG WINAPI PCSC_SCardFreeMemory ( SCARDCONTEXT  hContext,
LPVOID  pvMem 
)
static
Here is the call graph for this function:

◆ PCSC_SCardFreeMemory_Internal()

static LONG WINAPI PCSC_SCardFreeMemory_Internal ( SCARDCONTEXT  hContext,
LPVOID  pvMem 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ PCSC_SCardGetAttrib()

static LONG WINAPI PCSC_SCardGetAttrib ( SCARDHANDLE  hCard,
DWORD  dwAttrId,
LPBYTE  pbAttr,
LPDWORD  pcbAttrLen 
)
static

pcsc-lite returns SCARD_E_INSUFFICIENT_BUFFER if the given buffer size is larger than PCSC_MAX_BUFFER_SIZE (264)

pcsc-lite adds a null terminator to the vendor name, while WinSCard doesn't. Strip the null terminator.

Here is the call graph for this function:

◆ PCSC_SCardGetAttrib_FriendlyName()

static LONG WINAPI PCSC_SCardGetAttrib_FriendlyName ( SCARDHANDLE  hCard,
DWORD  dwAttrId,
LPBYTE  pbAttr,
LPDWORD  pcbAttrLen 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ PCSC_SCardGetAttrib_Internal()

static LONG WINAPI PCSC_SCardGetAttrib_Internal ( SCARDHANDLE  hCard,
DWORD  dwAttrId,
LPBYTE  pbAttr,
LPDWORD  pcbAttrLen 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ PCSC_SCardGetCardTypeProviderNameA()

static LONG WINAPI PCSC_SCardGetCardTypeProviderNameA ( SCARDCONTEXT  hContext,
LPCSTR  szCardName,
DWORD  dwProviderId,
CHAR *  szProvider,
LPDWORD  pcchProvider 
)
static

◆ PCSC_SCardGetCardTypeProviderNameW()

static LONG WINAPI PCSC_SCardGetCardTypeProviderNameW ( SCARDCONTEXT  hContext,
LPCWSTR  szCardName,
DWORD  dwProviderId,
WCHAR *  szProvider,
LPDWORD  pcchProvider 
)
static

◆ PCSC_SCardGetDeviceTypeIdA()

static LONG WINAPI PCSC_SCardGetDeviceTypeIdA ( SCARDCONTEXT  hContext,
LPCSTR  szReaderName,
LPDWORD  pdwDeviceTypeId 
)
static

◆ PCSC_SCardGetDeviceTypeIdW()

static LONG WINAPI PCSC_SCardGetDeviceTypeIdW ( SCARDCONTEXT  hContext,
LPCWSTR  szReaderName,
LPDWORD  pdwDeviceTypeId 
)
static

◆ PCSC_SCardGetProviderIdA()

static LONG WINAPI PCSC_SCardGetProviderIdA ( SCARDCONTEXT  hContext,
LPCSTR  szCard,
LPGUID  pguidProviderId 
)
static

◆ PCSC_SCardGetProviderIdW()

static LONG WINAPI PCSC_SCardGetProviderIdW ( SCARDCONTEXT  hContext,
LPCWSTR  szCard,
LPGUID  pguidProviderId 
)
static

◆ PCSC_SCardGetReaderDeviceInstanceIdA()

static LONG WINAPI PCSC_SCardGetReaderDeviceInstanceIdA ( SCARDCONTEXT  hContext,
LPCSTR  szReaderName,
LPSTR  szDeviceInstanceId,
LPDWORD  pcchDeviceInstanceId 
)
static

◆ PCSC_SCardGetReaderDeviceInstanceIdW()

static LONG WINAPI PCSC_SCardGetReaderDeviceInstanceIdW ( SCARDCONTEXT  hContext,
LPCWSTR  szReaderName,
LPWSTR  szDeviceInstanceId,
LPDWORD  pcchDeviceInstanceId 
)
static

◆ PCSC_SCardGetReaderIconA()

static LONG WINAPI PCSC_SCardGetReaderIconA ( SCARDCONTEXT  hContext,
LPCSTR  szReaderName,
LPBYTE  pbIcon,
LPDWORD  pcbIcon 
)
static

◆ PCSC_SCardGetReaderIconW()

static LONG WINAPI PCSC_SCardGetReaderIconW ( SCARDCONTEXT  hContext,
LPCWSTR  szReaderName,
LPBYTE  pbIcon,
LPDWORD  pcbIcon 
)
static

◆ PCSC_SCardGetStatusChange_Internal()

static LONG WINAPI PCSC_SCardGetStatusChange_Internal ( SCARDCONTEXT  hContext,
DWORD  dwTimeout,
LPSCARD_READERSTATEA  rgReaderStates,
DWORD  cReaders 
)
static

Apple's SmartCard Services (not vanilla pcsc-lite) appears to have trouble with the "\\\\?PnP?\\Notification" reader name. I am always getting EXC_BAD_ACCESS with it.

The SmartCard Services tarballs can be found here: http://opensource.apple.com/tarballs/SmartCardServices/

The "\\\\?PnP?\\Notification" string cannot be found anywhere in the sources, while this string is present in the vanilla pcsc-lite sources.

To work around this apparent lack of "\\\\?PnP?\\Notification" support, we have to filter rgReaderStates to exclude the special PnP reader name.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ PCSC_SCardGetStatusChangeA()

static LONG WINAPI PCSC_SCardGetStatusChangeA ( SCARDCONTEXT  hContext,
DWORD  dwTimeout,
LPSCARD_READERSTATEA  rgReaderStates,
DWORD  cReaders 
)
static
Here is the call graph for this function:

◆ PCSC_SCardGetStatusChangeW()

static LONG WINAPI PCSC_SCardGetStatusChangeW ( SCARDCONTEXT  hContext,
DWORD  dwTimeout,
LPSCARD_READERSTATEW  rgReaderStates,
DWORD  cReaders 
)
static
Here is the call graph for this function:

◆ PCSC_SCardGetTransmitCount()

static LONG WINAPI PCSC_SCardGetTransmitCount ( SCARDHANDLE  hCard,
LPDWORD  pcTransmitCount 
)
static
Here is the call graph for this function:

◆ PCSC_SCardIntroduceCardTypeA()

static LONG WINAPI PCSC_SCardIntroduceCardTypeA ( SCARDCONTEXT  hContext,
LPCSTR  szCardName,
LPCGUID  pguidPrimaryProvider,
LPCGUID  rgguidInterfaces,
DWORD  dwInterfaceCount,
LPCBYTE  pbAtr,
LPCBYTE  pbAtrMask,
DWORD  cbAtrLen 
)
static

◆ PCSC_SCardIntroduceCardTypeW()

static LONG WINAPI PCSC_SCardIntroduceCardTypeW ( SCARDCONTEXT  hContext,
LPCWSTR  szCardName,
LPCGUID  pguidPrimaryProvider,
LPCGUID  rgguidInterfaces,
DWORD  dwInterfaceCount,
LPCBYTE  pbAtr,
LPCBYTE  pbAtrMask,
DWORD  cbAtrLen 
)
static

◆ PCSC_SCardIntroduceReaderA()

static LONG WINAPI PCSC_SCardIntroduceReaderA ( SCARDCONTEXT  hContext,
LPCSTR  szReaderName,
LPCSTR  szDeviceName 
)
static

◆ PCSC_SCardIntroduceReaderGroupA()

static LONG WINAPI PCSC_SCardIntroduceReaderGroupA ( SCARDCONTEXT  hContext,
LPCSTR  szGroupName 
)
static

◆ PCSC_SCardIntroduceReaderGroupW()

static LONG WINAPI PCSC_SCardIntroduceReaderGroupW ( SCARDCONTEXT  hContext,
LPCWSTR  szGroupName 
)
static

◆ PCSC_SCardIntroduceReaderW()

static LONG WINAPI PCSC_SCardIntroduceReaderW ( SCARDCONTEXT  hContext,
LPCWSTR  szReaderName,
LPCWSTR  szDeviceName 
)
static

◆ PCSC_SCardIsValidContext()

static LONG WINAPI PCSC_SCardIsValidContext ( SCARDCONTEXT  hContext)
static
Here is the call graph for this function:

◆ PCSC_SCardListCardsA()

static LONG WINAPI PCSC_SCardListCardsA ( SCARDCONTEXT  hContext,
LPCBYTE  pbAtr,
LPCGUID  rgquidInterfaces,
DWORD  cguidInterfaceCount,
CHAR *  mszCards,
LPDWORD  pcchCards 
)
static
Here is the call graph for this function:

◆ PCSC_SCardListCardsW()

static LONG WINAPI PCSC_SCardListCardsW ( SCARDCONTEXT  hContext,
LPCBYTE  pbAtr,
LPCGUID  rgquidInterfaces,
DWORD  cguidInterfaceCount,
WCHAR *  mszCards,
LPDWORD  pcchCards 
)
static
Here is the call graph for this function:

◆ PCSC_SCardListInterfacesA()

static LONG WINAPI PCSC_SCardListInterfacesA ( SCARDCONTEXT  hContext,
LPCSTR  szCard,
LPGUID  pguidInterfaces,
LPDWORD  pcguidInterfaces 
)
static

◆ PCSC_SCardListInterfacesW()

static LONG WINAPI PCSC_SCardListInterfacesW ( SCARDCONTEXT  hContext,
LPCWSTR  szCard,
LPGUID  pguidInterfaces,
LPDWORD  pcguidInterfaces 
)
static

◆ PCSC_SCardListReaderGroups_Internal()

static LONG WINAPI PCSC_SCardListReaderGroups_Internal ( SCARDCONTEXT  hContext,
LPSTR  mszGroups,
LPDWORD  pcchGroups 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ PCSC_SCardListReaderGroupsA()

static LONG WINAPI PCSC_SCardListReaderGroupsA ( SCARDCONTEXT  hContext,
LPSTR  mszGroups,
LPDWORD  pcchGroups 
)
static
Here is the call graph for this function:

◆ PCSC_SCardListReaderGroupsW()

static LONG WINAPI PCSC_SCardListReaderGroupsW ( SCARDCONTEXT  hContext,
LPWSTR  mszGroups,
LPDWORD  pcchGroups 
)
static
Here is the call graph for this function:

◆ PCSC_SCardListReaders_Internal()

static LONG WINAPI PCSC_SCardListReaders_Internal ( SCARDCONTEXT  hContext,
LPCSTR  mszGroups,
LPSTR  mszReaders,
LPDWORD  pcchReaders 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ PCSC_SCardListReadersA()

static LONG WINAPI PCSC_SCardListReadersA ( SCARDCONTEXT  hContext,
LPCSTR  mszGroups,
LPSTR  mszReaders,
LPDWORD  pcchReaders 
)
static
Here is the call graph for this function:

◆ PCSC_SCardListReadersW()

static LONG WINAPI PCSC_SCardListReadersW ( SCARDCONTEXT  hContext,
LPCWSTR  mszGroups,
LPWSTR  mszReaders,
LPDWORD  pcchReaders 
)
static
Here is the call graph for this function:

◆ PCSC_SCardListReadersWithDeviceInstanceIdA()

static LONG WINAPI PCSC_SCardListReadersWithDeviceInstanceIdA ( SCARDCONTEXT  hContext,
LPCSTR  szDeviceInstanceId,
LPSTR  mszReaders,
LPDWORD  pcchReaders 
)
static

◆ PCSC_SCardListReadersWithDeviceInstanceIdW()

static LONG WINAPI PCSC_SCardListReadersWithDeviceInstanceIdW ( SCARDCONTEXT  hContext,
LPCWSTR  szDeviceInstanceId,
LPWSTR  mszReaders,
LPDWORD  pcchReaders 
)
static

◆ PCSC_SCardLocateCardsA()

static LONG WINAPI PCSC_SCardLocateCardsA ( SCARDCONTEXT  hContext,
LPCSTR  mszCards,
LPSCARD_READERSTATEA  rgReaderStates,
DWORD  cReaders 
)
static

◆ PCSC_SCardLocateCardsByATRA()

static LONG WINAPI PCSC_SCardLocateCardsByATRA ( SCARDCONTEXT  hContext,
LPSCARD_ATRMASK  rgAtrMasks,
DWORD  cAtrs,
LPSCARD_READERSTATEA  rgReaderStates,
DWORD  cReaders 
)
static

◆ PCSC_SCardLocateCardsByATRW()

static LONG WINAPI PCSC_SCardLocateCardsByATRW ( SCARDCONTEXT  hContext,
LPSCARD_ATRMASK  rgAtrMasks,
DWORD  cAtrs,
LPSCARD_READERSTATEW  rgReaderStates,
DWORD  cReaders 
)
static

◆ PCSC_SCardLocateCardsW()

static LONG WINAPI PCSC_SCardLocateCardsW ( SCARDCONTEXT  hContext,
LPCWSTR  mszCards,
LPSCARD_READERSTATEW  rgReaderStates,
DWORD  cReaders 
)
static

◆ PCSC_SCardReadCacheA()

static LONG WINAPI PCSC_SCardReadCacheA ( SCARDCONTEXT  hContext,
UUID *  CardIdentifier,
DWORD  FreshnessCounter,
LPSTR  LookupName,
PBYTE  Data,
DWORD *  DataLen 
)
static
Here is the call graph for this function:

◆ PCSC_SCardReadCacheW()

static LONG WINAPI PCSC_SCardReadCacheW ( SCARDCONTEXT  hContext,
UUID *  CardIdentifier,
DWORD  FreshnessCounter,
LPWSTR  LookupName,
PBYTE  Data,
DWORD *  DataLen 
)
static
Here is the call graph for this function:

◆ PCSC_SCardReconnect()

static LONG WINAPI PCSC_SCardReconnect ( SCARDHANDLE  hCard,
DWORD  dwShareMode,
DWORD  dwPreferredProtocols,
DWORD  dwInitialization,
LPDWORD  pdwActiveProtocol 
)
static
Here is the call graph for this function:

◆ PCSC_SCardReleaseContext()

static LONG WINAPI PCSC_SCardReleaseContext ( SCARDCONTEXT  hContext)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ PCSC_SCardReleaseContext_Internal()

static LONG WINAPI PCSC_SCardReleaseContext_Internal ( SCARDCONTEXT  hContext)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ PCSC_SCardReleaseStartedEvent()

static void WINAPI PCSC_SCardReleaseStartedEvent ( void  )
static
Here is the call graph for this function:

◆ PCSC_SCardRemoveReaderFromGroupA()

static LONG WINAPI PCSC_SCardRemoveReaderFromGroupA ( SCARDCONTEXT  hContext,
LPCSTR  szReaderName,
LPCSTR  szGroupName 
)
static

◆ PCSC_SCardRemoveReaderFromGroupW()

static LONG WINAPI PCSC_SCardRemoveReaderFromGroupW ( SCARDCONTEXT  hContext,
LPCWSTR  szReaderName,
LPCWSTR  szGroupName 
)
static

◆ PCSC_SCardSetAttrib()

static LONG WINAPI PCSC_SCardSetAttrib ( SCARDHANDLE  hCard,
DWORD  dwAttrId,
LPCBYTE  pbAttr,
DWORD  cbAttrLen 
)
static
Here is the call graph for this function:

◆ PCSC_SCardSetCardTypeProviderNameA()

static LONG WINAPI PCSC_SCardSetCardTypeProviderNameA ( SCARDCONTEXT  hContext,
LPCSTR  szCardName,
DWORD  dwProviderId,
LPCSTR  szProvider 
)
static

◆ PCSC_SCardSetCardTypeProviderNameW()

static LONG WINAPI PCSC_SCardSetCardTypeProviderNameW ( SCARDCONTEXT  hContext,
LPCWSTR  szCardName,
DWORD  dwProviderId,
LPCWSTR  szProvider 
)
static

◆ PCSC_SCardState()

static LONG WINAPI PCSC_SCardState ( SCARDHANDLE  hCard,
LPDWORD  pdwState,
LPDWORD  pdwProtocol,
LPBYTE  pbAtr,
LPDWORD  pcbAtrLen 
)
static
Here is the call graph for this function:

◆ PCSC_SCardStatus_Internal()

static LONG WINAPI PCSC_SCardStatus_Internal ( SCARDHANDLE  hCard,
LPSTR  mszReaderNames,
LPDWORD  pcchReaderLen,
LPDWORD  pdwState,
LPDWORD  pdwProtocol,
LPBYTE  pbAtr,
LPDWORD  pcbAtrLen,
BOOL  unicode 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ PCSC_SCardStatusA()

static LONG WINAPI PCSC_SCardStatusA ( SCARDHANDLE  hCard,
LPSTR  mszReaderNames,
LPDWORD  pcchReaderLen,
LPDWORD  pdwState,
LPDWORD  pdwProtocol,
LPBYTE  pbAtr,
LPDWORD  pcbAtrLen 
)
static
Here is the call graph for this function:

◆ PCSC_SCardStatusW()

static LONG WINAPI PCSC_SCardStatusW ( SCARDHANDLE  hCard,
LPWSTR  mszReaderNames,
LPDWORD  pcchReaderLen,
LPDWORD  pdwState,
LPDWORD  pdwProtocol,
LPBYTE  pbAtr,
LPDWORD  pcbAtrLen 
)
static
Here is the call graph for this function:

◆ PCSC_SCardTransmit()

static LONG WINAPI PCSC_SCardTransmit ( SCARDHANDLE  hCard,
LPCSCARD_IO_REQUEST  pioSendPci,
LPCBYTE  pbSendBuffer,
DWORD  cbSendLength,
LPSCARD_IO_REQUEST  pioRecvPci,
LPBYTE  pbRecvBuffer,
LPDWORD  pcbRecvLength 
)
static

pcsc-lite cannot have a null pioSendPci parameter, unlike WinSCard. Query the current protocol and use default SCARD_IO_REQUEST for it.

Here is the call graph for this function:

◆ PCSC_SCardUIDlgSelectCardA()

static LONG WINAPI PCSC_SCardUIDlgSelectCardA ( LPOPENCARDNAMEA_EX  pDlgStruc)
static

◆ PCSC_SCardUIDlgSelectCardW()

static LONG WINAPI PCSC_SCardUIDlgSelectCardW ( LPOPENCARDNAMEW_EX  pDlgStruc)
static

◆ PCSC_SCardWriteCacheA()

static LONG WINAPI PCSC_SCardWriteCacheA ( SCARDCONTEXT  hContext,
UUID *  CardIdentifier,
DWORD  FreshnessCounter,
LPSTR  LookupName,
PBYTE  Data,
DWORD  DataLen 
)
static
Here is the call graph for this function:

◆ PCSC_SCardWriteCacheW()

static LONG WINAPI PCSC_SCardWriteCacheW ( SCARDCONTEXT  hContext,
UUID *  CardIdentifier,
DWORD  FreshnessCounter,
LPWSTR  LookupName,
PBYTE  Data,
DWORD  DataLen 
)
static
Here is the call graph for this function:

◆ PCSC_UnlockCardContext()

static BOOL PCSC_UnlockCardContext ( SCARDCONTEXT  hContext)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ PCSC_WaitForCardAccess()

static BOOL PCSC_WaitForCardAccess ( SCARDCONTEXT  hContext,
SCARDHANDLE  hCard,
BOOL  shared 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ g_CardContexts

wListDictionary* g_CardContexts = NULL
static

◆ g_CardHandles

wListDictionary* g_CardHandles = NULL
static

◆ g_MemoryBlocks

wListDictionary* g_MemoryBlocks = NULL
static

◆ g_PCSC

PCSCFunctionTable g_PCSC = { 0 }
static

◆ g_PCSC_rgSCardRawPci

const PCSC_SCARD_IO_REQUEST g_PCSC_rgSCardRawPci
static
Initial value:
#define PCSC_SCARD_PROTOCOL_RAW
Definition: smartcard_pcsc.h:117
Definition: smartcard_pcsc.h:150

◆ g_PCSC_rgSCardT0Pci

const PCSC_SCARD_IO_REQUEST g_PCSC_rgSCardT0Pci
static
Initial value:
#define SCARD_PROTOCOL_T0
Definition: include/winpr/smartcard.h:136

◆ g_PCSC_rgSCardT1Pci

const PCSC_SCARD_IO_REQUEST g_PCSC_rgSCardT1Pci
static
Initial value:
#define SCARD_PROTOCOL_T1
Definition: include/winpr/smartcard.h:137

◆ g_PCSCModule

HMODULE g_PCSCModule = NULL
static

◆ g_PnP_Notification

BOOL g_PnP_Notification = TRUE
static

◆ g_SCardAutoAllocate

BOOL g_SCardAutoAllocate = FALSE
static

◆ g_StartedEvent

HANDLE g_StartedEvent = NULL
static

◆ g_StartedEventRefCount

int g_StartedEventRefCount = 0
static

◆ knownAtrs

PcscKnownAtr knownAtrs[]
static
Initial value:
= {
{ { 0x3B, 0xFD, 0x13, 0x00, 0x00, 0x81, 0x31, 0xFE, 0x15, 0x80, 0x73, 0xC0,
0x21, 0xC0, 0x57, 0x59, 0x75, 0x62, 0x69, 0x4B, 0x65, 0x79, 0x40 },
23,
"NIST SP 800-73 [PIV]" },
{ { 0x3B, 0xFC, 0x18, 0x00, 0x00, 0x81, 0x31, 0x80, 0x45, 0x90, 0x67,
0x46, 0x4A, 0x00, 0x64, 0x16, 0x06, 0xF2, 0x72, 0x7E, 0x00, 0xE0 },
22,
"PIVKey Feitian (E0)" }
}

◆ PCSC_SCardApiFunctionTable

const SCardApiFunctionTable PCSC_SCardApiFunctionTable
static

◆ SMARTCARD_PNP_NOTIFICATION_A

const char SMARTCARD_PNP_NOTIFICATION_A[] = "\\\\?PnP?\\Notification"
static