diff --git a/sesman/chansrv/pcsc/wrapper/Makefile b/sesman/chansrv/pcsc/wrapper/Makefile new file mode 100755 index 00000000..181c6fbd --- /dev/null +++ b/sesman/chansrv/pcsc/wrapper/Makefile @@ -0,0 +1,14 @@ + +CC=bcc32.exe + +CFLAGS=-O2 + +OBJS=winscard.obj + +winscard.dll: $(OBJS) + $(CC) -ewinscard.dll -tWD $(OBJS) + +clean: + -del winscard.dll + -del *.obj + -del *.tds diff --git a/sesman/chansrv/pcsc/wrapper/winscard-func-names.txt b/sesman/chansrv/pcsc/wrapper/winscard-func-names.txt new file mode 100755 index 00000000..46c1cd17 --- /dev/null +++ b/sesman/chansrv/pcsc/wrapper/winscard-func-names.txt @@ -0,0 +1,78 @@ +ClassInstall32 +SCardAccessNewReaderEvent +SCardReleaseAllEvents +SCardReleaseNewReaderEvent +SCardAccessStartedEvent + +done SCardAddReaderToGroupA +done SCardAddReaderToGroupW +done SCardBeginTransaction +done SCardCancel +done SCardConnectA +done SCardConnectW +done SCardControl +done SCardDisconnect +done SCardEndTransaction +done SCardEstablishContext +done SCardForgetCardTypeA +done SCardForgetCardTypeW +done SCardForgetReaderA +done SCardForgetReaderGroupA +done SCardForgetReaderGroupW +done SCardForgetReaderW +done SCardFreeMemory +done SCardGetAttrib +done SCardGetCardTypeProviderNameA +done SCardGetCardTypeProviderNameW +done SCardGetProviderIdA +done SCardGetProviderIdW +done SCardGetStatusChangeA +done SCardGetStatusChangeW + +SCardGetTransmitCount + +done SCardIntroduceCardTypeA +done SCardIntroduceCardTypeW +done SCardIntroduceReaderA +done SCardIntroduceReaderGroupA +done SCardIntroduceReaderGroupW +done SCardIntroduceReaderW +done SCardIsValidContext +done SCardListCardsA +done SCardListCardsW +done SCardListInterfacesA +done SCardListInterfacesW +done SCardListReaderGroupsA +done SCardListReaderGroupsW +done SCardListReadersA +done SCardListReadersW +done SCardLocateCardsA + +SCardLocateCardsByATRA +SCardLocateCardsByATRW + +done SCardLocateCardsW + +SCardReadCacheA +SCardReadCacheW + +done SCardReconnect +done SCardReleaseContext + +SCardReleaseStartedEvent + +done SCardRemoveReaderFromGroupA +done SCardRemoveReaderFromGroupW +done SCardSetAttrib +done SCardSetCardTypeProviderNameA +done SCardSetCardTypeProviderNameW +done SCardState +done SCardStatusA +done SCardStatusW +done SCardTransmit + +SCardWriteCacheA +SCardWriteCacheW +g_rgSCardRawPci +g_rgSCardT0Pci +g_rgSCardT1Pci diff --git a/sesman/chansrv/pcsc/wrapper/winscard-funcs.h b/sesman/chansrv/pcsc/wrapper/winscard-funcs.h new file mode 100755 index 00000000..0a4198a3 --- /dev/null +++ b/sesman/chansrv/pcsc/wrapper/winscard-funcs.h @@ -0,0 +1,171 @@ + +#ifndef _WINSCARD_FUNCS_H +#define _WINSCARD_FUNCS_H + +typedef LONG WINAPI +(*tSCardEstablishContext)(DWORD dwScope, LPCVOID pvReserved1, + LPCVOID pvReserved2, LPSCARDCONTEXT phContext); +typedef LONG WINAPI +(*tSCardReleaseContext)(SCARDCONTEXT hContext); +typedef LONG WINAPI +(*tSCardIsValidContext)(SCARDCONTEXT hContext); +typedef LONG WINAPI +(*tSCardListReaderGroupsA)(SCARDCONTEXT hContext, LPSTR mszGroups, + LPDWORD pcchGroups); +typedef LONG WINAPI +(*tSCardListReaderGroupsW)(SCARDCONTEXT hContext, LPWSTR mszGroups, + LPDWORD pcchGroups); +typedef LONG WINAPI +(*tSCardListReadersA)(SCARDCONTEXT hContext, LPCSTR mszGroups, + LPSTR mszReaders, LPDWORD pcchReaders); +typedef LONG WINAPI +(*tSCardListReadersW)(SCARDCONTEXT hContext, LPCWSTR mszGroups, + LPWSTR mszReaders, LPDWORD pcchReaders); +typedef LONG WINAPI +(*tSCardListCardsA)(SCARDCONTEXT hContext, LPCBYTE pbAtr, + LPCGUID rgquidInterfaces, DWORD cguidInterfaceCount, + LPSTR mszCards, LPDWORD pcchCards); +typedef LONG WINAPI +(*tSCardListCardsW)(SCARDCONTEXT hContext, LPCBYTE pbAtr, + LPCGUID rgquidInterfaces, DWORD cguidInterfaceCount, + LPWSTR mszCards, LPDWORD pcchCards); +typedef LONG WINAPI +(*tSCardListInterfacesA)(SCARDCONTEXT hContext, LPCSTR szCard, + LPGUID pguidInterfaces, LPDWORD pcguidInterfaces); +typedef LONG WINAPI +(*tSCardListInterfacesW)(SCARDCONTEXT hContext, LPCWSTR szCard, + LPGUID pguidInterfaces, LPDWORD pcguidInterfaces); +typedef LONG WINAPI +(*tSCardGetProviderIdA)(SCARDCONTEXT hContext, LPCSTR szCard, + LPGUID pguidProviderId); +typedef LONG WINAPI +(*tSCardGetProviderIdW)(SCARDCONTEXT hContext, LPCWSTR szCard, + LPGUID pguidProviderId); +typedef LONG WINAPI +(*tSCardGetCardTypeProviderNameA)(SCARDCONTEXT hContext, LPCSTR szCardName, + DWORD dwProviderId, LPSTR szProvider, + LPDWORD pcchProvider); +typedef LONG WINAPI +(*tSCardGetCardTypeProviderNameW)(SCARDCONTEXT hContext, LPCWSTR szCardName, + DWORD dwProviderId, LPWSTR szProvider, + LPDWORD pcchProvider); +typedef LONG WINAPI +(*tSCardIntroduceReaderGroupA)(SCARDCONTEXT hContext, LPCSTR szGroupName); +typedef LONG WINAPI +(*tSCardIntroduceReaderGroupW)(SCARDCONTEXT hContext, LPCWSTR szGroupName); + +typedef LONG WINAPI +(*tSCardForgetReaderGroupA)(SCARDCONTEXT hContext, LPCSTR szGroupName); +typedef LONG WINAPI +(*tSCardForgetReaderGroupW)(SCARDCONTEXT hContext, LPCWSTR szGroupName); +typedef LONG WINAPI +(*tSCardIntroduceReaderA)(SCARDCONTEXT hContext, LPCSTR szReaderName, + LPCSTR szDeviceName); +typedef LONG WINAPI +(*tSCardIntroduceReaderW)(SCARDCONTEXT hContext, LPCWSTR szReaderName, + LPCWSTR szDeviceName); +typedef LONG WINAPI +(*tSCardForgetReaderA)(SCARDCONTEXT hContext, LPCSTR szReaderName); +typedef LONG WINAPI +(*tSCardForgetReaderW)(SCARDCONTEXT hContext, LPCWSTR szReaderName); + +typedef LONG WINAPI +(*tSCardAddReaderToGroupA)(SCARDCONTEXT hContext, LPCSTR szReaderName, + LPCSTR szGroupName); +typedef LONG WINAPI +(*tSCardAddReaderToGroupW)(SCARDCONTEXT hContext, LPCWSTR szReaderName, + LPCWSTR szGroupName); +typedef LONG WINAPI +(*tSCardRemoveReaderFromGroupA)(SCARDCONTEXT hContext, LPCSTR szReaderName, + LPCSTR szGroupName); +typedef LONG WINAPI +(*tSCardRemoveReaderFromGroupW)(SCARDCONTEXT hContext, LPCWSTR szReaderName, + LPCWSTR szGroupName); +typedef LONG WINAPI +(*tSCardIntroduceCardTypeA)(SCARDCONTEXT hContext, LPCSTR szCardName, + LPCGUID pguidPrimaryProvider, + LPCGUID rgguidInterfaces, + DWORD dwInterfaceCount, LPCBYTE pbAtr, + LPCBYTE pbAtrMask, DWORD cbAtrLen); +typedef LONG WINAPI +(*tSCardIntroduceCardTypeW)(SCARDCONTEXT hContext, LPCWSTR szCardName, + LPCGUID pguidPrimaryProvider, + LPCGUID rgguidInterfaces, + DWORD dwInterfaceCount, LPCBYTE pbAtr, + LPCBYTE pbAtrMask, DWORD cbAtrLen); +typedef LONG WINAPI +(*tSCardSetCardTypeProviderNameA)(SCARDCONTEXT hContext, LPCSTR szCardName, + DWORD dwProviderId, LPCSTR szProvider); +typedef LONG WINAPI +(*tSCardSetCardTypeProviderNameW)(SCARDCONTEXT hContext, LPCWSTR szCardName, + DWORD dwProviderId, LPCWSTR szProvider); +typedef LONG WINAPI +(*tSCardForgetCardTypeA)(SCARDCONTEXT hContext, LPCSTR szCardName); +typedef LONG WINAPI +(*tSCardForgetCardTypeW)(SCARDCONTEXT hContext, LPCWSTR szCardName); +typedef LONG WINAPI +(*tSCardFreeMemory)(SCARDCONTEXT hContext, LPCVOID pvMem); +typedef LONG WINAPI +(*tSCardLocateCardsA)(SCARDCONTEXT hContext, LPCSTR mszCards, + LPSCARD_READERSTATEA rgReaderStates, DWORD cReaders); +typedef LONG WINAPI +(*tSCardLocateCardsW)(SCARDCONTEXT hContext, LPCWSTR mszCards, + LPSCARD_READERSTATEW rgReaderStates, DWORD cReaders); +typedef LONG WINAPI +(*tSCardGetStatusChangeA)(SCARDCONTEXT hContext, DWORD dwTimeout, + LPSCARD_READERSTATEA rgReaderStates, + DWORD cReaders); +typedef LONG WINAPI +(*tSCardGetStatusChangeW)(SCARDCONTEXT hContext, DWORD dwTimeout, + LPSCARD_READERSTATEW rgReaderStates, + DWORD cReaders); +typedef LONG WINAPI +(*tSCardCancel)(SCARDCONTEXT hContext); +typedef LONG WINAPI +(*tSCardConnectA)(SCARDCONTEXT hContext, LPCSTR szReader, + DWORD dwShareMode, DWORD dwPreferredProtocols, + LPSCARDHANDLE phCard, LPDWORD pdwActiveProtocol); +typedef LONG WINAPI +(*tSCardConnectW)(SCARDCONTEXT hContext, LPCWSTR szReader, + DWORD dwShareMode, DWORD dwPreferredProtocols, + LPSCARDHANDLE phCard, LPDWORD pdwActiveProtocol); +typedef LONG WINAPI +(*tSCardReconnect)(SCARDHANDLE hCard, DWORD dwShareMode, + DWORD dwPreferredProtocols, DWORD dwInitialization, + LPDWORD pdwActiveProtocol); +typedef LONG WINAPI +(*tSCardDisconnect)(SCARDHANDLE hCard, DWORD dwDisposition); +typedef LONG WINAPI +(*tSCardBeginTransaction)(SCARDHANDLE hCard); +typedef LONG WINAPI +(*tSCardEndTransaction)(SCARDHANDLE hCard, DWORD dwDisposition); +typedef LONG WINAPI +(*tSCardCancelTransaction)(SCARDHANDLE hCard); +typedef LONG WINAPI +(*tSCardState)(SCARDHANDLE hCard, LPDWORD pdwState, LPDWORD pdwProtocol, + LPBYTE pbAtr, LPDWORD pcbAtrLen); +typedef LONG WINAPI +(*tSCardStatusA)(SCARDHANDLE hCard, LPSTR szReaderName, LPDWORD pcchReaderLen, + LPDWORD pdwState, LPDWORD pdwProtocol, LPBYTE pbAtr, + LPDWORD pcbAtrLen); +typedef LONG WINAPI +(*tSCardStatusW)(SCARDHANDLE hCard, LPWSTR szReaderName, LPDWORD pcchReaderLen, + LPDWORD pdwState, LPDWORD pdwProtocol, LPBYTE pbAtr, + LPDWORD pcbAtrLen); +typedef LONG WINAPI +(*tSCardTransmit)(SCARDHANDLE hCard, LPCSCARD_IO_REQUEST pioSendPci, + LPCBYTE pbSendBuffer, DWORD cbSendLength, + LPSCARD_IO_REQUEST pioRecvPci, LPBYTE pbRecvBuffer, + LPDWORD pcbRecvLength); +typedef LONG WINAPI +(*tSCardControl)(SCARDHANDLE hCard, DWORD dwControlCode, LPCVOID lpInBuffer, + DWORD nInBufferSize, LPVOID lpOutBuffer, + DWORD nOutBufferSize, LPDWORD lpBytesReturned); +typedef LONG WINAPI +(*tSCardGetAttrib)(SCARDHANDLE hCard, DWORD dwAttrId, LPBYTE pbAttr, + LPDWORD pcbAttrLen); +typedef LONG WINAPI +(*tSCardSetAttrib)(SCARDHANDLE hCard, DWORD dwAttrId, LPCBYTE pbAttr, + DWORD cbAttrLen); + +#endif diff --git a/sesman/chansrv/pcsc/wrapper/winscard.c b/sesman/chansrv/pcsc/wrapper/winscard.c new file mode 100755 index 00000000..09c8dfb8 --- /dev/null +++ b/sesman/chansrv/pcsc/wrapper/winscard.c @@ -0,0 +1,722 @@ + +#include +#include +#include +#include +#include + +#include "winscard-funcs.h" + +#define LUNUSED(_param) (void) _param + +static tSCardEstablishContext aSCardEstablishContext; +static tSCardReleaseContext aSCardReleaseContext; +static tSCardIsValidContext aSCardIsValidContext; +static tSCardListReaderGroupsA aSCardListReaderGroupsA; +static tSCardListReaderGroupsW aSCardListReaderGroupsW; +static tSCardListReadersA aSCardListReadersA; +static tSCardListReadersW aSCardListReadersW; +static tSCardListCardsA aSCardListCardsA; +static tSCardListCardsW aSCardListCardsW; +static tSCardListInterfacesA aSCardListInterfacesA; +static tSCardListInterfacesW aSCardListInterfacesW; +static tSCardGetProviderIdA aSCardGetProviderIdA; +static tSCardGetProviderIdW aSCardGetProviderIdW; +static tSCardGetCardTypeProviderNameA aSCardGetCardTypeProviderNameA; +static tSCardGetCardTypeProviderNameW aSCardGetCardTypeProviderNameW; +static tSCardIntroduceReaderGroupA aSCardIntroduceReaderGroupA; +static tSCardIntroduceReaderGroupW aSCardIntroduceReaderGroupW; +static tSCardForgetReaderGroupA aSCardForgetReaderGroupA; +static tSCardForgetReaderGroupW aSCardForgetReaderGroupW; +static tSCardIntroduceReaderA aSCardIntroduceReaderA; +static tSCardIntroduceReaderW aSCardIntroduceReaderW; +static tSCardForgetReaderA aSCardForgetReaderA; +static tSCardForgetReaderW aSCardForgetReaderW; +static tSCardAddReaderToGroupA aSCardAddReaderToGroupA; +static tSCardAddReaderToGroupW aSCardAddReaderToGroupW; +static tSCardRemoveReaderFromGroupA aSCardRemoveReaderFromGroupA; +static tSCardRemoveReaderFromGroupW aSCardRemoveReaderFromGroupW; +static tSCardIntroduceCardTypeA aSCardIntroduceCardTypeA; +static tSCardIntroduceCardTypeW aSCardIntroduceCardTypeW; +static tSCardSetCardTypeProviderNameA aSCardSetCardTypeProviderNameA; +static tSCardSetCardTypeProviderNameW aSCardSetCardTypeProviderNameW; +static tSCardForgetCardTypeA aSCardForgetCardTypeA; +static tSCardForgetCardTypeW aSCardForgetCardTypeW; +static tSCardFreeMemory aSCardFreeMemory; +static tSCardLocateCardsA aSCardLocateCardsA; +static tSCardLocateCardsW aSCardLocateCardsW; +static tSCardGetStatusChangeA aSCardGetStatusChangeA; +static tSCardGetStatusChangeW aSCardGetStatusChangeW; +static tSCardCancel aSCardCancel; +static tSCardConnectA aSCardConnectA; +static tSCardConnectW aSCardConnectW; +static tSCardReconnect aSCardReconnect; +static tSCardDisconnect aSCardDisconnect; +static tSCardBeginTransaction aSCardBeginTransaction; +static tSCardEndTransaction aSCardEndTransaction; +static tSCardCancelTransaction aSCardCancelTransaction; +static tSCardState aSCardState; +static tSCardStatusA aSCardStatusA; +static tSCardStatusW aSCardStatusW; +static tSCardTransmit aSCardTransmit; +static tSCardControl aSCardControl; +static tSCardGetAttrib aSCardGetAttrib; +static tSCardSetAttrib aSCardSetAttrib; + +//__declspec(dllexport) const SCARD_IO_REQUEST g_rgSCardT0Pci = { 0 }; +//__declspec(dllexport) const SCARD_IO_REQUEST g_rgSCardT1Pci = { 0 }; +//__declspec(dllexport) const SCARD_IO_REQUEST g_rgSCardRawPci = { 0 }; + +static int g_true = 1; + +#define LLOGLN(_level, _args) do { if ((_level < 1) && g_true) { writeln _args ; } } while (0) + +/*****************************************************************************/ +static int +writeln(const char* format, ...) +{ + va_list ap; + char text[256]; + + va_start(ap, format); + vsnprintf(text, 255, format, ap); + va_end(ap); + OutputDebugString(text); + return 0; +} + +#define LLOAD(_func, _type, _name) \ +do { \ + _func = (_type) GetProcAddress(lib, _name); \ + if (_func == 0) \ + { \ + writeln("LLOAD error %s", _name); \ + } \ +} while (0) + +static int g_funcs_loaded = 0; + +/*****************************************************************************/ +static int __fastcall +load_funsc(void) +{ + HMODULE lib; + + if (g_funcs_loaded) + { + return 0; + } + g_funcs_loaded = 1; + lib = LoadLibrary("winscard-org.dll"); + LLOGLN(0, ("load_funsc: lib %p", lib)); + LLOAD(aSCardEstablishContext, tSCardEstablishContext, "SCardEstablishContext"); + LLOAD(aSCardReleaseContext, tSCardReleaseContext, "SCardReleaseContext"); + LLOAD(aSCardIsValidContext, tSCardIsValidContext, "SCardIsValidContext"); + LLOAD(aSCardListReaderGroupsA, tSCardListReaderGroupsA, "SCardListReaderGroupsA"); + LLOAD(aSCardListReaderGroupsW, tSCardListReaderGroupsW, "SCardListReaderGroupsW"); + LLOAD(aSCardListReadersA, tSCardListReadersA, "SCardListReadersA"); + LLOAD(aSCardListReadersW, tSCardListReadersW, "SCardListReadersW"); + LLOAD(aSCardListCardsA, tSCardListCardsA, "SCardListCardsA"); + LLOAD(aSCardListCardsW, tSCardListCardsW, "SCardListCardsW"); + LLOAD(aSCardListInterfacesA, tSCardListInterfacesA, "SCardListInterfacesA"); + LLOAD(aSCardListInterfacesW, tSCardListInterfacesW, "SCardListInterfacesW"); + LLOAD(aSCardGetProviderIdA, tSCardGetProviderIdA, "SCardGetProviderIdA"); + LLOAD(aSCardGetProviderIdW, tSCardGetProviderIdW, "SCardGetProviderIdW"); + LLOAD(aSCardGetCardTypeProviderNameA, tSCardGetCardTypeProviderNameA, "SCardGetCardTypeProviderNameA"); + LLOAD(aSCardGetCardTypeProviderNameW, tSCardGetCardTypeProviderNameW, "SCardGetCardTypeProviderNameW"); + LLOAD(aSCardIntroduceReaderGroupA, tSCardIntroduceReaderGroupA, "SCardIntroduceReaderGroupA"); + LLOAD(aSCardIntroduceReaderGroupW, tSCardIntroduceReaderGroupW, "SCardIntroduceReaderGroupW"); + LLOAD(aSCardForgetReaderGroupA, tSCardForgetReaderGroupA, "SCardForgetReaderGroupA"); + LLOAD(aSCardForgetReaderGroupW, tSCardForgetReaderGroupW, "SCardForgetReaderGroupW"); + LLOAD(aSCardIntroduceReaderA, tSCardIntroduceReaderA, "SCardIntroduceReaderA"); + LLOAD(aSCardIntroduceReaderW, tSCardIntroduceReaderW, "SCardIntroduceReaderW"); + LLOAD(aSCardForgetReaderA, tSCardForgetReaderA, "SCardForgetReaderA"); + LLOAD(aSCardForgetReaderW, tSCardForgetReaderW, "SCardForgetReaderW"); + LLOAD(aSCardAddReaderToGroupA, tSCardAddReaderToGroupA, "SCardAddReaderToGroupA"); + LLOAD(aSCardAddReaderToGroupW, tSCardAddReaderToGroupW, "SCardAddReaderToGroupW"); + LLOAD(aSCardRemoveReaderFromGroupA, tSCardRemoveReaderFromGroupA, "SCardRemoveReaderFromGroupA"); + LLOAD(aSCardRemoveReaderFromGroupW, tSCardRemoveReaderFromGroupW, "SCardRemoveReaderFromGroupW"); + LLOAD(aSCardIntroduceCardTypeA, tSCardIntroduceCardTypeA, "SCardIntroduceCardTypeA"); + LLOAD(aSCardIntroduceCardTypeW, tSCardIntroduceCardTypeW, "SCardIntroduceCardTypeW"); + LLOAD(aSCardSetCardTypeProviderNameA, tSCardSetCardTypeProviderNameA, "SCardSetCardTypeProviderNameA"); + LLOAD(aSCardSetCardTypeProviderNameW, tSCardSetCardTypeProviderNameW, "SCardSetCardTypeProviderNameW"); + LLOAD(aSCardForgetCardTypeA, tSCardForgetCardTypeA, "SCardForgetCardTypeA"); + LLOAD(aSCardForgetCardTypeW, tSCardForgetCardTypeW, "SCardForgetCardTypeW"); + LLOAD(aSCardFreeMemory, tSCardFreeMemory, "SCardFreeMemory"); + LLOAD(aSCardLocateCardsA, tSCardLocateCardsA, "SCardLocateCardsA"); + LLOAD(aSCardLocateCardsW, tSCardLocateCardsW, "SCardLocateCardsW"); + LLOAD(aSCardGetStatusChangeA, tSCardGetStatusChangeA, "SCardGetStatusChangeA"); + LLOAD(aSCardGetStatusChangeW, tSCardGetStatusChangeW, "SCardGetStatusChangeW"); + LLOAD(aSCardCancel, tSCardCancel, "SCardCancel"); + LLOAD(aSCardConnectA, tSCardConnectA, "SCardConnectA"); + LLOAD(aSCardConnectW, tSCardConnectW, "SCardConnectW"); + LLOAD(aSCardReconnect, tSCardReconnect, "SCardReconnect"); + LLOAD(aSCardDisconnect, tSCardDisconnect, "SCardDisconnect"); + LLOAD(aSCardBeginTransaction, tSCardBeginTransaction, "SCardBeginTransaction"); + LLOAD(aSCardEndTransaction, tSCardEndTransaction, "SCardEndTransaction"); + LLOAD(aSCardCancelTransaction, tSCardCancelTransaction, "SCardCancelTransaction"); + LLOAD(aSCardState, tSCardState, "SCardState"); + LLOAD(aSCardStatusA, tSCardStatusA, "SCardStatusA"); + LLOAD(aSCardStatusW, tSCardStatusW, "SCardStatusW"); + LLOAD(aSCardTransmit, tSCardTransmit, "SCardTransmit"); + LLOAD(aSCardGetAttrib, tSCardGetAttrib, "SCardGetAttrib"); + LLOAD(aSCardSetAttrib, tSCardSetAttrib, "SCardSetAttrib"); + + return 0; +} + +/*****************************************************************************/ +BOOL WINAPI +DllEntryPoint(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) +{ + BOOL rv; + LUNUSED(hinstDLL); + LUNUSED(lpvReserved); + + LLOGLN(10, ("DllEntryPoint: hinstDLL %p fdwReason %d", hinstDLL, fdwReason)); + rv = FALSE; + switch (fdwReason) + { + case DLL_PROCESS_ATTACH: + LLOGLN(0, ("DllEntryPoint: DLL_PROCESS_ATTACH")); + load_funsc(); + rv = TRUE; + break; + case DLL_THREAD_ATTACH: + LLOGLN(10, ("DllEntryPoint: DLL_THREAD_ATTACH")); + rv = TRUE; + break; + case DLL_THREAD_DETACH: + LLOGLN(10, ("DllEntryPoint: DLL_THREAD_DETACH")); + rv = TRUE; + break; + case DLL_PROCESS_DETACH: + LLOGLN(0, ("DllEntryPoint: DLL_PROCESS_DETACH")); + rv = TRUE; + break; + default: + LLOGLN(0, ("DllEntryPoint: unknown fdwReason %d", fdwReason)); + break; + + } + return rv; +} + +/*****************************************************************************/ +LONG WINAPI +SCardEstablishContext(DWORD dwScope, LPCVOID pvReserved1, + LPCVOID pvReserved2, LPSCARDCONTEXT phContext) +{ + LLOGLN(0, ("SCardEstablishContext:")); + return aSCardEstablishContext(dwScope, pvReserved1, pvReserved2, phContext); +} + +/*****************************************************************************/ +LONG WINAPI +SCardReleaseContext(SCARDCONTEXT hContext) +{ + LLOGLN(0, ("SCardReleaseContext:")); + return aSCardReleaseContext(hContext); +} + +/*****************************************************************************/ +LONG WINAPI +SCardIsValidContext(SCARDCONTEXT hContext) +{ + LLOGLN(0, ("SCardIsValidContext:")); + return aSCardIsValidContext(hContext); +} + +/*****************************************************************************/ +LONG WINAPI +SCardListReaderGroupsA(SCARDCONTEXT hContext, LPSTR mszGroups, + LPDWORD pcchGroups) +{ + LLOGLN(0, ("SCardListReaderGroupsA:")); + return aSCardListReaderGroupsA(hContext, mszGroups, pcchGroups); +} + +/*****************************************************************************/ +LONG WINAPI +SCardListReaderGroupsW(SCARDCONTEXT hContext, LPWSTR mszGroups, + LPDWORD pcchGroups) +{ + LLOGLN(0, ("SCardListReaderGroupsW:")); + return aSCardListReaderGroupsW(hContext, mszGroups, pcchGroups); +} + +/*****************************************************************************/ +LONG WINAPI +SCardListReadersA(SCARDCONTEXT hContext, LPCSTR mszGroups, + LPSTR mszReaders, LPDWORD pcchReaders) +{ + LLOGLN(0, ("SCardListReadersA:")); + return aSCardListReadersA(hContext, mszGroups, mszReaders, pcchReaders); +} + +/*****************************************************************************/ +LONG WINAPI +SCardListReadersW(SCARDCONTEXT hContext, LPCWSTR mszGroups, + LPWSTR mszReaders, LPDWORD pcchReaders) +{ + char text[256]; + LONG rv; + DWORD cchReaders; + + text[0] = 0; + if (mszGroups != 0) + { + wcstombs(text, mszGroups, 255); + } + cchReaders = *pcchReaders; + LLOGLN(0, ("SCardListReadersW: mszGroups [%s] cchReaders [%d]", text, *pcchReaders)); + rv = aSCardListReadersW(hContext, mszGroups, mszReaders, pcchReaders); + text[0] = 0; + if (cchReaders > 0) + { + wcstombs(text, mszReaders, 255); + } + LLOGLN(0, (" mszReaders [%s] cchReaders [%d]", text, *pcchReaders)); + return rv; +} + +/*****************************************************************************/ +LONG WINAPI +SCardListCardsA(SCARDCONTEXT hContext, LPCBYTE pbAtr, + LPCGUID rgquidInterfaces, DWORD cguidInterfaceCount, + LPSTR mszCards, LPDWORD pcchCards) +{ + LLOGLN(0, ("SCardListCardsA:")); + return aSCardListCardsA(hContext, pbAtr, rgquidInterfaces, + cguidInterfaceCount, mszCards, pcchCards); +} + +/*****************************************************************************/ +LONG WINAPI +SCardListCardsW(SCARDCONTEXT hContext, LPCBYTE pbAtr, + LPCGUID rgquidInterfaces, DWORD cguidInterfaceCount, + LPWSTR mszCards, LPDWORD pcchCards) +{ + LLOGLN(0, ("SCardListCardsW:")); + return aSCardListCardsW(hContext, pbAtr, rgquidInterfaces, + cguidInterfaceCount, mszCards, pcchCards); +} + +/*****************************************************************************/ +LONG WINAPI +SCardListInterfacesA(SCARDCONTEXT hContext, LPCSTR szCard, + LPGUID pguidInterfaces, LPDWORD pcguidInterfaces) +{ + LLOGLN(0, ("SCardListInterfacesA:")); + return aSCardListInterfacesA(hContext, szCard, pguidInterfaces, + pcguidInterfaces); +} + +/*****************************************************************************/ +LONG WINAPI +SCardListInterfacesW(SCARDCONTEXT hContext, LPCWSTR szCard, + LPGUID pguidInterfaces, LPDWORD pcguidInterfaces) +{ + LLOGLN(0, ("SCardListInterfacesW:")); + return aSCardListInterfacesW(hContext, szCard, pguidInterfaces, + pcguidInterfaces); +} + +/*****************************************************************************/ +LONG WINAPI +SCardGetProviderIdA(SCARDCONTEXT hContext, LPCSTR szCard, + LPGUID pguidProviderId) +{ + LLOGLN(0, ("SCardGetProviderIdA:")); + return aSCardGetProviderIdA(hContext, szCard, pguidProviderId); +} + +/****************************************************************************/ +LONG WINAPI +SCardGetProviderIdW(SCARDCONTEXT hContext, LPCWSTR szCard, + LPGUID pguidProviderId) +{ + LLOGLN(0, ("SCardGetProviderIdW:")); + return aSCardGetProviderIdW(hContext, szCard, pguidProviderId); +} + +/****************************************************************************/ +LONG WINAPI +SCardGetCardTypeProviderNameA(SCARDCONTEXT hContext, LPCSTR szCardName, + DWORD dwProviderId, LPSTR szProvider, + LPDWORD pcchProvider) +{ + LLOGLN(0, ("SCardGetCardTypeProviderNameA:")); + return aSCardGetCardTypeProviderNameA(hContext, szCardName, dwProviderId, + szProvider, pcchProvider); +} + +/*****************************************************************************/ +LONG WINAPI +SCardGetCardTypeProviderNameW(SCARDCONTEXT hContext, LPCWSTR szCardName, + DWORD dwProviderId, LPWSTR szProvider, + LPDWORD pcchProvider) +{ + LLOGLN(0, ("SCardGetCardTypeProviderNameW:")); + return aSCardGetCardTypeProviderNameW(hContext, szCardName, dwProviderId, + szProvider, pcchProvider); +} + +/*****************************************************************************/ +LONG WINAPI +SCardIntroduceReaderGroupA(SCARDCONTEXT hContext, LPCSTR szGroupName) +{ + LLOGLN(0, ("SCardIntroduceReaderGroupA:")); + return aSCardIntroduceReaderGroupA(hContext, szGroupName); +} + +/*****************************************************************************/ +LONG WINAPI +SCardIntroduceReaderGroupW(SCARDCONTEXT hContext, LPCWSTR szGroupName) +{ + LLOGLN(0, ("SCardIntroduceReaderGroupW:")); + return aSCardIntroduceReaderGroupW(hContext, szGroupName); +} + +/*****************************************************************************/ +LONG WINAPI +SCardForgetReaderGroupA(SCARDCONTEXT hContext, LPCSTR szGroupName) +{ + LLOGLN(0, ("SCardForgetReaderGroupA:")); + return aSCardForgetReaderGroupA(hContext, szGroupName); +} + +/*****************************************************************************/ +LONG WINAPI +SCardForgetReaderGroupW(SCARDCONTEXT hContext, LPCWSTR szGroupName) +{ + LLOGLN(0, ("SCardForgetReaderGroupW:")); + return aSCardForgetReaderGroupW(hContext, szGroupName); +} + +/*****************************************************************************/ +LONG WINAPI +SCardIntroduceReaderA(SCARDCONTEXT hContext, LPCSTR szReaderName, + LPCSTR szDeviceName) +{ + LLOGLN(0, ("SCardIntroduceReaderA:")); + return aSCardIntroduceReaderA(hContext, szReaderName, szDeviceName); +} + +/*****************************************************************************/ +LONG WINAPI +SCardIntroduceReaderW(SCARDCONTEXT hContext, LPCWSTR szReaderName, + LPCWSTR szDeviceName) +{ + LLOGLN(0, ("SCardIntroduceReaderW:")); + return aSCardIntroduceReaderW(hContext, szReaderName, szDeviceName); +} + +/*****************************************************************************/ +LONG WINAPI +SCardForgetReaderA(SCARDCONTEXT hContext, LPCSTR szReaderName) +{ + LLOGLN(0, ("SCardForgetReaderA:")); + return aSCardForgetReaderA(hContext, szReaderName); +} + +/*****************************************************************************/ +LONG WINAPI +SCardForgetReaderW(SCARDCONTEXT hContext, LPCWSTR szReaderName) +{ + LLOGLN(0, ("SCardForgetReaderW:")); + return aSCardForgetReaderW(hContext, szReaderName); +} + +/*****************************************************************************/ +LONG WINAPI +SCardAddReaderToGroupA(SCARDCONTEXT hContext, LPCSTR szReaderName, + LPCSTR szGroupName) +{ + LLOGLN(0, ("SCardAddReaderToGroupA:")); + return aSCardAddReaderToGroupA(hContext, szReaderName, szGroupName); +} + +/*****************************************************************************/ +LONG WINAPI +SCardAddReaderToGroupW(SCARDCONTEXT hContext, LPCWSTR szReaderName, + LPCWSTR szGroupName) +{ + LLOGLN(0, ("SCardAddReaderToGroupW:")); + return aSCardAddReaderToGroupW(hContext, szReaderName, szGroupName); +} + +/*****************************************************************************/ +LONG WINAPI +SCardRemoveReaderFromGroupA(SCARDCONTEXT hContext, LPCSTR szReaderName, + LPCSTR szGroupName) +{ + LLOGLN(0, ("SCardRemoveReaderFromGroupA:")); + return aSCardRemoveReaderFromGroupA(hContext, szReaderName, szGroupName); +} + +/*****************************************************************************/ +LONG WINAPI +SCardRemoveReaderFromGroupW(SCARDCONTEXT hContext, LPCWSTR szReaderName, + LPCWSTR szGroupName) +{ + LLOGLN(0, ("SCardRemoveReaderFromGroupW:")); + return aSCardRemoveReaderFromGroupW(hContext, szReaderName, szGroupName); +} + +/*****************************************************************************/ +LONG WINAPI +SCardIntroduceCardTypeA(SCARDCONTEXT hContext, LPCSTR szCardName, + LPCGUID pguidPrimaryProvider, + LPCGUID rgguidInterfaces, + DWORD dwInterfaceCount, LPCBYTE pbAtr, + LPCBYTE pbAtrMask, DWORD cbAtrLen) +{ + LLOGLN(0, ("SCardIntroduceCardTypeA:")); + return aSCardIntroduceCardTypeA(hContext, szCardName, pguidPrimaryProvider, + rgguidInterfaces, dwInterfaceCount, pbAtr, + pbAtrMask, cbAtrLen); +} + +/*****************************************************************************/ +LONG WINAPI +SCardIntroduceCardTypeW(SCARDCONTEXT hContext, LPCWSTR szCardName, + LPCGUID pguidPrimaryProvider, LPCGUID rgguidInterfaces, + DWORD dwInterfaceCount, LPCBYTE pbAtr, + LPCBYTE pbAtrMask, DWORD cbAtrLen) +{ + LLOGLN(0, ("SCardIntroduceCardTypeW:")); + return aSCardIntroduceCardTypeW(hContext, szCardName, pguidPrimaryProvider, + rgguidInterfaces, dwInterfaceCount, pbAtr, + pbAtrMask, cbAtrLen); +} + +/*****************************************************************************/ +LONG WINAPI +SCardSetCardTypeProviderNameA(SCARDCONTEXT hContext, LPCSTR szCardName, + DWORD dwProviderId, LPCSTR szProvider) +{ + LLOGLN(0, ("SCardSetCardTypeProviderNameA:")); + return aSCardSetCardTypeProviderNameA(hContext, szCardName, + dwProviderId, szProvider); +} + +/*****************************************************************************/ +LONG WINAPI +SCardSetCardTypeProviderNameW(SCARDCONTEXT hContext, LPCWSTR szCardName, + DWORD dwProviderId, LPCWSTR szProvider) +{ + LLOGLN(0, ("SCardSetCardTypeProviderNameW:")); + return aSCardSetCardTypeProviderNameW(hContext, szCardName, + dwProviderId, szProvider); +} + +/*****************************************************************************/ +LONG WINAPI +SCardForgetCardTypeA(SCARDCONTEXT hContext, LPCSTR szCardName) +{ + LLOGLN(0, ("SCardForgetCardTypeA:")); + return aSCardForgetCardTypeA(hContext, szCardName); +} + +/*****************************************************************************/ +LONG WINAPI +SCardForgetCardTypeW(SCARDCONTEXT hContext, LPCWSTR szCardName) +{ + LLOGLN(0, ("SCardForgetCardTypeW:")); + return aSCardForgetCardTypeW(hContext, szCardName); +} + +/*****************************************************************************/ +LONG WINAPI +SCardFreeMemory(SCARDCONTEXT hContext, LPCVOID pvMem) +{ + LLOGLN(0, ("SCardFreeMemory:")); + return aSCardFreeMemory(hContext, pvMem); +} + +/*****************************************************************************/ +LONG WINAPI +SCardLocateCardsA(SCARDCONTEXT hContext, LPCSTR mszCards, + LPSCARD_READERSTATEA rgReaderStates, DWORD cReaders) +{ + LLOGLN(0, ("SCardLocateCardsA:")); + return aSCardLocateCardsA(hContext, mszCards, rgReaderStates, cReaders); +} + +/*****************************************************************************/ +LONG WINAPI +SCardLocateCardsW(SCARDCONTEXT hContext, LPCWSTR mszCards, + LPSCARD_READERSTATEW rgReaderStates, DWORD cReaders) +{ + LLOGLN(0, ("SCardLocateCardsW:")); + return aSCardLocateCardsW(hContext, mszCards, rgReaderStates, cReaders); +} + +/*****************************************************************************/ +LONG WINAPI +SCardGetStatusChangeA(SCARDCONTEXT hContext, DWORD dwTimeout, + LPSCARD_READERSTATEA rgReaderStates, + DWORD cReaders) +{ + LLOGLN(0, ("SCardGetStatusChangeA:")); + return aSCardGetStatusChangeA(hContext, dwTimeout, rgReaderStates, cReaders); +} + +/*****************************************************************************/ +LONG WINAPI +SCardGetStatusChangeW(SCARDCONTEXT hContext, DWORD dwTimeout, + LPSCARD_READERSTATEW rgReaderStates, + DWORD cReaders) +{ + LLOGLN(0, ("SCardGetStatusChangeW:")); + return aSCardGetStatusChangeW(hContext, dwTimeout, rgReaderStates, cReaders); +} + +/*****************************************************************************/ +LONG WINAPI +SCardCancel(SCARDCONTEXT hContext) +{ + LLOGLN(0, ("SCardCancel:")); + return aSCardCancel(hContext); +} + +/*****************************************************************************/ +LONG WINAPI +SCardConnectA(SCARDCONTEXT hContext, LPCSTR szReader, DWORD dwShareMode, + DWORD dwPreferredProtocols, LPSCARDHANDLE phCard, + LPDWORD pdwActiveProtocol) +{ + LLOGLN(0, ("SCardConnectA:")); + return aSCardConnectA(hContext, szReader, dwShareMode, + dwPreferredProtocols, phCard, + pdwActiveProtocol); +} + +/*****************************************************************************/ +LONG WINAPI +SCardConnectW(SCARDCONTEXT hContext, LPCWSTR szReader, DWORD dwShareMode, + DWORD dwPreferredProtocols, LPSCARDHANDLE phCard, + LPDWORD pdwActiveProtocol) +{ + LLOGLN(0, ("SCardConnectW:")); + return aSCardConnectW(hContext, szReader, dwShareMode, + dwPreferredProtocols, phCard, + pdwActiveProtocol); +} + +/*****************************************************************************/ +LONG WINAPI +SCardReconnect(SCARDHANDLE hCard, DWORD dwShareMode, + DWORD dwPreferredProtocols, DWORD dwInitialization, + LPDWORD pdwActiveProtocol) +{ + LLOGLN(0, ("SCardReconnect:")); + return SCardReconnect(hCard, dwShareMode, dwPreferredProtocols, + dwInitialization, pdwActiveProtocol); +} + +/*****************************************************************************/ +LONG WINAPI +SCardDisconnect(SCARDHANDLE hCard, DWORD dwDisposition) +{ + LLOGLN(0, ("SCardDisconnect:")); + return aSCardDisconnect(hCard, dwDisposition); +} + +/*****************************************************************************/ +LONG WINAPI +SCardBeginTransaction(SCARDHANDLE hCard) +{ + LLOGLN(0, ("SCardBeginTransaction:")); + return aSCardBeginTransaction(hCard); +} + +/*****************************************************************************/ +LONG WINAPI +SCardEndTransaction(SCARDHANDLE hCard, DWORD dwDisposition) +{ + LLOGLN(0, ("SCardEndTransaction:")); + return aSCardEndTransaction(hCard, dwDisposition); +} + +/*****************************************************************************/ +LONG WINAPI +SCardCancelTransaction(SCARDHANDLE hCard) +{ + LLOGLN(0, ("SCardCancelTransaction:")); + return aSCardCancelTransaction(hCard); +} + +/*****************************************************************************/ +LONG WINAPI +SCardState(SCARDHANDLE hCard, LPDWORD pdwState, LPDWORD pdwProtocol, + LPBYTE pbAtr, LPDWORD pcbAtrLen) +{ + LLOGLN(0, ("SCardState:")); + return aSCardState(hCard, pdwState, pdwProtocol, pbAtr, pcbAtrLen); +} + +/*****************************************************************************/ +LONG WINAPI +SCardStatusA(SCARDHANDLE hCard, LPSTR szReaderName, LPDWORD pcchReaderLen, + LPDWORD pdwState, LPDWORD pdwProtocol, LPBYTE pbAtr, + LPDWORD pcbAtrLen) +{ + LLOGLN(0, ("SCardStatusA:")); + return aSCardStatusA(hCard, szReaderName, pcchReaderLen, + pdwState, pdwProtocol, pbAtr, pcbAtrLen); +} + +/*****************************************************************************/ +LONG WINAPI +SCardStatusW(SCARDHANDLE hCard, LPWSTR szReaderName, LPDWORD pcchReaderLen, + LPDWORD pdwState, LPDWORD pdwProtocol, LPBYTE pbAtr, + LPDWORD pcbAtrLen) +{ + LLOGLN(0, ("SCardStatusW:")); + return aSCardStatusW(hCard, szReaderName, pcchReaderLen, + pdwState, pdwProtocol, pbAtr, pcbAtrLen); +} + +/*****************************************************************************/ +LONG WINAPI +SCardTransmit(SCARDHANDLE hCard, LPCSCARD_IO_REQUEST pioSendPci, + LPCBYTE pbSendBuffer, DWORD cbSendLength, + LPSCARD_IO_REQUEST pioRecvPci, LPBYTE pbRecvBuffer, + LPDWORD pcbRecvLength) +{ + LLOGLN(0, ("SCardTransmit:")); + return aSCardTransmit(hCard, pioSendPci, pbSendBuffer, cbSendLength, + pioRecvPci, pbRecvBuffer, pcbRecvLength); +} + +/*****************************************************************************/ +LONG WINAPI +SCardControl(SCARDHANDLE hCard, DWORD dwControlCode, LPCVOID lpInBuffer, + DWORD nInBufferSize, LPVOID lpOutBuffer, + DWORD nOutBufferSize, LPDWORD lpBytesReturned) +{ + LLOGLN(0, ("SCardControl:")); + return aSCardControl(hCard, dwControlCode, lpInBuffer, + nInBufferSize, lpOutBuffer, nOutBufferSize, + lpBytesReturned); +} + +/*****************************************************************************/ +LONG WINAPI +SCardGetAttrib(SCARDHANDLE hCard, DWORD dwAttrId, LPBYTE pbAttr, + LPDWORD pcbAttrLen) +{ + LLOGLN(0, ("SCardGetAttrib:")); + return aSCardGetAttrib(hCard, dwAttrId, pbAttr, pcbAttrLen); +} + +/*****************************************************************************/ +LONG WINAPI +SCardSetAttrib(SCARDHANDLE hCard, DWORD dwAttrId, LPCBYTE pbAttr, + DWORD cbAttrLen) +{ + LLOGLN(0, ("SCardSetAttrib:")); + return aSCardSetAttrib(hCard, dwAttrId, pbAttr, cbAttrLen); +} diff --git a/sesman/chansrv/pcsc/wrapper/winscard.def b/sesman/chansrv/pcsc/wrapper/winscard.def new file mode 100755 index 00000000..eb6d18df --- /dev/null +++ b/sesman/chansrv/pcsc/wrapper/winscard.def @@ -0,0 +1,53 @@ +EXPORTS +SCardEstablishContext +SCardReleaseContext +SCardIsValidContext +SCardListReaderGroupsA +SCardListReaderGroupsW +SCardListReadersA +SCardListReadersW +SCardListCardsA +SCardListCardsW +SCardListInterfacesA +SCardListInterfacesW +SCardGetProviderIdA +SCardGetProviderIdW +SCardGetCardTypeProviderNameA +SCardGetCardTypeProviderNameW +SCardIntroduceReaderGroupA +SCardIntroduceReaderGroupW +SCardForgetReaderGroupA +SCardForgetReaderGroupW +SCardIntroduceReaderA +SCardIntroduceReaderW +SCardForgetReaderA +SCardForgetReaderW +SCardAddReaderToGroupA +SCardAddReaderToGroupW +SCardRemoveReaderFromGroupA +SCardRemoveReaderFromGroupW +SCardIntroduceCardTypeA +SCardIntroduceCardTypeW +SCardSetCardTypeProviderNameA +SCardSetCardTypeProviderNameW +SCardForgetCardTypeA +SCardForgetCardTypeW +SCardFreeMemory +SCardLocateCardsA +SCardLocateCardsW +SCardGetStatusChangeA +SCardGetStatusChangeW +SCardCancel +SCardConnectA +SCardConnectW +SCardReconnect +SCardDisconnect +SCardBeginTransaction +SCardEndTransaction +SCardState +SCardStatusA +SCardStatusW +SCardTransmit +SCardControl +SCardGetAttrib +SCardSetAttrib