Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/core/Database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
#include <algorithm>

#ifdef Q_OS_WIN
#include <Windows.h>
#include <windows.h>
#endif

QHash<QUuid, QPointer<Database>> Database::s_uuidMap;
Expand Down Expand Up @@ -338,7 +338,7 @@ bool Database::saveAs(const QString& filePath, SaveAction action, const QString&

#ifdef Q_OS_WIN
if (isHidden) {
SetFileAttributes(realFilePath.toStdString().c_str(), FILE_ATTRIBUTE_HIDDEN);
SetFileAttributes(static_cast<LPCWSTR>(realFilePath.toStdString().c_str()), FILE_ATTRIBUTE_HIDDEN);
}
#endif
m_ignoreFileChangesUntilSaved = false;
Expand Down
17 changes: 11 additions & 6 deletions src/keys/drivers/YubiKeyInterfacePCSC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ typedef unsigned long SCUINT;
typedef long RETVAL;
#endif

// LPWSTR is needs to be defined when compiling outside of Windows
#ifndef Q_OS_WIN
#define LPWSTR char *
#endif

// This namescape contains static wrappers for the smart card API
// Which enable the communication with a Yubikey via PCSC ADPUs
namespace
Expand Down Expand Up @@ -107,7 +112,7 @@ namespace
}
char* mszReaders = new char[dwReaders + 2];

rv = SCardListReaders(context, nullptr, mszReaders, &dwReaders);
rv = SCardListReaders(context, nullptr, static_cast<LPWSTR>(mszReaders), &dwReaders);
if (rv == SCARD_S_SUCCESS) {
char* readhead = mszReaders;
// Names are separated by a null byte
Expand Down Expand Up @@ -143,7 +148,7 @@ namespace
uint8_t pbAtr[MAX_ATR_SIZE] = {0}; // ATR record
SCUINT dwAtrLen = sizeof(pbAtr); // ATR record size

auto rv = SCardStatus(handle, pbReader, &dwReaderLen, &dwState, &dwProt, pbAtr, &dwAtrLen);
auto rv = SCardStatus(handle, static_cast<LPWSTR>(pbReader), &dwReaderLen, &dwState, &dwProt, pbAtr, &dwAtrLen);
if (rv == SCARD_S_SUCCESS) {
switch (dwProt) {
case SCARD_PROTOCOL_T0:
Expand Down Expand Up @@ -431,7 +436,7 @@ namespace
SCARDHANDLE hCard;
SCUINT dwActiveProtocol = SCARD_PROTOCOL_UNDEFINED;
rv = SCardConnect(context,
reader_name.toStdString().c_str(),
static_cast<const LPWSTR>(reader_name.toStdString().c_str()),
SCARD_SHARE_SHARED,
SCARD_PROTOCOL_T0 | SCARD_PROTOCOL_T1,
&hCard,
Expand All @@ -446,7 +451,7 @@ namespace
uint8_t pbAtr[MAX_ATR_SIZE] = {0};
SCUINT dwAtrLen = sizeof(pbAtr);

rv = SCardStatus(hCard, pbReader, &dwReaderLen, &dwState, &dwProt, pbAtr, &dwAtrLen);
rv = SCardStatus(hCard, static_cast<LPWSTR>(pbReader), &dwReaderLen, &dwState, &dwProt, pbAtr, &dwAtrLen);
if (rv == SCARD_S_SUCCESS && (dwProt == SCARD_PROTOCOL_T0 || dwProt == SCARD_PROTOCOL_T1)) {
// Find which AID to use
SCardAID satr;
Expand Down Expand Up @@ -568,7 +573,7 @@ YubiKey::KeyMap YubiKeyInterfacePCSC::findValidKeys(int& connectedKeys)
SCARDHANDLE hCard;
SCUINT dwActiveProtocol = SCARD_PROTOCOL_UNDEFINED;
auto rv = SCardConnect(m_sc_context,
reader_name.toStdString().c_str(),
static_cast<const LPWSTR>(reader_name.toStdString().c_str()),
SCARD_SHARE_SHARED,
SCARD_PROTOCOL_T0 | SCARD_PROTOCOL_T1,
&hCard,
Expand All @@ -589,7 +594,7 @@ YubiKey::KeyMap YubiKeyInterfacePCSC::findValidKeys(int& connectedKeys)
uint8_t pbAtr[MAX_ATR_SIZE] = {0};
SCUINT dwAtrLen = sizeof(pbAtr);

rv = SCardStatus(hCard, pbReader, &dwReaderLen, &dwState, &dwProt, pbAtr, &dwAtrLen);
rv = SCardStatus(hCard, static_cast<LPWSTR>(pbReader), &dwReaderLen, &dwState, &dwProt, pbAtr, &dwAtrLen);
if (rv != SCARD_S_SUCCESS || (dwProt != SCARD_PROTOCOL_T0 && dwProt != SCARD_PROTOCOL_T1)) {
// Could not read the ATR record or the protocol is not supported
continue;
Expand Down