VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Common/Dlgcode.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/Common/Dlgcode.c')
-rw-r--r--src/Common/Dlgcode.c62
1 files changed, 53 insertions, 9 deletions
diff --git a/src/Common/Dlgcode.c b/src/Common/Dlgcode.c
index 0db43737..05aa813a 100644
--- a/src/Common/Dlgcode.c
+++ b/src/Common/Dlgcode.c
@@ -4167,6 +4167,7 @@ BOOL CALLBACK TextEditDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa
case WM_INITDIALOG:
{
prm = (TEXT_INFO_DIALOG_PARAM_PTR)lParam;
+ LocalizeDialog (hwndDlg, NULL);
// increase size limit of rich edit control
SendMessage(GetDlgItem (hwndDlg, IDC_INFO_BOX_TEXT), EM_EXLIMITTEXT, 0, -1);
@@ -4177,9 +4178,43 @@ BOOL CALLBACK TextEditDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa
if (prm->ReadOnly)
{
// switch rich edit control to ReadOnly
- SendMessage(GetDlgItem (hwndDlg, IDC_INFO_BOX_TEXT), ES_READONLY, TRUE, 0);
+ SendMessage(GetDlgItem (hwndDlg, IDC_INFO_BOX_TEXT), EM_SETREADONLY , TRUE, 0);
// hide cancel button
- ShowWindow(GetDlgItem(hwndDlg, IDCANCEL), SW_HIDE);
+ HWND hwndCancel = GetDlgItem(hwndDlg, IDCANCEL);
+ ShowWindow(hwndCancel, SW_HIDE);
+
+ // Reposition OK button to Cancel button's position
+ HWND hwndOK = GetDlgItem(hwndDlg, IDOK);
+ if (hwndOK && hwndCancel)
+ {
+ // Get Cancel button's position in screen coordinates
+ RECT rectCancel;
+ if (GetWindowRect(hwndCancel, &rectCancel))
+ {
+ // Convert Cancel button's position to dialog's client coordinates
+ POINT ptCancel = { rectCancel.left, rectCancel.top };
+ ScreenToClient(hwndDlg, &ptCancel);
+
+ // Get OK button's current size
+ RECT rectOK;
+ if (GetWindowRect(hwndOK, &rectOK))
+ {
+ int width = rectOK.right - rectOK.left;
+ int height = rectOK.bottom - rectOK.top;
+
+ // Move OK button to Cancel button's position
+ SetWindowPos(
+ hwndOK,
+ NULL,
+ ptCancel.x,
+ ptCancel.y,
+ width,
+ height,
+ SWP_NOZORDER | SWP_NOACTIVATE
+ );
+ }
+ }
+ }
}
SendMessage (hwndDlg, TC_APPMSG_LOAD_TEXT_BOX_CONTENT, 0, 0);
@@ -4191,8 +4226,12 @@ BOOL CALLBACK TextEditDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa
{
if (!prm->ReadOnly)
{
- prm->Text.resize(GetWindowTextLengthA (GetDlgItem (hwndDlg, IDC_INFO_BOX_TEXT)) + 1);
- GetWindowTextA (GetDlgItem (hwndDlg, IDC_INFO_BOX_TEXT), &(prm->Text)[0], (int) prm->Text.size());
+ // read content of the text box as UTF16 and then convert it to UTF8
+ HWND hEdit = GetDlgItem(hwndDlg, IDC_INFO_BOX_TEXT);
+ int size = GetWindowTextLengthW(hEdit);
+ std::vector<WCHAR> buffer(size + 1);
+ GetWindowTextW(hEdit, buffer.data(), size + 1);
+ prm->Text = WideToUtf8String(buffer.data());
}
NormalCursor ();
EndDialog (hwndDlg, IDOK);
@@ -4209,7 +4248,8 @@ BOOL CALLBACK TextEditDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa
case TC_APPMSG_LOAD_TEXT_BOX_CONTENT:
{
- SetWindowTextA (GetDlgItem (hwndDlg, IDC_INFO_BOX_TEXT), prm->Text.c_str());
+ // convert prm->Text to UTF16 using Utf8StringToWide
+ SetWindowTextW(GetDlgItem(hwndDlg, IDC_INFO_BOX_TEXT), Utf8StringToWide(prm->Text).c_str());
}
return 0;
@@ -6249,6 +6289,10 @@ static BOOL PerformBenchmark(HWND hBenchDlg, HWND hwndDlg)
{
if (benchmarkPreBoot && !benchmarkGPT && !HashForSystemEncryption (thid))
continue;
+
+ // we don't support Argon2 for system encryption
+ if (benchmarkPreBoot && thid == ARGON2)
+ continue;
if (QueryPerformanceCounter (&performanceCountStart) == 0)
goto counter_error;
@@ -6760,7 +6804,7 @@ static BOOL CALLBACK RandomPoolEnrichementDlgProc (HWND hwndDlg, UINT msg, WPARA
SendMessage (hComboBox, CB_RESETCONTENT, 0, 0);
for (hid = FIRST_PRF_ID; hid <= LAST_PRF_ID; hid++)
{
- if (!HashIsDeprecated (hid))
+ if (!HashIsDeprecated (hid) && HashIsAvailable (hid))
AddComboPair (hComboBox, HashGetName(hid), hid);
}
SelectAlgo (hComboBox, &hash_algo);
@@ -6955,7 +6999,7 @@ BOOL CALLBACK KeyfileGeneratorDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LP
SendMessage (hComboBox, CB_RESETCONTENT, 0, 0);
for (hid = FIRST_PRF_ID; hid <= LAST_PRF_ID; hid++)
{
- if (!HashIsDeprecated (hid))
+ if (!HashIsDeprecated (hid) && HashIsAvailable (hid))
AddComboPair (hComboBox, HashGetName(hid), hid);
}
SelectAlgo (hComboBox, &hash_algo);
@@ -13729,11 +13773,11 @@ BOOL SetPrivilege(LPTSTR szPrivilegeName, BOOL bEnable)
&tkp.Privileges[0].Luid))
{
tkp.PrivilegeCount = 1;
- tkp.Privileges[0].Attributes = bEnable? SE_PRIVILEGE_ENABLED : SE_PRIVILEGE_REMOVED;
+ tkp.Privileges[0].Attributes = bEnable? SE_PRIVILEGE_ENABLED : 0;
bRet = AdjustTokenPrivileges(hToken, FALSE, &tkp, 0, NULL, NULL);
dwLastError = GetLastError ();
- if ( ERROR_SUCCESS != dwLastError)
+ if (bRet && (ERROR_NOT_ALL_ASSIGNED == dwLastError))
{
bRet = FALSE;
}