Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Option to Enable/Disable Screen Capture #1418

Merged
merged 1 commit into from
Sep 16, 2024
Merged
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: 4 additions & 0 deletions src/Main/CommandLineInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ namespace VeraCrypt
ArgPim (-1),
ArgSize (0),
ArgVolumeType (VolumeType::Unknown),
ArgAllowScreencapture (false),
ArgDisableFileSizeCheck (false),
ArgUseLegacyPassword (false),
#if defined(TC_LINUX ) || defined (TC_FREEBSD)
Expand All @@ -41,6 +42,7 @@ namespace VeraCrypt

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"));
Expand Down Expand Up @@ -142,6 +144,8 @@ namespace VeraCrypt
ArgMountOptions = Preferences.DefaultMountOptions;
}

ArgAllowScreencapture = parser.Found (L"allow-screencapture");

// Commands
if (parser.Found (L"auto-mount", &str))
{
Expand Down
1 change: 1 addition & 0 deletions src/Main/CommandLineInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ namespace VeraCrypt
VolumeInfoList ArgVolumes;
VolumeType::Enum ArgVolumeType;
shared_ptr<SecureBuffer> ArgTokenPin;
bool ArgAllowScreencapture;
bool ArgDisableFileSizeCheck;
bool ArgUseLegacyPassword;
#if defined(TC_LINUX ) || defined (TC_FREEBSD)
Expand Down
7 changes: 7 additions & 0 deletions src/Main/Forms/MainFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ namespace VeraCrypt
InitTaskBarIcon();
InitEvents();
InitMessageFilter();
InitWindowPrivacy();

if (!GetPreferences().SecurityTokenModule.IsEmpty() && !SecurityToken::IsInitialized())
{
Expand Down Expand Up @@ -470,6 +471,12 @@ namespace VeraCrypt
#endif
}


void MainFrame::InitWindowPrivacy ()
{
Gui->SetContentProtection(!CmdLine->ArgAllowScreencapture);
}

void MainFrame::InitPreferences ()
{
try
Expand Down
1 change: 1 addition & 0 deletions src/Main/Forms/MainFrame.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ namespace VeraCrypt
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 ();
Expand Down
8 changes: 8 additions & 0 deletions src/Main/GraphicUserInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1874,6 +1874,14 @@ namespace VeraCrypt
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);
Expand Down
1 change: 1 addition & 0 deletions src/Main/GraphicUserInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ namespace VeraCrypt
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]); }
Expand Down
Loading