1 // Licensed under the Apache License, Version 2.0
2 // <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
3 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option.
4 // All files in the project carrying such notice may not be copied, modified, or distributed
5 // except according to those terms.
6 //! Data Protection API Prototypes and Definitions
7 // This header file provides the definitions and symbols necessary for an
8 // Application or Smart Card Service Provider to access the Smartcard Subsystem.
9 use shared::basetsd::ULONG_PTR;
10 use shared::guiddef::{LPCGUID, LPGUID};
11 use shared::minwindef::{BOOL, BYTE, DWORD, LPBYTE, LPCVOID, LPDWORD, LPVOID, PBYTE};
12 use shared::rpcdce::UUID;
13 use shared::windef::{HICON, HWND};
14 use um::winnt::{CHAR, HANDLE, LONG, LPCSTR, LPCWSTR, LPSTR, LPWSTR, PVOID, WCHAR};
15 use um::winsmcrd::{LPCSCARD_IO_REQUEST, LPSCARD_IO_REQUEST};
16 pub type LPCBYTE = *const BYTE;
17 pub type SCARDCONTEXT = ULONG_PTR;
18 pub type PSCARDCONTEXT = *mut SCARDCONTEXT;
19 pub type LPSCARDCONTEXT = *mut SCARDCONTEXT;
20 pub type SCARDHANDLE = ULONG_PTR;
21 pub type PSCARDHANDLE = *mut SCARDHANDLE;
22 pub type LPSCARDHANDLE = *mut SCARDHANDLE;
23 pub const SCARD_AUTOALLOCATE: DWORD = -1i32 as u32;
24 pub const SCARD_SCOPE_USER: DWORD = 0;
25 pub const SCARD_SCOPE_TERMINAL: DWORD = 1;
26 pub const SCARD_SCOPE_SYSTEM: DWORD = 2;
27 extern "system" {
SCardEstablishContext( dwScope: DWORD, pvReserved1: LPCVOID, pvReserved2: LPCVOID, phContext: LPSCARDCONTEXT, ) -> LONG28     pub fn SCardEstablishContext(
29         dwScope: DWORD,
30         pvReserved1: LPCVOID,
31         pvReserved2: LPCVOID,
32         phContext: LPSCARDCONTEXT,
33     ) -> LONG;
SCardReleaseContext( hContext: SCARDCONTEXT, ) -> LONG34     pub fn SCardReleaseContext(
35         hContext: SCARDCONTEXT,
36     ) -> LONG;
SCardIsValidContext( hContext: SCARDCONTEXT, ) -> LONG37     pub fn SCardIsValidContext(
38         hContext: SCARDCONTEXT,
39     ) -> LONG;
40 }
41 pub const SCARD_PROVIDER_PRIMARY: DWORD = 1;
42 pub const SCARD_PROVIDER_CSP: DWORD = 2;
43 pub const SCARD_PROVIDER_KSP: DWORD = 3;
44 extern "system" {
SCardListReaderGroupsA( hContext: SCARDCONTEXT, mszGroups: LPSTR, pcchGroups: LPDWORD, ) -> LONG45     pub fn SCardListReaderGroupsA(
46         hContext: SCARDCONTEXT,
47         mszGroups: LPSTR,
48         pcchGroups: LPDWORD,
49     ) -> LONG;
SCardListReaderGroupsW( hContext: SCARDCONTEXT, mszGroups: LPWSTR, pcchGroups: LPDWORD, ) -> LONG50     pub fn SCardListReaderGroupsW(
51         hContext: SCARDCONTEXT,
52         mszGroups: LPWSTR,
53         pcchGroups: LPDWORD,
54     ) -> LONG;
SCardListReadersA( hContext: SCARDCONTEXT, mszGroups: LPCSTR, mszReaders: LPSTR, pcchReaders: LPDWORD, ) -> LONG55     pub fn SCardListReadersA(
56         hContext: SCARDCONTEXT,
57         mszGroups: LPCSTR,
58         mszReaders: LPSTR,
59         pcchReaders: LPDWORD,
60     ) -> LONG;
SCardListReadersW( hContext: SCARDCONTEXT, mszGroups: LPCWSTR, mszReaders: LPWSTR, pcchReaders: LPDWORD, ) -> LONG61     pub fn SCardListReadersW(
62         hContext: SCARDCONTEXT,
63         mszGroups: LPCWSTR,
64         mszReaders: LPWSTR,
65         pcchReaders: LPDWORD,
66     ) -> LONG;
SCardListCardsA( hContext: SCARDCONTEXT, pbAtr: LPCBYTE, rgquidInterfaces: LPCGUID, cguidInterfaceCount: DWORD, mszCards: *mut CHAR, pcchCards: LPDWORD, ) -> LONG67     pub fn SCardListCardsA(
68         hContext: SCARDCONTEXT,
69         pbAtr: LPCBYTE,
70         rgquidInterfaces: LPCGUID,
71         cguidInterfaceCount: DWORD,
72         mszCards: *mut CHAR,
73         pcchCards: LPDWORD,
74     ) -> LONG;
SCardListCardsW( hContext: SCARDCONTEXT, pbAtr: LPCBYTE, rgquidInterfaces: LPCGUID, cguidInterfaceCount: DWORD, mszCards: *mut WCHAR, pcchCards: LPDWORD, ) -> LONG75     pub fn SCardListCardsW(
76         hContext: SCARDCONTEXT,
77         pbAtr: LPCBYTE,
78         rgquidInterfaces: LPCGUID,
79         cguidInterfaceCount: DWORD,
80         mszCards: *mut WCHAR,
81         pcchCards: LPDWORD,
82     ) -> LONG;
SCardListInterfacesA( hContext: SCARDCONTEXT, szCard: LPCSTR, pguidInterfaces: LPGUID, pcguidInterfaces: LPDWORD, ) -> LONG83     pub fn SCardListInterfacesA(
84         hContext: SCARDCONTEXT,
85         szCard: LPCSTR,
86         pguidInterfaces: LPGUID,
87         pcguidInterfaces: LPDWORD,
88     ) -> LONG;
SCardListInterfacesW( hContext: SCARDCONTEXT, szCard: LPCWSTR, pguidInterfaces: LPGUID, pcguidInterfaces: LPDWORD, ) -> LONG89     pub fn SCardListInterfacesW(
90         hContext: SCARDCONTEXT,
91         szCard: LPCWSTR,
92         pguidInterfaces: LPGUID,
93         pcguidInterfaces: LPDWORD,
94     ) -> LONG;
SCardGetProviderIdA( hContext: SCARDCONTEXT, szCard: LPCSTR, pguidProviderId: LPGUID, ) -> LONG95     pub fn SCardGetProviderIdA(
96         hContext: SCARDCONTEXT,
97         szCard: LPCSTR,
98         pguidProviderId: LPGUID,
99     ) -> LONG;
SCardGetProviderIdW( hContext: SCARDCONTEXT, szCard: LPCWSTR, pguidProviderId: LPGUID, ) -> LONG100     pub fn SCardGetProviderIdW(
101         hContext: SCARDCONTEXT,
102         szCard: LPCWSTR,
103         pguidProviderId: LPGUID,
104     ) -> LONG;
SCardGetCardTypeProviderNameA( hContext: SCARDCONTEXT, szCardName: LPCSTR, dwProviderId: DWORD, szProvider: *mut CHAR, pcchProvider: LPDWORD, ) -> LONG105     pub fn SCardGetCardTypeProviderNameA(
106         hContext: SCARDCONTEXT,
107         szCardName: LPCSTR,
108         dwProviderId: DWORD,
109         szProvider: *mut CHAR,
110         pcchProvider: LPDWORD,
111     ) -> LONG;
SCardGetCardTypeProviderNameW( hContext: SCARDCONTEXT, szCardName: LPCWSTR, dwProviderId: DWORD, szProvider: *mut WCHAR, pcchProvider: LPDWORD, ) -> LONG112     pub fn SCardGetCardTypeProviderNameW(
113         hContext: SCARDCONTEXT,
114         szCardName: LPCWSTR,
115         dwProviderId: DWORD,
116         szProvider: *mut WCHAR,
117         pcchProvider: LPDWORD,
118     ) -> LONG;
SCardIntroduceReaderGroupA( hContext: SCARDCONTEXT, szGroupName: LPCSTR, ) -> LONG119     pub fn SCardIntroduceReaderGroupA(
120         hContext: SCARDCONTEXT,
121         szGroupName: LPCSTR,
122     ) -> LONG;
SCardIntroduceReaderGroupW( hContext: SCARDCONTEXT, szGroupName: LPCWSTR, ) -> LONG123     pub fn SCardIntroduceReaderGroupW(
124         hContext: SCARDCONTEXT,
125         szGroupName: LPCWSTR,
126     ) -> LONG;
SCardForgetReaderGroupA( hContext: SCARDCONTEXT, szGroupName: LPCSTR, ) -> LONG127     pub fn SCardForgetReaderGroupA(
128         hContext: SCARDCONTEXT,
129         szGroupName: LPCSTR,
130     ) -> LONG;
SCardForgetReaderGroupW( hContext: SCARDCONTEXT, szGroupName: LPCWSTR, ) -> LONG131     pub fn SCardForgetReaderGroupW(
132         hContext: SCARDCONTEXT,
133         szGroupName: LPCWSTR,
134     ) -> LONG;
SCardIntroduceReaderA( hContext: SCARDCONTEXT, szReaderName: LPCSTR, szDeviceName: LPCSTR, ) -> LONG135     pub fn SCardIntroduceReaderA(
136         hContext: SCARDCONTEXT,
137         szReaderName: LPCSTR,
138         szDeviceName: LPCSTR,
139     ) -> LONG;
SCardIntroduceReaderW( hContext: SCARDCONTEXT, szReaderName: LPCWSTR, szDeviceName: LPCWSTR, ) -> LONG140     pub fn SCardIntroduceReaderW(
141         hContext: SCARDCONTEXT,
142         szReaderName: LPCWSTR,
143         szDeviceName: LPCWSTR,
144     ) -> LONG;
SCardForgetReaderA( hContext: SCARDCONTEXT, szReaderName: LPCSTR, ) -> LONG145     pub fn SCardForgetReaderA(
146         hContext: SCARDCONTEXT,
147         szReaderName: LPCSTR,
148     ) -> LONG;
SCardForgetReaderW( hContext: SCARDCONTEXT, szReaderName: LPCWSTR, ) -> LONG149     pub fn SCardForgetReaderW(
150         hContext: SCARDCONTEXT,
151         szReaderName: LPCWSTR,
152     ) -> LONG;
SCardAddReaderToGroupA( hContext: SCARDCONTEXT, szReaderName: LPCSTR, szGroupName: LPCSTR, ) -> LONG153     pub fn SCardAddReaderToGroupA(
154         hContext: SCARDCONTEXT,
155         szReaderName: LPCSTR,
156         szGroupName: LPCSTR,
157     ) -> LONG;
SCardAddReaderToGroupW( hContext: SCARDCONTEXT, szReaderName: LPCWSTR, szGroupName: LPCWSTR, ) -> LONG158     pub fn SCardAddReaderToGroupW(
159         hContext: SCARDCONTEXT,
160         szReaderName: LPCWSTR,
161         szGroupName: LPCWSTR,
162     ) -> LONG;
SCardRemoveReaderFromGroupA( hContext: SCARDCONTEXT, szReaderName: LPCSTR, szGroupName: LPCSTR, ) -> LONG163     pub fn SCardRemoveReaderFromGroupA(
164         hContext: SCARDCONTEXT,
165         szReaderName: LPCSTR,
166         szGroupName: LPCSTR,
167     ) -> LONG;
SCardRemoveReaderFromGroupW( hContext: SCARDCONTEXT, szReaderName: LPCWSTR, szGroupName: LPCWSTR, ) -> LONG168     pub fn SCardRemoveReaderFromGroupW(
169         hContext: SCARDCONTEXT,
170         szReaderName: LPCWSTR,
171         szGroupName: LPCWSTR,
172     ) -> LONG;
SCardIntroduceCardTypeA( hContext: SCARDCONTEXT, szCardName: LPCSTR, pguidPrimaryProvider: LPCGUID, rgguidInterfaces: LPCGUID, dwInterfaceCount: DWORD, pbAtr: LPCBYTE, pbAtrMask: LPCBYTE, cbAtrLen: DWORD, ) -> LONG173     pub fn SCardIntroduceCardTypeA(
174         hContext: SCARDCONTEXT,
175         szCardName: LPCSTR,
176         pguidPrimaryProvider: LPCGUID,
177         rgguidInterfaces: LPCGUID,
178         dwInterfaceCount: DWORD,
179         pbAtr: LPCBYTE,
180         pbAtrMask: LPCBYTE,
181         cbAtrLen: DWORD,
182     ) -> LONG;
SCardIntroduceCardTypeW( hContext: SCARDCONTEXT, szCardName: LPCWSTR, pguidPrimaryProvider: LPCGUID, rgguidInterfaces: LPCGUID, dwInterfaceCount: DWORD, pbAtr: LPCBYTE, pbAtrMask: LPCBYTE, cbAtrLen: DWORD, ) -> LONG183     pub fn SCardIntroduceCardTypeW(
184         hContext: SCARDCONTEXT,
185         szCardName: LPCWSTR,
186         pguidPrimaryProvider: LPCGUID,
187         rgguidInterfaces: LPCGUID,
188         dwInterfaceCount: DWORD,
189         pbAtr: LPCBYTE,
190         pbAtrMask: LPCBYTE,
191         cbAtrLen: DWORD,
192     ) -> LONG;
SCardSetCardTypeProviderNameA( hContext: SCARDCONTEXT, szCardName: LPCSTR, dwProviderId: DWORD, szProvider: LPCSTR, ) -> LONG193     pub fn SCardSetCardTypeProviderNameA(
194         hContext: SCARDCONTEXT,
195         szCardName: LPCSTR,
196         dwProviderId: DWORD,
197         szProvider: LPCSTR,
198     ) -> LONG;
SCardSetCardTypeProviderNameW( hContext: SCARDCONTEXT, szCardName: LPCWSTR, dwProviderId: DWORD, szProvider: LPCWSTR, ) -> LONG199     pub fn SCardSetCardTypeProviderNameW(
200         hContext: SCARDCONTEXT,
201         szCardName: LPCWSTR,
202         dwProviderId: DWORD,
203         szProvider: LPCWSTR,
204     ) -> LONG;
SCardForgetCardTypeA( hContext: SCARDCONTEXT, szCardName: LPCSTR, ) -> LONG205     pub fn SCardForgetCardTypeA(
206         hContext: SCARDCONTEXT,
207         szCardName: LPCSTR,
208     ) -> LONG;
SCardForgetCardTypeW( hContext: SCARDCONTEXT, szCardName: LPCWSTR, ) -> LONG209     pub fn SCardForgetCardTypeW(
210         hContext: SCARDCONTEXT,
211         szCardName: LPCWSTR,
212     ) -> LONG;
SCardFreeMemory( hContext: SCARDCONTEXT, pvMem: LPCVOID, ) -> LONG213     pub fn SCardFreeMemory(
214         hContext: SCARDCONTEXT,
215         pvMem: LPCVOID,
216     ) -> LONG;
SCardAccessStartedEvent() -> HANDLE217     pub fn SCardAccessStartedEvent() -> HANDLE;
SCardReleaseStartedEvent()218     pub fn SCardReleaseStartedEvent();
219 }
220 STRUCT!{struct SCARD_READERSTATEA {
221     szReader: LPCSTR,
222     pvUserData: LPVOID,
223     dwCurrentState: DWORD,
224     dwEventState: DWORD,
225     cbAtr: DWORD,
226     rgbAtr: [BYTE; 36],
227 }}
228 pub type PSCARD_READERSTATEA = *mut SCARD_READERSTATEA;
229 pub type LPSCARD_READERSTATEA = *mut SCARD_READERSTATEA;
230 STRUCT!{struct SCARD_READERSTATEW {
231     szReader: LPCWSTR,
232     pvUserData: LPVOID,
233     dwCurrentState: DWORD,
234     dwEventState: DWORD,
235     cbAtr: DWORD,
236     rgbAtr: [BYTE; 36],
237 }}
238 pub type PSCARD_READERSTATEW = *mut SCARD_READERSTATEW;
239 pub type LPSCARD_READERSTATEW = *mut SCARD_READERSTATEW;
240 pub type SCARD_READERSTATE_A = SCARD_READERSTATEA;
241 pub type SCARD_READERSTATE_W = SCARD_READERSTATEW;
242 pub type PSCARD_READERSTATE_A = PSCARD_READERSTATEA;
243 pub type PSCARD_READERSTATE_W = PSCARD_READERSTATEW;
244 pub type LPSCARD_READERSTATE_A = LPSCARD_READERSTATEA;
245 pub type LPSCARD_READERSTATE_W = LPSCARD_READERSTATEW;
246 pub const SCARD_STATE_UNAWARE: DWORD = 0x00000000;
247 pub const SCARD_STATE_IGNORE: DWORD = 0x00000001;
248 pub const SCARD_STATE_CHANGED: DWORD = 0x00000002;
249 pub const SCARD_STATE_UNKNOWN: DWORD = 0x00000004;
250 pub const SCARD_STATE_UNAVAILABLE: DWORD = 0x00000008;
251 pub const SCARD_STATE_EMPTY: DWORD = 0x00000010;
252 pub const SCARD_STATE_PRESENT: DWORD = 0x00000020;
253 pub const SCARD_STATE_ATRMATCH: DWORD = 0x00000040;
254 pub const SCARD_STATE_EXCLUSIVE: DWORD = 0x00000080;
255 pub const SCARD_STATE_INUSE: DWORD = 0x00000100;
256 pub const SCARD_STATE_MUTE: DWORD = 0x00000200;
257 pub const SCARD_STATE_UNPOWERED: DWORD = 0x00000400;
258 extern "system" {
SCardLocateCardsA( hContext: SCARDCONTEXT, mszCards: LPCSTR, rgReaderStates: LPSCARD_READERSTATEA, cReaders: DWORD, ) -> LONG259     pub fn SCardLocateCardsA(
260         hContext: SCARDCONTEXT,
261         mszCards: LPCSTR,
262         rgReaderStates: LPSCARD_READERSTATEA,
263         cReaders: DWORD,
264     ) -> LONG;
SCardLocateCardsW( hContext: SCARDCONTEXT, mszCards: LPCWSTR, rgReaderStates: LPSCARD_READERSTATEW, cReaders: DWORD, ) -> LONG265     pub fn SCardLocateCardsW(
266         hContext: SCARDCONTEXT,
267         mszCards: LPCWSTR,
268         rgReaderStates: LPSCARD_READERSTATEW,
269         cReaders: DWORD,
270     ) -> LONG;
271 }
272 STRUCT!{struct SCARD_ATRMASK {
273     cbAtr: DWORD,
274     rgbAtr: [BYTE; 36],
275     rgbMask: [BYTE; 36],
276 }}
277 pub type PSCARD_ATRMASK = *mut SCARD_ATRMASK;
278 pub type LPSCARD_ATRMASK = *mut SCARD_ATRMASK;
279 extern "system" {
SCardLocateCardsByATRA( hContext: SCARDCONTEXT, rgAtrMasks: LPSCARD_ATRMASK, cAtrs: DWORD, rgReaderStates: LPSCARD_READERSTATEA, cReaders: DWORD, ) -> LONG280     pub fn SCardLocateCardsByATRA(
281         hContext: SCARDCONTEXT,
282         rgAtrMasks: LPSCARD_ATRMASK,
283         cAtrs: DWORD,
284         rgReaderStates: LPSCARD_READERSTATEA,
285         cReaders: DWORD,
286     ) -> LONG;
SCardLocateCardsByATRW( hContext: SCARDCONTEXT, rgAtrMasks: LPSCARD_ATRMASK, cAtrs: DWORD, rgReaderStates: LPSCARD_READERSTATEW, cReaders: DWORD, ) -> LONG287     pub fn SCardLocateCardsByATRW(
288         hContext: SCARDCONTEXT,
289         rgAtrMasks: LPSCARD_ATRMASK,
290         cAtrs: DWORD,
291         rgReaderStates: LPSCARD_READERSTATEW,
292         cReaders: DWORD,
293     ) -> LONG;
SCardGetStatusChangeA( hContext: SCARDCONTEXT, dwTimeout: DWORD, rgReaderStates: LPSCARD_READERSTATEA, cReaders: DWORD, ) -> LONG294     pub fn SCardGetStatusChangeA(
295         hContext: SCARDCONTEXT,
296         dwTimeout: DWORD,
297         rgReaderStates: LPSCARD_READERSTATEA,
298         cReaders: DWORD,
299     ) -> LONG;
SCardGetStatusChangeW( hContext: SCARDCONTEXT, dwTimeout: DWORD, rgReaderStates: LPSCARD_READERSTATEW, cReaders: DWORD, ) -> LONG300     pub fn SCardGetStatusChangeW(
301         hContext: SCARDCONTEXT,
302         dwTimeout: DWORD,
303         rgReaderStates: LPSCARD_READERSTATEW,
304         cReaders: DWORD,
305     ) -> LONG;
SCardCancel( hContext: SCARDCONTEXT, ) -> LONG306     pub fn SCardCancel(
307         hContext: SCARDCONTEXT,
308     ) -> LONG;
309 }
310 pub const SCARD_SHARE_EXCLUSIVE: DWORD = 1;
311 pub const SCARD_SHARE_SHARED: DWORD = 2;
312 pub const SCARD_SHARE_DIRECT: DWORD = 3;
313 pub const SCARD_LEAVE_CARD: DWORD = 0;
314 pub const SCARD_RESET_CARD: DWORD = 1;
315 pub const SCARD_UNPOWER_CARD: DWORD = 2;
316 pub const SCARD_EJECT_CARD: DWORD = 3;
317 extern "system" {
SCardConnectA( hContext: SCARDCONTEXT, szReader: LPCSTR, dwShareMode: DWORD, dwPreferredProtocols: DWORD, phCard: LPSCARDHANDLE, pdwActiveProtocol: LPDWORD, ) -> LONG318     pub fn SCardConnectA(
319         hContext: SCARDCONTEXT,
320         szReader: LPCSTR,
321         dwShareMode: DWORD,
322         dwPreferredProtocols: DWORD,
323         phCard: LPSCARDHANDLE,
324         pdwActiveProtocol: LPDWORD,
325     ) -> LONG;
SCardConnectW( hContext: SCARDCONTEXT, szReader: LPCWSTR, dwShareMode: DWORD, dwPreferredProtocols: DWORD, phCard: LPSCARDHANDLE, pdwActiveProtocol: LPDWORD, ) -> LONG326     pub fn SCardConnectW(
327         hContext: SCARDCONTEXT,
328         szReader: LPCWSTR,
329         dwShareMode: DWORD,
330         dwPreferredProtocols: DWORD,
331         phCard: LPSCARDHANDLE,
332         pdwActiveProtocol: LPDWORD,
333     ) -> LONG;
SCardReconnect( hCard: SCARDHANDLE, dwShareMode: DWORD, dwPreferredProtocols: DWORD, dwInitialization: DWORD, pdwActiveProtocol: LPDWORD, ) -> LONG334     pub fn SCardReconnect(
335         hCard: SCARDHANDLE,
336         dwShareMode: DWORD,
337         dwPreferredProtocols: DWORD,
338         dwInitialization: DWORD,
339         pdwActiveProtocol: LPDWORD,
340     ) -> LONG;
SCardDisconnect( hCard: SCARDHANDLE, dwDisposition: DWORD, ) -> LONG341     pub fn SCardDisconnect(
342         hCard: SCARDHANDLE,
343         dwDisposition: DWORD,
344     ) -> LONG;
SCardBeginTransaction( hCard: SCARDHANDLE, ) -> LONG345     pub fn SCardBeginTransaction(
346         hCard: SCARDHANDLE,
347     ) -> LONG;
SCardEndTransaction( hCard: SCARDHANDLE, dwDisposition: DWORD, ) -> LONG348     pub fn SCardEndTransaction(
349         hCard: SCARDHANDLE,
350         dwDisposition: DWORD,
351     ) -> LONG;
SCardState( hCard: SCARDHANDLE, pdwState: LPDWORD, pdwProtocol: LPDWORD, pbAtr: LPBYTE, pcbAtrLen: LPDWORD, ) -> LONG352     pub fn SCardState(
353         hCard: SCARDHANDLE,
354         pdwState: LPDWORD,
355         pdwProtocol: LPDWORD,
356         pbAtr: LPBYTE,
357         pcbAtrLen: LPDWORD,
358     ) -> LONG;
SCardStatusA( hCard: SCARDHANDLE, mszReaderNames: LPSTR, pcchReaderLen: LPDWORD, pdwState: LPDWORD, pdwProtocol: LPDWORD, pbAtr: LPBYTE, pcbAtrLen: LPDWORD, ) -> LONG359     pub fn SCardStatusA(
360         hCard: SCARDHANDLE,
361         mszReaderNames: LPSTR,
362         pcchReaderLen: LPDWORD,
363         pdwState: LPDWORD,
364         pdwProtocol: LPDWORD,
365         pbAtr: LPBYTE,
366         pcbAtrLen: LPDWORD,
367     ) -> LONG;
SCardStatusW( hCard: SCARDHANDLE, mszReaderNames: LPWSTR, pcchReaderLen: LPDWORD, pdwState: LPDWORD, pdwProtocol: LPDWORD, pbAtr: LPBYTE, pcbAtrLen: LPDWORD, ) -> LONG368     pub fn SCardStatusW(
369         hCard: SCARDHANDLE,
370         mszReaderNames: LPWSTR,
371         pcchReaderLen: LPDWORD,
372         pdwState: LPDWORD,
373         pdwProtocol: LPDWORD,
374         pbAtr: LPBYTE,
375         pcbAtrLen: LPDWORD,
376     ) -> LONG;
SCardTransmit( hCard: SCARDHANDLE, pioSendPci: LPCSCARD_IO_REQUEST, pbSendBuffer: LPCBYTE, cbSendLength: DWORD, pioRecvPci: LPSCARD_IO_REQUEST, pbRecvBuffer: LPBYTE, pcbRecvLength: LPDWORD, ) -> LONG377     pub fn SCardTransmit(
378         hCard: SCARDHANDLE,
379         pioSendPci: LPCSCARD_IO_REQUEST,
380         pbSendBuffer: LPCBYTE,
381         cbSendLength: DWORD,
382         pioRecvPci: LPSCARD_IO_REQUEST,
383         pbRecvBuffer: LPBYTE,
384         pcbRecvLength: LPDWORD,
385     ) -> LONG;
SCardGetTransmitCount( hCard: SCARDHANDLE, pcTransmitCount: LPDWORD, ) -> LONG386     pub fn SCardGetTransmitCount(
387         hCard: SCARDHANDLE,
388         pcTransmitCount: LPDWORD,
389     ) -> LONG;
SCardControl( hCard: SCARDHANDLE, dwControlCode: DWORD, lpInBuffer: LPCVOID, cbInBufferSize: DWORD, lpOutBuffer: LPVOID, cbOutBufferSize: DWORD, lpBytesReturned: LPDWORD, ) -> LONG390     pub fn SCardControl(
391         hCard: SCARDHANDLE,
392         dwControlCode: DWORD,
393         lpInBuffer: LPCVOID,
394         cbInBufferSize: DWORD,
395         lpOutBuffer: LPVOID,
396         cbOutBufferSize: DWORD,
397         lpBytesReturned: LPDWORD,
398     ) -> LONG;
SCardGetAttrib( hCard: SCARDHANDLE, dwAttrId: DWORD, pbAttr: LPBYTE, pcbAttrLen: LPDWORD, ) -> LONG399     pub fn SCardGetAttrib(
400         hCard: SCARDHANDLE,
401         dwAttrId: DWORD,
402         pbAttr: LPBYTE,
403         pcbAttrLen: LPDWORD,
404     ) -> LONG;
SCardSetAttrib( hCard: SCARDHANDLE, dwAttrId: DWORD, pbAttr: LPCBYTE, cbAttrLen: DWORD, ) -> LONG405     pub fn SCardSetAttrib(
406         hCard: SCARDHANDLE,
407         dwAttrId: DWORD,
408         pbAttr: LPCBYTE,
409         cbAttrLen: DWORD,
410     ) -> LONG;
411 }
412 pub const SC_DLG_MINIMAL_UI: DWORD = 0x01;
413 pub const SC_DLG_NO_UI: DWORD = 0x02;
414 pub const SC_DLG_FORCE_UI: DWORD = 0x04;
415 pub const SCERR_NOCARDNAME: DWORD = 0x4000;
416 pub const SCERR_NOGUIDS: DWORD = 0x8000;
417 FN!{stdcall LPOCNCONNPROCA(
418     SCARDCONTEXT,
419     LPSTR,
420     LPSTR,
421     PVOID,
422 ) -> SCARDHANDLE}
423 FN!{stdcall LPOCNCONNPROCW(
424     SCARDCONTEXT,
425     LPWSTR,
426     LPWSTR,
427     PVOID,
428 ) -> SCARDHANDLE}
429 FN!{stdcall LPOCNCHKPROC(
430     SCARDCONTEXT,
431     SCARDHANDLE,
432     PVOID,
433 ) -> BOOL}
434 FN!{stdcall LPOCNDSCPROC(
435     SCARDCONTEXT,
436     SCARDHANDLE,
437     PVOID,
438 ) -> ()}
439 STRUCT!{struct OPENCARD_SEARCH_CRITERIAA {
440     dwStructSize: DWORD,
441     lpstrGroupNames: LPSTR,
442     nMaxGroupNames: DWORD,
443     rgguidInterfaces: LPCGUID,
444     cguidInterfaces: DWORD,
445     lpstrCardNames: LPSTR,
446     nMaxCardNames: DWORD,
447     lpfnCheck: LPOCNCHKPROC,
448     lpfnConnect: LPOCNCONNPROCA,
449     lpfnDisconnect: LPOCNDSCPROC,
450     pvUserData: LPVOID,
451     dwShareMode: DWORD,
452     dwPreferredProtocols: DWORD,
453 }}
454 pub type POPENCARD_SEARCH_CRITERIAA = *mut OPENCARD_SEARCH_CRITERIAA;
455 pub type LPOPENCARD_SEARCH_CRITERIAA = *mut OPENCARD_SEARCH_CRITERIAA;
456 STRUCT!{struct OPENCARD_SEARCH_CRITERIAW {
457     dwStructSize: DWORD,
458     lpstrGroupNames: LPWSTR,
459     nMaxGroupNames: DWORD,
460     rgguidInterfaces: LPCGUID,
461     cguidInterfaces: DWORD,
462     lpstrCardNames: LPWSTR,
463     nMaxCardNames: DWORD,
464     lpfnCheck: LPOCNCHKPROC,
465     lpfnConnect: LPOCNCONNPROCW,
466     lpfnDisconnect: LPOCNDSCPROC,
467     pvUserData: LPVOID,
468     dwShareMode: DWORD,
469     dwPreferredProtocols: DWORD,
470 }}
471 pub type POPENCARD_SEARCH_CRITERIAW = *mut OPENCARD_SEARCH_CRITERIAW;
472 pub type LPOPENCARD_SEARCH_CRITERIAW = *mut OPENCARD_SEARCH_CRITERIAW;
473 STRUCT!{struct OPENCARDNAME_EXA {
474     dwStructSize: DWORD,
475     hSCardContext: SCARDCONTEXT,
476     hwndOwner: HWND,
477     dwFlags: DWORD,
478     lpstrTitle: LPCSTR,
479     lpstrSearchDesc: LPCSTR,
480     hIcon: HICON,
481     pOpenCardSearchCriteria: POPENCARD_SEARCH_CRITERIAA,
482     lpfnConnect: LPOCNCONNPROCA,
483     pvUserData: LPVOID,
484     dwShareMode: DWORD,
485     dwPreferredProtocols: DWORD,
486     lpstrRdr: LPSTR,
487     nMaxRdr: DWORD,
488     lpstrCard: LPSTR,
489     nMaxCard: DWORD,
490     dwActiveProtocol: DWORD,
491     hCardHandle: SCARDHANDLE,
492 }}
493 pub type POPENCARDNAME_EXA = *mut OPENCARDNAME_EXA;
494 pub type LPOPENCARDNAME_EXA = *mut OPENCARDNAME_EXA;
495 STRUCT!{struct OPENCARDNAME_EXW {
496     dwStructSize: DWORD,
497     hSCardContext: SCARDCONTEXT,
498     hwndOwner: HWND,
499     dwFlags: DWORD,
500     lpstrTitle: LPCWSTR,
501     lpstrSearchDesc: LPCWSTR,
502     hIcon: HICON,
503     pOpenCardSearchCriteria: POPENCARD_SEARCH_CRITERIAW,
504     lpfnConnect: LPOCNCONNPROCW,
505     pvUserData: LPVOID,
506     dwShareMode: DWORD,
507     dwPreferredProtocols: DWORD,
508     lpstrRdr: LPWSTR,
509     nMaxRdr: DWORD,
510     lpstrCard: LPWSTR,
511     nMaxCard: DWORD,
512     dwActiveProtocol: DWORD,
513     hCardHandle: SCARDHANDLE,
514 }}
515 pub type POPENCARDNAME_EXW = *mut OPENCARDNAME_EXW;
516 pub type LPOPENCARDNAME_EXW = *mut OPENCARDNAME_EXW;
517 pub type OPENCARDNAMEA_EX = OPENCARDNAME_EXA;
518 pub type OPENCARDNAMEW_EX = OPENCARDNAME_EXW;
519 pub type POPENCARDNAMEA_EX = POPENCARDNAME_EXA;
520 pub type POPENCARDNAMEW_EX = POPENCARDNAME_EXW;
521 pub type LPOPENCARDNAMEA_EX = LPOPENCARDNAME_EXA;
522 pub type LPOPENCARDNAMEW_EX = LPOPENCARDNAME_EXW;
523 pub const SCARD_READER_SEL_AUTH_PACKAGE: DWORD = -629i32 as u32;
524 ENUM!{enum READER_SEL_REQUEST_MATCH_TYPE {
525     RSR_MATCH_TYPE_READER_AND_CONTAINER = 1,
526     RSR_MATCH_TYPE_SERIAL_NUMBER,
527     RSR_MATCH_TYPE_ALL_CARDS,
528 }}
529 STRUCT!{struct READER_SEL_REQUEST_ReaderAndContainerParameter {
530     cbReaderNameOffset: DWORD,
531     cchReaderNameLength: DWORD,
532     cbContainerNameOffset: DWORD,
533     cchContainerNameLength: DWORD,
534     dwDesiredCardModuleVersion: DWORD,
535     dwCspFlags: DWORD,
536 }}
537 STRUCT!{struct READER_SEL_REQUEST_SerialNumberParameter {
538     cbSerialNumberOffset: DWORD,
539     cbSerialNumberLength: DWORD,
540     dwDesiredCardModuleVersion: DWORD,
541 }}
542 UNION!{union READER_SEL_REQUEST_u {
543     [u32; 6],
544     ReaderAndContainerParameter ReaderAndContainerParameter_mut:
545         READER_SEL_REQUEST_ReaderAndContainerParameter,
546     SerialNumberParameter SerialNumberParameter_mut: READER_SEL_REQUEST_SerialNumberParameter,
547 }}
548 STRUCT!{struct READER_SEL_REQUEST {
549     dwShareMode: DWORD,
550     dwPreferredProtocols: DWORD,
551     MatchType: READER_SEL_REQUEST_MATCH_TYPE,
552     u: READER_SEL_REQUEST_u,
553 }}
554 pub type PREADER_SEL_REQUEST = *mut READER_SEL_REQUEST;
555 STRUCT!{struct READER_SEL_RESPONSE {
556     cbReaderNameOffset: DWORD,
557     cchReaderNameLength: DWORD,
558     cbCardNameOffset: DWORD,
559     cchCardNameLength: DWORD,
560 }}
561 pub type PREADER_SEL_RESPONSE = *mut READER_SEL_RESPONSE;
562 STRUCT!{struct OPENCARDNAMEA {
563     dwStructSize: DWORD,
564     hwndOwner: HWND,
565     hSCardContext: SCARDCONTEXT,
566     lpstrGroupNames: LPSTR,
567     nMaxGroupNames: DWORD,
568     lpstrCardNames: LPSTR,
569     nMaxCardNames: DWORD,
570     rgguidInterfaces: LPCGUID,
571     cguidInterfaces: DWORD,
572     lpstrRdr: LPSTR,
573     nMaxRdr: DWORD,
574     lpstrCard: LPSTR,
575     nMaxCard: DWORD,
576     lpstrTitle: LPCSTR,
577     dwFlags: DWORD,
578     pvUserData: LPVOID,
579     dwShareMode: DWORD,
580     dwPreferredProtocols: DWORD,
581     dwActiveProtocol: DWORD,
582     lpfnConnect: LPOCNCONNPROCA,
583     lpfnCheck: LPOCNCHKPROC,
584     lpfnDisconnect: LPOCNDSCPROC,
585     hCardHandle: SCARDHANDLE,
586 }}
587 pub type POPENCARDNAMEA = *mut OPENCARDNAMEA;
588 pub type LPOPENCARDNAMEA = *mut OPENCARDNAMEA;
589 STRUCT!{struct OPENCARDNAMEW {
590     dwStructSize: DWORD,
591     hwndOwner: HWND,
592     hSCardContext: SCARDCONTEXT,
593     lpstrGroupNames: LPWSTR,
594     nMaxGroupNames: DWORD,
595     lpstrCardNames: LPWSTR,
596     nMaxCardNames: DWORD,
597     rgguidInterfaces: LPCGUID,
598     cguidInterfaces: DWORD,
599     lpstrRdr: LPWSTR,
600     nMaxRdr: DWORD,
601     lpstrCard: LPWSTR,
602     nMaxCard: DWORD,
603     lpstrTitle: LPCWSTR,
604     dwFlags: DWORD,
605     pvUserData: LPVOID,
606     dwShareMode: DWORD,
607     dwPreferredProtocols: DWORD,
608     dwActiveProtocol: DWORD,
609     lpfnConnect: LPOCNCONNPROCW,
610     lpfnCheck: LPOCNCHKPROC,
611     lpfnDisconnect: LPOCNDSCPROC,
612     hCardHandle: SCARDHANDLE,
613 }}
614 pub type POPENCARDNAMEW = *mut OPENCARDNAMEW;
615 pub type LPOPENCARDNAMEW = *mut OPENCARDNAMEW;
616 pub type OPENCARDNAME_A = OPENCARDNAMEA;
617 pub type OPENCARDNAME_W = OPENCARDNAMEW;
618 pub type POPENCARDNAME_A = POPENCARDNAMEA;
619 pub type POPENCARDNAME_W = POPENCARDNAMEW;
620 pub type LPOPENCARDNAME_A = LPOPENCARDNAMEA;
621 pub type LPOPENCARDNAME_W = LPOPENCARDNAMEW;
622 extern "system" {
SCardReadCacheA( hContext: SCARDCONTEXT, CardIdentifier: *mut UUID, FreshnessCounter: DWORD, LookupName: LPSTR, Data: PBYTE, DataLen: *mut DWORD, ) -> LONG623     pub fn SCardReadCacheA(
624         hContext: SCARDCONTEXT,
625         CardIdentifier: *mut UUID,
626         FreshnessCounter: DWORD,
627         LookupName: LPSTR,
628         Data: PBYTE,
629         DataLen: *mut DWORD,
630     ) -> LONG;
SCardReadCacheW( hContext: SCARDCONTEXT, CardIdentifier: *mut UUID, FreshnessCounter: DWORD, LookupName: LPWSTR, Data: PBYTE, DataLen: *mut DWORD, ) -> LONG631     pub fn SCardReadCacheW(
632         hContext: SCARDCONTEXT,
633         CardIdentifier: *mut UUID,
634         FreshnessCounter: DWORD,
635         LookupName: LPWSTR,
636         Data: PBYTE,
637         DataLen: *mut DWORD,
638     ) -> LONG;
SCardWriteCacheA( hContext: SCARDCONTEXT, CardIdentifier: *mut UUID, FreshnessCounter: DWORD, LookupName: LPSTR, Data: PBYTE, DataLen: DWORD, ) -> LONG639     pub fn SCardWriteCacheA(
640         hContext: SCARDCONTEXT,
641         CardIdentifier: *mut UUID,
642         FreshnessCounter: DWORD,
643         LookupName: LPSTR,
644         Data: PBYTE,
645         DataLen: DWORD,
646     ) -> LONG;
SCardWriteCacheW( hContext: SCARDCONTEXT, CardIdentifier: *mut UUID, FreshnessCounter: DWORD, LookupName: LPWSTR, Data: PBYTE, DataLen: DWORD, ) -> LONG647     pub fn SCardWriteCacheW(
648         hContext: SCARDCONTEXT,
649         CardIdentifier: *mut UUID,
650         FreshnessCounter: DWORD,
651         LookupName: LPWSTR,
652         Data: PBYTE,
653         DataLen: DWORD,
654     ) -> LONG;
SCardGetReaderIconA( hContext: SCARDCONTEXT, szReaderName: LPCSTR, pbIcon: LPBYTE, pcbIcon: LPDWORD, ) -> LONG655     pub fn SCardGetReaderIconA(
656         hContext: SCARDCONTEXT,
657         szReaderName: LPCSTR,
658         pbIcon: LPBYTE,
659         pcbIcon: LPDWORD,
660     ) -> LONG;
SCardGetReaderIconW( hContext: SCARDCONTEXT, szReaderName: LPCWSTR, pbIcon: LPBYTE, pcbIcon: LPDWORD, ) -> LONG661     pub fn SCardGetReaderIconW(
662         hContext: SCARDCONTEXT,
663         szReaderName: LPCWSTR,
664         pbIcon: LPBYTE,
665         pcbIcon: LPDWORD,
666     ) -> LONG;
SCardGetDeviceTypeIdA( hContext: SCARDCONTEXT, szReaderName: LPCSTR, pdwDeviceTypeId: LPDWORD, ) -> LONG667     pub fn SCardGetDeviceTypeIdA(
668         hContext: SCARDCONTEXT,
669         szReaderName: LPCSTR,
670         pdwDeviceTypeId: LPDWORD,
671     ) -> LONG;
SCardGetDeviceTypeIdW( hContext: SCARDCONTEXT, szReaderName: LPCWSTR, pdwDeviceTypeId: LPDWORD, ) -> LONG672     pub fn SCardGetDeviceTypeIdW(
673         hContext: SCARDCONTEXT,
674         szReaderName: LPCWSTR,
675         pdwDeviceTypeId: LPDWORD,
676     ) -> LONG;
SCardGetReaderDeviceInstanceIdA( hContext: SCARDCONTEXT, szReaderName: LPCSTR, szDeviceInstanceId: LPSTR, pcchDeviceInstanceId: LPDWORD, ) -> LONG677     pub fn SCardGetReaderDeviceInstanceIdA(
678         hContext: SCARDCONTEXT,
679         szReaderName: LPCSTR,
680         szDeviceInstanceId: LPSTR,
681         pcchDeviceInstanceId: LPDWORD,
682     ) -> LONG;
SCardGetReaderDeviceInstanceIdW( hContext: SCARDCONTEXT, szReaderName: LPCWSTR, szDeviceInstanceId: LPWSTR, pcchDeviceInstanceId: LPDWORD, ) -> LONG683     pub fn SCardGetReaderDeviceInstanceIdW(
684         hContext: SCARDCONTEXT,
685         szReaderName: LPCWSTR,
686         szDeviceInstanceId: LPWSTR,
687         pcchDeviceInstanceId: LPDWORD,
688     ) -> LONG;
SCardListReadersWithDeviceInstanceIdA( hContext: SCARDCONTEXT, szDeviceInstanceId: LPCSTR, mszReaders: LPSTR, pcchReaders: LPDWORD, ) -> LONG689     pub fn SCardListReadersWithDeviceInstanceIdA(
690         hContext: SCARDCONTEXT,
691         szDeviceInstanceId: LPCSTR,
692         mszReaders: LPSTR,
693         pcchReaders: LPDWORD,
694     ) -> LONG;
SCardListReadersWithDeviceInstanceIdW( hContext: SCARDCONTEXT, szDeviceInstanceId: LPCWSTR, mszReaders: LPWSTR, pcchReaders: LPDWORD, ) -> LONG695     pub fn SCardListReadersWithDeviceInstanceIdW(
696         hContext: SCARDCONTEXT,
697         szDeviceInstanceId: LPCWSTR,
698         mszReaders: LPWSTR,
699         pcchReaders: LPDWORD,
700     ) -> LONG;
701 }
702 pub const SCARD_AUDIT_CHV_FAILURE: DWORD = 0x0;
703 pub const SCARD_AUDIT_CHV_SUCCESS: DWORD = 0x1;
704 extern "system" {
SCardAudit( hContext: SCARDCONTEXT, dwEvent: DWORD, ) -> LONG705     pub fn SCardAudit(
706         hContext: SCARDCONTEXT,
707         dwEvent: DWORD,
708     ) -> LONG;
709 }
710