FreeRDP
smartcard_windows.c
1 
20 #include <winpr/config.h>
21 
22 #include <winpr/crt.h>
23 #include <winpr/library.h>
24 #include <winpr/smartcard.h>
25 
26 #include "smartcard_windows.h"
27 
28 static HMODULE g_WinSCardModule = NULL;
29 
30 static SCardApiFunctionTable Windows_SCardApiFunctionTable = {
31  0, /* dwVersion */
32  0, /* dwFlags */
33 
34  NULL, /* SCardEstablishContext */
35  NULL, /* SCardReleaseContext */
36  NULL, /* SCardIsValidContext */
37  NULL, /* SCardListReaderGroupsA */
38  NULL, /* SCardListReaderGroupsW */
39  NULL, /* SCardListReadersA */
40  NULL, /* SCardListReadersW */
41  NULL, /* SCardListCardsA */
42  NULL, /* SCardListCardsW */
43  NULL, /* SCardListInterfacesA */
44  NULL, /* SCardListInterfacesW */
45  NULL, /* SCardGetProviderIdA */
46  NULL, /* SCardGetProviderIdW */
47  NULL, /* SCardGetCardTypeProviderNameA */
48  NULL, /* SCardGetCardTypeProviderNameW */
49  NULL, /* SCardIntroduceReaderGroupA */
50  NULL, /* SCardIntroduceReaderGroupW */
51  NULL, /* SCardForgetReaderGroupA */
52  NULL, /* SCardForgetReaderGroupW */
53  NULL, /* SCardIntroduceReaderA */
54  NULL, /* SCardIntroduceReaderW */
55  NULL, /* SCardForgetReaderA */
56  NULL, /* SCardForgetReaderW */
57  NULL, /* SCardAddReaderToGroupA */
58  NULL, /* SCardAddReaderToGroupW */
59  NULL, /* SCardRemoveReaderFromGroupA */
60  NULL, /* SCardRemoveReaderFromGroupW */
61  NULL, /* SCardIntroduceCardTypeA */
62  NULL, /* SCardIntroduceCardTypeW */
63  NULL, /* SCardSetCardTypeProviderNameA */
64  NULL, /* SCardSetCardTypeProviderNameW */
65  NULL, /* SCardForgetCardTypeA */
66  NULL, /* SCardForgetCardTypeW */
67  NULL, /* SCardFreeMemory */
68  NULL, /* SCardAccessStartedEvent */
69  NULL, /* SCardReleaseStartedEvent */
70  NULL, /* SCardLocateCardsA */
71  NULL, /* SCardLocateCardsW */
72  NULL, /* SCardLocateCardsByATRA */
73  NULL, /* SCardLocateCardsByATRW */
74  NULL, /* SCardGetStatusChangeA */
75  NULL, /* SCardGetStatusChangeW */
76  NULL, /* SCardCancel */
77  NULL, /* SCardConnectA */
78  NULL, /* SCardConnectW */
79  NULL, /* SCardReconnect */
80  NULL, /* SCardDisconnect */
81  NULL, /* SCardBeginTransaction */
82  NULL, /* SCardEndTransaction */
83  NULL, /* SCardCancelTransaction */
84  NULL, /* SCardState */
85  NULL, /* SCardStatusA */
86  NULL, /* SCardStatusW */
87  NULL, /* SCardTransmit */
88  NULL, /* SCardGetTransmitCount */
89  NULL, /* SCardControl */
90  NULL, /* SCardGetAttrib */
91  NULL, /* SCardSetAttrib */
92  NULL, /* SCardUIDlgSelectCardA */
93  NULL, /* SCardUIDlgSelectCardW */
94  NULL, /* GetOpenCardNameA */
95  NULL, /* GetOpenCardNameW */
96  NULL, /* SCardDlgExtendedError */
97  NULL, /* SCardReadCacheA */
98  NULL, /* SCardReadCacheW */
99  NULL, /* SCardWriteCacheA */
100  NULL, /* SCardWriteCacheW */
101  NULL, /* SCardGetReaderIconA */
102  NULL, /* SCardGetReaderIconW */
103  NULL, /* SCardGetDeviceTypeIdA */
104  NULL, /* SCardGetDeviceTypeIdW */
105  NULL, /* SCardGetReaderDeviceInstanceIdA */
106  NULL, /* SCardGetReaderDeviceInstanceIdW */
107  NULL, /* SCardListReadersWithDeviceInstanceIdA */
108  NULL, /* SCardListReadersWithDeviceInstanceIdW */
109  NULL /* SCardAudit */
110 };
111 
112 const SCardApiFunctionTable* Windows_GetSCardApiFunctionTable(void)
113 {
114  return &Windows_SCardApiFunctionTable;
115 }
116 
117 int Windows_InitializeSCardApi(void)
118 {
119  g_WinSCardModule = LoadLibraryA("WinSCard.dll");
120 
121  if (!g_WinSCardModule)
122  return -1;
123 
124  WinSCard_LoadApiTableFunctions(&Windows_SCardApiFunctionTable, g_WinSCardModule);
125  return 1;
126 }