[smartcard] clean up function table wrapper
This commit is contained in:
parent
30c31d64e8
commit
3e744e13c3
@ -51,9 +51,12 @@
|
||||
#define wrap(ctx, fkt, ...) \
|
||||
ctx->useEmulatedCard ? Emulate_##fkt(ctx->emulation, ##__VA_ARGS__) \
|
||||
: ctx->pWinSCardApi->pfn##fkt(__VA_ARGS__)
|
||||
#define wrap_ptr(ctx, fkt, ...) wrap(ctx, fkt, ##__VA_ARGS__)
|
||||
#else
|
||||
#define wrap(ctx, fkt, ...) \
|
||||
ctx->useEmulatedCard ? SCARD_F_INTERNAL_ERROR : ctx->pWinSCardApi->pfn##fkt(__VA_ARGS__)
|
||||
#define wrap_ptr(ctx, fkt, ...) \
|
||||
ctx->useEmulatedCard ? NULL : ctx->pWinSCardApi->pfn##fkt(__VA_ARGS__)
|
||||
#endif
|
||||
|
||||
#define SCARD_MAX_TIMEOUT 60000
|
||||
@ -69,7 +72,7 @@ struct s_scard_call_context
|
||||
#endif
|
||||
HANDLE hWinSCardLibrary;
|
||||
SCardApiFunctionTable WinSCardApi;
|
||||
SCardApiFunctionTable const* pWinSCardApi;
|
||||
const SCardApiFunctionTable* pWinSCardApi;
|
||||
HANDLE stopEvent;
|
||||
void* userdata;
|
||||
|
||||
@ -1446,7 +1449,7 @@ static LONG smartcard_AccessStartedEvent_Call(scard_call_context* smartcard, wSt
|
||||
WINPR_UNUSED(operation);
|
||||
|
||||
if (!smartcard->StartedEvent)
|
||||
smartcard->StartedEvent = wrap(smartcard, SCardAccessStartedEvent);
|
||||
smartcard->StartedEvent = wrap_ptr(smartcard, SCardAccessStartedEvent);
|
||||
|
||||
if (!smartcard->StartedEvent)
|
||||
status = SCARD_E_NO_SERVICE;
|
||||
@ -1873,8 +1876,9 @@ scard_call_context* smartcard_call_context_new(const rdpSettings* settings)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (!WinSCard_LoadApiTableFunctions(&ctx->WinSCardApi, ctx->hWinSCardLibrary))
|
||||
goto fail;
|
||||
ctx->pWinSCardApi = &ctx->WinSCardApi;
|
||||
WinSCard_LoadApiTableFunctions(ctx->pWinSCardApi, ctx->hWinSCardLibrary);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1209,9 +1209,9 @@ extern "C"
|
||||
WINSCARDAPI const char* WINAPI SCardGetCardStateString(DWORD dwCardState);
|
||||
WINSCARDAPI char* WINAPI SCardGetReaderStateString(DWORD dwReaderState);
|
||||
|
||||
WINPR_API bool WinSCard_LoadApiTableFunctions(PSCardApiFunctionTable pWinSCardApiTable,
|
||||
WINPR_API BOOL WinSCard_LoadApiTableFunctions(PSCardApiFunctionTable pWinSCardApiTable,
|
||||
HMODULE hWinSCardLibrary);
|
||||
WINPR_API SCardApiFunctionTable const* WinPR_GetSCardApiFunctionTable(void);
|
||||
WINPR_API const SCardApiFunctionTable* WinPR_GetSCardApiFunctionTable(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -1103,7 +1103,7 @@ WINSCARDAPI char* WINAPI SCardGetReaderStateString(DWORD dwReaderState)
|
||||
#define WINSCARD_LOAD_PROC(_name, ...) \
|
||||
pWinSCardApiTable->pfn##_name = (fn##_name)GetProcAddress(hWinSCardLibrary, #_name);
|
||||
|
||||
bool WinSCard_LoadApiTableFunctions(PSCardApiFunctionTable pWinSCardApiTable,
|
||||
BOOL WinSCard_LoadApiTableFunctions(PSCardApiFunctionTable pWinSCardApiTable,
|
||||
HMODULE hWinSCardLibrary)
|
||||
{
|
||||
WINPR_ASSERT(pWinSCardApiTable);
|
||||
@ -1186,7 +1186,7 @@ bool WinSCard_LoadApiTableFunctions(PSCardApiFunctionTable pWinSCardApiTable,
|
||||
WINSCARD_LOAD_PROC(SCardListReadersWithDeviceInstanceIdW);
|
||||
WINSCARD_LOAD_PROC(SCardAudit);
|
||||
|
||||
return true;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static const SCardApiFunctionTable WinPR_SCardApiFunctionTable = {
|
||||
@ -1271,9 +1271,7 @@ static const SCardApiFunctionTable WinPR_SCardApiFunctionTable = {
|
||||
SCardAudit /* SCardAudit */
|
||||
};
|
||||
|
||||
static SCardApiFunctionTable const* pWinPR_SCardApiFunctionTable = &WinPR_SCardApiFunctionTable;
|
||||
|
||||
SCardApiFunctionTable const* WinPR_GetSCardApiFunctionTable(void)
|
||||
const SCardApiFunctionTable* WinPR_GetSCardApiFunctionTable(void)
|
||||
{
|
||||
return pWinPR_SCardApiFunctionTable;
|
||||
return &WinPR_SCardApiFunctionTable;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user