VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Common
diff options
context:
space:
mode:
Diffstat (limited to 'src/Common')
-rw-r--r--src/Common/Dlgcode.c122
-rw-r--r--src/Common/Dlgcode.h3
-rw-r--r--src/Common/Language.xml3
-rw-r--r--src/Common/Resource.h3
4 files changed, 129 insertions, 2 deletions
diff --git a/src/Common/Dlgcode.c b/src/Common/Dlgcode.c
index 325a2579..a81dc984 100644
--- a/src/Common/Dlgcode.c
+++ b/src/Common/Dlgcode.c
@@ -1759,6 +1759,88 @@ void AccommodateTextField (HWND hwndDlg, UINT ctrlId, BOOL bFirstUpdate, HFONT h
}
}
+// Resizes width of a checkbox according to actual width in pixels of its label text (font size is taken into account)
+void AccommodateCheckBoxTextWidth (HWND hwndDlg, UINT ctrlId)
+{
+ RECT rec;
+ HWND hwndCtrl = GetDlgItem (hwndDlg, ctrlId);
+ int width, origWidth, origHeight;
+ int horizSubOffset;
+ wchar_t text [MAX_URL_LENGTH];
+ HFONT hFont = (HFONT) SendDlgItemMessage (hwndDlg, ctrlId, WM_GETFONT, 0, 0);
+
+ // Resize the field according to its length and font size and move if centered or right-aligned
+
+ GetWindowTextW (hwndCtrl, text, sizeof (text) / sizeof (wchar_t));
+
+ width = GetTextGfxWidth (hwndCtrl, text, hFont);
+
+ // add to width variable value the width of the checkbox square. We use SM_CXMENUCHECK which is a little larger than actual width
+ width += GetSystemMetrics(SM_CXMENUCHECK);
+
+
+ GetClientRect (hwndCtrl, &rec);
+ origWidth = rec.right;
+ origHeight = rec.bottom;
+
+ if (width >= 0
+ && (origWidth > width)) // The original width of the field is the maximum allowed size
+ {
+ horizSubOffset = origWidth - width;
+
+ // Resize the text field
+ SetWindowPos (hwndCtrl, 0, 0, 0,
+ origWidth - horizSubOffset,
+ origHeight,
+ SWP_NOMOVE | SWP_NOZORDER);
+
+ InvalidateRect (hwndCtrl, NULL, TRUE);
+ }
+}
+
+// makes controls contiguous by moving the second control right next to the first one horizontally
+void MakeControlsContiguous(HWND hwndDlg, UINT ctrl1ID, UINT ctrl2ID) {
+ HWND hwndCtrl1 = GetDlgItem(hwndDlg, ctrl1ID);
+ HWND hwndCtrl2 = GetDlgItem(hwndDlg, ctrl2ID);
+ RECT rect1, rect2;
+ POINT pt1, pt2;
+ int newLeftPosition;
+
+ // Exit silently if one or both controls are missing
+ if (!hwndCtrl1 || !hwndCtrl2) {
+ return;
+ }
+
+
+ GetWindowRect(hwndCtrl1, &rect1);
+ GetWindowRect(hwndCtrl2, &rect2);
+
+ // Convert the top-right point of the first control from screen to client coordinates
+ pt1.x = rect1.right;
+ pt1.y = rect1.top;
+ if (!ScreenToClient(hwndDlg, &pt1)) {
+ return; // Exit if the conversion fails
+ }
+
+ // Convert the top-left point of the second control from screen to client coordinates
+ pt2.x = rect2.left;
+ pt2.y = rect2.top;
+ if (!ScreenToClient(hwndDlg, &pt2)) {
+ return; // Exit if the conversion fails
+ }
+
+ // Ensure the second control is always placed to the right of the first one
+ newLeftPosition = pt1.x + 1;
+
+ if (pt2.x < pt1.x) { // if the second control is to the left of the first one
+ newLeftPosition += (pt1.x - pt2.x);
+ }
+
+ // Move the second control to its new position
+ SetWindowPos(hwndCtrl2, NULL, newLeftPosition, pt2.y, 0, 0, SWP_NOZORDER | SWP_NOSIZE);
+}
+
+
// Note that the user can still close the window by right-clicking its taskbar icon and selecting 'Close window', or by pressing Alt-F4, or using the Task Manager.
void DisableCloseButton (HWND hwndDlg)
{
@@ -2129,6 +2211,42 @@ BOOL CALLBACK AboutDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam
return 0;
}
+HWND CreateToolTip(int toolID, HWND hDlg, const char* strID)
+{
+ if (!toolID || !hDlg)
+ {
+ return FALSE;
+ }
+
+ // Create the tooltip.
+ HWND hwndTip = CreateWindowExW(NULL, TOOLTIPS_CLASS, NULL,
+ WS_POPUP | TTS_ALWAYSTIP | TTS_NOPREFIX | TTS_BALLOON,
+ CW_USEDEFAULT, CW_USEDEFAULT,
+ CW_USEDEFAULT, CW_USEDEFAULT,
+ hDlg, NULL,
+ hInst, NULL);
+
+ if (!hwndTip)
+ {
+ return (HWND)NULL;
+ }
+
+ // Associate the tooltip with the tool.
+ TOOLINFOW toolInfo = { 0 };
+ toolInfo.cbSize = sizeof(toolInfo);
+ toolInfo.hwnd = hDlg;
+ toolInfo.uFlags = TTF_SUBCLASS | TTF_IDISHWND;
+ toolInfo.uId = (UINT_PTR) GetDlgItem(hDlg, toolID);
+ toolInfo.lpszText = GetString(strID);
+
+ // set tooltip maximum width
+ SendMessage(hwndTip, TTM_SETMAXTIPWIDTH, 0, (LPARAM) 300);
+
+ SendMessage(hwndTip, TTM_ADDTOOL, 0, (LPARAM)&toolInfo);
+
+ return hwndTip;
+}
+
static HWND StaticModelessWaitDlgHandle = NULL;
@@ -11093,6 +11211,10 @@ void Applink (const char *dest)
{
StringCbCopyW (page, sizeof (page),L"Personal%20Iterations%20Multiplier%20%28PIM%29.html");
}
+ else if (strcmp(dest, "memoryprotection") == 0)
+ {
+ StringCbCopyW (page, sizeof (page),L"VeraCrypt%20Memory%20Protection.html");
+ }
else
{
StringCbCopyW (url, sizeof (url),TC_APPLINK);
diff --git a/src/Common/Dlgcode.h b/src/Common/Dlgcode.h
index 7947fcf9..3611371d 100644
--- a/src/Common/Dlgcode.h
+++ b/src/Common/Dlgcode.h
@@ -327,6 +327,7 @@ void HandCursor ();
void AddComboPair (HWND hComboBox, const wchar_t *lpszItem, int value);
void SelectAlgo ( HWND hComboBox , int *nCipher );
void PopulateWipeModeCombo (HWND hComboBox, BOOL bNA, BOOL bInPlaceEncryption, BOOL bHeaderWipe);
+HWND CreateToolTip(int toolID, HWND hDlg, const char* strID);
wchar_t *GetWipeModeName (WipeAlgorithmId modeId);
wchar_t *GetPathType (const wchar_t *path, BOOL bUpperCase, BOOL *bIsPartition);
LRESULT CALLBACK CustomDlgProc ( HWND hwnd , UINT uMsg , WPARAM wParam , LPARAM lParam );
@@ -532,6 +533,8 @@ void EnableCloseButton (HWND hwndDlg);
void ToBootPwdField (HWND hwndDlg, UINT ctrlId);
void ToNormalPwdField (HWND hwndDlg, UINT ctrlId);
void AccommodateTextField (HWND hwndDlg, UINT ctrlId, BOOL bFirstUpdate, HFONT hFont);
+void AccommodateCheckBoxTextWidth (HWND hwndDlg, UINT ctrlId);
+void MakeControlsContiguous(HWND hwndDlg, UINT ctrl1ID, UINT ctrl2ID);
BOOL GetDriveLabel (int driveNo, wchar_t *label, int labelSize);
BOOL GetSysDevicePaths (HWND hwndDlg);
BOOL DoDriverInstall (HWND hwndDlg);
diff --git a/src/Common/Language.xml b/src/Common/Language.xml
index ddb20159..32930193 100644
--- a/src/Common/Language.xml
+++ b/src/Common/Language.xml
@@ -1633,7 +1633,8 @@
<entry lang="en" key="EXPANDER_EXTENDING_FILESYSTEM">Extending file system ...\n</entry>
<entry lang="en" key="PARTIAL_SYSENC_MOUNT_READONLY">Warning: The system partition you attempted to mount was not fully encrypted. As a safety measure to prevent potential corruption or unwanted modifications, volume '%s' was mounted as read-only.</entry>
<entry lang="en" key="IDC_LINK_KEYFILES_EXTENSIONS_WARNING">Important information on using third-party file extensions</entry>
- <entry lang="en" key="IDC_DISABLE_MEMORY_PROTECTION">Disable memory protection in VeraCrypt</entry>
+ <entry lang="en" key="IDC_DISABLE_MEMORY_PROTECTION">Disable memory protection for Accessibility tools compatibility</entry>
+ <entry lang="en" key="DISABLE_MEMORY_PROTECTION_WARNING">WARNING: Disabling memory protection significantly reduces security. Enable this option ONLY if you rely on Accessibility tools, like Screen Readers, to interact with VeraCrypt's UI.</entry>
</localization>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="VeraCrypt">
diff --git a/src/Common/Resource.h b/src/Common/Resource.h
index b6ad14c0..0098542e 100644
--- a/src/Common/Resource.h
+++ b/src/Common/Resource.h
@@ -227,6 +227,7 @@
#define IDC_KEYFILES_SIZE_UNIT 5143
#define IDC_LINK_KEYFILES_EXTENSIONS_WARNING 5144
#define IDC_DISABLE_MEMORY_PROTECTION 5145
+#define IDC_DISABLE_MEMORY_PROTECTION_HELP 5146
// Next default values for new objects
//
@@ -235,7 +236,7 @@
#define _APS_NO_MFC 1
#define _APS_NEXT_RESOURCE_VALUE 578
#define _APS_NEXT_COMMAND_VALUE 40001
-#define _APS_NEXT_CONTROL_VALUE 5146
+#define _APS_NEXT_CONTROL_VALUE 5147
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif