Skip to content

Commit

Permalink
Revert "Linux: Make the C++ code compatible with old compilers (g++ 4…
Browse files Browse the repository at this point in the history
….4.7 on CentOS 6)"

This reverts commit 9697416.

Breaks admin prompts on Linux.
  • Loading branch information
Jertzukka committed Jul 10, 2024
1 parent 82b9eef commit 2effa5e
Show file tree
Hide file tree
Showing 13 changed files with 130 additions and 138 deletions.
2 changes: 1 addition & 1 deletion src/Common/SCard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace VeraCrypt
{
SCardManager SCard::manager;

SCard::SCard()
SCard::SCard() : m_reader(NULL)
{
}

Expand Down
4 changes: 2 additions & 2 deletions src/Common/SCardLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ namespace VeraCrypt
return scardStatus(hCard, mszReaderNames, pcchReaderLen, pdwState, pdwProtocol, pbAtr, pcbAtrLen);
}

LONG SCardLoader::SCardGetStatusChange(SCARDCONTEXT hContext, DWORD dwTimeout, SCARD_READERSTATE* rgReaderStates, DWORD cReaders)
LONG SCardLoader::SCardGetStatusChange(SCARDCONTEXT hContext, DWORD dwTimeout, LPSCARD_READERSTATE rgReaderStates, DWORD cReaders)
{
Initialize();

Expand Down Expand Up @@ -399,4 +399,4 @@ namespace VeraCrypt

return scardSetAttrib(hCard, dwAttrId, pbAttr, cbAttrLen);
}
}
}
9 changes: 6 additions & 3 deletions src/Common/SCardLoader.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,16 @@
#include <PCSC/winscard.h>
#include <PCSC/wintypes.h>
#include "reader.h"
typedef LPSCARD_READERSTATE_A LPSCARD_READERSTATE;
using VeraCrypt::uint8;
#define BOOL int
#else
#undef BOOL
#include "pcsclite.h"
#include <winscard.h>
#include <wintypes.h>
#include <reader.h>
using VeraCrypt::uint8;
#define BOOL int
#endif
#endif
Expand All @@ -45,7 +48,7 @@ namespace VeraCrypt
typedef LONG (SCARD_CALL_SPEC *SCardBeginTransactionPtr)(SCARDHANDLE hCard);
typedef LONG (SCARD_CALL_SPEC *SCardEndTransactionPtr)(SCARDHANDLE hCard, DWORD dwDisposition);
typedef LONG (SCARD_CALL_SPEC *SCardStatusPtr)(SCARDHANDLE hCard, LPTSTR mszReaderNames, LPDWORD pcchReaderLen, LPDWORD pdwState, LPDWORD pdwProtocol, BYTE* pbAtr, LPDWORD pcbAtrLen);
typedef LONG (SCARD_CALL_SPEC *SCardGetStatusChangePtr)(SCARDCONTEXT hContext, DWORD dwTimeout, SCARD_READERSTATE* rgReaderStates, DWORD cReaders);
typedef LONG (SCARD_CALL_SPEC *SCardGetStatusChangePtr)(SCARDCONTEXT hContext, DWORD dwTimeout, LPSCARD_READERSTATE rgReaderStates, DWORD cReaders);
typedef LONG (SCARD_CALL_SPEC *SCardControlPtr)(SCARDHANDLE hCard, DWORD dwControlCode, LPCVOID pbSendBuffer, DWORD cbSendLength, LPVOID pbRecvBuffer, DWORD cbRecvLength, LPDWORD lpBytesReturned);
typedef LONG (SCARD_CALL_SPEC *SCardTransmitPtr)(SCARDHANDLE hCard, LPCSCARD_IO_REQUEST pioSendPci, const BYTE* pbSendBuffer, DWORD cbSendLength, LPSCARD_IO_REQUEST pioRecvPci, BYTE* pbRecvBuffer, LPDWORD pcbRecvLength);
typedef LONG (SCARD_CALL_SPEC *SCardListReaderGroupsPtr)(SCARDCONTEXT hContext, LPTSTR mszGroups, LPDWORD pcchGroups);
Expand Down Expand Up @@ -108,7 +111,7 @@ namespace VeraCrypt
static LONG SCardBeginTransaction(SCARDHANDLE hCard);
static LONG SCardEndTransaction(SCARDHANDLE hCard, DWORD dwDisposition);
static LONG SCardStatus(SCARDHANDLE hCard, LPTSTR mszReaderNames, LPDWORD pcchReaderLen, LPDWORD pdwState, LPDWORD pdwProtocol, BYTE* pbAtr, LPDWORD pcbAtrLen);
static LONG SCardGetStatusChange(SCARDCONTEXT hContext, DWORD dwTimeout, SCARD_READERSTATE* rgReaderStates, DWORD cReaders);
static LONG SCardGetStatusChange(SCARDCONTEXT hContext, DWORD dwTimeout, LPSCARD_READERSTATE rgReaderStates, DWORD cReaders);
static LONG SCardControl(SCARDHANDLE hCard, DWORD dwControlCode, LPCVOID pbSendBuffer, DWORD cbSendLength, LPVOID pbRecvBuffer, DWORD cbRecvLength, LPDWORD lpBytesReturned);
static LONG SCardTransmit(SCARDHANDLE hCard, LPCSCARD_IO_REQUEST pioSendPci, const BYTE* pbSendBuffer, DWORD cbSendLength, LPSCARD_IO_REQUEST pioRecvPci, BYTE* pbRecvBuffer, LPDWORD pcbRecvLength);
static LONG SCardListReaderGroups(SCARDCONTEXT hContext, LPTSTR mszGroups, LPDWORD pcchGroups);
Expand All @@ -119,4 +122,4 @@ namespace VeraCrypt
};
};

#endif // TC_HEADER_Common_SCardLoader
#endif // TC_HEADER_Common_SCardLoader
4 changes: 2 additions & 2 deletions src/Common/SCardReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace VeraCrypt
}
else
{
m_scardLoader.reset();
m_scardLoader = NULL;
m_hSCReaderContext = 0;
}
m_hCard = hCard;
Expand Down Expand Up @@ -84,7 +84,7 @@ namespace VeraCrypt
void SCardReader::Clear(void)
{
m_szSCReaderName = L"";
m_scardLoader.reset();
m_scardLoader = NULL;
m_hSCReaderContext = 0;
m_hCard = 0;
m_dwProtocol = 0;
Expand Down
8 changes: 4 additions & 4 deletions src/Common/TLVParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,19 +169,19 @@ namespace VeraCrypt
shared_ptr<TLVNode> TLVParser::TLV_Find(shared_ptr<TLVNode> node, uint16 tag)
{
size_t i = 0;
shared_ptr<TLVNode> tmpnode;
shared_ptr<TLVNode> tmpnode = NULL;
if (node->Tag == tag)
{
return node;
}
for (i = 0; i < node->Subs->size(); i++)
{
tmpnode = TLV_Find(node->Subs->at(i),tag);
if (tmpnode)
if (tmpnode != NULL)
{
return tmpnode;
}
}
return shared_ptr<TLVNode>();
return NULL;
}
}
}
53 changes: 4 additions & 49 deletions src/Main/Forms/PreferencesDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,51 +82,6 @@ namespace VeraCrypt
LanguageListBox->Append("System default");
LanguageListBox->Append("English");

langEntries = {
{"system", L"System default"},
{"ar", L"العربية"},
{"be", L"Беларуская"},
{"bg", L"Български"},
{"ca", L"Català"},
{"co", L"Corsu"},
{"cs", L"Čeština"},
{"da", L"Dansk"},
{"de", L"Deutsch"},
{"el", L"Ελληνικά"},
{"en", L"English"},
{"es", L"Español"},
{"et", L"Eesti"},
{"eu", L"Euskara"},
{"fa", L"فارسي"},
{"fi", L"Suomi"},
{"fr", L"Français"},
{"he", L"עברית"},
{"hu", L"Magyar"},
{"id", L"Bahasa Indonesia"},
{"it", L"Italiano"},
{"ja", L"日本語"},
{"ka", L"ქართული"},
{"ko", L"한국어"},
{"lv", L"Latviešu"},
{"nl", L"Nederlands"},
{"nn", L"Norsk Nynorsk"},
{"pl", L"Polski"},
{"ro", L"Română"},
{"ru", L"Русский"},
{"pt-br", L"Português-Brasil"},
{"sk", L"Slovenčina"},
{"sl", L"Slovenščina"},
{"sv", L"Svenska"},
{"th", L"ภาษาไทย"},
{"tr", L"Türkçe"},
{"uk", L"Українська"},
{"uz", L"Ўзбекча"},
{"vi", L"Tiếng Việt"},
{"zh-cn", L"简体中文"},
{"zh-hk", L"繁體中文(香港)"},
{"zh-tw", L"繁體中文"}
};

if (wxDir::Exists(languagesFolder.GetName())) {
size_t langCount;
langCount = wxDir::GetAllFiles(languagesFolder.GetName(), &langArray, wxEmptyString, wxDIR_FILES);
Expand Down Expand Up @@ -480,11 +435,11 @@ namespace VeraCrypt

if (LanguageListBox->GetSelection() != wxNOT_FOUND) {
wxString langToFind = LanguageListBox->GetString(LanguageListBox->GetSelection());
for (map<wxString, std::wstring>::const_iterator each = langEntries.begin(); each != langEntries.end(); ++each) {
if (each->second == langToFind) {
Preferences.Language = each->first;
for (const auto &each: langEntries) {
if (each.second == langToFind) {
Preferences.Language = each.first;
#ifdef DEBUG
cout << "Lang set to: " << each->first << endl;
cout << "Lang set to: " << each.first << endl;
#endif
}
}
Expand Down
45 changes: 44 additions & 1 deletion src/Main/Forms/PreferencesDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,50 @@ namespace VeraCrypt
UserPreferences Preferences;
bool RestoreValidatorBell;
HotkeyList UnregisteredHotkeys;
map<wxString, wstring> langEntries;
map<wxString, wstring> langEntries = {
{"system", L"System default"},
{"ar", L"العربية"},
{"be", L"Беларуская"},
{"bg", L"Български"},
{"ca", L"Català"},
{"co", L"Corsu"},
{"cs", L"Čeština"},
{"da", L"Dansk"},
{"de", L"Deutsch"},
{"el", L"Ελληνικά"},
{"en", L"English"},
{"es", L"Español"},
{"et", L"Eesti"},
{"eu", L"Euskara"},
{"fa", L"فارسي"},
{"fi", L"Suomi"},
{"fr", L"Français"},
{"he", L"עברית"},
{"hu", L"Magyar"},
{"id", L"Bahasa Indonesia"},
{"it", L"Italiano"},
{"ja", L"日本語"},
{"ka", L"ქართული"},
{"ko", L"한국어"},
{"lv", L"Latviešu"},
{"nl", L"Nederlands"},
{"nn", L"Norsk Nynorsk"},
{"pl", L"Polski"},
{"ro", L"Română"},
{"ru", L"Русский"},
{"pt-br", L"Português-Brasil"},
{"sk", L"Slovenčina"},
{"sl", L"Slovenščina"},
{"sv", L"Svenska"},
{"th", L"ภาษาไทย"},
{"tr", L"Türkçe"},
{"uk", L"Українська"},
{"uz", L"Ўзбекча"},
{"vi", L"Tiếng Việt"},
{"zh-cn", L"简体中文"},
{"zh-hk", L"繁體中文(香港)"},
{"zh-tw", L"繁體中文"}
};
};
}

Expand Down
25 changes: 12 additions & 13 deletions src/Main/Forms/VolumeCreationWizard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,6 @@

namespace VeraCrypt
{
class OpenOuterVolumeFunctor : public Functor
{
public:
OpenOuterVolumeFunctor (const DirectoryPath &outerVolumeMountPoint) : OuterVolumeMountPoint (outerVolumeMountPoint) { }

virtual void operator() ()
{
Gui->OpenExplorerWindow (OuterVolumeMountPoint);
}

DirectoryPath OuterVolumeMountPoint;
};

#ifdef TC_MACOSX

bool VolumeCreationWizard::ProcessEvent(wxEvent& event)
Expand Down Expand Up @@ -351,6 +338,18 @@ namespace VeraCrypt
return new InfoWizardPage (GetPageParent());
}

struct OpenOuterVolumeFunctor : public Functor
{
OpenOuterVolumeFunctor (const DirectoryPath &outerVolumeMountPoint) : OuterVolumeMountPoint (outerVolumeMountPoint) { }

virtual void operator() ()
{
Gui->OpenExplorerWindow (OuterVolumeMountPoint);
}

DirectoryPath OuterVolumeMountPoint;
};

InfoWizardPage *page = new InfoWizardPage (GetPageParent(), LangString["LINUX_OPEN_OUTER_VOL"],
shared_ptr <Functor> (new OpenOuterVolumeFunctor (MountedOuterVolume->MountPoint)));

Expand Down
53 changes: 26 additions & 27 deletions src/Main/GraphicUserInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,33 +37,6 @@

namespace VeraCrypt
{
class AdminPasswordRequestHandler : public GetStringFunctor
{
public:
virtual void operator() (string &passwordStr)
{

wxString sValue;
if (Gui->GetWaitDialog())
{
Gui->GetWaitDialog()->RequestAdminPassword(sValue);
if (sValue.IsEmpty())
throw UserAbort (SRC_POS);
}
else
{
wxPasswordEntryDialog dialog (Gui->GetActiveWindow(), LangString["LINUX_ADMIN_PW_QUERY"], LangString["LINUX_ADMIN_PW_QUERY_TITLE"]);
if (dialog.ShowModal() != wxID_OK)
throw UserAbort (SRC_POS);
sValue = dialog.GetValue();
}
wstring wPassword (sValue); // A copy of the password is created here by wxWidgets, which cannot be erased
finally_do_arg (wstring *, &wPassword, { StringConverter::Erase (*finally_arg); });

StringConverter::ToSingle (wPassword, passwordStr);
}
};

#ifdef TC_MACOSX
int GraphicUserInterface::g_customIdCmdV = 0;
int GraphicUserInterface::g_customIdCmdA = 0;
Expand Down Expand Up @@ -479,6 +452,32 @@ namespace VeraCrypt

shared_ptr <GetStringFunctor> GraphicUserInterface::GetAdminPasswordRequestHandler ()
{
struct AdminPasswordRequestHandler : public GetStringFunctor
{
virtual void operator() (string &passwordStr)
{

wxString sValue;
if (Gui->GetWaitDialog())
{
Gui->GetWaitDialog()->RequestAdminPassword(sValue);
if (sValue.IsEmpty())
throw UserAbort (SRC_POS);
}
else
{
wxPasswordEntryDialog dialog (Gui->GetActiveWindow(), LangString["LINUX_ADMIN_PW_QUERY"], LangString["LINUX_ADMIN_PW_QUERY_TITLE"]);
if (dialog.ShowModal() != wxID_OK)
throw UserAbort (SRC_POS);
sValue = dialog.GetValue();
}
wstring wPassword (sValue); // A copy of the password is created here by wxWidgets, which cannot be erased
finally_do_arg (wstring *, &wPassword, { StringConverter::Erase (*finally_arg); });

StringConverter::ToSingle (wPassword, passwordStr);
}
};

return shared_ptr <GetStringFunctor> (new AdminPasswordRequestHandler);
}

Expand Down
5 changes: 1 addition & 4 deletions src/Main/StringFormatter.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,7 @@ namespace VeraCrypt
StringFormatter (const wxString &format, StringFormatterArg arg0 = StringFormatterArg(), StringFormatterArg arg1 = StringFormatterArg(), StringFormatterArg arg2 = StringFormatterArg(), StringFormatterArg arg3 = StringFormatterArg(), StringFormatterArg arg4 = StringFormatterArg(), StringFormatterArg arg5 = StringFormatterArg(), StringFormatterArg arg6 = StringFormatterArg(), StringFormatterArg arg7 = StringFormatterArg(), StringFormatterArg arg8 = StringFormatterArg(), StringFormatterArg arg9 = StringFormatterArg());
virtual ~StringFormatter ();

#if (__cplusplus >= 201103L)
explicit
#endif
operator wstring () const { return wstring (FormattedString); }
explicit operator wstring () const { return wstring (FormattedString); }
operator wxString () const { return FormattedString; }
operator StringFormatterArg () const { return FormattedString; }

Expand Down
Loading

0 comments on commit 2effa5e

Please sign in to comment.