@@ -41,6 +41,11 @@ typedef unsigned long SCUINT;
4141typedef long RETVAL;
4242#endif
4343
44+ // LPWSTR is needs to be defined when compiling outside of Windows
45+ #ifndef Q_OS_WIN
46+ #define LPWSTR char *
47+ #endif
48+
4449// This namescape contains static wrappers for the smart card API
4550// Which enable the communication with a Yubikey via PCSC ADPUs
4651namespace
@@ -107,7 +112,7 @@ namespace
107112 }
108113 char * mszReaders = new char [dwReaders + 2 ];
109114
110- rv = SCardListReaders (context, nullptr , mszReaders, &dwReaders);
115+ rv = SCardListReaders (context, nullptr , static_cast <LPWSTR>( mszReaders) , &dwReaders);
111116 if (rv == SCARD_S_SUCCESS) {
112117 char * readhead = mszReaders;
113118 // Names are separated by a null byte
@@ -143,7 +148,7 @@ namespace
143148 uint8_t pbAtr[MAX_ATR_SIZE] = {0 }; // ATR record
144149 SCUINT dwAtrLen = sizeof (pbAtr); // ATR record size
145150
146- auto rv = SCardStatus (handle, pbReader, &dwReaderLen, &dwState, &dwProt, pbAtr, &dwAtrLen);
151+ auto rv = SCardStatus (handle, static_cast <LPWSTR>( pbReader) , &dwReaderLen, &dwState, &dwProt, pbAtr, &dwAtrLen);
147152 if (rv == SCARD_S_SUCCESS) {
148153 switch (dwProt) {
149154 case SCARD_PROTOCOL_T0:
@@ -431,7 +436,7 @@ namespace
431436 SCARDHANDLE hCard;
432437 SCUINT dwActiveProtocol = SCARD_PROTOCOL_UNDEFINED;
433438 rv = SCardConnect (context,
434- reader_name.toStdString ().c_str (),
439+ static_cast <LPWSTR>( reader_name.toStdString ().c_str () ),
435440 SCARD_SHARE_SHARED,
436441 SCARD_PROTOCOL_T0 | SCARD_PROTOCOL_T1,
437442 &hCard,
@@ -446,7 +451,7 @@ namespace
446451 uint8_t pbAtr[MAX_ATR_SIZE] = {0 };
447452 SCUINT dwAtrLen = sizeof (pbAtr);
448453
449- rv = SCardStatus (hCard, pbReader, &dwReaderLen, &dwState, &dwProt, pbAtr, &dwAtrLen);
454+ rv = SCardStatus (hCard, static_cast <LPWSTR>( pbReader) , &dwReaderLen, &dwState, &dwProt, pbAtr, &dwAtrLen);
450455 if (rv == SCARD_S_SUCCESS && (dwProt == SCARD_PROTOCOL_T0 || dwProt == SCARD_PROTOCOL_T1)) {
451456 // Find which AID to use
452457 SCardAID satr;
@@ -568,7 +573,7 @@ YubiKey::KeyMap YubiKeyInterfacePCSC::findValidKeys(int& connectedKeys)
568573 SCARDHANDLE hCard;
569574 SCUINT dwActiveProtocol = SCARD_PROTOCOL_UNDEFINED;
570575 auto rv = SCardConnect (m_sc_context,
571- reader_name.toStdString ().c_str (),
576+ static_cast <LPWSTR>( reader_name.toStdString ().c_str () ),
572577 SCARD_SHARE_SHARED,
573578 SCARD_PROTOCOL_T0 | SCARD_PROTOCOL_T1,
574579 &hCard,
@@ -589,7 +594,7 @@ YubiKey::KeyMap YubiKeyInterfacePCSC::findValidKeys(int& connectedKeys)
589594 uint8_t pbAtr[MAX_ATR_SIZE] = {0 };
590595 SCUINT dwAtrLen = sizeof (pbAtr);
591596
592- rv = SCardStatus (hCard, pbReader, &dwReaderLen, &dwState, &dwProt, pbAtr, &dwAtrLen);
597+ rv = SCardStatus (hCard, static_cast <LPWSTR>( pbReader) , &dwReaderLen, &dwState, &dwProt, pbAtr, &dwAtrLen);
593598 if (rv != SCARD_S_SUCCESS || (dwProt != SCARD_PROTOCOL_T0 && dwProt != SCARD_PROTOCOL_T1)) {
594599 // Could not read the ATR record or the protocol is not supported
595600 continue ;
0 commit comments