FreeRDP
smartcard_inspect.c
1 
22 #include <winpr/config.h>
23 
24 #include <winpr/crt.h>
25 #include <winpr/wlog.h>
26 #include <winpr/file.h>
27 #include <winpr/path.h>
28 #include <winpr/library.h>
29 #include <winpr/smartcard.h>
30 
31 #include "smartcard_inspect.h"
32 
33 #include "../log.h"
34 #define TAG WINPR_TAG("smartcard.inspect")
35 
36 #define xstr(s) str(s)
37 #define str(s) #s
38 
39 #define SCARDAPI_STUB_CALL_LONG(status, _name, ...) \
40  if (!g_SCardApi || !g_SCardApi->pfn##_name) \
41  { \
42  WLog_DBG(TAG, "Missing function pointer g_SCardApi=%p->" xstr(pfn##_name) "=%p", \
43  g_SCardApi, g_SCardApi ? g_SCardApi->pfn##_name : NULL); \
44  status = SCARD_E_NO_SERVICE; \
45  } \
46  else \
47  status = g_SCardApi->pfn##_name(__VA_ARGS__)
48 
49 #define SCARDAPI_STUB_CALL_HANDLE(status, _name, ...) \
50  if (!g_SCardApi || !g_SCardApi->pfn##_name) \
51  { \
52  WLog_DBG(TAG, "Missing function pointer g_SCardApi=%p->" xstr(pfn##_name) "=%p", \
53  g_SCardApi, g_SCardApi ? g_SCardApi->pfn##_name : NULL); \
54  status = NULL; \
55  } \
56  else \
57  status = g_SCardApi->pfn##_name(__VA_ARGS__)
58 
59 #define SCARDAPI_STUB_CALL_VOID(_name, ...) \
60  if (!g_SCardApi || !g_SCardApi->pfn##_name) \
61  { \
62  WLog_DBG(TAG, "Missing function pointer g_SCardApi=%p->" xstr(pfn##_name) "=%p", \
63  g_SCardApi, g_SCardApi ? g_SCardApi->pfn##_name : NULL); \
64  } \
65  else \
66  g_SCardApi->pfn##_name(__VA_ARGS__)
67 
68 static const DWORD g_LogLevel = WLOG_DEBUG;
69 static wLog* g_Log = NULL;
70 
71 static const SCardApiFunctionTable* g_SCardApi = NULL;
72 
77 static LONG WINAPI Inspect_SCardEstablishContext(DWORD dwScope, LPCVOID pvReserved1,
78  LPCVOID pvReserved2, LPSCARDCONTEXT phContext)
79 {
80  LONG status = 0;
81 
82  WLog_Print(g_Log, g_LogLevel, "SCardEstablishContext { dwScope: %s (0x%08" PRIX32 ")",
83  SCardGetScopeString(dwScope), dwScope);
84 
85  SCARDAPI_STUB_CALL_LONG(status, SCardEstablishContext, dwScope, pvReserved1, pvReserved2,
86  phContext);
87 
88  WLog_Print(g_Log, g_LogLevel, "SCardEstablishContext } status: %s (0x%08" PRIX32 ")",
89  SCardGetErrorString(status), status);
90 
91  return status;
92 }
93 
94 static LONG WINAPI Inspect_SCardReleaseContext(SCARDCONTEXT hContext)
95 {
96  LONG status = 0;
97 
98  WLog_Print(g_Log, g_LogLevel, "SCardReleaseContext { hContext: %p", (void*)hContext);
99 
100  SCARDAPI_STUB_CALL_LONG(status, SCardReleaseContext, hContext);
101 
102  WLog_Print(g_Log, g_LogLevel, "SCardReleaseContext } status: %s (0x%08" PRIX32 ")",
103  SCardGetErrorString(status), status);
104 
105  return status;
106 }
107 
108 static LONG WINAPI Inspect_SCardIsValidContext(SCARDCONTEXT hContext)
109 {
110  LONG status = 0;
111 
112  WLog_Print(g_Log, g_LogLevel, "SCardIsValidContext { hContext: %p", (void*)hContext);
113 
114  SCARDAPI_STUB_CALL_LONG(status, SCardIsValidContext, hContext);
115 
116  WLog_Print(g_Log, g_LogLevel, "SCardIsValidContext } status: %s (0x%08" PRIX32 ")",
117  SCardGetErrorString(status), status);
118 
119  return status;
120 }
121 
122 static LONG WINAPI Inspect_SCardListReaderGroupsA(SCARDCONTEXT hContext, LPSTR mszGroups,
123  LPDWORD pcchGroups)
124 {
125  LONG status = 0;
126 
127  WLog_Print(g_Log, g_LogLevel, "SCardListReaderGroupsA { hContext: %p", (void*)hContext);
128 
129  SCARDAPI_STUB_CALL_LONG(status, SCardListReaderGroupsA, hContext, mszGroups, pcchGroups);
130 
131  WLog_Print(g_Log, g_LogLevel, "SCardListReaderGroupsA } status: %s (0x%08" PRIX32 ")",
132  SCardGetErrorString(status), status);
133 
134  return status;
135 }
136 
137 static LONG WINAPI Inspect_SCardListReaderGroupsW(SCARDCONTEXT hContext, LPWSTR mszGroups,
138  LPDWORD pcchGroups)
139 {
140  LONG status = 0;
141 
142  WLog_Print(g_Log, g_LogLevel, "SCardListReaderGroupsW { hContext: %p", (void*)hContext);
143 
144  SCARDAPI_STUB_CALL_LONG(status, SCardListReaderGroupsW, hContext, mszGroups, pcchGroups);
145 
146  WLog_Print(g_Log, g_LogLevel, "SCardListReaderGroupsW } status: %s (0x%08" PRIX32 ")",
147  SCardGetErrorString(status), status);
148 
149  return status;
150 }
151 
152 static LONG WINAPI Inspect_SCardListReadersA(SCARDCONTEXT hContext, LPCSTR mszGroups,
153  LPSTR mszReaders, LPDWORD pcchReaders)
154 {
155  LONG status = 0;
156 
157  WLog_Print(g_Log, g_LogLevel, "SCardListReadersA { hContext: %p", (void*)hContext);
158 
159  SCARDAPI_STUB_CALL_LONG(status, SCardListReadersA, hContext, mszGroups, mszReaders,
160  pcchReaders);
161 
162  WLog_Print(g_Log, g_LogLevel, "SCardListReadersA } status: %s (0x%08" PRIX32 ")",
163  SCardGetErrorString(status), status);
164 
165  return status;
166 }
167 
168 static LONG WINAPI Inspect_SCardListReadersW(SCARDCONTEXT hContext, LPCWSTR mszGroups,
169  LPWSTR mszReaders, LPDWORD pcchReaders)
170 {
171  LONG status = 0;
172  WLog_Print(g_Log, g_LogLevel, "SCardListReadersW { hContext: %p", (void*)hContext);
173 
174  SCARDAPI_STUB_CALL_LONG(status, SCardListReadersW, hContext, mszGroups, mszReaders,
175  pcchReaders);
176  WLog_Print(g_Log, g_LogLevel, "SCardListReadersW } status: %s (0x%08" PRIX32 ")",
177  SCardGetErrorString(status), status);
178 
179  return status;
180 }
181 
182 static LONG WINAPI Inspect_SCardListCardsA(SCARDCONTEXT hContext, LPCBYTE pbAtr,
183  LPCGUID rgquidInterfaces, DWORD cguidInterfaceCount,
184  CHAR* mszCards, LPDWORD pcchCards)
185 {
186  LONG status = 0;
187 
188  WLog_Print(g_Log, g_LogLevel, "SCardListCardsA { hContext: %p", (void*)hContext);
189 
190  SCARDAPI_STUB_CALL_LONG(status, SCardListCardsA, hContext, pbAtr, rgquidInterfaces,
191  cguidInterfaceCount, mszCards, pcchCards);
192 
193  WLog_Print(g_Log, g_LogLevel, "SCardListCardsA } status: %s (0x%08" PRIX32 ")",
194  SCardGetErrorString(status), status);
195 
196  return status;
197 }
198 
199 static LONG WINAPI Inspect_SCardListCardsW(SCARDCONTEXT hContext, LPCBYTE pbAtr,
200  LPCGUID rgquidInterfaces, DWORD cguidInterfaceCount,
201  WCHAR* mszCards, LPDWORD pcchCards)
202 {
203  LONG status = 0;
204 
205  WLog_Print(g_Log, g_LogLevel, "SCardListCardsW { hContext: %p", (void*)hContext);
206 
207  SCARDAPI_STUB_CALL_LONG(status, SCardListCardsW, hContext, pbAtr, rgquidInterfaces,
208  cguidInterfaceCount, mszCards, pcchCards);
209 
210  WLog_Print(g_Log, g_LogLevel, "SCardListCardsW } status: %s (0x%08" PRIX32 ")",
211  SCardGetErrorString(status), status);
212 
213  return status;
214 }
215 
216 static LONG WINAPI Inspect_SCardListInterfacesA(SCARDCONTEXT hContext, LPCSTR szCard,
217  LPGUID pguidInterfaces, LPDWORD pcguidInterfaces)
218 {
219  LONG status = 0;
220 
221  WLog_Print(g_Log, g_LogLevel, "SCardListInterfacesA { hContext: %p", (void*)hContext);
222 
223  SCARDAPI_STUB_CALL_LONG(status, SCardListInterfacesA, hContext, szCard, pguidInterfaces,
224  pcguidInterfaces);
225 
226  WLog_Print(g_Log, g_LogLevel, "SCardListInterfacesA } status: %s (0x%08" PRIX32 ")",
227  SCardGetErrorString(status), status);
228 
229  return status;
230 }
231 
232 static LONG WINAPI Inspect_SCardListInterfacesW(SCARDCONTEXT hContext, LPCWSTR szCard,
233  LPGUID pguidInterfaces, LPDWORD pcguidInterfaces)
234 {
235  LONG status = 0;
236 
237  WLog_Print(g_Log, g_LogLevel, "SCardListInterfacesW { hContext: %p", (void*)hContext);
238 
239  SCARDAPI_STUB_CALL_LONG(status, SCardListInterfacesW, hContext, szCard, pguidInterfaces,
240  pcguidInterfaces);
241 
242  WLog_Print(g_Log, g_LogLevel, "SCardListInterfacesW } status: %s (0x%08" PRIX32 ")",
243  SCardGetErrorString(status), status);
244 
245  return status;
246 }
247 
248 static LONG WINAPI Inspect_SCardGetProviderIdA(SCARDCONTEXT hContext, LPCSTR szCard,
249  LPGUID pguidProviderId)
250 {
251  LONG status = 0;
252 
253  WLog_Print(g_Log, g_LogLevel, "SCardGetProviderIdA { hContext: %p", (void*)hContext);
254 
255  SCARDAPI_STUB_CALL_LONG(status, SCardGetProviderIdA, hContext, szCard, pguidProviderId);
256 
257  WLog_Print(g_Log, g_LogLevel, "SCardGetProviderIdA } status: %s (0x%08" PRIX32 ")",
258  SCardGetErrorString(status), status);
259 
260  return status;
261 }
262 
263 static LONG WINAPI Inspect_SCardGetProviderIdW(SCARDCONTEXT hContext, LPCWSTR szCard,
264  LPGUID pguidProviderId)
265 {
266  LONG status = 0;
267 
268  WLog_Print(g_Log, g_LogLevel, "SCardGetProviderIdW { hContext: %p", (void*)hContext);
269 
270  SCARDAPI_STUB_CALL_LONG(status, SCardGetProviderIdW, hContext, szCard, pguidProviderId);
271 
272  WLog_Print(g_Log, g_LogLevel, "SCardGetProviderIdW } status: %s (0x%08" PRIX32 ")",
273  SCardGetErrorString(status), status);
274 
275  return status;
276 }
277 
278 static LONG WINAPI Inspect_SCardGetCardTypeProviderNameA(SCARDCONTEXT hContext, LPCSTR szCardName,
279  DWORD dwProviderId, CHAR* szProvider,
280  LPDWORD pcchProvider)
281 {
282  LONG status = 0;
283 
284  WLog_Print(g_Log, g_LogLevel, "SCardGetCardTypeProviderNameA { hContext: %p", (void*)hContext);
285 
286  SCARDAPI_STUB_CALL_LONG(status, SCardGetCardTypeProviderNameA, hContext, szCardName,
287  dwProviderId, szProvider, pcchProvider);
288 
289  WLog_Print(g_Log, g_LogLevel, "SCardGetCardTypeProviderNameA } status: %s (0x%08" PRIX32 ")",
290  SCardGetErrorString(status), status);
291 
292  return status;
293 }
294 
295 static LONG WINAPI Inspect_SCardGetCardTypeProviderNameW(SCARDCONTEXT hContext, LPCWSTR szCardName,
296  DWORD dwProviderId, WCHAR* szProvider,
297  LPDWORD pcchProvider)
298 {
299  LONG status = 0;
300 
301  WLog_Print(g_Log, g_LogLevel, "SCardGetCardTypeProviderNameW { hContext: %p", (void*)hContext);
302 
303  SCARDAPI_STUB_CALL_LONG(status, SCardGetCardTypeProviderNameW, hContext, szCardName,
304  dwProviderId, szProvider, pcchProvider);
305 
306  WLog_Print(g_Log, g_LogLevel, "SCardGetCardTypeProviderNameW } status: %s (0x%08" PRIX32 ")",
307  SCardGetErrorString(status), status);
308 
309  return status;
310 }
311 
312 static LONG WINAPI Inspect_SCardIntroduceReaderGroupA(SCARDCONTEXT hContext, LPCSTR szGroupName)
313 {
314  LONG status = 0;
315 
316  WLog_Print(g_Log, g_LogLevel, "SCardIntroduceReaderGroupA { hContext: %p", (void*)hContext);
317 
318  SCARDAPI_STUB_CALL_LONG(status, SCardIntroduceReaderGroupA, hContext, szGroupName);
319 
320  WLog_Print(g_Log, g_LogLevel, "SCardIntroduceReaderGroupA } status: %s (0x%08" PRIX32 ")",
321  SCardGetErrorString(status), status);
322 
323  return status;
324 }
325 
326 static LONG WINAPI Inspect_SCardIntroduceReaderGroupW(SCARDCONTEXT hContext, LPCWSTR szGroupName)
327 {
328  LONG status = 0;
329 
330  WLog_Print(g_Log, g_LogLevel, "SCardIntroduceReaderGroupW { hContext: %p", (void*)hContext);
331 
332  SCARDAPI_STUB_CALL_LONG(status, SCardIntroduceReaderGroupW, hContext, szGroupName);
333 
334  WLog_Print(g_Log, g_LogLevel, "SCardIntroduceReaderGroupW } status: %s (0x%08" PRIX32 ")",
335  SCardGetErrorString(status), status);
336 
337  return status;
338 }
339 
340 static LONG WINAPI Inspect_SCardForgetReaderGroupA(SCARDCONTEXT hContext, LPCSTR szGroupName)
341 {
342  LONG status = 0;
343 
344  WLog_Print(g_Log, g_LogLevel, "SCardForgetReaderGroupA { hContext: %p", (void*)hContext);
345 
346  SCARDAPI_STUB_CALL_LONG(status, SCardForgetReaderGroupA, hContext, szGroupName);
347 
348  WLog_Print(g_Log, g_LogLevel, "SCardForgetReaderGroupA } status: %s (0x%08" PRIX32 ")",
349  SCardGetErrorString(status), status);
350 
351  return status;
352 }
353 
354 static LONG WINAPI Inspect_SCardForgetReaderGroupW(SCARDCONTEXT hContext, LPCWSTR szGroupName)
355 {
356  LONG status = 0;
357 
358  WLog_Print(g_Log, g_LogLevel, "SCardForgetReaderGroupW { hContext: %p", (void*)hContext);
359 
360  SCARDAPI_STUB_CALL_LONG(status, SCardForgetReaderGroupW, hContext, szGroupName);
361 
362  WLog_Print(g_Log, g_LogLevel, "SCardForgetReaderGroupW } status: %s (0x%08" PRIX32 ")",
363  SCardGetErrorString(status), status);
364 
365  return status;
366 }
367 
368 static LONG WINAPI Inspect_SCardIntroduceReaderA(SCARDCONTEXT hContext, LPCSTR szReaderName,
369  LPCSTR szDeviceName)
370 {
371  LONG status = 0;
372 
373  WLog_Print(g_Log, g_LogLevel, "SCardIntroduceReaderA { hContext: %p", (void*)hContext);
374 
375  SCARDAPI_STUB_CALL_LONG(status, SCardIntroduceReaderA, hContext, szReaderName, szDeviceName);
376 
377  WLog_Print(g_Log, g_LogLevel, "SCardIntroduceReaderA } status: %s (0x%08" PRIX32 ")",
378  SCardGetErrorString(status), status);
379 
380  return status;
381 }
382 
383 static LONG WINAPI Inspect_SCardIntroduceReaderW(SCARDCONTEXT hContext, LPCWSTR szReaderName,
384  LPCWSTR szDeviceName)
385 {
386  LONG status = 0;
387 
388  WLog_Print(g_Log, g_LogLevel, "SCardIntroduceReaderW { hContext: %p", (void*)hContext);
389 
390  SCARDAPI_STUB_CALL_LONG(status, SCardIntroduceReaderW, hContext, szReaderName, szDeviceName);
391 
392  WLog_Print(g_Log, g_LogLevel, "SCardIntroduceReaderW } status: %s (0x%08" PRIX32 ")",
393  SCardGetErrorString(status), status);
394 
395  return status;
396 }
397 
398 static LONG WINAPI Inspect_SCardForgetReaderA(SCARDCONTEXT hContext, LPCSTR szReaderName)
399 {
400  LONG status = 0;
401 
402  WLog_Print(g_Log, g_LogLevel, "SCardForgetReaderA { hContext: %p", (void*)hContext);
403 
404  SCARDAPI_STUB_CALL_LONG(status, SCardForgetReaderA, hContext, szReaderName);
405 
406  WLog_Print(g_Log, g_LogLevel, "SCardForgetReaderA } status: %s (0x%08" PRIX32 ")",
407  SCardGetErrorString(status), status);
408 
409  return status;
410 }
411 
412 static LONG WINAPI Inspect_SCardForgetReaderW(SCARDCONTEXT hContext, LPCWSTR szReaderName)
413 {
414  LONG status = 0;
415 
416  WLog_Print(g_Log, g_LogLevel, "SCardForgetReaderW { hContext: %p", (void*)hContext);
417 
418  SCARDAPI_STUB_CALL_LONG(status, SCardForgetReaderW, hContext, szReaderName);
419 
420  WLog_Print(g_Log, g_LogLevel, "SCardForgetReaderW } status: %s (0x%08" PRIX32 ")",
421  SCardGetErrorString(status), status);
422 
423  return status;
424 }
425 
426 static LONG WINAPI Inspect_SCardAddReaderToGroupA(SCARDCONTEXT hContext, LPCSTR szReaderName,
427  LPCSTR szGroupName)
428 {
429  LONG status = 0;
430 
431  WLog_Print(g_Log, g_LogLevel, "SCardAddReaderToGroupA { hContext: %p", (void*)hContext);
432 
433  SCARDAPI_STUB_CALL_LONG(status, SCardAddReaderToGroupA, hContext, szReaderName, szGroupName);
434 
435  WLog_Print(g_Log, g_LogLevel, "SCardAddReaderToGroupA } status: %s (0x%08" PRIX32 ")",
436  SCardGetErrorString(status), status);
437 
438  return status;
439 }
440 
441 static LONG WINAPI Inspect_SCardAddReaderToGroupW(SCARDCONTEXT hContext, LPCWSTR szReaderName,
442  LPCWSTR szGroupName)
443 {
444  LONG status = 0;
445 
446  WLog_Print(g_Log, g_LogLevel, "SCardAddReaderToGroupW { hContext: %p", (void*)hContext);
447 
448  SCARDAPI_STUB_CALL_LONG(status, SCardAddReaderToGroupW, hContext, szReaderName, szGroupName);
449 
450  WLog_Print(g_Log, g_LogLevel, "SCardAddReaderToGroupW } status: %s (0x%08" PRIX32 ")",
451  SCardGetErrorString(status), status);
452 
453  return status;
454 }
455 
456 static LONG WINAPI Inspect_SCardRemoveReaderFromGroupA(SCARDCONTEXT hContext, LPCSTR szReaderName,
457  LPCSTR szGroupName)
458 {
459  LONG status = 0;
460 
461  WLog_Print(g_Log, g_LogLevel, "SCardRemoveReaderFromGroupA { hContext: %p", (void*)hContext);
462 
463  SCARDAPI_STUB_CALL_LONG(status, SCardRemoveReaderFromGroupA, hContext, szReaderName,
464  szGroupName);
465 
466  WLog_Print(g_Log, g_LogLevel, "SCardRemoveReaderFromGroupA } status: %s (0x%08" PRIX32 ")",
467  SCardGetErrorString(status), status);
468 
469  return status;
470 }
471 
472 static LONG WINAPI Inspect_SCardRemoveReaderFromGroupW(SCARDCONTEXT hContext, LPCWSTR szReaderName,
473  LPCWSTR szGroupName)
474 {
475  LONG status = 0;
476 
477  WLog_Print(g_Log, g_LogLevel, "SCardRemoveReaderFromGroupW { hContext: %p", (void*)hContext);
478 
479  SCARDAPI_STUB_CALL_LONG(status, SCardRemoveReaderFromGroupW, hContext, szReaderName,
480  szGroupName);
481 
482  WLog_Print(g_Log, g_LogLevel, "SCardRemoveReaderFromGroupW } status: %s (0x%08" PRIX32 ")",
483  SCardGetErrorString(status), status);
484 
485  return status;
486 }
487 
488 static LONG WINAPI Inspect_SCardIntroduceCardTypeA(SCARDCONTEXT hContext, LPCSTR szCardName,
489  LPCGUID pguidPrimaryProvider,
490  LPCGUID rgguidInterfaces, DWORD dwInterfaceCount,
491  LPCBYTE pbAtr, LPCBYTE pbAtrMask, DWORD cbAtrLen)
492 {
493  LONG status = 0;
494 
495  WLog_Print(g_Log, g_LogLevel, "SCardIntroduceCardTypeA { hContext: %p", (void*)hContext);
496 
497  SCARDAPI_STUB_CALL_LONG(status, SCardIntroduceCardTypeA, hContext, szCardName,
498  pguidPrimaryProvider, rgguidInterfaces, dwInterfaceCount, pbAtr,
499  pbAtrMask, cbAtrLen);
500 
501  WLog_Print(g_Log, g_LogLevel, "SCardIntroduceCardTypeA } status: %s (0x%08" PRIX32 ")",
502  SCardGetErrorString(status), status);
503 
504  return status;
505 }
506 
507 static LONG WINAPI Inspect_SCardIntroduceCardTypeW(SCARDCONTEXT hContext, LPCWSTR szCardName,
508  LPCGUID pguidPrimaryProvider,
509  LPCGUID rgguidInterfaces, DWORD dwInterfaceCount,
510  LPCBYTE pbAtr, LPCBYTE pbAtrMask, DWORD cbAtrLen)
511 {
512  LONG status = 0;
513 
514  WLog_Print(g_Log, g_LogLevel, "SCardIntroduceCardTypeW { hContext: %p", (void*)hContext);
515 
516  SCARDAPI_STUB_CALL_LONG(status, SCardIntroduceCardTypeW, hContext, szCardName,
517  pguidPrimaryProvider, rgguidInterfaces, dwInterfaceCount, pbAtr,
518  pbAtrMask, cbAtrLen);
519 
520  WLog_Print(g_Log, g_LogLevel, "SCardIntroduceCardTypeW } status: %s (0x%08" PRIX32 ")",
521  SCardGetErrorString(status), status);
522 
523  return status;
524 }
525 
526 static LONG WINAPI Inspect_SCardSetCardTypeProviderNameA(SCARDCONTEXT hContext, LPCSTR szCardName,
527  DWORD dwProviderId, LPCSTR szProvider)
528 {
529  LONG status = 0;
530 
531  WLog_Print(g_Log, g_LogLevel, "SCardSetCardTypeProviderNameA { hContext: %p", (void*)hContext);
532 
533  SCARDAPI_STUB_CALL_LONG(status, SCardSetCardTypeProviderNameA, hContext, szCardName,
534  dwProviderId, szProvider);
535 
536  WLog_Print(g_Log, g_LogLevel, "SCardSetCardTypeProviderNameA } status: %s (0x%08" PRIX32 ")",
537  SCardGetErrorString(status), status);
538 
539  return status;
540 }
541 
542 static LONG WINAPI Inspect_SCardSetCardTypeProviderNameW(SCARDCONTEXT hContext, LPCWSTR szCardName,
543  DWORD dwProviderId, LPCWSTR szProvider)
544 {
545  LONG status = 0;
546 
547  WLog_Print(g_Log, g_LogLevel, "SCardSetCardTypeProviderNameA { hContext: %p", (void*)hContext);
548 
549  SCARDAPI_STUB_CALL_LONG(status, SCardSetCardTypeProviderNameW, hContext, szCardName,
550  dwProviderId, szProvider);
551 
552  WLog_Print(g_Log, g_LogLevel, "SCardSetCardTypeProviderNameW } status: %s (0x%08" PRIX32 ")",
553  SCardGetErrorString(status), status);
554 
555  return status;
556 }
557 
558 static LONG WINAPI Inspect_SCardForgetCardTypeA(SCARDCONTEXT hContext, LPCSTR szCardName)
559 {
560  LONG status = 0;
561 
562  WLog_Print(g_Log, g_LogLevel, "SCardForgetCardTypeA { hContext: %p", (void*)hContext);
563 
564  SCARDAPI_STUB_CALL_LONG(status, SCardForgetCardTypeA, hContext, szCardName);
565 
566  WLog_Print(g_Log, g_LogLevel, "SCardForgetCardTypeA } status: %s (0x%08" PRIX32 ")",
567  SCardGetErrorString(status), status);
568 
569  return status;
570 }
571 
572 static LONG WINAPI Inspect_SCardForgetCardTypeW(SCARDCONTEXT hContext, LPCWSTR szCardName)
573 {
574  LONG status = 0;
575 
576  WLog_Print(g_Log, g_LogLevel, "SCardForgetCardTypeW { hContext: %p", (void*)hContext);
577 
578  SCARDAPI_STUB_CALL_LONG(status, SCardForgetCardTypeW, hContext, szCardName);
579 
580  WLog_Print(g_Log, g_LogLevel, "SCardForgetCardTypeW } status: %s (0x%08" PRIX32 ")",
581  SCardGetErrorString(status), status);
582 
583  return status;
584 }
585 
586 static LONG WINAPI Inspect_SCardFreeMemory(SCARDCONTEXT hContext, LPVOID pvMem)
587 {
588  LONG status = 0;
589 
590  WLog_Print(g_Log, g_LogLevel, "SCardFreeMemory { hContext: %p", (void*)hContext);
591 
592  SCARDAPI_STUB_CALL_LONG(status, SCardFreeMemory, hContext, pvMem);
593 
594  WLog_Print(g_Log, g_LogLevel, "SCardFreeMemory } status: %s (0x%08" PRIX32 ")",
595  SCardGetErrorString(status), status);
596 
597  return status;
598 }
599 
600 static HANDLE WINAPI Inspect_SCardAccessStartedEvent(void)
601 {
602  HANDLE hEvent = NULL;
603 
604  WLog_Print(g_Log, g_LogLevel, "SCardAccessStartedEvent {");
605 
606  SCARDAPI_STUB_CALL_HANDLE(hEvent, SCardAccessStartedEvent);
607 
608  WLog_Print(g_Log, g_LogLevel, "SCardAccessStartedEvent } hEvent: %p", hEvent);
609 
610  return hEvent;
611 }
612 
613 static void WINAPI Inspect_SCardReleaseStartedEvent(void)
614 {
615  WLog_Print(g_Log, g_LogLevel, "SCardReleaseStartedEvent {");
616 
617  SCARDAPI_STUB_CALL_VOID(SCardReleaseStartedEvent);
618 
619  WLog_Print(g_Log, g_LogLevel, "SCardReleaseStartedEvent }");
620 }
621 
622 static LONG WINAPI Inspect_SCardLocateCardsA(SCARDCONTEXT hContext, LPCSTR mszCards,
623  LPSCARD_READERSTATEA rgReaderStates, DWORD cReaders)
624 {
625  LONG status = 0;
626 
627  WLog_Print(g_Log, g_LogLevel, "SCardLocateCardsA { hContext: %p", (void*)hContext);
628 
629  SCARDAPI_STUB_CALL_LONG(status, SCardLocateCardsA, hContext, mszCards, rgReaderStates,
630  cReaders);
631 
632  WLog_Print(g_Log, g_LogLevel, "SCardLocateCardsA } status: %s (0x%08" PRIX32 ")",
633  SCardGetErrorString(status), status);
634 
635  return status;
636 }
637 
638 static LONG WINAPI Inspect_SCardLocateCardsW(SCARDCONTEXT hContext, LPCWSTR mszCards,
639  LPSCARD_READERSTATEW rgReaderStates, DWORD cReaders)
640 {
641  LONG status = 0;
642 
643  WLog_Print(g_Log, g_LogLevel, "SCardLocateCardsW { hContext: %p", (void*)hContext);
644 
645  SCARDAPI_STUB_CALL_LONG(status, SCardLocateCardsW, hContext, mszCards, rgReaderStates,
646  cReaders);
647 
648  WLog_Print(g_Log, g_LogLevel, "SCardLocateCardsW } status: %s (0x%08" PRIX32 ")",
649  SCardGetErrorString(status), status);
650 
651  return status;
652 }
653 
654 static LONG WINAPI Inspect_SCardLocateCardsByATRA(SCARDCONTEXT hContext, LPSCARD_ATRMASK rgAtrMasks,
655  DWORD cAtrs, LPSCARD_READERSTATEA rgReaderStates,
656  DWORD cReaders)
657 {
658  LONG status = 0;
659 
660  WLog_Print(g_Log, g_LogLevel, "SCardLocateCardsByATRA { hContext: %p", (void*)hContext);
661 
662  SCARDAPI_STUB_CALL_LONG(status, SCardLocateCardsByATRA, hContext, rgAtrMasks, cAtrs,
663  rgReaderStates, cReaders);
664 
665  WLog_Print(g_Log, g_LogLevel, "SCardLocateCardsByATRA } status: %s (0x%08" PRIX32 ")",
666  SCardGetErrorString(status), status);
667 
668  return status;
669 }
670 
671 static LONG WINAPI Inspect_SCardLocateCardsByATRW(SCARDCONTEXT hContext, LPSCARD_ATRMASK rgAtrMasks,
672  DWORD cAtrs, LPSCARD_READERSTATEW rgReaderStates,
673  DWORD cReaders)
674 {
675  LONG status = 0;
676 
677  WLog_Print(g_Log, g_LogLevel, "SCardLocateCardsByATRW { hContext: %p", (void*)hContext);
678 
679  SCARDAPI_STUB_CALL_LONG(status, SCardLocateCardsByATRW, hContext, rgAtrMasks, cAtrs,
680  rgReaderStates, cReaders);
681 
682  WLog_Print(g_Log, g_LogLevel, "SCardLocateCardsByATRW } status: %s (0x%08" PRIX32 ")",
683  SCardGetErrorString(status), status);
684 
685  return status;
686 }
687 
688 static LONG WINAPI Inspect_SCardGetStatusChangeA(SCARDCONTEXT hContext, DWORD dwTimeout,
689  LPSCARD_READERSTATEA rgReaderStates,
690  DWORD cReaders)
691 {
692  LONG status = 0;
693 
694  WLog_Print(g_Log, g_LogLevel, "SCardGetStatusChangeA { hContext: %p", (void*)hContext);
695 
696  SCARDAPI_STUB_CALL_LONG(status, SCardGetStatusChangeA, hContext, dwTimeout, rgReaderStates,
697  cReaders);
698 
699  WLog_Print(g_Log, g_LogLevel, "SCardGetStatusChangeA } status: %s (0x%08" PRIX32 ")",
700  SCardGetErrorString(status), status);
701 
702  return status;
703 }
704 
705 static LONG WINAPI Inspect_SCardGetStatusChangeW(SCARDCONTEXT hContext, DWORD dwTimeout,
706  LPSCARD_READERSTATEW rgReaderStates,
707  DWORD cReaders)
708 {
709  LONG status = 0;
710 
711  WLog_Print(g_Log, g_LogLevel, "SCardGetStatusChangeW { hContext: %p", (void*)hContext);
712 
713  SCARDAPI_STUB_CALL_LONG(status, SCardGetStatusChangeW, hContext, dwTimeout, rgReaderStates,
714  cReaders);
715 
716  WLog_Print(g_Log, g_LogLevel, "SCardGetStatusChangeW } status: %s (0x%08" PRIX32 ")",
717  SCardGetErrorString(status), status);
718 
719  return status;
720 }
721 
722 static LONG WINAPI Inspect_SCardCancel(SCARDCONTEXT hContext)
723 {
724  LONG status = 0;
725 
726  WLog_Print(g_Log, g_LogLevel, "SCardCancel { hContext: %p", (void*)hContext);
727 
728  SCARDAPI_STUB_CALL_LONG(status, SCardCancel, hContext);
729 
730  WLog_Print(g_Log, g_LogLevel, "SCardCancel } status: %s (0x%08" PRIX32 ")",
731  SCardGetErrorString(status), status);
732 
733  return status;
734 }
735 
736 static LONG WINAPI Inspect_SCardConnectA(SCARDCONTEXT hContext, LPCSTR szReader, DWORD dwShareMode,
737  DWORD dwPreferredProtocols, LPSCARDHANDLE phCard,
738  LPDWORD pdwActiveProtocol)
739 {
740  LONG status = 0;
741 
742  WLog_Print(g_Log, g_LogLevel, "SCardConnectA { hContext: %p", (void*)hContext);
743 
744  SCARDAPI_STUB_CALL_LONG(status, SCardConnectA, hContext, szReader, dwShareMode,
745  dwPreferredProtocols, phCard, pdwActiveProtocol);
746 
747  WLog_Print(g_Log, g_LogLevel, "SCardConnectA } status: %s (0x%08" PRIX32 ")",
748  SCardGetErrorString(status), status);
749 
750  return status;
751 }
752 
753 static LONG WINAPI Inspect_SCardConnectW(SCARDCONTEXT hContext, LPCWSTR szReader, DWORD dwShareMode,
754  DWORD dwPreferredProtocols, LPSCARDHANDLE phCard,
755  LPDWORD pdwActiveProtocol)
756 {
757  LONG status = 0;
758 
759  WLog_Print(g_Log, g_LogLevel, "SCardConnectW { hContext: %p", (void*)hContext);
760 
761  SCARDAPI_STUB_CALL_LONG(status, SCardConnectW, hContext, szReader, dwShareMode,
762  dwPreferredProtocols, phCard, pdwActiveProtocol);
763 
764  WLog_Print(g_Log, g_LogLevel, "SCardConnectW } status: %s (0x%08" PRIX32 ")",
765  SCardGetErrorString(status), status);
766 
767  return status;
768 }
769 
770 static LONG WINAPI Inspect_SCardReconnect(SCARDHANDLE hCard, DWORD dwShareMode,
771  DWORD dwPreferredProtocols, DWORD dwInitialization,
772  LPDWORD pdwActiveProtocol)
773 {
774  LONG status = 0;
775 
776  WLog_Print(g_Log, g_LogLevel, "SCardReconnect { hCard: %p", (void*)hCard);
777 
778  SCARDAPI_STUB_CALL_LONG(status, SCardReconnect, hCard, dwShareMode, dwPreferredProtocols,
779  dwInitialization, pdwActiveProtocol);
780 
781  WLog_Print(g_Log, g_LogLevel, "SCardReconnect } status: %s (0x%08" PRIX32 ")",
782  SCardGetErrorString(status), status);
783 
784  return status;
785 }
786 
787 static LONG WINAPI Inspect_SCardDisconnect(SCARDHANDLE hCard, DWORD dwDisposition)
788 {
789  LONG status = 0;
790 
791  WLog_Print(g_Log, g_LogLevel, "SCardDisconnect { hCard: %p", (void*)hCard);
792 
793  SCARDAPI_STUB_CALL_LONG(status, SCardDisconnect, hCard, dwDisposition);
794 
795  WLog_Print(g_Log, g_LogLevel, "SCardDisconnect } status: %s (0x%08" PRIX32 ")",
796  SCardGetErrorString(status), status);
797 
798  return status;
799 }
800 
801 static LONG WINAPI Inspect_SCardBeginTransaction(SCARDHANDLE hCard)
802 {
803  LONG status = 0;
804 
805  WLog_Print(g_Log, g_LogLevel, "SCardBeginTransaction { hCard: %p", (void*)hCard);
806 
807  SCARDAPI_STUB_CALL_LONG(status, SCardBeginTransaction, hCard);
808 
809  WLog_Print(g_Log, g_LogLevel, "SCardBeginTransaction } status: %s (0x%08" PRIX32 ")",
810  SCardGetErrorString(status), status);
811 
812  return status;
813 }
814 
815 static LONG WINAPI Inspect_SCardEndTransaction(SCARDHANDLE hCard, DWORD dwDisposition)
816 {
817  LONG status = 0;
818 
819  WLog_Print(g_Log, g_LogLevel, "SCardEndTransaction { hCard: %p", (void*)hCard);
820 
821  SCARDAPI_STUB_CALL_LONG(status, SCardEndTransaction, hCard, dwDisposition);
822 
823  WLog_Print(g_Log, g_LogLevel, "SCardEndTransaction } status: %s (0x%08" PRIX32 ")",
824  SCardGetErrorString(status), status);
825 
826  return status;
827 }
828 
829 static LONG WINAPI Inspect_SCardCancelTransaction(SCARDHANDLE hCard)
830 {
831  LONG status = 0;
832 
833  WLog_Print(g_Log, g_LogLevel, "SCardCancelTransaction { hCard: %p", (void*)hCard);
834 
835  SCARDAPI_STUB_CALL_LONG(status, SCardCancelTransaction, hCard);
836 
837  WLog_Print(g_Log, g_LogLevel, "SCardCancelTransaction } status: %s (0x%08" PRIX32 ")",
838  SCardGetErrorString(status), status);
839 
840  return status;
841 }
842 
843 static LONG WINAPI Inspect_SCardState(SCARDHANDLE hCard, LPDWORD pdwState, LPDWORD pdwProtocol,
844  LPBYTE pbAtr, LPDWORD pcbAtrLen)
845 {
846  LONG status = 0;
847 
848  WLog_Print(g_Log, g_LogLevel, "SCardState { hCard: %p", (void*)hCard);
849 
850  SCARDAPI_STUB_CALL_LONG(status, SCardState, hCard, pdwState, pdwProtocol, pbAtr, pcbAtrLen);
851 
852  WLog_Print(g_Log, g_LogLevel, "SCardState } status: %s (0x%08" PRIX32 ")",
853  SCardGetErrorString(status), status);
854 
855  return status;
856 }
857 
858 static LONG WINAPI Inspect_SCardStatusA(SCARDHANDLE hCard, LPSTR mszReaderNames,
859  LPDWORD pcchReaderLen, LPDWORD pdwState,
860  LPDWORD pdwProtocol, LPBYTE pbAtr, LPDWORD pcbAtrLen)
861 {
862  LONG status = 0;
863 
864  WLog_Print(g_Log, g_LogLevel, "SCardStatusA { hCard: %p", (void*)hCard);
865 
866  SCARDAPI_STUB_CALL_LONG(status, SCardStatusA, hCard, mszReaderNames, pcchReaderLen, pdwState,
867  pdwProtocol, pbAtr, pcbAtrLen);
868 
869  WLog_Print(g_Log, g_LogLevel, "SCardStatusA } status: %s (0x%08" PRIX32 ")",
870  SCardGetErrorString(status), status);
871 
872  return status;
873 }
874 
875 static LONG WINAPI Inspect_SCardStatusW(SCARDHANDLE hCard, LPWSTR mszReaderNames,
876  LPDWORD pcchReaderLen, LPDWORD pdwState,
877  LPDWORD pdwProtocol, LPBYTE pbAtr, LPDWORD pcbAtrLen)
878 {
879  LONG status = 0;
880 
881  WLog_Print(g_Log, g_LogLevel, "SCardStatusW { hCard: %p", (void*)hCard);
882 
883  SCARDAPI_STUB_CALL_LONG(status, SCardStatusW, hCard, mszReaderNames, pcchReaderLen, pdwState,
884  pdwProtocol, pbAtr, pcbAtrLen);
885 
886  WLog_Print(g_Log, g_LogLevel, "SCardStatusW } status: %s (0x%08" PRIX32 ")",
887  SCardGetErrorString(status), status);
888 
889  return status;
890 }
891 
892 static LONG WINAPI Inspect_SCardTransmit(SCARDHANDLE hCard, LPCSCARD_IO_REQUEST pioSendPci,
893  LPCBYTE pbSendBuffer, DWORD cbSendLength,
894  LPSCARD_IO_REQUEST pioRecvPci, LPBYTE pbRecvBuffer,
895  LPDWORD pcbRecvLength)
896 {
897  LONG status = 0;
898 
899  WLog_Print(g_Log, g_LogLevel, "SCardTransmit { hCard: %p", (void*)hCard);
900 
901  SCARDAPI_STUB_CALL_LONG(status, SCardTransmit, hCard, pioSendPci, pbSendBuffer, cbSendLength,
902  pioRecvPci, pbRecvBuffer, pcbRecvLength);
903 
904  WLog_Print(g_Log, g_LogLevel, "SCardTransmit } status: %s (0x%08" PRIX32 ")",
905  SCardGetErrorString(status), status);
906 
907  return status;
908 }
909 
910 static LONG WINAPI Inspect_SCardGetTransmitCount(SCARDHANDLE hCard, LPDWORD pcTransmitCount)
911 {
912  LONG status = 0;
913 
914  WLog_Print(g_Log, g_LogLevel, "SCardGetTransmitCount { hCard: %p", (void*)hCard);
915 
916  SCARDAPI_STUB_CALL_LONG(status, SCardGetTransmitCount, hCard, pcTransmitCount);
917 
918  WLog_Print(g_Log, g_LogLevel, "SCardGetTransmitCount } status: %s (0x%08" PRIX32 ")",
919  SCardGetErrorString(status), status);
920 
921  return status;
922 }
923 
924 static LONG WINAPI Inspect_SCardControl(SCARDHANDLE hCard, DWORD dwControlCode, LPCVOID lpInBuffer,
925  DWORD cbInBufferSize, LPVOID lpOutBuffer,
926  DWORD cbOutBufferSize, LPDWORD lpBytesReturned)
927 {
928  LONG status = 0;
929 
930  WLog_Print(g_Log, g_LogLevel, "SCardControl { hCard: %p", (void*)hCard);
931 
932  SCARDAPI_STUB_CALL_LONG(status, SCardControl, hCard, dwControlCode, lpInBuffer, cbInBufferSize,
933  lpOutBuffer, cbOutBufferSize, lpBytesReturned);
934 
935  WLog_Print(g_Log, g_LogLevel, "SCardControl } status: %s (0x%08" PRIX32 ")",
936  SCardGetErrorString(status), status);
937 
938  return status;
939 }
940 
941 static LONG WINAPI Inspect_SCardGetAttrib(SCARDHANDLE hCard, DWORD dwAttrId, LPBYTE pbAttr,
942  LPDWORD pcbAttrLen)
943 {
944  LONG status = 0;
945 
946  WLog_Print(g_Log, g_LogLevel, "SCardGetAttrib { hCard: %p", (void*)hCard);
947 
948  SCARDAPI_STUB_CALL_LONG(status, SCardGetAttrib, hCard, dwAttrId, pbAttr, pcbAttrLen);
949 
950  WLog_Print(g_Log, g_LogLevel, "SCardGetAttrib } status: %s (0x%08" PRIX32 ")",
951  SCardGetErrorString(status), status);
952 
953  return status;
954 }
955 
956 static LONG WINAPI Inspect_SCardSetAttrib(SCARDHANDLE hCard, DWORD dwAttrId, LPCBYTE pbAttr,
957  DWORD cbAttrLen)
958 {
959  LONG status = 0;
960 
961  WLog_Print(g_Log, g_LogLevel, "SCardSetAttrib { hCard: %p", (void*)hCard);
962 
963  SCARDAPI_STUB_CALL_LONG(status, SCardSetAttrib, hCard, dwAttrId, pbAttr, cbAttrLen);
964 
965  WLog_Print(g_Log, g_LogLevel, "SCardSetAttrib } status: %s (0x%08" PRIX32 ")",
966  SCardGetErrorString(status), status);
967 
968  return status;
969 }
970 
971 static LONG WINAPI Inspect_SCardUIDlgSelectCardA(LPOPENCARDNAMEA_EX pDlgStruc)
972 {
973  LONG status = 0;
974 
975  WLog_Print(g_Log, g_LogLevel, "SCardUIDlgSelectCardA {");
976 
977  SCARDAPI_STUB_CALL_LONG(status, SCardUIDlgSelectCardA, pDlgStruc);
978 
979  WLog_Print(g_Log, g_LogLevel, "SCardUIDlgSelectCardA } status: %s (0x%08" PRIX32 ")",
980  SCardGetErrorString(status), status);
981 
982  return status;
983 }
984 
985 static LONG WINAPI Inspect_SCardUIDlgSelectCardW(LPOPENCARDNAMEW_EX pDlgStruc)
986 {
987  LONG status = 0;
988 
989  WLog_Print(g_Log, g_LogLevel, "SCardUIDlgSelectCardW {");
990 
991  SCARDAPI_STUB_CALL_LONG(status, SCardUIDlgSelectCardW, pDlgStruc);
992 
993  WLog_Print(g_Log, g_LogLevel, "SCardUIDlgSelectCardW } status: %s (0x%08" PRIX32 ")",
994  SCardGetErrorString(status), status);
995 
996  return status;
997 }
998 
999 static LONG WINAPI Inspect_GetOpenCardNameA(LPOPENCARDNAMEA pDlgStruc)
1000 {
1001  LONG status = 0;
1002 
1003  WLog_Print(g_Log, g_LogLevel, "GetOpenCardNameA {");
1004 
1005  SCARDAPI_STUB_CALL_LONG(status, GetOpenCardNameA, pDlgStruc);
1006 
1007  WLog_Print(g_Log, g_LogLevel, "GetOpenCardNameA } status: %s (0x%08" PRIX32 ")",
1008  SCardGetErrorString(status), status);
1009 
1010  return status;
1011 }
1012 
1013 static LONG WINAPI Inspect_GetOpenCardNameW(LPOPENCARDNAMEW pDlgStruc)
1014 {
1015  LONG status = 0;
1016 
1017  WLog_Print(g_Log, g_LogLevel, "GetOpenCardNameW {");
1018 
1019  SCARDAPI_STUB_CALL_LONG(status, GetOpenCardNameW, pDlgStruc);
1020 
1021  WLog_Print(g_Log, g_LogLevel, "GetOpenCardNameW } status: %s (0x%08" PRIX32 ")",
1022  SCardGetErrorString(status), status);
1023 
1024  return status;
1025 }
1026 
1027 static LONG WINAPI Inspect_SCardDlgExtendedError(void)
1028 {
1029  LONG status = 0;
1030 
1031  WLog_Print(g_Log, g_LogLevel, "SCardDlgExtendedError {");
1032 
1033  SCARDAPI_STUB_CALL_LONG(status, SCardDlgExtendedError);
1034 
1035  WLog_Print(g_Log, g_LogLevel, "SCardDlgExtendedError } status: %s (0x%08" PRIX32 ")",
1036  SCardGetErrorString(status), status);
1037 
1038  return status;
1039 }
1040 
1041 static LONG WINAPI Inspect_SCardReadCacheA(SCARDCONTEXT hContext, UUID* CardIdentifier,
1042  DWORD FreshnessCounter, LPSTR LookupName, PBYTE Data,
1043  DWORD* DataLen)
1044 {
1045  LONG status = 0;
1046 
1047  WLog_Print(g_Log, g_LogLevel, "SCardReadCacheA { hContext: %p", (void*)hContext);
1048 
1049  SCARDAPI_STUB_CALL_LONG(status, SCardReadCacheA, hContext, CardIdentifier, FreshnessCounter,
1050  LookupName, Data, DataLen);
1051 
1052  WLog_Print(g_Log, g_LogLevel, "SCardReadCacheA } status: %s (0x%08" PRIX32 ")",
1053  SCardGetErrorString(status), status);
1054 
1055  return status;
1056 }
1057 
1058 static LONG WINAPI Inspect_SCardReadCacheW(SCARDCONTEXT hContext, UUID* CardIdentifier,
1059  DWORD FreshnessCounter, LPWSTR LookupName, PBYTE Data,
1060  DWORD* DataLen)
1061 {
1062  LONG status = 0;
1063 
1064  WLog_Print(g_Log, g_LogLevel, "SCardReadCacheW { hContext: %p", (void*)hContext);
1065 
1066  SCARDAPI_STUB_CALL_LONG(status, SCardReadCacheW, hContext, CardIdentifier, FreshnessCounter,
1067  LookupName, Data, DataLen);
1068 
1069  WLog_Print(g_Log, g_LogLevel, "SCardReadCacheW } status: %s (0x%08" PRIX32 ")",
1070  SCardGetErrorString(status), status);
1071 
1072  return status;
1073 }
1074 
1075 static LONG WINAPI Inspect_SCardWriteCacheA(SCARDCONTEXT hContext, UUID* CardIdentifier,
1076  DWORD FreshnessCounter, LPSTR LookupName, PBYTE Data,
1077  DWORD DataLen)
1078 {
1079  LONG status = 0;
1080 
1081  WLog_Print(g_Log, g_LogLevel, "SCardWriteCacheA { hContext: %p", (void*)hContext);
1082 
1083  SCARDAPI_STUB_CALL_LONG(status, SCardWriteCacheA, hContext, CardIdentifier, FreshnessCounter,
1084  LookupName, Data, DataLen);
1085 
1086  WLog_Print(g_Log, g_LogLevel, "SCardWriteCacheA } status: %s (0x%08" PRIX32 ")",
1087  SCardGetErrorString(status), status);
1088 
1089  return status;
1090 }
1091 
1092 static LONG WINAPI Inspect_SCardWriteCacheW(SCARDCONTEXT hContext, UUID* CardIdentifier,
1093  DWORD FreshnessCounter, LPWSTR LookupName, PBYTE Data,
1094  DWORD DataLen)
1095 {
1096  LONG status = 0;
1097 
1098  WLog_Print(g_Log, g_LogLevel, "SCardWriteCacheW { hContext: %p", (void*)hContext);
1099 
1100  SCARDAPI_STUB_CALL_LONG(status, SCardWriteCacheW, hContext, CardIdentifier, FreshnessCounter,
1101  LookupName, Data, DataLen);
1102 
1103  WLog_Print(g_Log, g_LogLevel, "SCardWriteCacheW } status: %s (0x%08" PRIX32 ")",
1104  SCardGetErrorString(status), status);
1105 
1106  return status;
1107 }
1108 
1109 static LONG WINAPI Inspect_SCardGetReaderIconA(SCARDCONTEXT hContext, LPCSTR szReaderName,
1110  LPBYTE pbIcon, LPDWORD pcbIcon)
1111 {
1112  LONG status = 0;
1113 
1114  WLog_Print(g_Log, g_LogLevel, "SCardGetReaderIconA { hContext: %p", (void*)hContext);
1115 
1116  SCARDAPI_STUB_CALL_LONG(status, SCardGetReaderIconA, hContext, szReaderName, pbIcon, pcbIcon);
1117 
1118  WLog_Print(g_Log, g_LogLevel, "SCardGetReaderIconA } status: %s (0x%08" PRIX32 ")",
1119  SCardGetErrorString(status), status);
1120 
1121  return status;
1122 }
1123 
1124 static LONG WINAPI Inspect_SCardGetReaderIconW(SCARDCONTEXT hContext, LPCWSTR szReaderName,
1125  LPBYTE pbIcon, LPDWORD pcbIcon)
1126 {
1127  LONG status = 0;
1128 
1129  WLog_Print(g_Log, g_LogLevel, "SCardGetReaderIconW { hContext: %p", (void*)hContext);
1130 
1131  SCARDAPI_STUB_CALL_LONG(status, SCardGetReaderIconW, hContext, szReaderName, pbIcon, pcbIcon);
1132 
1133  WLog_Print(g_Log, g_LogLevel, "SCardGetReaderIconW } status: %s (0x%08" PRIX32 ")",
1134  SCardGetErrorString(status), status);
1135 
1136  return status;
1137 }
1138 
1139 static LONG WINAPI Inspect_SCardGetDeviceTypeIdA(SCARDCONTEXT hContext, LPCSTR szReaderName,
1140  LPDWORD pdwDeviceTypeId)
1141 {
1142  LONG status = 0;
1143 
1144  WLog_Print(g_Log, g_LogLevel, "SCardGetDeviceTypeIdA { hContext: %p", (void*)hContext);
1145 
1146  SCARDAPI_STUB_CALL_LONG(status, SCardGetDeviceTypeIdA, hContext, szReaderName, pdwDeviceTypeId);
1147 
1148  WLog_Print(g_Log, g_LogLevel, "SCardGetDeviceTypeIdA } status: %s (0x%08" PRIX32 ")",
1149  SCardGetErrorString(status), status);
1150 
1151  return status;
1152 }
1153 
1154 static LONG WINAPI Inspect_SCardGetDeviceTypeIdW(SCARDCONTEXT hContext, LPCWSTR szReaderName,
1155  LPDWORD pdwDeviceTypeId)
1156 {
1157  LONG status = 0;
1158 
1159  WLog_Print(g_Log, g_LogLevel, "SCardGetDeviceTypeIdW { hContext: %p", (void*)hContext);
1160 
1161  SCARDAPI_STUB_CALL_LONG(status, SCardGetDeviceTypeIdW, hContext, szReaderName, pdwDeviceTypeId);
1162 
1163  WLog_Print(g_Log, g_LogLevel, "SCardGetDeviceTypeIdW } status: %s (0x%08" PRIX32 ")",
1164  SCardGetErrorString(status), status);
1165 
1166  return status;
1167 }
1168 
1169 static LONG WINAPI Inspect_SCardGetReaderDeviceInstanceIdA(SCARDCONTEXT hContext,
1170  LPCSTR szReaderName,
1171  LPSTR szDeviceInstanceId,
1172  LPDWORD pcchDeviceInstanceId)
1173 {
1174  LONG status = 0;
1175 
1176  WLog_Print(g_Log, g_LogLevel, "SCardGetReaderDeviceInstanceIdA { hContext: %p",
1177  (void*)hContext);
1178 
1179  SCARDAPI_STUB_CALL_LONG(status, SCardGetReaderDeviceInstanceIdA, hContext, szReaderName,
1180  szDeviceInstanceId, pcchDeviceInstanceId);
1181 
1182  WLog_Print(g_Log, g_LogLevel, "SCardGetReaderDeviceInstanceIdA } status: %s (0x%08" PRIX32 ")",
1183  SCardGetErrorString(status), status);
1184 
1185  return status;
1186 }
1187 
1188 static LONG WINAPI Inspect_SCardGetReaderDeviceInstanceIdW(SCARDCONTEXT hContext,
1189  LPCWSTR szReaderName,
1190  LPWSTR szDeviceInstanceId,
1191  LPDWORD pcchDeviceInstanceId)
1192 {
1193  LONG status = 0;
1194 
1195  WLog_Print(g_Log, g_LogLevel, "SCardGetReaderDeviceInstanceIdW { hContext: %p",
1196  (void*)hContext);
1197 
1198  SCARDAPI_STUB_CALL_LONG(status, SCardGetReaderDeviceInstanceIdW, hContext, szReaderName,
1199  szDeviceInstanceId, pcchDeviceInstanceId);
1200 
1201  WLog_Print(g_Log, g_LogLevel, "SCardGetReaderDeviceInstanceIdW } status: %s (0x%08" PRIX32 ")",
1202  SCardGetErrorString(status), status);
1203 
1204  return status;
1205 }
1206 
1207 static LONG WINAPI Inspect_SCardListReadersWithDeviceInstanceIdA(SCARDCONTEXT hContext,
1208  LPCSTR szDeviceInstanceId,
1209  LPSTR mszReaders,
1210  LPDWORD pcchReaders)
1211 {
1212  LONG status = 0;
1213 
1214  WLog_Print(g_Log, g_LogLevel, "SCardListReadersWithDeviceInstanceIdA { hContext: %p",
1215  (void*)hContext);
1216 
1217  SCARDAPI_STUB_CALL_LONG(status, SCardListReadersWithDeviceInstanceIdA, hContext,
1218  szDeviceInstanceId, mszReaders, pcchReaders);
1219 
1220  WLog_Print(g_Log, g_LogLevel,
1221  "SCardListReadersWithDeviceInstanceIdA } status: %s (0x%08" PRIX32 ")",
1222  SCardGetErrorString(status), status);
1223 
1224  return status;
1225 }
1226 
1227 static LONG WINAPI Inspect_SCardListReadersWithDeviceInstanceIdW(SCARDCONTEXT hContext,
1228  LPCWSTR szDeviceInstanceId,
1229  LPWSTR mszReaders,
1230  LPDWORD pcchReaders)
1231 {
1232  LONG status = 0;
1233 
1234  WLog_Print(g_Log, g_LogLevel, "SCardListReadersWithDeviceInstanceIdW { hContext: %p",
1235  (void*)hContext);
1236 
1237  SCARDAPI_STUB_CALL_LONG(status, SCardListReadersWithDeviceInstanceIdW, hContext,
1238  szDeviceInstanceId, mszReaders, pcchReaders);
1239 
1240  WLog_Print(g_Log, g_LogLevel,
1241  "SCardListReadersWithDeviceInstanceIdW } status: %s (0x%08" PRIX32 ")",
1242  SCardGetErrorString(status), status);
1243 
1244  return status;
1245 }
1246 
1247 static LONG WINAPI Inspect_SCardAudit(SCARDCONTEXT hContext, DWORD dwEvent)
1248 {
1249  LONG status = 0;
1250 
1251  WLog_Print(g_Log, g_LogLevel, "SCardAudit { hContext: %p", (void*)hContext);
1252 
1253  SCARDAPI_STUB_CALL_LONG(status, SCardAudit, hContext, dwEvent);
1254 
1255  WLog_Print(g_Log, g_LogLevel, "SCardAudit } status: %s (0x%08" PRIX32 ")",
1256  SCardGetErrorString(status), status);
1257 
1258  return status;
1259 }
1260 
1265 static const SCardApiFunctionTable Inspect_SCardApiFunctionTable = {
1266  0, /* dwVersion */
1267  0, /* dwFlags */
1268 
1269  Inspect_SCardEstablishContext, /* SCardEstablishContext */
1270  Inspect_SCardReleaseContext, /* SCardReleaseContext */
1271  Inspect_SCardIsValidContext, /* SCardIsValidContext */
1272  Inspect_SCardListReaderGroupsA, /* SCardListReaderGroupsA */
1273  Inspect_SCardListReaderGroupsW, /* SCardListReaderGroupsW */
1274  Inspect_SCardListReadersA, /* SCardListReadersA */
1275  Inspect_SCardListReadersW, /* SCardListReadersW */
1276  Inspect_SCardListCardsA, /* SCardListCardsA */
1277  Inspect_SCardListCardsW, /* SCardListCardsW */
1278  Inspect_SCardListInterfacesA, /* SCardListInterfacesA */
1279  Inspect_SCardListInterfacesW, /* SCardListInterfacesW */
1280  Inspect_SCardGetProviderIdA, /* SCardGetProviderIdA */
1281  Inspect_SCardGetProviderIdW, /* SCardGetProviderIdW */
1282  Inspect_SCardGetCardTypeProviderNameA, /* SCardGetCardTypeProviderNameA */
1283  Inspect_SCardGetCardTypeProviderNameW, /* SCardGetCardTypeProviderNameW */
1284  Inspect_SCardIntroduceReaderGroupA, /* SCardIntroduceReaderGroupA */
1285  Inspect_SCardIntroduceReaderGroupW, /* SCardIntroduceReaderGroupW */
1286  Inspect_SCardForgetReaderGroupA, /* SCardForgetReaderGroupA */
1287  Inspect_SCardForgetReaderGroupW, /* SCardForgetReaderGroupW */
1288  Inspect_SCardIntroduceReaderA, /* SCardIntroduceReaderA */
1289  Inspect_SCardIntroduceReaderW, /* SCardIntroduceReaderW */
1290  Inspect_SCardForgetReaderA, /* SCardForgetReaderA */
1291  Inspect_SCardForgetReaderW, /* SCardForgetReaderW */
1292  Inspect_SCardAddReaderToGroupA, /* SCardAddReaderToGroupA */
1293  Inspect_SCardAddReaderToGroupW, /* SCardAddReaderToGroupW */
1294  Inspect_SCardRemoveReaderFromGroupA, /* SCardRemoveReaderFromGroupA */
1295  Inspect_SCardRemoveReaderFromGroupW, /* SCardRemoveReaderFromGroupW */
1296  Inspect_SCardIntroduceCardTypeA, /* SCardIntroduceCardTypeA */
1297  Inspect_SCardIntroduceCardTypeW, /* SCardIntroduceCardTypeW */
1298  Inspect_SCardSetCardTypeProviderNameA, /* SCardSetCardTypeProviderNameA */
1299  Inspect_SCardSetCardTypeProviderNameW, /* SCardSetCardTypeProviderNameW */
1300  Inspect_SCardForgetCardTypeA, /* SCardForgetCardTypeA */
1301  Inspect_SCardForgetCardTypeW, /* SCardForgetCardTypeW */
1302  Inspect_SCardFreeMemory, /* SCardFreeMemory */
1303  Inspect_SCardAccessStartedEvent, /* SCardAccessStartedEvent */
1304  Inspect_SCardReleaseStartedEvent, /* SCardReleaseStartedEvent */
1305  Inspect_SCardLocateCardsA, /* SCardLocateCardsA */
1306  Inspect_SCardLocateCardsW, /* SCardLocateCardsW */
1307  Inspect_SCardLocateCardsByATRA, /* SCardLocateCardsByATRA */
1308  Inspect_SCardLocateCardsByATRW, /* SCardLocateCardsByATRW */
1309  Inspect_SCardGetStatusChangeA, /* SCardGetStatusChangeA */
1310  Inspect_SCardGetStatusChangeW, /* SCardGetStatusChangeW */
1311  Inspect_SCardCancel, /* SCardCancel */
1312  Inspect_SCardConnectA, /* SCardConnectA */
1313  Inspect_SCardConnectW, /* SCardConnectW */
1314  Inspect_SCardReconnect, /* SCardReconnect */
1315  Inspect_SCardDisconnect, /* SCardDisconnect */
1316  Inspect_SCardBeginTransaction, /* SCardBeginTransaction */
1317  Inspect_SCardEndTransaction, /* SCardEndTransaction */
1318  Inspect_SCardCancelTransaction, /* SCardCancelTransaction */
1319  Inspect_SCardState, /* SCardState */
1320  Inspect_SCardStatusA, /* SCardStatusA */
1321  Inspect_SCardStatusW, /* SCardStatusW */
1322  Inspect_SCardTransmit, /* SCardTransmit */
1323  Inspect_SCardGetTransmitCount, /* SCardGetTransmitCount */
1324  Inspect_SCardControl, /* SCardControl */
1325  Inspect_SCardGetAttrib, /* SCardGetAttrib */
1326  Inspect_SCardSetAttrib, /* SCardSetAttrib */
1327  Inspect_SCardUIDlgSelectCardA, /* SCardUIDlgSelectCardA */
1328  Inspect_SCardUIDlgSelectCardW, /* SCardUIDlgSelectCardW */
1329  Inspect_GetOpenCardNameA, /* GetOpenCardNameA */
1330  Inspect_GetOpenCardNameW, /* GetOpenCardNameW */
1331  Inspect_SCardDlgExtendedError, /* SCardDlgExtendedError */
1332  Inspect_SCardReadCacheA, /* SCardReadCacheA */
1333  Inspect_SCardReadCacheW, /* SCardReadCacheW */
1334  Inspect_SCardWriteCacheA, /* SCardWriteCacheA */
1335  Inspect_SCardWriteCacheW, /* SCardWriteCacheW */
1336  Inspect_SCardGetReaderIconA, /* SCardGetReaderIconA */
1337  Inspect_SCardGetReaderIconW, /* SCardGetReaderIconW */
1338  Inspect_SCardGetDeviceTypeIdA, /* SCardGetDeviceTypeIdA */
1339  Inspect_SCardGetDeviceTypeIdW, /* SCardGetDeviceTypeIdW */
1340  Inspect_SCardGetReaderDeviceInstanceIdA, /* SCardGetReaderDeviceInstanceIdA */
1341  Inspect_SCardGetReaderDeviceInstanceIdW, /* SCardGetReaderDeviceInstanceIdW */
1342  Inspect_SCardListReadersWithDeviceInstanceIdA, /* SCardListReadersWithDeviceInstanceIdA */
1343  Inspect_SCardListReadersWithDeviceInstanceIdW, /* SCardListReadersWithDeviceInstanceIdW */
1344  Inspect_SCardAudit /* SCardAudit */
1345 };
1346 
1347 static void Inspect_InitLog(void)
1348 {
1349  if (g_Log)
1350  return;
1351 
1352  if (!(g_Log = WLog_Get("WinSCard")))
1353  return;
1354 }
1355 
1356 const SCardApiFunctionTable* Inspect_RegisterSCardApi(const SCardApiFunctionTable* pSCardApi)
1357 {
1358  g_SCardApi = pSCardApi;
1359 
1360  Inspect_InitLog();
1361 
1362  return &Inspect_SCardApiFunctionTable;
1363 }