WinSCard dynamic API loading with /winscard-module cli argument

This commit is contained in:
Marc-André Moreau 2023-08-21 14:26:53 -04:00 committed by akallabeth
parent 98b4ff559b
commit 30c31d64e8
13 changed files with 268 additions and 109 deletions

View File

@ -2890,6 +2890,11 @@ static int freerdp_client_settings_parse_command_line_arguments_int(rdpSettings*
if (!freerdp_settings_set_string(settings, FreeRDP_SspiModule, arg->Value))
return COMMAND_LINE_ERROR_MEMORY;
}
CommandLineSwitchCase(arg, "winscard-module")
{
if (!freerdp_settings_set_string(settings, FreeRDP_WinSCardModule, arg->Value))
return COMMAND_LINE_ERROR_MEMORY;
}
CommandLineSwitchCase(arg, "redirect-prefer")
{
size_t count = 0;

View File

@ -435,6 +435,8 @@ static const COMMAND_LINE_ARGUMENT_A global_cmd_args[] = {
"SSH Agent forwarding channel" },
{ "sspi-module", COMMAND_LINE_VALUE_REQUIRED, "<SSPI module path>", NULL, NULL, -1, NULL,
"SSPI shared library module file path" },
{ "winscard-module", COMMAND_LINE_VALUE_REQUIRED, "<WinSCard module path>", NULL, NULL, -1,
NULL, "WinSCard shared library module file path" },
{ "disable-output", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL,
"Deactivate all graphics decoding in the client session. Useful for load tests with many "
"simultaneous connections" },

View File

@ -647,6 +647,7 @@ extern "C"
#define FreeRDP_AuthenticationPackageList (1110)
#define FreeRDP_RdstlsSecurity (1111)
#define FreeRDP_AadSecurity (1112)
#define FreeRDP_WinSCardModule (1113)
#define FreeRDP_MstscCookieMode (1152)
#define FreeRDP_CookieMaxLength (1153)
#define FreeRDP_PreconnectionId (1154)
@ -1168,7 +1169,8 @@ extern "C"
ALIGN64 char* AuthenticationPackageList; /* 1110 */
ALIGN64 BOOL RdstlsSecurity; /* 1111 */
ALIGN64 BOOL AadSecurity; /* 1112 */
UINT64 padding1152[1152 - 1113]; /* 1113 */
ALIGN64 char* WinSCardModule; /* 1113 */
UINT64 padding1152[1152 - 1114]; /* 1114 */
/* Connection Cookie */
ALIGN64 BOOL MstscCookieMode; /* 1152 */

View File

@ -2828,6 +2828,9 @@ const char* freerdp_settings_get_string(const rdpSettings* settings, size_t id)
case FreeRDP_Username:
return settings->Username;
case FreeRDP_WinSCardModule:
return settings->WinSCardModule;
case FreeRDP_WindowTitle:
return settings->WindowTitle;
@ -3106,6 +3109,9 @@ char* freerdp_settings_get_string_writable(rdpSettings* settings, size_t id)
case FreeRDP_Username:
return settings->Username;
case FreeRDP_WinSCardModule:
return settings->WinSCardModule;
case FreeRDP_WindowTitle:
return settings->WindowTitle;
@ -3393,6 +3399,9 @@ BOOL freerdp_settings_set_string_(rdpSettings* settings, size_t id, char* val, s
case FreeRDP_Username:
return update_string_(&settings->Username, cnv.c, len);
case FreeRDP_WinSCardModule:
return update_string_(&settings->WinSCardModule, cnv.c, len);
case FreeRDP_WindowTitle:
return update_string_(&settings->WindowTitle, cnv.c, len);
@ -3698,6 +3707,9 @@ BOOL freerdp_settings_set_string_copy_(rdpSettings* settings, size_t id, const c
case FreeRDP_Username:
return update_string_copy_(&settings->Username, cnv.cc, len, cleanup);
case FreeRDP_WinSCardModule:
return update_string_copy_(&settings->WinSCardModule, cnv.cc, len, cleanup);
case FreeRDP_WindowTitle:
return update_string_copy_(&settings->WindowTitle, cnv.cc, len, cleanup);

View File

@ -540,6 +540,7 @@ static const struct settings_str_entry settings_map[] = {
{ FreeRDP_UserSpecifiedServerName, FREERDP_SETTINGS_TYPE_STRING,
"FreeRDP_UserSpecifiedServerName" },
{ FreeRDP_Username, FREERDP_SETTINGS_TYPE_STRING, "FreeRDP_Username" },
{ FreeRDP_WinSCardModule, FREERDP_SETTINGS_TYPE_STRING, "FreeRDP_WinSCardModule" },
{ FreeRDP_WindowTitle, FREERDP_SETTINGS_TYPE_STRING, "FreeRDP_WindowTitle" },
{ FreeRDP_WmClass, FREERDP_SETTINGS_TYPE_STRING, "FreeRDP_WmClass" },
{ FreeRDP_BitmapCacheV2CellInfo, FREERDP_SETTINGS_TYPE_POINTER,

View File

@ -430,6 +430,7 @@ static const size_t string_list_indices[] = {
FreeRDP_TransportDumpFile,
FreeRDP_UserSpecifiedServerName,
FreeRDP_Username,
FreeRDP_WinSCardModule,
FreeRDP_WindowTitle,
FreeRDP_WmClass,
};

View File

@ -30,6 +30,7 @@
#include <winpr/crt.h>
#include <winpr/print.h>
#include <winpr/stream.h>
#include <winpr/library.h>
#include <winpr/smartcard.h>
#include <freerdp/freerdp.h>
@ -47,10 +48,12 @@
#include <freerdp/emulate/scard/smartcard_emulate.h>
#define str(x) #x
#define wrap(ctx, fkt, ...) \
ctx->useEmulatedCard ? Emulate_##fkt(ctx->emulation, ##__VA_ARGS__) : fkt(__VA_ARGS__)
#define wrap(ctx, fkt, ...) \
ctx->useEmulatedCard ? Emulate_##fkt(ctx->emulation, ##__VA_ARGS__) \
: ctx->pWinSCardApi->pfn##fkt(__VA_ARGS__)
#else
#define wrap(ctx, fkt, ...) ctx->useEmulatedCard ? SCARD_F_INTERNAL_ERROR : fkt(__VA_ARGS__)
#define wrap(ctx, fkt, ...) \
ctx->useEmulatedCard ? SCARD_F_INTERNAL_ERROR : ctx->pWinSCardApi->pfn##fkt(__VA_ARGS__)
#endif
#define SCARD_MAX_TIMEOUT 60000
@ -64,6 +67,9 @@ struct s_scard_call_context
#if defined(WITH_SMARTCARD_EMULATE)
SmartcardEmulationContext* emulation;
#endif
HANDLE hWinSCardLibrary;
SCardApiFunctionTable WinSCardApi;
SCardApiFunctionTable const* pWinSCardApi;
HANDLE stopEvent;
void* userdata;
@ -1855,6 +1861,32 @@ scard_call_context* smartcard_call_context_new(const rdpSettings* settings)
goto fail;
#endif
}
else
{
if (settings->WinSCardModule)
{
ctx->hWinSCardLibrary = LoadLibraryX(settings->WinSCardModule);
if (!ctx->hWinSCardLibrary)
{
WLog_ERR(TAG, "Failed to load WinSCard library: '%s'", settings->WinSCardModule);
goto fail;
}
ctx->pWinSCardApi = &ctx->WinSCardApi;
WinSCard_LoadApiTableFunctions(ctx->pWinSCardApi, ctx->hWinSCardLibrary);
}
else
{
ctx->pWinSCardApi = WinPR_GetSCardApiFunctionTable();
}
if (!ctx->pWinSCardApi)
{
WLog_ERR(TAG, "Failed to load WinSCard API!");
goto fail;
}
}
ctx->rgSCardContextList = HashTable_New(FALSE);
if (!ctx->rgSCardContextList)
@ -1893,6 +1925,16 @@ void smartcard_call_context_free(scard_call_context* ctx)
}
#endif
}
if (ctx->hWinSCardLibrary)
{
ZeroMemory(&ctx->WinSCardApi, sizeof(SCardApiFunctionTable));
FreeLibrary(ctx->hWinSCardLibrary);
ctx->hWinSCardLibrary = NULL;
}
ctx->pWinSCardApi = NULL;
HashTable_Free(ctx->rgSCardContextList);
CloseHandle(ctx->stopEvent);
free(ctx);

View File

@ -1209,6 +1209,10 @@ extern "C"
WINSCARDAPI const char* WINAPI SCardGetCardStateString(DWORD dwCardState);
WINSCARDAPI char* WINAPI SCardGetReaderStateString(DWORD dwReaderState);
WINPR_API bool WinSCard_LoadApiTableFunctions(PSCardApiFunctionTable pWinSCardApiTable,
HMODULE hWinSCardLibrary);
WINPR_API SCardApiFunctionTable const* WinPR_GetSCardApiFunctionTable(void);
#ifdef __cplusplus
}
#endif

View File

@ -44,8 +44,8 @@ endif()
if(WIN32)
list(APPEND ${MODULE_PREFIX}_SRCS
smartcard_winscard.c
smartcard_winscard.h)
smartcard_windows.c
smartcard_windows.h)
endif()
winpr_module_add(${${MODULE_PREFIX}_SRCS})

View File

@ -26,6 +26,7 @@
#include <winpr/smartcard.h>
#include <winpr/synch.h>
#include <winpr/wlog.h>
#include <winpr/assert.h>
#include "../log.h"
@ -83,19 +84,16 @@ const SCARD_IO_REQUEST g_rgSCardRawPci = { SCARD_PROTOCOL_RAW, 8 };
static BOOL CALLBACK InitializeSCardApiStubs(PINIT_ONCE once, PVOID param, PVOID* context)
{
#ifdef _WIN32
if (Windows_InitializeSCardApi() >= 0)
g_SCardApi = Windows_GetSCardApiFunctionTable();
#else
#if defined(WITH_SMARTCARD_PCSC)
#ifndef _WIN32
if (PCSC_InitializeSCardApi() >= 0)
g_SCardApi = PCSC_GetSCardApiFunctionTable();
#else
if (WinSCard_InitializeSCardApi() >= 0)
g_SCardApi = WinSCard_GetSCardApiFunctionTable();
#endif
#endif
#if defined(WITH_SMARTCARD_INSPECT)
g_SCardApi = Inspect_RegisterSCardApi(g_SCardApi);
#endif
@ -1101,3 +1099,181 @@ WINSCARDAPI char* WINAPI SCardGetReaderStateString(DWORD dwReaderState)
return buffer;
}
#define WINSCARD_LOAD_PROC(_name, ...) \
pWinSCardApiTable->pfn##_name = (fn##_name)GetProcAddress(hWinSCardLibrary, #_name);
bool WinSCard_LoadApiTableFunctions(PSCardApiFunctionTable pWinSCardApiTable,
HMODULE hWinSCardLibrary)
{
WINPR_ASSERT(pWinSCardApiTable);
WINPR_ASSERT(hWinSCardLibrary);
WINSCARD_LOAD_PROC(SCardEstablishContext);
WINSCARD_LOAD_PROC(SCardReleaseContext);
WINSCARD_LOAD_PROC(SCardIsValidContext);
WINSCARD_LOAD_PROC(SCardListReaderGroupsA);
WINSCARD_LOAD_PROC(SCardListReaderGroupsW);
WINSCARD_LOAD_PROC(SCardListReadersA);
WINSCARD_LOAD_PROC(SCardListReadersW);
WINSCARD_LOAD_PROC(SCardListCardsA);
WINSCARD_LOAD_PROC(SCardListCardsW);
WINSCARD_LOAD_PROC(SCardListInterfacesA);
WINSCARD_LOAD_PROC(SCardListInterfacesW);
WINSCARD_LOAD_PROC(SCardGetProviderIdA);
WINSCARD_LOAD_PROC(SCardGetProviderIdW);
WINSCARD_LOAD_PROC(SCardGetCardTypeProviderNameA);
WINSCARD_LOAD_PROC(SCardGetCardTypeProviderNameW);
WINSCARD_LOAD_PROC(SCardIntroduceReaderGroupA);
WINSCARD_LOAD_PROC(SCardIntroduceReaderGroupW);
WINSCARD_LOAD_PROC(SCardForgetReaderGroupA);
WINSCARD_LOAD_PROC(SCardForgetReaderGroupW);
WINSCARD_LOAD_PROC(SCardIntroduceReaderA);
WINSCARD_LOAD_PROC(SCardIntroduceReaderW);
WINSCARD_LOAD_PROC(SCardForgetReaderA);
WINSCARD_LOAD_PROC(SCardForgetReaderW);
WINSCARD_LOAD_PROC(SCardAddReaderToGroupA);
WINSCARD_LOAD_PROC(SCardAddReaderToGroupW);
WINSCARD_LOAD_PROC(SCardRemoveReaderFromGroupA);
WINSCARD_LOAD_PROC(SCardRemoveReaderFromGroupW);
WINSCARD_LOAD_PROC(SCardIntroduceCardTypeA);
WINSCARD_LOAD_PROC(SCardIntroduceCardTypeW);
WINSCARD_LOAD_PROC(SCardSetCardTypeProviderNameA);
WINSCARD_LOAD_PROC(SCardSetCardTypeProviderNameW);
WINSCARD_LOAD_PROC(SCardForgetCardTypeA);
WINSCARD_LOAD_PROC(SCardForgetCardTypeW);
WINSCARD_LOAD_PROC(SCardFreeMemory);
WINSCARD_LOAD_PROC(SCardAccessStartedEvent);
WINSCARD_LOAD_PROC(SCardReleaseStartedEvent);
WINSCARD_LOAD_PROC(SCardLocateCardsA);
WINSCARD_LOAD_PROC(SCardLocateCardsW);
WINSCARD_LOAD_PROC(SCardLocateCardsByATRA);
WINSCARD_LOAD_PROC(SCardLocateCardsByATRW);
WINSCARD_LOAD_PROC(SCardGetStatusChangeA);
WINSCARD_LOAD_PROC(SCardGetStatusChangeW);
WINSCARD_LOAD_PROC(SCardCancel);
WINSCARD_LOAD_PROC(SCardConnectA);
WINSCARD_LOAD_PROC(SCardConnectW);
WINSCARD_LOAD_PROC(SCardReconnect);
WINSCARD_LOAD_PROC(SCardDisconnect);
WINSCARD_LOAD_PROC(SCardBeginTransaction);
WINSCARD_LOAD_PROC(SCardEndTransaction);
WINSCARD_LOAD_PROC(SCardCancelTransaction);
WINSCARD_LOAD_PROC(SCardState);
WINSCARD_LOAD_PROC(SCardStatusA);
WINSCARD_LOAD_PROC(SCardStatusW);
WINSCARD_LOAD_PROC(SCardTransmit);
WINSCARD_LOAD_PROC(SCardGetTransmitCount);
WINSCARD_LOAD_PROC(SCardControl);
WINSCARD_LOAD_PROC(SCardGetAttrib);
WINSCARD_LOAD_PROC(SCardSetAttrib);
WINSCARD_LOAD_PROC(SCardUIDlgSelectCardA);
WINSCARD_LOAD_PROC(SCardUIDlgSelectCardW);
WINSCARD_LOAD_PROC(GetOpenCardNameA);
WINSCARD_LOAD_PROC(GetOpenCardNameW);
WINSCARD_LOAD_PROC(SCardDlgExtendedError);
WINSCARD_LOAD_PROC(SCardReadCacheA);
WINSCARD_LOAD_PROC(SCardReadCacheW);
WINSCARD_LOAD_PROC(SCardWriteCacheA);
WINSCARD_LOAD_PROC(SCardWriteCacheW);
WINSCARD_LOAD_PROC(SCardGetReaderIconA);
WINSCARD_LOAD_PROC(SCardGetReaderIconW);
WINSCARD_LOAD_PROC(SCardGetDeviceTypeIdA);
WINSCARD_LOAD_PROC(SCardGetDeviceTypeIdW);
WINSCARD_LOAD_PROC(SCardGetReaderDeviceInstanceIdA);
WINSCARD_LOAD_PROC(SCardGetReaderDeviceInstanceIdW);
WINSCARD_LOAD_PROC(SCardListReadersWithDeviceInstanceIdA);
WINSCARD_LOAD_PROC(SCardListReadersWithDeviceInstanceIdW);
WINSCARD_LOAD_PROC(SCardAudit);
return true;
}
static const SCardApiFunctionTable WinPR_SCardApiFunctionTable = {
0, /* dwVersion */
0, /* dwFlags */
SCardEstablishContext, /* SCardEstablishContext */
SCardReleaseContext, /* SCardReleaseContext */
SCardIsValidContext, /* SCardIsValidContext */
SCardListReaderGroupsA, /* SCardListReaderGroupsA */
SCardListReaderGroupsW, /* SCardListReaderGroupsW */
SCardListReadersA, /* SCardListReadersA */
SCardListReadersW, /* SCardListReadersW */
SCardListCardsA, /* SCardListCardsA */
SCardListCardsW, /* SCardListCardsW */
SCardListInterfacesA, /* SCardListInterfacesA */
SCardListInterfacesW, /* SCardListInterfacesW */
SCardGetProviderIdA, /* SCardGetProviderIdA */
SCardGetProviderIdW, /* SCardGetProviderIdW */
SCardGetCardTypeProviderNameA, /* SCardGetCardTypeProviderNameA */
SCardGetCardTypeProviderNameW, /* SCardGetCardTypeProviderNameW */
SCardIntroduceReaderGroupA, /* SCardIntroduceReaderGroupA */
SCardIntroduceReaderGroupW, /* SCardIntroduceReaderGroupW */
SCardForgetReaderGroupA, /* SCardForgetReaderGroupA */
SCardForgetReaderGroupW, /* SCardForgetReaderGroupW */
SCardIntroduceReaderA, /* SCardIntroduceReaderA */
SCardIntroduceReaderW, /* SCardIntroduceReaderW */
SCardForgetReaderA, /* SCardForgetReaderA */
SCardForgetReaderW, /* SCardForgetReaderW */
SCardAddReaderToGroupA, /* SCardAddReaderToGroupA */
SCardAddReaderToGroupW, /* SCardAddReaderToGroupW */
SCardRemoveReaderFromGroupA, /* SCardRemoveReaderFromGroupA */
SCardRemoveReaderFromGroupW, /* SCardRemoveReaderFromGroupW */
SCardIntroduceCardTypeA, /* SCardIntroduceCardTypeA */
SCardIntroduceCardTypeW, /* SCardIntroduceCardTypeW */
SCardSetCardTypeProviderNameA, /* SCardSetCardTypeProviderNameA */
SCardSetCardTypeProviderNameW, /* SCardSetCardTypeProviderNameW */
SCardForgetCardTypeA, /* SCardForgetCardTypeA */
SCardForgetCardTypeW, /* SCardForgetCardTypeW */
SCardFreeMemory, /* SCardFreeMemory */
SCardAccessStartedEvent, /* SCardAccessStartedEvent */
SCardReleaseStartedEvent, /* SCardReleaseStartedEvent */
SCardLocateCardsA, /* SCardLocateCardsA */
SCardLocateCardsW, /* SCardLocateCardsW */
SCardLocateCardsByATRA, /* SCardLocateCardsByATRA */
SCardLocateCardsByATRW, /* SCardLocateCardsByATRW */
SCardGetStatusChangeA, /* SCardGetStatusChangeA */
SCardGetStatusChangeW, /* SCardGetStatusChangeW */
SCardCancel, /* SCardCancel */
SCardConnectA, /* SCardConnectA */
SCardConnectW, /* SCardConnectW */
SCardReconnect, /* SCardReconnect */
SCardDisconnect, /* SCardDisconnect */
SCardBeginTransaction, /* SCardBeginTransaction */
SCardEndTransaction, /* SCardEndTransaction */
SCardCancelTransaction, /* SCardCancelTransaction */
SCardState, /* SCardState */
SCardStatusA, /* SCardStatusA */
SCardStatusW, /* SCardStatusW */
SCardTransmit, /* SCardTransmit */
SCardGetTransmitCount, /* SCardGetTransmitCount */
SCardControl, /* SCardControl */
SCardGetAttrib, /* SCardGetAttrib */
SCardSetAttrib, /* SCardSetAttrib */
SCardUIDlgSelectCardA, /* SCardUIDlgSelectCardA */
SCardUIDlgSelectCardW, /* SCardUIDlgSelectCardW */
GetOpenCardNameA, /* GetOpenCardNameA */
GetOpenCardNameW, /* GetOpenCardNameW */
SCardDlgExtendedError, /* SCardDlgExtendedError */
SCardReadCacheA, /* SCardReadCacheA */
SCardReadCacheW, /* SCardReadCacheW */
SCardWriteCacheA, /* SCardWriteCacheA */
SCardWriteCacheW, /* SCardWriteCacheW */
SCardGetReaderIconA, /* SCardGetReaderIconA */
SCardGetReaderIconW, /* SCardGetReaderIconW */
SCardGetDeviceTypeIdA, /* SCardGetDeviceTypeIdA */
SCardGetDeviceTypeIdW, /* SCardGetDeviceTypeIdW */
SCardGetReaderDeviceInstanceIdA, /* SCardGetReaderDeviceInstanceIdA */
SCardGetReaderDeviceInstanceIdW, /* SCardGetReaderDeviceInstanceIdW */
SCardListReadersWithDeviceInstanceIdA, /* SCardListReadersWithDeviceInstanceIdA */
SCardListReadersWithDeviceInstanceIdW, /* SCardListReadersWithDeviceInstanceIdW */
SCardAudit /* SCardAudit */
};
static SCardApiFunctionTable const* pWinPR_SCardApiFunctionTable = &WinPR_SCardApiFunctionTable;
SCardApiFunctionTable const* WinPR_GetSCardApiFunctionTable(void)
{
return pWinPR_SCardApiFunctionTable;
}

View File

@ -25,7 +25,7 @@
#ifndef _WIN32
#include "smartcard_pcsc.h"
#else
#include "smartcard_winscard.h"
#include "smartcard_windows.h"
#endif
#endif /* WINPR_SMARTCARD_PRIVATE_H */

View File

@ -19,17 +19,15 @@
#include <winpr/config.h>
#ifdef _WIN32
#include <winpr/crt.h>
#include <winpr/library.h>
#include <winpr/smartcard.h>
#include "smartcard_winscard.h"
#include "smartcard_windows.h"
static HMODULE g_WinSCardModule = NULL;
SCardApiFunctionTable WinSCard_SCardApiFunctionTable = {
static SCardApiFunctionTable Windows_SCardApiFunctionTable = {
0, /* dwVersion */
0, /* dwFlags */
@ -111,95 +109,18 @@ SCardApiFunctionTable WinSCard_SCardApiFunctionTable = {
NULL /* SCardAudit */
};
PSCardApiFunctionTable WinSCard_GetSCardApiFunctionTable(void)
const SCardApiFunctionTable* Windows_GetSCardApiFunctionTable(void)
{
return &WinSCard_SCardApiFunctionTable;
return &Windows_SCardApiFunctionTable;
}
int WinSCard_InitializeSCardApi(void)
int Windows_InitializeSCardApi(void)
{
g_WinSCardModule = LoadLibraryA("WinSCard.dll");
if (!g_WinSCardModule)
return -1;
WINSCARD_LOAD_PROC(SCardEstablishContext);
WINSCARD_LOAD_PROC(SCardReleaseContext);
WINSCARD_LOAD_PROC(SCardIsValidContext);
WINSCARD_LOAD_PROC(SCardListReaderGroupsA);
WINSCARD_LOAD_PROC(SCardListReaderGroupsW);
WINSCARD_LOAD_PROC(SCardListReadersA);
WINSCARD_LOAD_PROC(SCardListReadersW);
WINSCARD_LOAD_PROC(SCardListCardsA);
WINSCARD_LOAD_PROC(SCardListCardsW);
WINSCARD_LOAD_PROC(SCardListInterfacesA);
WINSCARD_LOAD_PROC(SCardListInterfacesW);
WINSCARD_LOAD_PROC(SCardGetProviderIdA);
WINSCARD_LOAD_PROC(SCardGetProviderIdW);
WINSCARD_LOAD_PROC(SCardGetCardTypeProviderNameA);
WINSCARD_LOAD_PROC(SCardGetCardTypeProviderNameW);
WINSCARD_LOAD_PROC(SCardIntroduceReaderGroupA);
WINSCARD_LOAD_PROC(SCardIntroduceReaderGroupW);
WINSCARD_LOAD_PROC(SCardForgetReaderGroupA);
WINSCARD_LOAD_PROC(SCardForgetReaderGroupW);
WINSCARD_LOAD_PROC(SCardIntroduceReaderA);
WINSCARD_LOAD_PROC(SCardIntroduceReaderW);
WINSCARD_LOAD_PROC(SCardForgetReaderA);
WINSCARD_LOAD_PROC(SCardForgetReaderW);
WINSCARD_LOAD_PROC(SCardAddReaderToGroupA);
WINSCARD_LOAD_PROC(SCardAddReaderToGroupW);
WINSCARD_LOAD_PROC(SCardRemoveReaderFromGroupA);
WINSCARD_LOAD_PROC(SCardRemoveReaderFromGroupW);
WINSCARD_LOAD_PROC(SCardIntroduceCardTypeA);
WINSCARD_LOAD_PROC(SCardIntroduceCardTypeW);
WINSCARD_LOAD_PROC(SCardSetCardTypeProviderNameA);
WINSCARD_LOAD_PROC(SCardSetCardTypeProviderNameW);
WINSCARD_LOAD_PROC(SCardForgetCardTypeA);
WINSCARD_LOAD_PROC(SCardForgetCardTypeW);
WINSCARD_LOAD_PROC(SCardFreeMemory);
WINSCARD_LOAD_PROC(SCardAccessStartedEvent);
WINSCARD_LOAD_PROC(SCardReleaseStartedEvent);
WINSCARD_LOAD_PROC(SCardLocateCardsA);
WINSCARD_LOAD_PROC(SCardLocateCardsW);
WINSCARD_LOAD_PROC(SCardLocateCardsByATRA);
WINSCARD_LOAD_PROC(SCardLocateCardsByATRW);
WINSCARD_LOAD_PROC(SCardGetStatusChangeA);
WINSCARD_LOAD_PROC(SCardGetStatusChangeW);
WINSCARD_LOAD_PROC(SCardCancel);
WINSCARD_LOAD_PROC(SCardConnectA);
WINSCARD_LOAD_PROC(SCardConnectW);
WINSCARD_LOAD_PROC(SCardReconnect);
WINSCARD_LOAD_PROC(SCardDisconnect);
WINSCARD_LOAD_PROC(SCardBeginTransaction);
WINSCARD_LOAD_PROC(SCardEndTransaction);
WINSCARD_LOAD_PROC(SCardCancelTransaction);
WINSCARD_LOAD_PROC(SCardState);
WINSCARD_LOAD_PROC(SCardStatusA);
WINSCARD_LOAD_PROC(SCardStatusW);
WINSCARD_LOAD_PROC(SCardTransmit);
WINSCARD_LOAD_PROC(SCardGetTransmitCount);
WINSCARD_LOAD_PROC(SCardControl);
WINSCARD_LOAD_PROC(SCardGetAttrib);
WINSCARD_LOAD_PROC(SCardSetAttrib);
WINSCARD_LOAD_PROC(SCardUIDlgSelectCardA);
WINSCARD_LOAD_PROC(SCardUIDlgSelectCardW);
WINSCARD_LOAD_PROC(GetOpenCardNameA);
WINSCARD_LOAD_PROC(GetOpenCardNameW);
WINSCARD_LOAD_PROC(SCardDlgExtendedError);
WINSCARD_LOAD_PROC(SCardReadCacheA);
WINSCARD_LOAD_PROC(SCardReadCacheW);
WINSCARD_LOAD_PROC(SCardWriteCacheA);
WINSCARD_LOAD_PROC(SCardWriteCacheW);
WINSCARD_LOAD_PROC(SCardGetReaderIconA);
WINSCARD_LOAD_PROC(SCardGetReaderIconW);
WINSCARD_LOAD_PROC(SCardGetDeviceTypeIdA);
WINSCARD_LOAD_PROC(SCardGetDeviceTypeIdW);
WINSCARD_LOAD_PROC(SCardGetReaderDeviceInstanceIdA);
WINSCARD_LOAD_PROC(SCardGetReaderDeviceInstanceIdW);
WINSCARD_LOAD_PROC(SCardListReadersWithDeviceInstanceIdA);
WINSCARD_LOAD_PROC(SCardListReadersWithDeviceInstanceIdW);
WINSCARD_LOAD_PROC(SCardAudit);
WinSCard_LoadApiTableFunctions(&Windows_SCardApiFunctionTable, g_WinSCardModule);
return 1;
}
#endif

View File

@ -20,16 +20,9 @@
#ifndef WINPR_SMARTCARD_WINSCARD_PRIVATE_H
#define WINPR_SMARTCARD_WINSCARD_PRIVATE_H
#ifdef _WIN32
#include <winpr/smartcard.h>
#define WINSCARD_LOAD_PROC(_name, ...) \
WinSCard_SCardApiFunctionTable.pfn##_name = (fn##_name)GetProcAddress(g_WinSCardModule, #_name);
int WinSCard_InitializeSCardApi(void);
PSCardApiFunctionTable WinSCard_GetSCardApiFunctionTable(void);
#endif
int Windows_InitializeSCardApi(void);
const SCardApiFunctionTable* Windows_GetSCardApiFunctionTable(void);
#endif /* WINPR_SMARTCARD_WINSCARD_PRIVATE_H */