From e3d45c458057910a2409626858492a9de33728be Mon Sep 17 00:00:00 2001 From: Bernhard Miklautz Date: Mon, 11 Dec 2017 14:31:19 +0100 Subject: [PATCH] fix channel/smartcard: remove SCardAddReaderName SCardAddReaderName isn't part of the SCard API. Note: removing this also removes the possibility to redirect single smartcard readers with /smartcard:READERNAME. However this features wasn't implemented in a general way and will be re-added as part of the smart card channel directly. --- channels/smartcard/client/smartcard_main.c | 8 --- winpr/include/winpr/smartcard.h | 5 -- winpr/libwinpr/smartcard/smartcard.c | 5 -- winpr/libwinpr/smartcard/smartcard_pcsc.c | 71 ++------------------------- winpr/libwinpr/smartcard/smartcard_pcsc.h | 1 - winpr/libwinpr/smartcard/smartcard_winscard.c | 3 +- 6 files changed, 4 insertions(+), 89 deletions(-) diff --git a/channels/smartcard/client/smartcard_main.c b/channels/smartcard/client/smartcard_main.c index 9fe2c36..d3555f9 100644 --- a/channels/smartcard/client/smartcard_main.c +++ b/channels/smartcard/client/smartcard_main.c @@ -708,14 +708,6 @@ UINT DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints) Stream_Write(smartcard->device.data, "SCARD", 6); - status = SCardAddReaderName(&smartcard->thread, (LPSTR) device->Name); - - if (status != SCARD_S_SUCCESS) - { - WLog_ERR(TAG, "Failed to add reader name!"); - goto error_device_data; - } - smartcard->IrpQueue = MessageQueue_New(NULL); if (!smartcard->IrpQueue) diff --git a/winpr/include/winpr/smartcard.h b/winpr/include/winpr/smartcard.h index 8b52beb..d168f2d 100644 --- a/winpr/include/winpr/smartcard.h +++ b/winpr/include/winpr/smartcard.h @@ -789,8 +789,6 @@ WINSCARDAPI LONG WINAPI SCardListReadersWithDeviceInstanceIdW(SCARDCONTEXT hCont WINSCARDAPI LONG WINAPI SCardAudit(SCARDCONTEXT hContext, DWORD dwEvent); -WINSCARDAPI LONG WINAPI SCardAddReaderName(HANDLE* key, LPSTR readerName); - #ifdef UNICODE #define SCardListReaderGroups SCardListReaderGroupsW #define SCardListReaders SCardListReadersW @@ -1045,8 +1043,6 @@ typedef LONG(WINAPI* fnSCardListReadersWithDeviceInstanceIdW)(SCARDCONTEXT hCont typedef LONG(WINAPI* fnSCardAudit)(SCARDCONTEXT hContext, DWORD dwEvent); -typedef LONG(WINAPI* fnSCardAddReaderName)(HANDLE* key, LPSTR readerName); - struct _SCardApiFunctionTable { DWORD dwVersion; @@ -1128,7 +1124,6 @@ struct _SCardApiFunctionTable fnSCardListReadersWithDeviceInstanceIdA pfnSCardListReadersWithDeviceInstanceIdA; fnSCardListReadersWithDeviceInstanceIdW pfnSCardListReadersWithDeviceInstanceIdW; fnSCardAudit pfnSCardAudit; - fnSCardAddReaderName pfnSCardAddReaderName; }; typedef struct _SCardApiFunctionTable SCardApiFunctionTable; diff --git a/winpr/libwinpr/smartcard/smartcard.c b/winpr/libwinpr/smartcard/smartcard.c index 2d2a8e5..96ecc6f 100644 --- a/winpr/libwinpr/smartcard/smartcard.c +++ b/winpr/libwinpr/smartcard/smartcard.c @@ -507,11 +507,6 @@ WINSCARDAPI LONG WINAPI SCardAudit(SCARDCONTEXT hContext, DWORD dwEvent) SCARDAPI_STUB_CALL_LONG(SCardAudit, hContext, dwEvent); } -WINSCARDAPI LONG WINAPI SCardAddReaderName(HANDLE* key, LPSTR readerName) -{ - SCARDAPI_STUB_CALL_LONG(SCardAddReaderName, key, readerName); -} - /** * Extended API */ diff --git a/winpr/libwinpr/smartcard/smartcard_pcsc.c b/winpr/libwinpr/smartcard/smartcard_pcsc.c index dddfe30..997d1eb 100644 --- a/winpr/libwinpr/smartcard/smartcard_pcsc.c +++ b/winpr/libwinpr/smartcard/smartcard_pcsc.c @@ -156,7 +156,6 @@ static wArrayList* g_Readers = NULL; static wListDictionary* g_CardHandles = NULL; static wListDictionary* g_CardContexts = NULL; static wListDictionary* g_MemoryBlocks = NULL; -static wListDictionary* g_ReadersNames = NULL; char SMARTCARD_PNP_NOTIFICATION_A[] = "\\\\?PnP?\\Notification"; @@ -754,38 +753,6 @@ char* PCSC_GetReaderAliasFromName(char* namePCSC) return nameWinSCard; } -int PCSC_RedirectReader(char* readerName) -{ - char* name; - ULONG_PTR* readers; - int i, nbReaders; - nbReaders = ListDictionary_GetKeys(g_ReadersNames, &readers); - - for (i = 0; i < nbReaders; i++) - { - name = ListDictionary_GetItemValue(g_ReadersNames, (void*) readers[i]); - - if (name) - { - if (strcmp(name, "") == 0) - { - return 1; - } - - if (strncmp(readerName, name, strlen(readerName)) == 0) - { - return 1; - } - } - else - { - return 2; - } - } - - return 0; -} - char* PCSC_ConvertReaderNamesToWinSCard(const char* names, LPDWORD pcchReaders) { int ret = 0; @@ -813,18 +780,8 @@ char* PCSC_ConvertReaderNamesToWinSCard(const char* names, LPDWORD pcchReaders) if (nameWinSCard) { length = strlen(nameWinSCard); - ret = PCSC_RedirectReader(nameWinSCard); - - if (ret == 1) - { - CopyMemory(q, nameWinSCard, length); - endReaderName = TRUE; - } - else if (ret == 2) - { - CopyMemory(q, nameWinSCard, length); - allReaders = TRUE; - } + CopyMemory(q, nameWinSCard, length); + allReaders = TRUE; free(nameWinSCard); } @@ -2808,27 +2765,6 @@ WINSCARDAPI LONG WINAPI PCSC_SCardAudit(SCARDCONTEXT hContext, DWORD dwEvent) return 0; } -WINSCARDAPI LONG WINAPI PCSC_SCardAddReaderName(HANDLE* key, LPSTR readerName) -{ - LONG status = SCARD_S_SUCCESS; - int count = 0; - - if (!g_ReadersNames) - { - g_ReadersNames = ListDictionary_New(TRUE); - - if (!g_ReadersNames) - return SCARD_E_NO_SERVICE; - } - - count = ListDictionary_Count(g_ReadersNames); - - if (!ListDictionary_Add(g_ReadersNames, key, readerName)) - return SCARD_E_NO_SERVICE; - - return status; -} - #ifdef __MACOSX__ unsigned int determineMacOSXVersion(void) { @@ -3038,8 +2974,7 @@ SCardApiFunctionTable PCSC_SCardApiFunctionTable = PCSC_SCardGetReaderDeviceInstanceIdW, /* SCardGetReaderDeviceInstanceIdW */ PCSC_SCardListReadersWithDeviceInstanceIdA, /* SCardListReadersWithDeviceInstanceIdA */ PCSC_SCardListReadersWithDeviceInstanceIdW, /* SCardListReadersWithDeviceInstanceIdW */ - PCSC_SCardAudit, /* SCardAudit */ - PCSC_SCardAddReaderName /* SCardAddReaderName */ + PCSC_SCardAudit /* SCardAudit */ }; PSCardApiFunctionTable PCSC_GetSCardApiFunctionTable(void) diff --git a/winpr/libwinpr/smartcard/smartcard_pcsc.h b/winpr/libwinpr/smartcard/smartcard_pcsc.h index 85d1c32..1d85d25 100644 --- a/winpr/libwinpr/smartcard/smartcard_pcsc.h +++ b/winpr/libwinpr/smartcard/smartcard_pcsc.h @@ -155,7 +155,6 @@ struct _PCSCFunctionTable PCSC_LPDWORD pcbAttrLen); PCSC_LONG(* pfnSCardSetAttrib)(SCARDHANDLE hCard, PCSC_DWORD dwAttrId, LPCBYTE pbAttr, PCSC_DWORD cbAttrLen); - PCSC_LONG(* pfnSCardAddReaderName)(HANDLE* key, LPSTR readerName); }; typedef struct _PCSCFunctionTable PCSCFunctionTable; diff --git a/winpr/libwinpr/smartcard/smartcard_winscard.c b/winpr/libwinpr/smartcard/smartcard_winscard.c index c4b3b6f..29f1002 100644 --- a/winpr/libwinpr/smartcard/smartcard_winscard.c +++ b/winpr/libwinpr/smartcard/smartcard_winscard.c @@ -111,8 +111,7 @@ SCardApiFunctionTable WinSCard_SCardApiFunctionTable = NULL, /* SCardGetReaderDeviceInstanceIdW */ NULL, /* SCardListReadersWithDeviceInstanceIdA */ NULL, /* SCardListReadersWithDeviceInstanceIdW */ - NULL, /* SCardAudit */ - NULL /* SCardAddReaderName */ + NULL /* SCardAudit */ }; PSCardApiFunctionTable WinSCard_GetSCardApiFunctionTable(void) -- 2.7.4