1 /*
2 * Copyright 2007 Mounir IDRASSI (mounir.idrassi@idrix.fr, for IDRIX)
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17 */
18
19 #include <stdarg.h>
20 #include "windef.h"
21 #include "winbase.h"
22 #include "wine/debug.h"
23 #include "winscard.h"
24 #include "winternl.h"
25
26 WINE_DEFAULT_DEBUG_CHANNEL(winscard);
27
28 static HANDLE g_startedEvent = NULL;
29
30 const SCARD_IO_REQUEST g_rgSCardT0Pci = { SCARD_PROTOCOL_T0, 8 };
31 const SCARD_IO_REQUEST g_rgSCardT1Pci = { SCARD_PROTOCOL_T1, 8 };
32 const SCARD_IO_REQUEST g_rgSCardRawPci = { SCARD_PROTOCOL_RAW, 8 };
33
34
DllMain(HINSTANCE hinstDLL,DWORD fdwReason,LPVOID lpvReserved)35 BOOL WINAPI DllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
36 {
37 TRACE("%p,%x,%p\n", hinstDLL, fdwReason, lpvReserved);
38
39 switch (fdwReason)
40 {
41 case DLL_PROCESS_ATTACH:
42 DisableThreadLibraryCalls(hinstDLL);
43 /* FIXME: for now, we act as if the pcsc daemon is always started */
44 g_startedEvent = CreateEventA(NULL,TRUE,TRUE,NULL);
45 break;
46 case DLL_PROCESS_DETACH:
47 if (lpvReserved) break;
48 CloseHandle(g_startedEvent);
49 break;
50 }
51
52 return TRUE;
53 }
54
SCardAccessStartedEvent(void)55 HANDLE WINAPI SCardAccessStartedEvent(void)
56 {
57 return g_startedEvent;
58 }
59
SCardAddReaderToGroupA(SCARDCONTEXT context,LPCSTR reader,LPCSTR group)60 LONG WINAPI SCardAddReaderToGroupA(SCARDCONTEXT context, LPCSTR reader, LPCSTR group)
61 {
62 LONG retval;
63 UNICODE_STRING readerW, groupW;
64
65 if(reader) RtlCreateUnicodeStringFromAsciiz(&readerW,reader);
66 else readerW.Buffer = NULL;
67 if(group) RtlCreateUnicodeStringFromAsciiz(&groupW,group);
68 else groupW.Buffer = NULL;
69
70 retval = SCardAddReaderToGroupW(context, readerW.Buffer, groupW.Buffer);
71
72 RtlFreeUnicodeString(&readerW);
73 RtlFreeUnicodeString(&groupW);
74
75 return retval;
76 }
77
SCardAddReaderToGroupW(SCARDCONTEXT context,LPCWSTR reader,LPCWSTR group)78 LONG WINAPI SCardAddReaderToGroupW(SCARDCONTEXT context, LPCWSTR reader, LPCWSTR group)
79 {
80 FIXME("%x %s %s\n", (unsigned int) context, debugstr_w(reader), debugstr_w(group));
81 return SCARD_S_SUCCESS;
82 }
83
SCardEstablishContext(DWORD dwScope,LPCVOID pvReserved1,LPCVOID pvReserved2,LPSCARDCONTEXT phContext)84 LONG WINAPI SCardEstablishContext(DWORD dwScope, LPCVOID pvReserved1,
85 LPCVOID pvReserved2, LPSCARDCONTEXT phContext)
86 {
87 FIXME("(%x,%p,%p,%p) stub\n", dwScope, pvReserved1, pvReserved2, phContext);
88 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
89 return SCARD_F_INTERNAL_ERROR;
90 }
91
SCardIsValidContext(SCARDCONTEXT context)92 LONG WINAPI SCardIsValidContext(SCARDCONTEXT context)
93 {
94 FIXME("(%lx) stub\n", context);
95 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
96 return SCARD_F_INTERNAL_ERROR;
97 }
98
SCardListCardsA(SCARDCONTEXT hContext,LPCBYTE pbAtr,LPCGUID rgguidInterfaces,DWORD cguidInterfaceCount,LPSTR mszCards,LPDWORD pcchCards)99 LONG WINAPI SCardListCardsA(SCARDCONTEXT hContext, LPCBYTE pbAtr, LPCGUID rgguidInterfaces, DWORD cguidInterfaceCount, LPSTR mszCards, LPDWORD pcchCards)
100 {
101 FIXME(": stub\n");
102 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
103 return SCARD_F_INTERNAL_ERROR;
104 }
105
SCardReleaseContext(SCARDCONTEXT context)106 LONG WINAPI SCardReleaseContext(SCARDCONTEXT context)
107 {
108 FIXME("(%lx) stub\n", context);
109 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
110 return SCARD_F_INTERNAL_ERROR;
111 }
112
SCardStatusA(SCARDHANDLE context,LPSTR szReaderName,LPDWORD pcchReaderLen,LPDWORD pdwState,LPDWORD pdwProtocol,LPBYTE pbAtr,LPDWORD pcbAtrLen)113 LONG WINAPI SCardStatusA(SCARDHANDLE context, LPSTR szReaderName, LPDWORD pcchReaderLen, LPDWORD pdwState, LPDWORD pdwProtocol, LPBYTE pbAtr, LPDWORD pcbAtrLen)
114 {
115 FIXME("(%lx) stub\n", context);
116 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
117 return SCARD_F_INTERNAL_ERROR;
118 }
119
SCardStatusW(SCARDHANDLE context,LPWSTR szReaderName,LPDWORD pcchReaderLen,LPDWORD pdwState,LPDWORD pdwProtocol,LPBYTE pbAtr,LPDWORD pcbArtLen)120 LONG WINAPI SCardStatusW(SCARDHANDLE context, LPWSTR szReaderName, LPDWORD pcchReaderLen, LPDWORD pdwState,LPDWORD pdwProtocol,LPBYTE pbAtr,LPDWORD pcbArtLen)
121 {
122 FIXME("(%lx) stub\n", context);
123 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
124 return SCARD_F_INTERNAL_ERROR;
125 }
126
SCardReleaseStartedEvent(void)127 void WINAPI SCardReleaseStartedEvent(void)
128 {
129 FIXME("stub\n");
130 }
131
SCardListReadersA(SCARDCONTEXT context,const CHAR * groups,CHAR * readers,DWORD * buflen)132 LONG WINAPI SCardListReadersA(SCARDCONTEXT context, const CHAR *groups, CHAR *readers, DWORD *buflen)
133 {
134 FIXME("(%lx, %s, %p, %p) stub\n", context, debugstr_a(groups), readers, buflen);
135 return SCARD_E_NO_READERS_AVAILABLE;
136 }
137
SCardListReadersW(SCARDCONTEXT context,const WCHAR * groups,WCHAR * readers,DWORD * buflen)138 LONG WINAPI SCardListReadersW(SCARDCONTEXT context, const WCHAR *groups, WCHAR *readers, DWORD *buflen)
139 {
140 FIXME("(%lx, %s, %p, %p) stub\n", context, debugstr_w(groups), readers, buflen);
141 return SCARD_E_NO_READERS_AVAILABLE;
142 }
143
SCardCancel(SCARDCONTEXT context)144 LONG WINAPI SCardCancel(SCARDCONTEXT context)
145 {
146 FIXME("(%lx) stub\n", context);
147 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
148 return SCARD_F_INTERNAL_ERROR;
149 }
150