VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Main
diff options
context:
space:
mode:
Diffstat (limited to 'src/Main')
-rw-r--r--src/Main/CommandLineInterface.cpp4
-rw-r--r--src/Main/CommandLineInterface.h1
-rw-r--r--src/Main/Forms/MainFrame.cpp7
-rw-r--r--src/Main/Forms/MainFrame.h1
-rw-r--r--src/Main/GraphicUserInterface.cpp8
-rw-r--r--src/Main/GraphicUserInterface.h1
6 files changed, 22 insertions, 0 deletions
diff --git a/src/Main/CommandLineInterface.cpp b/src/Main/CommandLineInterface.cpp
index 1b4a0c1b..e26a5ee3 100644
--- a/src/Main/CommandLineInterface.cpp
+++ b/src/Main/CommandLineInterface.cpp
@@ -12,52 +12,54 @@
#include "System.h"
#include <wx/cmdline.h>
#include <wx/tokenzr.h>
#include "Core/Core.h"
#include "Application.h"
#include "CommandLineInterface.h"
#include "LanguageStrings.h"
#include "UserInterfaceException.h"
namespace VeraCrypt
{
CommandLineInterface::CommandLineInterface (int argc, wchar_t** argv, UserInterfaceType::Enum interfaceType) :
ArgCommand (CommandId::None),
ArgFilesystem (VolumeCreationOptions::FilesystemType::Unknown),
ArgNewPim (-1),
ArgNoHiddenVolumeProtection (false),
ArgPim (-1),
ArgSize (0),
ArgVolumeType (VolumeType::Unknown),
+ ArgAllowScreencapture (false),
ArgDisableFileSizeCheck (false),
ArgUseLegacyPassword (false),
#if defined(TC_LINUX ) || defined (TC_FREEBSD)
ArgUseDummySudoPassword (false),
#endif
StartBackgroundTask (false)
{
wxCmdLineParser parser;
parser.SetCmdLine (argc, argv);
parser.SetSwitchChars (L"-");
+ parser.AddSwitch (L"", L"allow-screencapture", _("Allow window to be included in screenshots and screen captures (Windows/MacOS)"));
parser.AddOption (L"", L"auto-mount", _("Auto mount device-hosted/favorite volumes"));
parser.AddSwitch (L"", L"backup-headers", _("Backup volume headers"));
parser.AddSwitch (L"", L"background-task", _("Start Background Task"));
#ifdef TC_WINDOWS
parser.AddSwitch (L"", L"cache", _("Cache passwords and keyfiles"));
#endif
parser.AddSwitch (L"C", L"change", _("Change password or keyfiles"));
parser.AddSwitch (L"c", L"create", _("Create new volume"));
parser.AddSwitch (L"", L"create-keyfile", _("Create new keyfile"));
parser.AddSwitch (L"", L"delete-token-keyfiles", _("Delete security token keyfiles"));
parser.AddSwitch (L"d", L"dismount", _("Dismount volume"));
parser.AddSwitch (L"", L"display-password", _("Display password while typing"));
parser.AddOption (L"", L"encryption", _("Encryption algorithm"));
parser.AddSwitch (L"", L"explore", _("Open explorer window for mounted volume"));
parser.AddSwitch (L"", L"export-token-keyfile",_("Export keyfile from token"));
parser.AddOption (L"", L"filesystem", _("Filesystem type"));
parser.AddSwitch (L"f", L"force", _("Force mount/dismount/overwrite"));
#if !defined(TC_WINDOWS) && !defined(TC_MACOSX)
parser.AddOption (L"", L"fs-options", _("Filesystem mount options"));
#endif
@@ -125,40 +127,42 @@ namespace VeraCrypt
{
wstring msg = wstring (_("Option -t or --text must be specified as the first argument."));
wcerr << msg << endl;
throw_err (msg);
}
if (parser.Found (L"version"))
{
ArgCommand = CommandId::DisplayVersion;
return;
}
// Preferences
if (parser.Found (L"load-preferences"))
{
// Load preferences first to allow command line options to override them
Preferences.Load();
ArgMountOptions = Preferences.DefaultMountOptions;
}
+ ArgAllowScreencapture = parser.Found (L"allow-screencapture");
+
// Commands
if (parser.Found (L"auto-mount", &str))
{
CheckCommandSingle();
wxStringTokenizer tokenizer (str, L",");
while (tokenizer.HasMoreTokens())
{
wxString token = tokenizer.GetNextToken();
if (token == L"devices")
{
if (ArgCommand == CommandId::AutoMountFavorites)
ArgCommand = CommandId::AutoMountDevicesFavorites;
else
ArgCommand = CommandId::AutoMountDevices;
param1IsMountPoint = true;
}
else if (token == L"favorites")
diff --git a/src/Main/CommandLineInterface.h b/src/Main/CommandLineInterface.h
index 4003dc05..f773ca6f 100644
--- a/src/Main/CommandLineInterface.h
+++ b/src/Main/CommandLineInterface.h
@@ -67,40 +67,41 @@ namespace VeraCrypt
VolumeCreationOptions::FilesystemType::Enum ArgFilesystem;
bool ArgForce;
shared_ptr <Hash> ArgHash;
shared_ptr <KeyfileList> ArgKeyfiles;
MountOptions ArgMountOptions;
shared_ptr <DirectoryPath> ArgMountPoint;
shared_ptr <Hash> ArgNewHash;
shared_ptr <KeyfileList> ArgNewKeyfiles;
shared_ptr <VolumePassword> ArgNewPassword;
int ArgNewPim;
bool ArgNoHiddenVolumeProtection;
shared_ptr <VolumePassword> ArgPassword;
int ArgPim;
bool ArgQuick;
FilesystemPath ArgRandomSourcePath;
uint64 ArgSize;
shared_ptr <VolumePath> ArgVolumePath;
VolumeInfoList ArgVolumes;
VolumeType::Enum ArgVolumeType;
shared_ptr<SecureBuffer> ArgTokenPin;
+ bool ArgAllowScreencapture;
bool ArgDisableFileSizeCheck;
bool ArgUseLegacyPassword;
#if defined(TC_LINUX ) || defined (TC_FREEBSD)
bool ArgUseDummySudoPassword;
#endif
bool StartBackgroundTask;
UserPreferences Preferences;
protected:
void CheckCommandSingle () const;
shared_ptr <KeyfileList> ToKeyfileList (const wxString &arg) const;
VolumeInfoList GetMountedVolumes (const wxString &filter) const;
private:
CommandLineInterface (const CommandLineInterface &);
CommandLineInterface &operator= (const CommandLineInterface &);
};
shared_ptr<VolumePassword> ToUTF8Password (const wchar_t* str, size_t charCount, size_t maxUtf8Len);
diff --git a/src/Main/Forms/MainFrame.cpp b/src/Main/Forms/MainFrame.cpp
index 6355f139..77f371d8 100644
--- a/src/Main/Forms/MainFrame.cpp
+++ b/src/Main/Forms/MainFrame.cpp
@@ -67,40 +67,41 @@ namespace VeraCrypt
remove (fifoPath.c_str());
throw_sys_if (mkfifo (fifoPath.c_str(), S_IRUSR | S_IWUSR) == -1);
ShowRequestFifo = open (fifoPath.c_str(), O_RDONLY | O_NONBLOCK);
throw_sys_if (ShowRequestFifo == -1);
}
catch (...)
{
#ifdef DEBUG
throw;
#endif
}
#endif
InitControls();
InitPreferences();
InitTaskBarIcon();
InitEvents();
InitMessageFilter();
+ InitWindowPrivacy();
if (!GetPreferences().SecurityTokenModule.IsEmpty() && !SecurityToken::IsInitialized())
{
try
{
Gui->InitSecurityTokenLibrary();
}
catch (exception &e)
{
Gui->ShowError (e);
}
}
Connect( wxID_EXIT, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrame::OnQuit ) );
Connect( wxID_ANY, wxEVT_COMMAND_UPDATE_VOLUME_LIST, wxCommandEventHandler( MainFrame::OnUpdateVolumeList ) );
Connect( wxID_ANY, wxEVT_COMMAND_PREF_UPDATED, wxCommandEventHandler( MainFrame::OnPreferencesUpdated ) );
Connect( wxID_ANY, wxEVT_COMMAND_OPEN_VOLUME_REQUEST, wxCommandEventHandler( MainFrame::OnOpenVolumeSystemRequest ) );
#ifdef TC_MACOSX
Connect( wxID_ANY, wxEVT_MOVE, wxMoveEventHandler( MainFrame::OnMoveHandler ) );
@@ -453,40 +454,46 @@ namespace VeraCrypt
}
else
{
frame->OnDeviceChange ();
}
}
return CallWindowProc (MainFrameWndProc, hwnd, message, wParam, lParam);
}
#endif
void MainFrame::InitMessageFilter ()
{
#ifdef TC_WINDOWS
HWND mainFrameHwnd = static_cast <HWND> (GetHandle());
MainFrameWndProc = (WNDPROC) GetWindowLongPtr (mainFrameHwnd, GWL_WNDPROC);
SetWindowLongPtr (mainFrameHwnd, GWL_WNDPROC, (LONG_PTR) MainFrameWndProcFilter);
#endif
}
+
+ void MainFrame::InitWindowPrivacy ()
+ {
+ Gui->SetContentProtection(!CmdLine->ArgAllowScreencapture);
+ }
+
void MainFrame::InitPreferences ()
{
try
{
LoadPreferences();
VolumeSlotNumber lastSelectedSlotNumber = GetPreferences().LastSelectedSlotNumber;
if (Core->IsSlotNumberValid (lastSelectedSlotNumber))
{
long slotIndex = SlotNumberToItemIndex (lastSelectedSlotNumber);
if (slotIndex >= 0)
{
SlotListCtrl->SetItemState (slotIndex, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
SlotListCtrl->EnsureVisible (slotIndex);
}
}
LoadFavoriteVolumes();
VolumeHistory::Load();
diff --git a/src/Main/Forms/MainFrame.h b/src/Main/Forms/MainFrame.h
index ab70eae3..ed1c44f7 100644
--- a/src/Main/Forms/MainFrame.h
+++ b/src/Main/Forms/MainFrame.h
@@ -67,40 +67,41 @@ namespace VeraCrypt
#else
ColumnMountPoint,
#endif
ColumnType
};
void AddToFavorites (const VolumeInfoList &volumes);
bool CanExit () const;
void ChangePassword (ChangePasswordDialog::Mode::Enum mode = ChangePasswordDialog::Mode::ChangePasswordAndKeyfiles);
void CheckFilesystem (bool repair = false);
bool CheckVolumePathNotEmpty () const;
void DismountVolume (shared_ptr <VolumeInfo> volume = shared_ptr <VolumeInfo> ());
const UserPreferences &GetPreferences () const { return Gui->GetPreferences(); }
shared_ptr <VolumeInfo> GetSelectedVolume () const;
shared_ptr <VolumePath> GetSelectedVolumePath () const { return make_shared <VolumePath> (wstring (VolumePathComboBox->GetValue())); }
void InitControls ();
void InitEvents ();
void InitMessageFilter ();
void InitPreferences ();
void InitTaskBarIcon ();
+ void InitWindowPrivacy();
bool IsFreeSlotSelected () const { return SlotListCtrl->GetSelectedItemCount() == 1 && Gui->GetListCtrlSubItemText (SlotListCtrl, SelectedItemIndex, ColumnPath).empty(); }
bool IsMountedSlotSelected () const { return SlotListCtrl->GetSelectedItemCount() == 1 && !Gui->GetListCtrlSubItemText (SlotListCtrl, SelectedItemIndex, ColumnPath).empty(); }
void LoadFavoriteVolumes ();
void LoadPreferences ();
void MountAllDevices ();
void MountVolume ();
void OnAboutMenuItemSelected (wxCommandEvent& event);
void OnQuit(wxCommandEvent& event) { Close(true); }
void OnActivate (wxActivateEvent& event);
void OnAddAllMountedToFavoritesMenuItemSelected (wxCommandEvent& event);
void OnAddToFavoritesMenuItemSelected (wxCommandEvent& event);
void OnBackupVolumeHeadersMenuItemSelected (wxCommandEvent& event);
void OnBeginnersTutorialMenuItemSelected (wxCommandEvent& event) { Gui->OpenHomepageLink (this, L"tutorial"); }
void OnBenchmarkMenuItemSelected (wxCommandEvent& event);
void OnChangeKeyfilesMenuItemSelected (wxCommandEvent& event) { ChangePassword (ChangePasswordDialog::Mode::ChangeKeyfiles); }
void OnChangePasswordMenuItemSelected (wxCommandEvent& event) { ChangePassword (); }
void OnChangePkcs5PrfMenuItemSelected (wxCommandEvent& event) { ChangePassword (ChangePasswordDialog::Mode::ChangePkcs5Prf); }
void OnCheckFilesystemMenuItemSelected( wxCommandEvent& event ) { CheckFilesystem (); }
void OnClearSlotSelectionMenuItemSelected (wxCommandEvent& event);
void OnClose (wxCloseEvent& event);
diff --git a/src/Main/GraphicUserInterface.cpp b/src/Main/GraphicUserInterface.cpp
index 41bfa100..1cb62671 100644
--- a/src/Main/GraphicUserInterface.cpp
+++ b/src/Main/GraphicUserInterface.cpp
@@ -1857,40 +1857,48 @@ namespace VeraCrypt
#elif defined (__WXGTK__)
headerHeight += 5;
#endif
int rowHeight = itemRect.height;
#ifdef TC_MACOSX
rowHeight += 1;
#endif
listCtrl->SetMinSize (wxSize (listCtrl->GetMinSize().GetWidth(), rowHeight * rowCount + headerHeight));
}
void GraphicUserInterface::SetListCtrlWidth (wxListCtrl *listCtrl, size_t charCount, bool hasVerticalScrollbar) const
{
int width = GetCharWidth (listCtrl) * charCount;
#ifdef TC_MACOSX
if (!hasVerticalScrollbar)
width += GetScrollbarWidth (listCtrl);
#endif
listCtrl->SetMinSize (wxSize (width, listCtrl->GetMinSize().GetHeight()));
}
+
+ void GraphicUserInterface::SetContentProtection (bool enable) const
+ {
+#if defined(TC_WINDOWS) || defined(TC_MACOSX)
+ GetActiveWindow()->SetContentProtection(enable ? wxCONTENT_PROTECTION_ENABLED : wxCONTENT_PROTECTION_NONE);
+#endif
+ }
+
void GraphicUserInterface::ShowErrorTopMost (const wxString &message) const
{
ShowMessage (message, wxOK | wxICON_ERROR, true);
}
void GraphicUserInterface::ShowInfoTopMost (const wxString &message) const
{
ShowMessage (message, wxOK | wxICON_INFORMATION, true);
}
int GraphicUserInterface::ShowMessage (const wxString &message, long style, bool topMost) const
{
wxString caption = Application::GetName();
wxString subMessage = message;
#ifdef TC_MACOSX
size_t p = message.find (L"\n");
if (p != string::npos)
{
// Divide message to caption and info message
diff --git a/src/Main/GraphicUserInterface.h b/src/Main/GraphicUserInterface.h
index d48b7973..d333551c 100644
--- a/src/Main/GraphicUserInterface.h
+++ b/src/Main/GraphicUserInterface.h
@@ -69,40 +69,41 @@ namespace VeraCrypt
virtual VolumeInfoList MountAllDeviceHostedVolumes (MountOptions &options) const;
virtual shared_ptr <VolumeInfo> MountVolume (MountOptions &options) const;
virtual void MoveListCtrlItem (wxListCtrl *listCtrl, long itemIndex, long newItemIndex) const;
virtual void OnAutoDismountAllEvent ();
virtual bool OnInit ();
virtual void OnLogOff ();
virtual void OpenDocument (wxWindow *parent, const wxFileName &document);
virtual void OpenHomepageLink (wxWindow *parent, const wxString &linkId, const wxString &extraVars = wxEmptyString);
virtual void OpenOnlineHelp (wxWindow *parent);
virtual void OpenUserGuide (wxWindow *parent);
virtual void RestoreVolumeHeaders (shared_ptr <VolumePath> volumePath) const;
virtual DevicePath SelectDevice (wxWindow *parent) const;
virtual DirectoryPath SelectDirectory (wxWindow *parent, const wxString &message = wxEmptyString, bool existingOnly = true) const;
virtual FilePathList SelectFiles (wxWindow *parent, const wxString &caption, bool saveMode = false, bool allowMultiple = false, const list < pair <wstring, wstring> > &fileExtensions = (list < pair <wstring, wstring> > ()), const DirectoryPath &directory = DirectoryPath()) const;
virtual FilePath SelectVolumeFile (wxWindow *parent, bool saveMode = false, const DirectoryPath &directory = DirectoryPath()) const;
virtual void SetActiveFrame (wxFrame *frame) { ActiveFrame = frame; }
virtual void SetBackgroundMode (bool state);
virtual void SetListCtrlColumnWidths (wxListCtrl *listCtrl, list <int> columnWidthPermilles, bool hasVerticalScrollbar = true) const;
virtual void SetListCtrlHeight (wxListCtrl *listCtrl, size_t rowCount) const;
virtual void SetListCtrlWidth (wxListCtrl *listCtrl, size_t charCount, bool hasVerticalScrollbar = true) const;
+ virtual void SetContentProtection(bool enable) const;
virtual void ShowErrorTopMost (char *langStringId) const { ShowErrorTopMost (LangString[langStringId]); }
virtual void ShowErrorTopMost (const wxString &message) const;
virtual void ShowInfoTopMost (char *langStringId) const { ShowInfoTopMost (LangString[langStringId]); }
virtual void ShowInfoTopMost (const wxString &message) const;
virtual void ShowWarningTopMost (char *langStringId) const { ShowWarningTopMost (LangString[langStringId]); }
virtual void ShowWarningTopMost (const wxString &message) const;
virtual bool UpdateListCtrlItem (wxListCtrl *listCtrl, long itemIndex, const vector <wstring> &itemFields) const;
virtual void UserEnrichRandomPool (wxWindow *parent, shared_ptr <Hash> hash = shared_ptr <Hash>()) const;
virtual void Yield () const;
virtual shared_ptr <VolumeInfo> MountVolumeThread (MountOptions &options) const;
WaitDialog* GetWaitDialog () { return mWaitDialog; }
void ExecuteWaitThreadRoutine (wxWindow *parent, WaitThreadRoutine *pRoutine) const;
#ifdef TC_MACOSX
virtual void MacOpenFiles (const wxArrayString &fileNames);
virtual void MacReopenApp ();
static bool HandlePasswordEntryCustomEvent (wxEvent& event);
static void InstallPasswordEntryCustomKeyboardShortcuts (wxWindow* window);
#endif