FreeRDP/winpr/libwinpr/smartcard/smartcard.c

1160 lines
36 KiB
C
Raw Normal View History

2014-04-03 04:54:46 +04:00
/**
* WinPR: Windows Portable Runtime
* Smart Card API
*
* Copyright 2014 Marc-Andre Moreau <marcandre.moreau@gmail.com>
* Copyright 2020 Armin Novak <armin.novak@thincast.com>
* Copyright 2020 Thincast Technologies GmbH
2014-04-03 04:54:46 +04:00
*
* 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.
*/
2022-02-16 12:08:00 +03:00
#include <winpr/config.h>
2014-04-03 04:54:46 +04:00
#include <winpr/crt.h>
#include <winpr/library.h>
2014-04-03 04:54:46 +04:00
#include <winpr/smartcard.h>
2018-01-08 12:37:48 +03:00
#include <winpr/synch.h>
#include <winpr/wlog.h>
#include "../log.h"
2014-04-03 04:54:46 +04:00
#include "smartcard.h"
2021-11-05 15:09:42 +03:00
#if defined(WITH_SMARTCARD_INSPECT)
#include "smartcard_inspect.h"
2021-11-05 15:09:42 +03:00
#endif
2018-01-08 12:37:48 +03:00
static INIT_ONCE g_Initialized = INIT_ONCE_STATIC_INIT;
2020-02-17 12:53:46 +03:00
static const SCardApiFunctionTable* g_SCardApi = NULL;
#define TAG WINPR_TAG("smartcard")
#define xstr(s) str(s)
#define str(s) #s
#define SCARDAPI_STUB_CALL_LONG(_name, ...) \
InitOnceExecuteOnce(&g_Initialized, InitializeSCardApiStubs, NULL, NULL); \
if (!g_SCardApi || !g_SCardApi->pfn##_name) \
{ \
WLog_DBG(TAG, "Missing function pointer g_SCardApi=%p->" xstr(pfn##_name) "=%p", \
g_SCardApi, g_SCardApi ? g_SCardApi->pfn##_name : NULL); \
return SCARD_E_NO_SERVICE; \
} \
2019-11-06 17:24:51 +03:00
return g_SCardApi->pfn##_name(__VA_ARGS__)
2018-01-08 12:37:48 +03:00
2021-11-05 15:09:42 +03:00
#define SCARDAPI_STUB_CALL_HANDLE(_name, ...) \
InitOnceExecuteOnce(&g_Initialized, InitializeSCardApiStubs, NULL, NULL); \
if (!g_SCardApi || !g_SCardApi->pfn##_name) \
{ \
WLog_DBG(TAG, "Missing function pointer g_SCardApi=%p->" xstr(pfn##_name) "=%p", \
g_SCardApi, g_SCardApi ? g_SCardApi->pfn##_name : NULL); \
return NULL; \
} \
2019-11-06 17:24:51 +03:00
return g_SCardApi->pfn##_name(__VA_ARGS__)
2018-01-08 12:37:48 +03:00
2021-11-05 15:09:42 +03:00
#define SCARDAPI_STUB_CALL_VOID(_name, ...) \
InitOnceExecuteOnce(&g_Initialized, InitializeSCardApiStubs, NULL, NULL); \
if (!g_SCardApi || !g_SCardApi->pfn##_name) \
{ \
WLog_DBG(TAG, "Missing function pointer g_SCardApi=%p->" xstr(pfn##_name) "=%p", \
g_SCardApi, g_SCardApi ? g_SCardApi->pfn##_name : NULL); \
return; \
} \
2019-11-06 17:24:51 +03:00
g_SCardApi->pfn##_name(__VA_ARGS__)
2018-01-08 12:37:48 +03:00
/**
* Standard Windows Smart Card API
2014-04-03 04:54:46 +04:00
*/
const SCARD_IO_REQUEST g_rgSCardT0Pci = { SCARD_PROTOCOL_T0, 8 };
const SCARD_IO_REQUEST g_rgSCardT1Pci = { SCARD_PROTOCOL_T1, 8 };
const SCARD_IO_REQUEST g_rgSCardRawPci = { SCARD_PROTOCOL_RAW, 8 };
2018-01-08 12:37:48 +03:00
static BOOL CALLBACK InitializeSCardApiStubs(PINIT_ONCE once, PVOID param, PVOID* context)
{
2021-11-05 15:09:42 +03:00
#if defined(WITH_SMARTCARD_PCSC)
2018-01-08 12:37:48 +03:00
#ifndef _WIN32
if (PCSC_InitializeSCardApi() >= 0)
g_SCardApi = PCSC_GetSCardApiFunctionTable();
#else
if (WinSCard_InitializeSCardApi() >= 0)
g_SCardApi = WinSCard_GetSCardApiFunctionTable();
#endif
2021-11-05 15:09:42 +03:00
#endif
#if defined(WITH_SMARTCARD_INSPECT)
2018-01-08 12:37:48 +03:00
g_SCardApi = Inspect_RegisterSCardApi(g_SCardApi);
#endif
2018-02-07 15:13:02 +03:00
return TRUE;
2018-01-08 12:37:48 +03:00
}
2019-11-06 17:24:51 +03:00
WINSCARDAPI LONG WINAPI SCardEstablishContext(DWORD dwScope, LPCVOID pvReserved1,
LPCVOID pvReserved2, LPSCARDCONTEXT phContext)
2014-04-03 04:54:46 +04:00
{
2019-11-06 17:24:51 +03:00
SCARDAPI_STUB_CALL_LONG(SCardEstablishContext, dwScope, pvReserved1, pvReserved2, phContext);
2014-04-03 04:54:46 +04:00
}
WINSCARDAPI LONG WINAPI SCardReleaseContext(SCARDCONTEXT hContext)
{
SCARDAPI_STUB_CALL_LONG(SCardReleaseContext, hContext);
2014-04-03 04:54:46 +04:00
}
WINSCARDAPI LONG WINAPI SCardIsValidContext(SCARDCONTEXT hContext)
{
SCARDAPI_STUB_CALL_LONG(SCardIsValidContext, hContext);
2014-04-03 04:54:46 +04:00
}
2019-11-06 17:24:51 +03:00
WINSCARDAPI LONG WINAPI SCardListReaderGroupsA(SCARDCONTEXT hContext, LPSTR mszGroups,
LPDWORD pcchGroups)
2014-04-03 04:54:46 +04:00
{
SCARDAPI_STUB_CALL_LONG(SCardListReaderGroupsA, hContext, mszGroups, pcchGroups);
2014-04-03 04:54:46 +04:00
}
2019-11-06 17:24:51 +03:00
WINSCARDAPI LONG WINAPI SCardListReaderGroupsW(SCARDCONTEXT hContext, LPWSTR mszGroups,
LPDWORD pcchGroups)
2014-04-03 04:54:46 +04:00
{
SCARDAPI_STUB_CALL_LONG(SCardListReaderGroupsW, hContext, mszGroups, pcchGroups);
2014-04-03 04:54:46 +04:00
}
2019-11-06 17:24:51 +03:00
WINSCARDAPI LONG WINAPI SCardListReadersA(SCARDCONTEXT hContext, LPCSTR mszGroups, LPSTR mszReaders,
LPDWORD pcchReaders)
2014-04-03 04:54:46 +04:00
{
SCARDAPI_STUB_CALL_LONG(SCardListReadersA, hContext, mszGroups, mszReaders, pcchReaders);
2014-04-03 04:54:46 +04:00
}
2019-11-06 17:24:51 +03:00
WINSCARDAPI LONG WINAPI SCardListReadersW(SCARDCONTEXT hContext, LPCWSTR mszGroups,
LPWSTR mszReaders, LPDWORD pcchReaders)
2014-04-03 04:54:46 +04:00
{
SCARDAPI_STUB_CALL_LONG(SCardListReadersW, hContext, mszGroups, mszReaders, pcchReaders);
2014-04-03 04:54:46 +04:00
}
2019-11-06 17:24:51 +03:00
WINSCARDAPI LONG WINAPI SCardListCardsA(SCARDCONTEXT hContext, LPCBYTE pbAtr,
LPCGUID rgquidInterfaces, DWORD cguidInterfaceCount,
CHAR* mszCards, LPDWORD pcchCards)
2014-04-03 04:54:46 +04:00
{
2019-11-06 17:24:51 +03:00
SCARDAPI_STUB_CALL_LONG(SCardListCardsA, hContext, pbAtr, rgquidInterfaces, cguidInterfaceCount,
mszCards, pcchCards);
2014-04-03 04:54:46 +04:00
}
2019-11-06 17:24:51 +03:00
WINSCARDAPI LONG WINAPI SCardListCardsW(SCARDCONTEXT hContext, LPCBYTE pbAtr,
LPCGUID rgquidInterfaces, DWORD cguidInterfaceCount,
WCHAR* mszCards, LPDWORD pcchCards)
2014-04-03 04:54:46 +04:00
{
2019-11-06 17:24:51 +03:00
SCARDAPI_STUB_CALL_LONG(SCardListCardsW, hContext, pbAtr, rgquidInterfaces, cguidInterfaceCount,
mszCards, pcchCards);
2014-04-03 04:54:46 +04:00
}
2019-11-06 17:24:51 +03:00
WINSCARDAPI LONG WINAPI SCardListInterfacesA(SCARDCONTEXT hContext, LPCSTR szCard,
LPGUID pguidInterfaces, LPDWORD pcguidInterfaces)
2014-04-03 04:54:46 +04:00
{
2019-11-06 17:24:51 +03:00
SCARDAPI_STUB_CALL_LONG(SCardListInterfacesA, hContext, szCard, pguidInterfaces,
pcguidInterfaces);
2014-04-03 04:54:46 +04:00
}
2019-11-06 17:24:51 +03:00
WINSCARDAPI LONG WINAPI SCardListInterfacesW(SCARDCONTEXT hContext, LPCWSTR szCard,
LPGUID pguidInterfaces, LPDWORD pcguidInterfaces)
2014-04-03 04:54:46 +04:00
{
2019-11-06 17:24:51 +03:00
SCARDAPI_STUB_CALL_LONG(SCardListInterfacesW, hContext, szCard, pguidInterfaces,
pcguidInterfaces);
2014-04-03 04:54:46 +04:00
}
2019-11-06 17:24:51 +03:00
WINSCARDAPI LONG WINAPI SCardGetProviderIdA(SCARDCONTEXT hContext, LPCSTR szCard,
LPGUID pguidProviderId)
2014-04-03 04:54:46 +04:00
{
SCARDAPI_STUB_CALL_LONG(SCardGetProviderIdA, hContext, szCard, pguidProviderId);
2014-04-03 04:54:46 +04:00
}
2019-11-06 17:24:51 +03:00
WINSCARDAPI LONG WINAPI SCardGetProviderIdW(SCARDCONTEXT hContext, LPCWSTR szCard,
LPGUID pguidProviderId)
2014-04-03 04:54:46 +04:00
{
SCARDAPI_STUB_CALL_LONG(SCardGetProviderIdW, hContext, szCard, pguidProviderId);
2014-04-03 04:54:46 +04:00
}
2019-11-06 17:24:51 +03:00
WINSCARDAPI LONG WINAPI SCardGetCardTypeProviderNameA(SCARDCONTEXT hContext, LPCSTR szCardName,
DWORD dwProviderId, CHAR* szProvider,
LPDWORD pcchProvider)
2014-04-03 04:54:46 +04:00
{
2019-11-06 17:24:51 +03:00
SCARDAPI_STUB_CALL_LONG(SCardGetCardTypeProviderNameA, hContext, szCardName, dwProviderId,
szProvider, pcchProvider);
2014-04-03 04:54:46 +04:00
}
2019-11-06 17:24:51 +03:00
WINSCARDAPI LONG WINAPI SCardGetCardTypeProviderNameW(SCARDCONTEXT hContext, LPCWSTR szCardName,
DWORD dwProviderId, WCHAR* szProvider,
LPDWORD pcchProvider)
2014-04-03 04:54:46 +04:00
{
2019-11-06 17:24:51 +03:00
SCARDAPI_STUB_CALL_LONG(SCardGetCardTypeProviderNameW, hContext, szCardName, dwProviderId,
szProvider, pcchProvider);
2014-04-03 04:54:46 +04:00
}
WINSCARDAPI LONG WINAPI SCardIntroduceReaderGroupA(SCARDCONTEXT hContext, LPCSTR szGroupName)
{
SCARDAPI_STUB_CALL_LONG(SCardIntroduceReaderGroupA, hContext, szGroupName);
2014-04-03 04:54:46 +04:00
}
2014-04-03 04:54:46 +04:00
WINSCARDAPI LONG WINAPI SCardIntroduceReaderGroupW(SCARDCONTEXT hContext, LPCWSTR szGroupName)
{
SCARDAPI_STUB_CALL_LONG(SCardIntroduceReaderGroupW, hContext, szGroupName);
2014-04-03 04:54:46 +04:00
}
WINSCARDAPI LONG WINAPI SCardForgetReaderGroupA(SCARDCONTEXT hContext, LPCSTR szGroupName)
{
SCARDAPI_STUB_CALL_LONG(SCardForgetReaderGroupA, hContext, szGroupName);
2014-04-03 04:54:46 +04:00
}
2014-04-03 04:54:46 +04:00
WINSCARDAPI LONG WINAPI SCardForgetReaderGroupW(SCARDCONTEXT hContext, LPCWSTR szGroupName)
{
SCARDAPI_STUB_CALL_LONG(SCardForgetReaderGroupW, hContext, szGroupName);
2014-04-03 04:54:46 +04:00
}
2019-11-06 17:24:51 +03:00
WINSCARDAPI LONG WINAPI SCardIntroduceReaderA(SCARDCONTEXT hContext, LPCSTR szReaderName,
LPCSTR szDeviceName)
2014-04-03 04:54:46 +04:00
{
SCARDAPI_STUB_CALL_LONG(SCardIntroduceReaderA, hContext, szReaderName, szDeviceName);
2014-04-03 04:54:46 +04:00
}
2019-11-06 17:24:51 +03:00
WINSCARDAPI LONG WINAPI SCardIntroduceReaderW(SCARDCONTEXT hContext, LPCWSTR szReaderName,
LPCWSTR szDeviceName)
2014-04-03 04:54:46 +04:00
{
SCARDAPI_STUB_CALL_LONG(SCardIntroduceReaderW, hContext, szReaderName, szDeviceName);
2014-04-03 04:54:46 +04:00
}
WINSCARDAPI LONG WINAPI SCardForgetReaderA(SCARDCONTEXT hContext, LPCSTR szReaderName)
{
SCARDAPI_STUB_CALL_LONG(SCardForgetReaderA, hContext, szReaderName);
2014-04-03 04:54:46 +04:00
}
2014-04-03 04:54:46 +04:00
WINSCARDAPI LONG WINAPI SCardForgetReaderW(SCARDCONTEXT hContext, LPCWSTR szReaderName)
{
SCARDAPI_STUB_CALL_LONG(SCardForgetReaderW, hContext, szReaderName);
2014-04-03 04:54:46 +04:00
}
2019-11-06 17:24:51 +03:00
WINSCARDAPI LONG WINAPI SCardAddReaderToGroupA(SCARDCONTEXT hContext, LPCSTR szReaderName,
LPCSTR szGroupName)
2014-04-03 04:54:46 +04:00
{
SCARDAPI_STUB_CALL_LONG(SCardAddReaderToGroupA, hContext, szReaderName, szGroupName);
2014-04-03 04:54:46 +04:00
}
2019-11-06 17:24:51 +03:00
WINSCARDAPI LONG WINAPI SCardAddReaderToGroupW(SCARDCONTEXT hContext, LPCWSTR szReaderName,
LPCWSTR szGroupName)
2014-04-03 04:54:46 +04:00
{
SCARDAPI_STUB_CALL_LONG(SCardAddReaderToGroupW, hContext, szReaderName, szGroupName);
2014-04-03 04:54:46 +04:00
}
2019-11-06 17:24:51 +03:00
WINSCARDAPI LONG WINAPI SCardRemoveReaderFromGroupA(SCARDCONTEXT hContext, LPCSTR szReaderName,
LPCSTR szGroupName)
2014-04-03 04:54:46 +04:00
{
SCARDAPI_STUB_CALL_LONG(SCardRemoveReaderFromGroupA, hContext, szReaderName, szGroupName);
2014-04-03 04:54:46 +04:00
}
2019-11-06 17:24:51 +03:00
WINSCARDAPI LONG WINAPI SCardRemoveReaderFromGroupW(SCARDCONTEXT hContext, LPCWSTR szReaderName,
LPCWSTR szGroupName)
2014-04-03 04:54:46 +04:00
{
SCARDAPI_STUB_CALL_LONG(SCardRemoveReaderFromGroupW, hContext, szReaderName, szGroupName);
2014-04-03 04:54:46 +04:00
}
2019-11-06 17:24:51 +03:00
WINSCARDAPI LONG WINAPI SCardIntroduceCardTypeA(SCARDCONTEXT hContext, LPCSTR szCardName,
LPCGUID pguidPrimaryProvider,
LPCGUID rgguidInterfaces, DWORD dwInterfaceCount,
LPCBYTE pbAtr, LPCBYTE pbAtrMask, DWORD cbAtrLen)
2014-04-03 04:54:46 +04:00
{
SCARDAPI_STUB_CALL_LONG(SCardIntroduceCardTypeA, hContext, szCardName, pguidPrimaryProvider,
2017-05-15 14:43:51 +03:00
rgguidInterfaces, dwInterfaceCount, pbAtr, pbAtrMask, cbAtrLen);
2014-04-03 04:54:46 +04:00
}
2019-11-06 17:24:51 +03:00
WINSCARDAPI LONG WINAPI SCardIntroduceCardTypeW(SCARDCONTEXT hContext, LPCWSTR szCardName,
LPCGUID pguidPrimaryProvider,
LPCGUID rgguidInterfaces, DWORD dwInterfaceCount,
LPCBYTE pbAtr, LPCBYTE pbAtrMask, DWORD cbAtrLen)
2014-04-03 04:54:46 +04:00
{
SCARDAPI_STUB_CALL_LONG(SCardIntroduceCardTypeW, hContext, szCardName, pguidPrimaryProvider,
2017-05-15 14:43:51 +03:00
rgguidInterfaces, dwInterfaceCount, pbAtr, pbAtrMask, cbAtrLen);
2014-04-03 04:54:46 +04:00
}
2019-11-06 17:24:51 +03:00
WINSCARDAPI LONG WINAPI SCardSetCardTypeProviderNameA(SCARDCONTEXT hContext, LPCSTR szCardName,
DWORD dwProviderId, LPCSTR szProvider)
2014-04-03 04:54:46 +04:00
{
2017-05-15 14:43:51 +03:00
SCARDAPI_STUB_CALL_LONG(SCardSetCardTypeProviderNameA, hContext, szCardName, dwProviderId,
szProvider);
2014-04-03 04:54:46 +04:00
}
2019-11-06 17:24:51 +03:00
WINSCARDAPI LONG WINAPI SCardSetCardTypeProviderNameW(SCARDCONTEXT hContext, LPCWSTR szCardName,
DWORD dwProviderId, LPCWSTR szProvider)
2014-04-03 04:54:46 +04:00
{
2017-05-15 14:43:51 +03:00
SCARDAPI_STUB_CALL_LONG(SCardSetCardTypeProviderNameW, hContext, szCardName, dwProviderId,
szProvider);
2014-04-03 04:54:46 +04:00
}
WINSCARDAPI LONG WINAPI SCardForgetCardTypeA(SCARDCONTEXT hContext, LPCSTR szCardName)
{
SCARDAPI_STUB_CALL_LONG(SCardForgetCardTypeA, hContext, szCardName);
2014-04-03 04:54:46 +04:00
}
2014-04-03 04:54:46 +04:00
WINSCARDAPI LONG WINAPI SCardForgetCardTypeW(SCARDCONTEXT hContext, LPCWSTR szCardName)
{
SCARDAPI_STUB_CALL_LONG(SCardForgetCardTypeW, hContext, szCardName);
2014-04-03 04:54:46 +04:00
}
2020-02-17 12:53:46 +03:00
WINSCARDAPI LONG WINAPI SCardFreeMemory(SCARDCONTEXT hContext, LPVOID pvMem)
2014-04-03 04:54:46 +04:00
{
SCARDAPI_STUB_CALL_LONG(SCardFreeMemory, hContext, pvMem);
2014-04-03 04:54:46 +04:00
}
WINSCARDAPI HANDLE WINAPI SCardAccessStartedEvent(void)
{
SCARDAPI_STUB_CALL_HANDLE(SCardAccessStartedEvent);
2014-04-03 04:54:46 +04:00
}
WINSCARDAPI void WINAPI SCardReleaseStartedEvent(void)
{
SCARDAPI_STUB_CALL_VOID(SCardReleaseStartedEvent);
2014-04-03 04:54:46 +04:00
}
2019-11-06 17:24:51 +03:00
WINSCARDAPI LONG WINAPI SCardLocateCardsA(SCARDCONTEXT hContext, LPCSTR mszCards,
LPSCARD_READERSTATEA rgReaderStates, DWORD cReaders)
2014-04-03 04:54:46 +04:00
{
SCARDAPI_STUB_CALL_LONG(SCardLocateCardsA, hContext, mszCards, rgReaderStates, cReaders);
2014-04-03 04:54:46 +04:00
}
2019-11-06 17:24:51 +03:00
WINSCARDAPI LONG WINAPI SCardLocateCardsW(SCARDCONTEXT hContext, LPCWSTR mszCards,
LPSCARD_READERSTATEW rgReaderStates, DWORD cReaders)
2014-04-03 04:54:46 +04:00
{
SCARDAPI_STUB_CALL_LONG(SCardLocateCardsW, hContext, mszCards, rgReaderStates, cReaders);
2014-04-03 04:54:46 +04:00
}
2019-11-06 17:24:51 +03:00
WINSCARDAPI LONG WINAPI SCardLocateCardsByATRA(SCARDCONTEXT hContext, LPSCARD_ATRMASK rgAtrMasks,
DWORD cAtrs, LPSCARD_READERSTATEA rgReaderStates,
DWORD cReaders)
2014-04-03 04:54:46 +04:00
{
2017-05-15 14:43:51 +03:00
SCARDAPI_STUB_CALL_LONG(SCardLocateCardsByATRA, hContext, rgAtrMasks, cAtrs, rgReaderStates,
cReaders);
2014-04-03 04:54:46 +04:00
}
2019-11-06 17:24:51 +03:00
WINSCARDAPI LONG WINAPI SCardLocateCardsByATRW(SCARDCONTEXT hContext, LPSCARD_ATRMASK rgAtrMasks,
DWORD cAtrs, LPSCARD_READERSTATEW rgReaderStates,
DWORD cReaders)
2014-04-03 04:54:46 +04:00
{
2017-05-15 14:43:51 +03:00
SCARDAPI_STUB_CALL_LONG(SCardLocateCardsByATRW, hContext, rgAtrMasks, cAtrs, rgReaderStates,
cReaders);
2014-04-03 04:54:46 +04:00
}
2019-11-06 17:24:51 +03:00
WINSCARDAPI LONG WINAPI SCardGetStatusChangeA(SCARDCONTEXT hContext, DWORD dwTimeout,
LPSCARD_READERSTATEA rgReaderStates, DWORD cReaders)
2014-04-03 04:54:46 +04:00
{
SCARDAPI_STUB_CALL_LONG(SCardGetStatusChangeA, hContext, dwTimeout, rgReaderStates, cReaders);
2014-04-03 04:54:46 +04:00
}
2019-11-06 17:24:51 +03:00
WINSCARDAPI LONG WINAPI SCardGetStatusChangeW(SCARDCONTEXT hContext, DWORD dwTimeout,
LPSCARD_READERSTATEW rgReaderStates, DWORD cReaders)
2014-04-03 04:54:46 +04:00
{
SCARDAPI_STUB_CALL_LONG(SCardGetStatusChangeW, hContext, dwTimeout, rgReaderStates, cReaders);
2014-04-03 04:54:46 +04:00
}
WINSCARDAPI LONG WINAPI SCardCancel(SCARDCONTEXT hContext)
{
SCARDAPI_STUB_CALL_LONG(SCardCancel, hContext);
}
2019-11-06 17:24:51 +03:00
WINSCARDAPI LONG WINAPI SCardConnectA(SCARDCONTEXT hContext, LPCSTR szReader, DWORD dwShareMode,
DWORD dwPreferredProtocols, LPSCARDHANDLE phCard,
LPDWORD pdwActiveProtocol)
2014-04-03 04:54:46 +04:00
{
2019-11-06 17:24:51 +03:00
SCARDAPI_STUB_CALL_LONG(SCardConnectA, hContext, szReader, dwShareMode, dwPreferredProtocols,
phCard, pdwActiveProtocol);
2014-04-03 04:54:46 +04:00
}
2019-11-06 17:24:51 +03:00
WINSCARDAPI LONG WINAPI SCardConnectW(SCARDCONTEXT hContext, LPCWSTR szReader, DWORD dwShareMode,
DWORD dwPreferredProtocols, LPSCARDHANDLE phCard,
LPDWORD pdwActiveProtocol)
2014-04-03 04:54:46 +04:00
{
2019-11-06 17:24:51 +03:00
SCARDAPI_STUB_CALL_LONG(SCardConnectW, hContext, szReader, dwShareMode, dwPreferredProtocols,
phCard, pdwActiveProtocol);
2014-04-03 04:54:46 +04:00
}
2019-11-06 17:24:51 +03:00
WINSCARDAPI LONG WINAPI SCardReconnect(SCARDHANDLE hCard, DWORD dwShareMode,
DWORD dwPreferredProtocols, DWORD dwInitialization,
LPDWORD pdwActiveProtocol)
2014-04-03 04:54:46 +04:00
{
2019-11-06 17:24:51 +03:00
SCARDAPI_STUB_CALL_LONG(SCardReconnect, hCard, dwShareMode, dwPreferredProtocols,
dwInitialization, pdwActiveProtocol);
2014-04-03 04:54:46 +04:00
}
WINSCARDAPI LONG WINAPI SCardDisconnect(SCARDHANDLE hCard, DWORD dwDisposition)
{
SCARDAPI_STUB_CALL_LONG(SCardDisconnect, hCard, dwDisposition);
2014-04-03 04:54:46 +04:00
}
WINSCARDAPI LONG WINAPI SCardBeginTransaction(SCARDHANDLE hCard)
{
SCARDAPI_STUB_CALL_LONG(SCardBeginTransaction, hCard);
2014-04-03 04:54:46 +04:00
}
WINSCARDAPI LONG WINAPI SCardEndTransaction(SCARDHANDLE hCard, DWORD dwDisposition)
{
SCARDAPI_STUB_CALL_LONG(SCardEndTransaction, hCard, dwDisposition);
2014-04-03 04:54:46 +04:00
}
WINSCARDAPI LONG WINAPI SCardCancelTransaction(SCARDHANDLE hCard)
{
SCARDAPI_STUB_CALL_LONG(SCardCancelTransaction, hCard);
2014-04-03 04:54:46 +04:00
}
2019-11-06 17:24:51 +03:00
WINSCARDAPI LONG WINAPI SCardState(SCARDHANDLE hCard, LPDWORD pdwState, LPDWORD pdwProtocol,
LPBYTE pbAtr, LPDWORD pcbAtrLen)
2014-04-03 04:54:46 +04:00
{
SCARDAPI_STUB_CALL_LONG(SCardState, hCard, pdwState, pdwProtocol, pbAtr, pcbAtrLen);
2014-04-03 04:54:46 +04:00
}
2019-11-06 17:24:51 +03:00
WINSCARDAPI LONG WINAPI SCardStatusA(SCARDHANDLE hCard, LPSTR mszReaderNames, LPDWORD pcchReaderLen,
LPDWORD pdwState, LPDWORD pdwProtocol, LPBYTE pbAtr,
LPDWORD pcbAtrLen)
2014-04-03 04:54:46 +04:00
{
2019-11-06 17:24:51 +03:00
SCARDAPI_STUB_CALL_LONG(SCardStatusA, hCard, mszReaderNames, pcchReaderLen, pdwState,
pdwProtocol, pbAtr, pcbAtrLen);
2014-04-03 04:54:46 +04:00
}
2019-11-06 17:24:51 +03:00
WINSCARDAPI LONG WINAPI SCardStatusW(SCARDHANDLE hCard, LPWSTR mszReaderNames,
LPDWORD pcchReaderLen, LPDWORD pdwState, LPDWORD pdwProtocol,
LPBYTE pbAtr, LPDWORD pcbAtrLen)
2014-04-03 04:54:46 +04:00
{
2019-11-06 17:24:51 +03:00
SCARDAPI_STUB_CALL_LONG(SCardStatusW, hCard, mszReaderNames, pcchReaderLen, pdwState,
pdwProtocol, pbAtr, pcbAtrLen);
2014-04-03 04:54:46 +04:00
}
2019-11-06 17:24:51 +03:00
WINSCARDAPI LONG WINAPI SCardTransmit(SCARDHANDLE hCard, LPCSCARD_IO_REQUEST pioSendPci,
LPCBYTE pbSendBuffer, DWORD cbSendLength,
LPSCARD_IO_REQUEST pioRecvPci, LPBYTE pbRecvBuffer,
LPDWORD pcbRecvLength)
2014-04-03 04:54:46 +04:00
{
SCARDAPI_STUB_CALL_LONG(SCardTransmit, hCard, pioSendPci, pbSendBuffer, cbSendLength,
2017-05-15 14:43:51 +03:00
pioRecvPci, pbRecvBuffer, pcbRecvLength);
2014-04-03 04:54:46 +04:00
}
WINSCARDAPI LONG WINAPI SCardGetTransmitCount(SCARDHANDLE hCard, LPDWORD pcTransmitCount)
{
SCARDAPI_STUB_CALL_LONG(SCardGetTransmitCount, hCard, pcTransmitCount);
2014-04-03 04:54:46 +04:00
}
2019-11-06 17:24:51 +03:00
WINSCARDAPI LONG WINAPI SCardControl(SCARDHANDLE hCard, DWORD dwControlCode, LPCVOID lpInBuffer,
DWORD cbInBufferSize, LPVOID lpOutBuffer,
DWORD cbOutBufferSize, LPDWORD lpBytesReturned)
2014-04-03 04:54:46 +04:00
{
SCARDAPI_STUB_CALL_LONG(SCardControl, hCard, dwControlCode, lpInBuffer, cbInBufferSize,
2017-05-15 14:43:51 +03:00
lpOutBuffer, cbOutBufferSize, lpBytesReturned);
2014-04-03 04:54:46 +04:00
}
2017-05-15 14:43:51 +03:00
WINSCARDAPI LONG WINAPI SCardGetAttrib(SCARDHANDLE hCard, DWORD dwAttrId, LPBYTE pbAttr,
LPDWORD pcbAttrLen)
2014-04-03 04:54:46 +04:00
{
SCARDAPI_STUB_CALL_LONG(SCardGetAttrib, hCard, dwAttrId, pbAttr, pcbAttrLen);
2014-04-03 04:54:46 +04:00
}
2017-05-15 14:43:51 +03:00
WINSCARDAPI LONG WINAPI SCardSetAttrib(SCARDHANDLE hCard, DWORD dwAttrId, LPCBYTE pbAttr,
DWORD cbAttrLen)
2014-04-03 04:54:46 +04:00
{
SCARDAPI_STUB_CALL_LONG(SCardSetAttrib, hCard, dwAttrId, pbAttr, cbAttrLen);
2014-04-03 04:54:46 +04:00
}
WINSCARDAPI LONG WINAPI SCardUIDlgSelectCardA(LPOPENCARDNAMEA_EX pDlgStruc)
{
SCARDAPI_STUB_CALL_LONG(SCardUIDlgSelectCardA, pDlgStruc);
2014-04-03 04:54:46 +04:00
}
2014-04-03 04:54:46 +04:00
WINSCARDAPI LONG WINAPI SCardUIDlgSelectCardW(LPOPENCARDNAMEW_EX pDlgStruc)
{
SCARDAPI_STUB_CALL_LONG(SCardUIDlgSelectCardW, pDlgStruc);
2014-04-03 04:54:46 +04:00
}
WINSCARDAPI LONG WINAPI GetOpenCardNameA(LPOPENCARDNAMEA pDlgStruc)
{
SCARDAPI_STUB_CALL_LONG(GetOpenCardNameA, pDlgStruc);
2014-04-03 04:54:46 +04:00
}
2014-04-03 04:54:46 +04:00
WINSCARDAPI LONG WINAPI GetOpenCardNameW(LPOPENCARDNAMEW pDlgStruc)
{
SCARDAPI_STUB_CALL_LONG(GetOpenCardNameW, pDlgStruc);
2014-04-03 04:54:46 +04:00
}
WINSCARDAPI LONG WINAPI SCardDlgExtendedError(void)
{
SCARDAPI_STUB_CALL_LONG(SCardDlgExtendedError);
2014-04-03 04:54:46 +04:00
}
2019-11-06 17:24:51 +03:00
WINSCARDAPI LONG WINAPI SCardReadCacheA(SCARDCONTEXT hContext, UUID* CardIdentifier,
DWORD FreshnessCounter, LPSTR LookupName, PBYTE Data,
DWORD* DataLen)
2014-04-03 04:54:46 +04:00
{
2019-11-06 17:24:51 +03:00
SCARDAPI_STUB_CALL_LONG(SCardReadCacheA, hContext, CardIdentifier, FreshnessCounter, LookupName,
Data, DataLen);
2014-04-03 04:54:46 +04:00
}
2019-11-06 17:24:51 +03:00
WINSCARDAPI LONG WINAPI SCardReadCacheW(SCARDCONTEXT hContext, UUID* CardIdentifier,
DWORD FreshnessCounter, LPWSTR LookupName, PBYTE Data,
DWORD* DataLen)
2014-04-03 04:54:46 +04:00
{
2019-11-06 17:24:51 +03:00
SCARDAPI_STUB_CALL_LONG(SCardReadCacheW, hContext, CardIdentifier, FreshnessCounter, LookupName,
Data, DataLen);
2014-04-03 04:54:46 +04:00
}
2019-11-06 17:24:51 +03:00
WINSCARDAPI LONG WINAPI SCardWriteCacheA(SCARDCONTEXT hContext, UUID* CardIdentifier,
DWORD FreshnessCounter, LPSTR LookupName, PBYTE Data,
DWORD DataLen)
2014-04-03 04:54:46 +04:00
{
2019-11-06 17:24:51 +03:00
SCARDAPI_STUB_CALL_LONG(SCardWriteCacheA, hContext, CardIdentifier, FreshnessCounter,
LookupName, Data, DataLen);
2014-04-03 04:54:46 +04:00
}
2019-11-06 17:24:51 +03:00
WINSCARDAPI LONG WINAPI SCardWriteCacheW(SCARDCONTEXT hContext, UUID* CardIdentifier,
DWORD FreshnessCounter, LPWSTR LookupName, PBYTE Data,
DWORD DataLen)
2014-04-03 04:54:46 +04:00
{
2019-11-06 17:24:51 +03:00
SCARDAPI_STUB_CALL_LONG(SCardWriteCacheW, hContext, CardIdentifier, FreshnessCounter,
LookupName, Data, DataLen);
2014-04-03 04:54:46 +04:00
}
2019-11-06 17:24:51 +03:00
WINSCARDAPI LONG WINAPI SCardGetReaderIconA(SCARDCONTEXT hContext, LPCSTR szReaderName,
LPBYTE pbIcon, LPDWORD pcbIcon)
2014-04-03 04:54:46 +04:00
{
SCARDAPI_STUB_CALL_LONG(SCardGetReaderIconA, hContext, szReaderName, pbIcon, pcbIcon);
2014-04-03 04:54:46 +04:00
}
2019-11-06 17:24:51 +03:00
WINSCARDAPI LONG WINAPI SCardGetReaderIconW(SCARDCONTEXT hContext, LPCWSTR szReaderName,
LPBYTE pbIcon, LPDWORD pcbIcon)
2014-04-03 04:54:46 +04:00
{
SCARDAPI_STUB_CALL_LONG(SCardGetReaderIconW, hContext, szReaderName, pbIcon, pcbIcon);
2014-04-03 04:54:46 +04:00
}
2017-05-15 14:43:51 +03:00
WINSCARDAPI LONG WINAPI SCardGetDeviceTypeIdA(SCARDCONTEXT hContext, LPCSTR szReaderName,
2019-11-06 17:24:51 +03:00
LPDWORD pdwDeviceTypeId)
2014-04-03 04:54:46 +04:00
{
SCARDAPI_STUB_CALL_LONG(SCardGetDeviceTypeIdA, hContext, szReaderName, pdwDeviceTypeId);
2014-04-03 04:54:46 +04:00
}
2017-05-15 14:43:51 +03:00
WINSCARDAPI LONG WINAPI SCardGetDeviceTypeIdW(SCARDCONTEXT hContext, LPCWSTR szReaderName,
2019-11-06 17:24:51 +03:00
LPDWORD pdwDeviceTypeId)
2014-04-03 04:54:46 +04:00
{
SCARDAPI_STUB_CALL_LONG(SCardGetDeviceTypeIdW, hContext, szReaderName, pdwDeviceTypeId);
2014-04-03 04:54:46 +04:00
}
2019-11-06 17:24:51 +03:00
WINSCARDAPI LONG WINAPI SCardGetReaderDeviceInstanceIdA(SCARDCONTEXT hContext, LPCSTR szReaderName,
LPSTR szDeviceInstanceId,
LPDWORD pcchDeviceInstanceId)
2014-04-03 04:54:46 +04:00
{
SCARDAPI_STUB_CALL_LONG(SCardGetReaderDeviceInstanceIdA, hContext, szReaderName,
2017-05-15 14:43:51 +03:00
szDeviceInstanceId, pcchDeviceInstanceId);
2014-04-03 04:54:46 +04:00
}
2019-11-06 17:24:51 +03:00
WINSCARDAPI LONG WINAPI SCardGetReaderDeviceInstanceIdW(SCARDCONTEXT hContext, LPCWSTR szReaderName,
LPWSTR szDeviceInstanceId,
LPDWORD pcchDeviceInstanceId)
2014-04-03 04:54:46 +04:00
{
SCARDAPI_STUB_CALL_LONG(SCardGetReaderDeviceInstanceIdW, hContext, szReaderName,
2017-05-15 14:43:51 +03:00
szDeviceInstanceId, pcchDeviceInstanceId);
2014-04-03 04:54:46 +04:00
}
WINSCARDAPI LONG WINAPI SCardListReadersWithDeviceInstanceIdA(SCARDCONTEXT hContext,
2019-11-06 17:24:51 +03:00
LPCSTR szDeviceInstanceId,
LPSTR mszReaders, LPDWORD pcchReaders)
2014-04-03 04:54:46 +04:00
{
2019-11-06 17:24:51 +03:00
SCARDAPI_STUB_CALL_LONG(SCardListReadersWithDeviceInstanceIdA, hContext, szDeviceInstanceId,
mszReaders, pcchReaders);
2014-04-03 04:54:46 +04:00
}
2014-04-03 04:54:46 +04:00
WINSCARDAPI LONG WINAPI SCardListReadersWithDeviceInstanceIdW(SCARDCONTEXT hContext,
2019-11-06 17:24:51 +03:00
LPCWSTR szDeviceInstanceId,
LPWSTR mszReaders,
LPDWORD pcchReaders)
2014-04-03 04:54:46 +04:00
{
2019-11-06 17:24:51 +03:00
SCARDAPI_STUB_CALL_LONG(SCardListReadersWithDeviceInstanceIdW, hContext, szDeviceInstanceId,
mszReaders, pcchReaders);
2014-04-03 04:54:46 +04:00
}
WINSCARDAPI LONG WINAPI SCardAudit(SCARDCONTEXT hContext, DWORD dwEvent)
{
SCARDAPI_STUB_CALL_LONG(SCardAudit, hContext, dwEvent);
2014-04-03 04:54:46 +04:00
}
/**
* Extended API
*/
WINSCARDAPI const char* WINAPI SCardGetErrorString(LONG errorCode)
{
switch (errorCode)
{
case SCARD_S_SUCCESS:
return "SCARD_S_SUCCESS";
2017-05-15 14:43:51 +03:00
case SCARD_F_INTERNAL_ERROR:
return "SCARD_F_INTERNAL_ERROR";
2017-05-15 14:43:51 +03:00
case SCARD_E_CANCELLED:
return "SCARD_E_CANCELLED";
2017-05-15 14:43:51 +03:00
case SCARD_E_INVALID_HANDLE:
return "SCARD_E_INVALID_HANDLE";
2017-05-15 14:43:51 +03:00
case SCARD_E_INVALID_PARAMETER:
return "SCARD_E_INVALID_PARAMETER";
2017-05-15 14:43:51 +03:00
case SCARD_E_INVALID_TARGET:
return "SCARD_E_INVALID_TARGET";
2017-05-15 14:43:51 +03:00
case SCARD_E_NO_MEMORY:
return "SCARD_E_NO_MEMORY";
2017-05-15 14:43:51 +03:00
case SCARD_F_WAITED_TOO_LONG:
return "SCARD_F_WAITED_TOO_LONG";
2017-05-15 14:43:51 +03:00
case SCARD_E_INSUFFICIENT_BUFFER:
return "SCARD_E_INSUFFICIENT_BUFFER";
2017-05-15 14:43:51 +03:00
case SCARD_E_UNKNOWN_READER:
return "SCARD_E_UNKNOWN_READER";
2017-05-15 14:43:51 +03:00
case SCARD_E_TIMEOUT:
return "SCARD_E_TIMEOUT";
2017-05-15 14:43:51 +03:00
case SCARD_E_SHARING_VIOLATION:
return "SCARD_E_SHARING_VIOLATION";
2017-05-15 14:43:51 +03:00
case SCARD_E_NO_SMARTCARD:
return "SCARD_E_NO_SMARTCARD";
2017-05-15 14:43:51 +03:00
case SCARD_E_UNKNOWN_CARD:
return "SCARD_E_UNKNOWN_CARD";
2017-05-15 14:43:51 +03:00
case SCARD_E_CANT_DISPOSE:
return "SCARD_E_CANT_DISPOSE";
2017-05-15 14:43:51 +03:00
case SCARD_E_PROTO_MISMATCH:
return "SCARD_E_PROTO_MISMATCH";
2017-05-15 14:43:51 +03:00
case SCARD_E_NOT_READY:
return "SCARD_E_NOT_READY";
2017-05-15 14:43:51 +03:00
case SCARD_E_INVALID_VALUE:
return "SCARD_E_INVALID_VALUE";
2017-05-15 14:43:51 +03:00
case SCARD_E_SYSTEM_CANCELLED:
return "SCARD_E_SYSTEM_CANCELLED";
2017-05-15 14:43:51 +03:00
case SCARD_F_COMM_ERROR:
return "SCARD_F_COMM_ERROR";
2017-05-15 14:43:51 +03:00
case SCARD_F_UNKNOWN_ERROR:
return "SCARD_F_UNKNOWN_ERROR";
2017-05-15 14:43:51 +03:00
case SCARD_E_INVALID_ATR:
return "SCARD_E_INVALID_ATR";
2017-05-15 14:43:51 +03:00
case SCARD_E_NOT_TRANSACTED:
return "SCARD_E_NOT_TRANSACTED";
2017-05-15 14:43:51 +03:00
case SCARD_E_READER_UNAVAILABLE:
return "SCARD_E_READER_UNAVAILABLE";
2017-05-15 14:43:51 +03:00
case SCARD_P_SHUTDOWN:
return "SCARD_P_SHUTDOWN";
2017-05-15 14:43:51 +03:00
case SCARD_E_PCI_TOO_SMALL:
return "SCARD_E_PCI_TOO_SMALL";
2017-05-15 14:43:51 +03:00
case SCARD_E_READER_UNSUPPORTED:
return "SCARD_E_READER_UNSUPPORTED";
2017-05-15 14:43:51 +03:00
case SCARD_E_DUPLICATE_READER:
return "SCARD_E_DUPLICATE_READER";
2017-05-15 14:43:51 +03:00
case SCARD_E_CARD_UNSUPPORTED:
return "SCARD_E_CARD_UNSUPPORTED";
2017-05-15 14:43:51 +03:00
case SCARD_E_NO_SERVICE:
return "SCARD_E_NO_SERVICE";
2017-05-15 14:43:51 +03:00
case SCARD_E_SERVICE_STOPPED:
return "SCARD_E_SERVICE_STOPPED";
2017-05-15 14:43:51 +03:00
case SCARD_E_UNEXPECTED:
return "SCARD_E_UNEXPECTED";
2017-05-15 14:43:51 +03:00
case SCARD_E_ICC_INSTALLATION:
return "SCARD_E_ICC_INSTALLATION";
2017-05-15 14:43:51 +03:00
case SCARD_E_ICC_CREATEORDER:
return "SCARD_E_ICC_CREATEORDER";
2017-05-15 14:43:51 +03:00
case SCARD_E_UNSUPPORTED_FEATURE:
return "SCARD_E_UNSUPPORTED_FEATURE";
2017-05-15 14:43:51 +03:00
case SCARD_E_DIR_NOT_FOUND:
return "SCARD_E_DIR_NOT_FOUND";
2017-05-15 14:43:51 +03:00
case SCARD_E_FILE_NOT_FOUND:
return "SCARD_E_FILE_NOT_FOUND";
2017-05-15 14:43:51 +03:00
case SCARD_E_NO_DIR:
return "SCARD_E_NO_DIR";
2017-05-15 14:43:51 +03:00
case SCARD_E_NO_FILE:
return "SCARD_E_NO_FILE";
2017-05-15 14:43:51 +03:00
case SCARD_E_NO_ACCESS:
return "SCARD_E_NO_ACCESS";
2017-05-15 14:43:51 +03:00
case SCARD_E_WRITE_TOO_MANY:
return "SCARD_E_WRITE_TOO_MANY";
2017-05-15 14:43:51 +03:00
case SCARD_E_BAD_SEEK:
return "SCARD_E_BAD_SEEK";
2017-05-15 14:43:51 +03:00
case SCARD_E_INVALID_CHV:
return "SCARD_E_INVALID_CHV";
2017-05-15 14:43:51 +03:00
case SCARD_E_UNKNOWN_RES_MNG:
return "SCARD_E_UNKNOWN_RES_MNG";
2017-05-15 14:43:51 +03:00
case SCARD_E_NO_SUCH_CERTIFICATE:
return "SCARD_E_NO_SUCH_CERTIFICATE";
2017-05-15 14:43:51 +03:00
case SCARD_E_CERTIFICATE_UNAVAILABLE:
return "SCARD_E_CERTIFICATE_UNAVAILABLE";
2017-05-15 14:43:51 +03:00
case SCARD_E_NO_READERS_AVAILABLE:
return "SCARD_E_NO_READERS_AVAILABLE";
2017-05-15 14:43:51 +03:00
case SCARD_E_COMM_DATA_LOST:
return "SCARD_E_COMM_DATA_LOST";
2017-05-15 14:43:51 +03:00
case SCARD_E_NO_KEY_CONTAINER:
return "SCARD_E_NO_KEY_CONTAINER";
2017-05-15 14:43:51 +03:00
case SCARD_E_SERVER_TOO_BUSY:
return "SCARD_E_SERVER_TOO_BUSY";
2017-05-15 14:43:51 +03:00
case SCARD_E_PIN_CACHE_EXPIRED:
return "SCARD_E_PIN_CACHE_EXPIRED";
2017-05-15 14:43:51 +03:00
case SCARD_E_NO_PIN_CACHE:
return "SCARD_E_NO_PIN_CACHE";
2017-05-15 14:43:51 +03:00
case SCARD_E_READ_ONLY_CARD:
return "SCARD_E_READ_ONLY_CARD";
2017-05-15 14:43:51 +03:00
case SCARD_W_UNSUPPORTED_CARD:
return "SCARD_W_UNSUPPORTED_CARD";
2017-05-15 14:43:51 +03:00
case SCARD_W_UNRESPONSIVE_CARD:
return "SCARD_W_UNRESPONSIVE_CARD";
2017-05-15 14:43:51 +03:00
case SCARD_W_UNPOWERED_CARD:
return "SCARD_W_UNPOWERED_CARD";
2017-05-15 14:43:51 +03:00
case SCARD_W_RESET_CARD:
return "SCARD_W_RESET_CARD";
2017-05-15 14:43:51 +03:00
case SCARD_W_REMOVED_CARD:
return "SCARD_W_REMOVED_CARD";
2017-05-15 14:43:51 +03:00
case SCARD_W_SECURITY_VIOLATION:
return "SCARD_W_SECURITY_VIOLATION";
2017-05-15 14:43:51 +03:00
case SCARD_W_WRONG_CHV:
return "SCARD_W_WRONG_CHV";
2017-05-15 14:43:51 +03:00
case SCARD_W_CHV_BLOCKED:
return "SCARD_W_CHV_BLOCKED";
2017-05-15 14:43:51 +03:00
case SCARD_W_EOF:
return "SCARD_W_EOF";
2017-05-15 14:43:51 +03:00
case SCARD_W_CANCELLED_BY_USER:
return "SCARD_W_CANCELLED_BY_USER";
2017-05-15 14:43:51 +03:00
case SCARD_W_CARD_NOT_AUTHENTICATED:
return "SCARD_W_CARD_NOT_AUTHENTICATED";
2017-05-15 14:43:51 +03:00
case SCARD_W_CACHE_ITEM_NOT_FOUND:
return "SCARD_W_CACHE_ITEM_NOT_FOUND";
2017-05-15 14:43:51 +03:00
case SCARD_W_CACHE_ITEM_STALE:
return "SCARD_W_CACHE_ITEM_STALE";
2017-05-15 14:43:51 +03:00
case SCARD_W_CACHE_ITEM_TOO_BIG:
return "SCARD_W_CACHE_ITEM_TOO_BIG";
2017-05-15 14:43:51 +03:00
default:
return "SCARD_E_UNKNOWN";
}
}
WINSCARDAPI const char* WINAPI SCardGetAttributeString(DWORD dwAttrId)
{
switch (dwAttrId)
{
case SCARD_ATTR_VENDOR_NAME:
return "SCARD_ATTR_VENDOR_NAME";
2017-05-15 14:43:51 +03:00
case SCARD_ATTR_VENDOR_IFD_TYPE:
return "SCARD_ATTR_VENDOR_IFD_TYPE";
2017-05-15 14:43:51 +03:00
case SCARD_ATTR_VENDOR_IFD_VERSION:
return "SCARD_ATTR_VENDOR_IFD_VERSION";
2017-05-15 14:43:51 +03:00
case SCARD_ATTR_VENDOR_IFD_SERIAL_NO:
return "SCARD_ATTR_VENDOR_IFD_SERIAL_NO";
2017-05-15 14:43:51 +03:00
case SCARD_ATTR_CHANNEL_ID:
return "SCARD_ATTR_CHANNEL_ID";
2017-05-15 14:43:51 +03:00
case SCARD_ATTR_PROTOCOL_TYPES:
return "SCARD_ATTR_PROTOCOL_TYPES";
2017-05-15 14:43:51 +03:00
case SCARD_ATTR_DEFAULT_CLK:
return "SCARD_ATTR_DEFAULT_CLK";
2017-05-15 14:43:51 +03:00
case SCARD_ATTR_MAX_CLK:
return "SCARD_ATTR_MAX_CLK";
2017-05-15 14:43:51 +03:00
case SCARD_ATTR_DEFAULT_DATA_RATE:
return "SCARD_ATTR_DEFAULT_DATA_RATE";
2017-05-15 14:43:51 +03:00
case SCARD_ATTR_MAX_DATA_RATE:
return "SCARD_ATTR_MAX_DATA_RATE";
2017-05-15 14:43:51 +03:00
case SCARD_ATTR_MAX_IFSD:
return "SCARD_ATTR_MAX_IFSD";
2017-05-15 14:43:51 +03:00
case SCARD_ATTR_POWER_MGMT_SUPPORT:
return "SCARD_ATTR_POWER_MGMT_SUPPORT";
2017-05-15 14:43:51 +03:00
case SCARD_ATTR_USER_TO_CARD_AUTH_DEVICE:
return "SCARD_ATTR_USER_TO_CARD_AUTH_DEVICE";
2017-05-15 14:43:51 +03:00
case SCARD_ATTR_USER_AUTH_INPUT_DEVICE:
return "SCARD_ATTR_USER_AUTH_INPUT_DEVICE";
2017-05-15 14:43:51 +03:00
case SCARD_ATTR_CHARACTERISTICS:
return "SCARD_ATTR_CHARACTERISTICS";
2017-05-15 14:43:51 +03:00
case SCARD_ATTR_CURRENT_PROTOCOL_TYPE:
return "SCARD_ATTR_CURRENT_PROTOCOL_TYPE";
2017-05-15 14:43:51 +03:00
case SCARD_ATTR_CURRENT_CLK:
return "SCARD_ATTR_CURRENT_CLK";
2017-05-15 14:43:51 +03:00
case SCARD_ATTR_CURRENT_F:
return "SCARD_ATTR_CURRENT_F";
2017-05-15 14:43:51 +03:00
case SCARD_ATTR_CURRENT_D:
return "SCARD_ATTR_CURRENT_D";
2017-05-15 14:43:51 +03:00
case SCARD_ATTR_CURRENT_N:
return "SCARD_ATTR_CURRENT_N";
2017-05-15 14:43:51 +03:00
case SCARD_ATTR_CURRENT_W:
return "SCARD_ATTR_CURRENT_W";
2017-05-15 14:43:51 +03:00
case SCARD_ATTR_CURRENT_IFSC:
return "SCARD_ATTR_CURRENT_IFSC";
2017-05-15 14:43:51 +03:00
case SCARD_ATTR_CURRENT_IFSD:
return "SCARD_ATTR_CURRENT_IFSD";
2017-05-15 14:43:51 +03:00
case SCARD_ATTR_CURRENT_BWT:
return "SCARD_ATTR_CURRENT_BWT";
2017-05-15 14:43:51 +03:00
case SCARD_ATTR_CURRENT_CWT:
return "SCARD_ATTR_CURRENT_CWT";
2017-05-15 14:43:51 +03:00
case SCARD_ATTR_CURRENT_EBC_ENCODING:
return "SCARD_ATTR_CURRENT_EBC_ENCODING";
2017-05-15 14:43:51 +03:00
case SCARD_ATTR_EXTENDED_BWT:
return "SCARD_ATTR_EXTENDED_BWT";
2017-05-15 14:43:51 +03:00
case SCARD_ATTR_ICC_PRESENCE:
return "SCARD_ATTR_ICC_PRESENCE";
2017-05-15 14:43:51 +03:00
case SCARD_ATTR_ICC_INTERFACE_STATUS:
return "SCARD_ATTR_ICC_INTERFACE_STATUS";
2017-05-15 14:43:51 +03:00
case SCARD_ATTR_CURRENT_IO_STATE:
return "SCARD_ATTR_CURRENT_IO_STATE";
2017-05-15 14:43:51 +03:00
case SCARD_ATTR_ATR_STRING:
return "SCARD_ATTR_ATR_STRING";
2017-05-15 14:43:51 +03:00
case SCARD_ATTR_ICC_TYPE_PER_ATR:
return "SCARD_ATTR_ICC_TYPE_PER_ATR";
2017-05-15 14:43:51 +03:00
case SCARD_ATTR_ESC_RESET:
return "SCARD_ATTR_ESC_RESET";
2017-05-15 14:43:51 +03:00
case SCARD_ATTR_ESC_CANCEL:
return "SCARD_ATTR_ESC_CANCEL";
2017-05-15 14:43:51 +03:00
case SCARD_ATTR_ESC_AUTHREQUEST:
return "SCARD_ATTR_ESC_AUTHREQUEST";
2017-05-15 14:43:51 +03:00
case SCARD_ATTR_MAXINPUT:
return "SCARD_ATTR_MAXINPUT";
2017-05-15 14:43:51 +03:00
case SCARD_ATTR_DEVICE_UNIT:
return "SCARD_ATTR_DEVICE_UNIT";
2017-05-15 14:43:51 +03:00
case SCARD_ATTR_DEVICE_IN_USE:
return "SCARD_ATTR_DEVICE_IN_USE";
2017-05-15 14:43:51 +03:00
case SCARD_ATTR_DEVICE_FRIENDLY_NAME_A:
return "SCARD_ATTR_DEVICE_FRIENDLY_NAME_A";
2017-05-15 14:43:51 +03:00
case SCARD_ATTR_DEVICE_SYSTEM_NAME_A:
return "SCARD_ATTR_DEVICE_SYSTEM_NAME_A";
2017-05-15 14:43:51 +03:00
case SCARD_ATTR_DEVICE_FRIENDLY_NAME_W:
return "SCARD_ATTR_DEVICE_FRIENDLY_NAME_W";
2017-05-15 14:43:51 +03:00
case SCARD_ATTR_DEVICE_SYSTEM_NAME_W:
return "SCARD_ATTR_DEVICE_SYSTEM_NAME_W";
2017-05-15 14:43:51 +03:00
case SCARD_ATTR_SUPRESS_T1_IFS_REQUEST:
return "SCARD_ATTR_SUPRESS_T1_IFS_REQUEST";
2017-05-15 14:43:51 +03:00
default:
return "SCARD_ATTR_UNKNOWN";
}
}
WINSCARDAPI const char* WINAPI SCardGetProtocolString(DWORD dwProtocols)
{
if (dwProtocols == SCARD_PROTOCOL_UNDEFINED)
return "SCARD_PROTOCOL_UNDEFINED";
if (dwProtocols == SCARD_PROTOCOL_T0)
return "SCARD_PROTOCOL_T0";
if (dwProtocols == SCARD_PROTOCOL_T1)
return "SCARD_PROTOCOL_T1";
if (dwProtocols == SCARD_PROTOCOL_Tx)
return "SCARD_PROTOCOL_Tx";
if (dwProtocols == SCARD_PROTOCOL_RAW)
return "SCARD_PROTOCOL_RAW";
if (dwProtocols == SCARD_PROTOCOL_DEFAULT)
return "SCARD_PROTOCOL_DEFAULT";
if (dwProtocols == (SCARD_PROTOCOL_T0 | SCARD_PROTOCOL_RAW))
return "SCARD_PROTOCOL_T0 | SCARD_PROTOCOL_RAW";
if (dwProtocols == (SCARD_PROTOCOL_T1 | SCARD_PROTOCOL_RAW))
return "SCARD_PROTOCOL_T1 | SCARD_PROTOCOL_RAW";
if (dwProtocols == (SCARD_PROTOCOL_Tx | SCARD_PROTOCOL_RAW))
return "SCARD_PROTOCOL_Tx | SCARD_PROTOCOL_RAW";
return "SCARD_PROTOCOL_UNKNOWN";
}
WINSCARDAPI const char* WINAPI SCardGetShareModeString(DWORD dwShareMode)
{
switch (dwShareMode)
{
case SCARD_SHARE_EXCLUSIVE:
return "SCARD_SHARE_EXCLUSIVE";
2017-05-15 14:43:51 +03:00
case SCARD_SHARE_SHARED:
return "SCARD_SHARE_SHARED";
2017-05-15 14:43:51 +03:00
case SCARD_SHARE_DIRECT:
return "SCARD_SHARE_DIRECT";
2017-05-15 14:43:51 +03:00
default:
return "SCARD_SHARE_UNKNOWN";
}
}
WINSCARDAPI const char* WINAPI SCardGetDispositionString(DWORD dwDisposition)
{
switch (dwDisposition)
{
case SCARD_LEAVE_CARD:
return "SCARD_LEAVE_CARD";
2017-05-15 14:43:51 +03:00
case SCARD_RESET_CARD:
return "SCARD_RESET_CARD";
2017-05-15 14:43:51 +03:00
case SCARD_UNPOWER_CARD:
return "SCARD_UNPOWER_CARD";
2017-05-15 14:43:51 +03:00
default:
return "SCARD_UNKNOWN_CARD";
}
}
WINSCARDAPI const char* WINAPI SCardGetScopeString(DWORD dwScope)
{
switch (dwScope)
{
case SCARD_SCOPE_USER:
return "SCARD_SCOPE_USER";
2017-05-15 14:43:51 +03:00
case SCARD_SCOPE_TERMINAL:
return "SCARD_SCOPE_TERMINAL";
2017-05-15 14:43:51 +03:00
case SCARD_SCOPE_SYSTEM:
return "SCARD_SCOPE_SYSTEM";
2017-05-15 14:43:51 +03:00
default:
return "SCARD_SCOPE_UNKNOWN";
}
}
WINSCARDAPI const char* WINAPI SCardGetCardStateString(DWORD dwCardState)
{
switch (dwCardState)
{
case SCARD_UNKNOWN:
return "SCARD_UNKNOWN";
2017-05-15 14:43:51 +03:00
case SCARD_ABSENT:
return "SCARD_ABSENT";
2017-05-15 14:43:51 +03:00
case SCARD_PRESENT:
return "SCARD_PRESENT";
2017-05-15 14:43:51 +03:00
case SCARD_SWALLOWED:
return "SCARD_SWALLOWED";
2017-05-15 14:43:51 +03:00
case SCARD_POWERED:
return "SCARD_POWERED";
2017-05-15 14:43:51 +03:00
case SCARD_NEGOTIABLE:
return "SCARD_NEGOTIABLE";
2017-05-15 14:43:51 +03:00
case SCARD_SPECIFIC:
return "SCARD_SPECIFIC";
2017-05-15 14:43:51 +03:00
default:
return "SCARD_UNKNOWN";
}
}
WINSCARDAPI char* WINAPI SCardGetReaderStateString(DWORD dwReaderState)
{
char* szReaderState = malloc(512);
if (!szReaderState)
return NULL;
szReaderState[0] = '\0';
if (dwReaderState & SCARD_STATE_IGNORE)
{
if (szReaderState[0])
strcat(szReaderState, " | ");
2017-05-15 14:43:51 +03:00
strcat(szReaderState, "SCARD_STATE_IGNORE");
}
2017-05-15 14:43:51 +03:00
if (dwReaderState & SCARD_STATE_CHANGED)
{
if (szReaderState[0])
strcat(szReaderState, " | ");
2017-05-15 14:43:51 +03:00
strcat(szReaderState, "SCARD_STATE_CHANGED");
}
2017-05-15 14:43:51 +03:00
if (dwReaderState & SCARD_STATE_UNKNOWN)
{
if (szReaderState[0])
strcat(szReaderState, " | ");
2017-05-15 14:43:51 +03:00
strcat(szReaderState, "SCARD_STATE_UNKNOWN");
}
2017-05-15 14:43:51 +03:00
if (dwReaderState & SCARD_STATE_UNAVAILABLE)
{
if (szReaderState[0])
strcat(szReaderState, " | ");
2017-05-15 14:43:51 +03:00
strcat(szReaderState, "SCARD_STATE_UNAVAILABLE");
}
2017-05-15 14:43:51 +03:00
if (dwReaderState & SCARD_STATE_EMPTY)
{
if (szReaderState[0])
strcat(szReaderState, " | ");
2017-05-15 14:43:51 +03:00
strcat(szReaderState, "SCARD_STATE_EMPTY");
}
2017-05-15 14:43:51 +03:00
if (dwReaderState & SCARD_STATE_PRESENT)
{
if (szReaderState[0])
strcat(szReaderState, " | ");
2017-05-15 14:43:51 +03:00
strcat(szReaderState, "SCARD_STATE_PRESENT");
}
2017-05-15 14:43:51 +03:00
if (dwReaderState & SCARD_STATE_ATRMATCH)
{
if (szReaderState[0])
strcat(szReaderState, " | ");
2017-05-15 14:43:51 +03:00
strcat(szReaderState, "SCARD_STATE_ATRMATCH");
}
2017-05-15 14:43:51 +03:00
if (dwReaderState & SCARD_STATE_EXCLUSIVE)
{
if (szReaderState[0])
strcat(szReaderState, " | ");
2017-05-15 14:43:51 +03:00
strcat(szReaderState, "SCARD_STATE_EXCLUSIVE");
}
2017-05-15 14:43:51 +03:00
if (dwReaderState & SCARD_STATE_INUSE)
{
if (szReaderState[0])
strcat(szReaderState, " | ");
2017-05-15 14:43:51 +03:00
strcat(szReaderState, "SCARD_STATE_INUSE");
}
2017-05-15 14:43:51 +03:00
if (dwReaderState & SCARD_STATE_MUTE)
{
if (szReaderState[0])
strcat(szReaderState, " | ");
2017-05-15 14:43:51 +03:00
strcat(szReaderState, "SCARD_STATE_MUTE");
}
2017-05-15 14:43:51 +03:00
if (dwReaderState & SCARD_STATE_UNPOWERED)
{
if (szReaderState[0])
strcat(szReaderState, " | ");
2017-05-15 14:43:51 +03:00
strcat(szReaderState, "SCARD_STATE_UNPOWERED");
}
if (!szReaderState[0])
strcat(szReaderState, "SCARD_STATE_UNAWARE");
return szReaderState;
}