Skip to content

Commit f3ad98c

Browse files
committed
Add Option to Enable/Disable Screen Capture
Veracrypt currently appears in screenshots and screen captures, which can unintentionally expose sensitive information, such as the fact that Veracrypt is running or the location of your volumes. Both Windows and macOS offer mechanisms to exclude specific windows from being captured. While not foolproof, this is a useful preventative measure. The method is a no-op for Linux/FreeBSD. For more details on the wxWidgets API, see: https://docs.wxwidgets.org/3.2/classwx_top_level_window.html#a337b9cec62b0cbd3b1b1545a83270f64
1 parent 35eeaca commit f3ad98c

File tree

6 files changed

+22
-0
lines changed

6 files changed

+22
-0
lines changed

src/Main/CommandLineInterface.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ namespace VeraCrypt
2929
ArgPim (-1),
3030
ArgSize (0),
3131
ArgVolumeType (VolumeType::Unknown),
32+
ArgAllowScreencapture (false),
3233
ArgDisableFileSizeCheck (false),
3334
ArgUseLegacyPassword (false),
3435
#if defined(TC_LINUX ) || defined (TC_FREEBSD)
@@ -41,6 +42,7 @@ namespace VeraCrypt
4142

4243
parser.SetSwitchChars (L"-");
4344

45+
parser.AddSwitch (L"", L"allow-screencapture", _("Allow window to be included in screenshots and screen captures (Windows/MacOS)"));
4446
parser.AddOption (L"", L"auto-mount", _("Auto mount device-hosted/favorite volumes"));
4547
parser.AddSwitch (L"", L"backup-headers", _("Backup volume headers"));
4648
parser.AddSwitch (L"", L"background-task", _("Start Background Task"));
@@ -142,6 +144,8 @@ namespace VeraCrypt
142144
ArgMountOptions = Preferences.DefaultMountOptions;
143145
}
144146

147+
ArgAllowScreencapture = parser.Found (L"allow-screencapture");
148+
145149
// Commands
146150
if (parser.Found (L"auto-mount", &str))
147151
{

src/Main/CommandLineInterface.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ namespace VeraCrypt
8484
VolumeInfoList ArgVolumes;
8585
VolumeType::Enum ArgVolumeType;
8686
shared_ptr<SecureBuffer> ArgTokenPin;
87+
bool ArgAllowScreencapture;
8788
bool ArgDisableFileSizeCheck;
8889
bool ArgUseLegacyPassword;
8990
#if defined(TC_LINUX ) || defined (TC_FREEBSD)

src/Main/Forms/MainFrame.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ namespace VeraCrypt
8484
InitTaskBarIcon();
8585
InitEvents();
8686
InitMessageFilter();
87+
InitWindowPrivacy();
8788

8889
if (!GetPreferences().SecurityTokenModule.IsEmpty() && !SecurityToken::IsInitialized())
8990
{
@@ -470,6 +471,12 @@ namespace VeraCrypt
470471
#endif
471472
}
472473

474+
475+
void MainFrame::InitWindowPrivacy ()
476+
{
477+
Gui->SetContentProtection(!CmdLine->ArgAllowScreencapture);
478+
}
479+
473480
void MainFrame::InitPreferences ()
474481
{
475482
try

src/Main/Forms/MainFrame.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ namespace VeraCrypt
8484
void InitMessageFilter ();
8585
void InitPreferences ();
8686
void InitTaskBarIcon ();
87+
void InitWindowPrivacy();
8788
bool IsFreeSlotSelected () const { return SlotListCtrl->GetSelectedItemCount() == 1 && Gui->GetListCtrlSubItemText (SlotListCtrl, SelectedItemIndex, ColumnPath).empty(); }
8889
bool IsMountedSlotSelected () const { return SlotListCtrl->GetSelectedItemCount() == 1 && !Gui->GetListCtrlSubItemText (SlotListCtrl, SelectedItemIndex, ColumnPath).empty(); }
8990
void LoadFavoriteVolumes ();

src/Main/GraphicUserInterface.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1874,6 +1874,14 @@ namespace VeraCrypt
18741874
listCtrl->SetMinSize (wxSize (width, listCtrl->GetMinSize().GetHeight()));
18751875
}
18761876

1877+
1878+
void GraphicUserInterface::SetContentProtection (bool enable) const
1879+
{
1880+
#if defined(TC_WINDOWS) || defined(TC_MACOSX)
1881+
GetActiveWindow()->SetContentProtection(enable ? wxCONTENT_PROTECTION_ENABLED : wxCONTENT_PROTECTION_NONE);
1882+
#endif
1883+
}
1884+
18771885
void GraphicUserInterface::ShowErrorTopMost (const wxString &message) const
18781886
{
18791887
ShowMessage (message, wxOK | wxICON_ERROR, true);

src/Main/GraphicUserInterface.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ namespace VeraCrypt
8686
virtual void SetListCtrlColumnWidths (wxListCtrl *listCtrl, list <int> columnWidthPermilles, bool hasVerticalScrollbar = true) const;
8787
virtual void SetListCtrlHeight (wxListCtrl *listCtrl, size_t rowCount) const;
8888
virtual void SetListCtrlWidth (wxListCtrl *listCtrl, size_t charCount, bool hasVerticalScrollbar = true) const;
89+
virtual void SetContentProtection(bool enable) const;
8990
virtual void ShowErrorTopMost (char *langStringId) const { ShowErrorTopMost (LangString[langStringId]); }
9091
virtual void ShowErrorTopMost (const wxString &message) const;
9192
virtual void ShowInfoTopMost (char *langStringId) const { ShowInfoTopMost (LangString[langStringId]); }

0 commit comments

Comments
 (0)