VeraCrypt
aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Common/Dlgcode.c197
-rw-r--r--src/Mount/Hotkeys.c35
2 files changed, 117 insertions, 115 deletions
diff --git a/src/Common/Dlgcode.c b/src/Common/Dlgcode.c
index 9020b402..f7d86cfb 100644
--- a/src/Common/Dlgcode.c
+++ b/src/Common/Dlgcode.c
@@ -3123,7 +3123,7 @@ BOOL CALLBACK RawDevicesDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l
int selectedItem = ListView_GetSelectionMark (GetDlgItem (hwndDlg, IDC_DEVICELIST));
if (selectedItem == -1 || itemToDeviceMap.find (selectedItem) == itemToDeviceMap.end())
- return 1; // non-device line selected
+ return 1; // non-device line selected
const HostDevice selectedDevice = itemToDeviceMap[selectedItem];
strcpy_s (lpszFileName, TC_MAX_PATH, selectedDevice.Path.c_str());
@@ -3256,7 +3256,7 @@ BOOL CALLBACK RawDevicesDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l
return 1;
}
- if (lw == IDCANCEL)
+ if ((msg == WM_COMMAND) && (lw == IDCANCEL))
{
NormalCursor ();
EndDialog (hwndDlg, IDCANCEL);
@@ -4750,7 +4750,6 @@ BOOL CALLBACK BenchmarkDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
break;
case WM_COMMAND:
- case WM_NOTIFY:
switch (lw)
{
@@ -9581,141 +9580,143 @@ BOOL CALLBACK SecurityTokenKeyfileDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam
return 1;
}
- switch (lw)
+ if (msg == WM_COMMAND)
{
- case IDCANCEL:
- EndDialog (hwndDlg, IDCANCEL);
- return 1;
-
- case IDC_IMPORT_KEYFILE:
+ switch (lw)
{
- char keyfilePath[TC_MAX_PATH];
+ case IDCANCEL:
+ EndDialog (hwndDlg, IDCANCEL);
+ return 1;
- if (BrowseFiles (hwndDlg, "SELECT_KEYFILE", keyfilePath, bHistory, FALSE, NULL))
+ case IDC_IMPORT_KEYFILE:
{
- DWORD keyfileSize;
- byte *keyfileData = (byte *) LoadFile (keyfilePath, &keyfileSize);
- if (!keyfileData)
- {
- handleWin32Error (hwndDlg);
- return 1;
- }
+ char keyfilePath[TC_MAX_PATH];
- if (keyfileSize != 0)
+ if (BrowseFiles (hwndDlg, "SELECT_KEYFILE", keyfilePath, bHistory, FALSE, NULL))
{
- NewSecurityTokenKeyfileDlgProcParams newParams;
- newParams.Name = WideToUtf8String (SingleStringToWide (keyfilePath));
-
- size_t lastBackSlash = newParams.Name.find_last_of ('\\');
- if (lastBackSlash != string::npos)
- newParams.Name = newParams.Name.substr (lastBackSlash + 1);
+ DWORD keyfileSize;
+ byte *keyfileData = (byte *) LoadFile (keyfilePath, &keyfileSize);
+ if (!keyfileData)
+ {
+ handleWin32Error (hwndDlg);
+ return 1;
+ }
- if (DialogBoxParamW (hInst, MAKEINTRESOURCEW (IDD_NEW_TOKEN_KEYFILE), hwndDlg, (DLGPROC) NewSecurityTokenKeyfileDlgProc, (LPARAM) &newParams) == IDOK)
+ if (keyfileSize != 0)
{
- vector <byte> keyfileDataVector (keyfileSize);
- memcpy (&keyfileDataVector.front(), keyfileData, keyfileSize);
+ NewSecurityTokenKeyfileDlgProcParams newParams;
+ newParams.Name = WideToUtf8String (SingleStringToWide (keyfilePath));
- try
+ size_t lastBackSlash = newParams.Name.find_last_of ('\\');
+ if (lastBackSlash != string::npos)
+ newParams.Name = newParams.Name.substr (lastBackSlash + 1);
+
+ if (DialogBoxParamW (hInst, MAKEINTRESOURCEW (IDD_NEW_TOKEN_KEYFILE), hwndDlg, (DLGPROC) NewSecurityTokenKeyfileDlgProc, (LPARAM) &newParams) == IDOK)
{
- WaitCursor();
- finally_do ({ NormalCursor(); });
+ vector <byte> keyfileDataVector (keyfileSize);
+ memcpy (&keyfileDataVector.front(), keyfileData, keyfileSize);
- SecurityToken::CreateKeyfile (newParams.SlotId, keyfileDataVector, newParams.Name);
+ try
+ {
+ WaitCursor();
+ finally_do ({ NormalCursor(); });
- keyfiles = SecurityToken::GetAvailableKeyfiles();
- SecurityTokenKeyfileDlgFillList (hwndDlg, keyfiles);
- }
- catch (Exception &e)
- {
- e.Show (hwndDlg);
- }
+ SecurityToken::CreateKeyfile (newParams.SlotId, keyfileDataVector, newParams.Name);
+
+ keyfiles = SecurityToken::GetAvailableKeyfiles();
+ SecurityTokenKeyfileDlgFillList (hwndDlg, keyfiles);
+ }
+ catch (Exception &e)
+ {
+ e.Show (hwndDlg);
+ }
- burn (&keyfileDataVector.front(), keyfileSize);
+ burn (&keyfileDataVector.front(), keyfileSize);
+ }
}
- }
- else
- {
- SetLastError (ERROR_HANDLE_EOF);
- handleWin32Error (hwndDlg);
+ else
+ {
+ SetLastError (ERROR_HANDLE_EOF);
+ handleWin32Error (hwndDlg);
+ }
+
+ burn (keyfileData, keyfileSize);
+ TCfree (keyfileData);
}
- burn (keyfileData, keyfileSize);
- TCfree (keyfileData);
+ return 1;
}
- return 1;
- }
-
- case IDC_EXPORT:
- {
- try
+ case IDC_EXPORT:
{
- foreach (const SecurityTokenKeyfile &keyfile, SecurityTokenKeyfileDlgGetSelected (hwndDlg, keyfiles))
+ try
{
- char keyfilePath[TC_MAX_PATH];
+ foreach (const SecurityTokenKeyfile &keyfile, SecurityTokenKeyfileDlgGetSelected (hwndDlg, keyfiles))
+ {
+ char keyfilePath[TC_MAX_PATH];
- if (!BrowseFiles (hwndDlg, "OPEN_TITLE", keyfilePath, bHistory, TRUE, NULL))
- break;
+ if (!BrowseFiles (hwndDlg, "OPEN_TITLE", keyfilePath, bHistory, TRUE, NULL))
+ break;
- {
- WaitCursor();
- finally_do ({ NormalCursor(); });
+ {
+ WaitCursor();
+ finally_do ({ NormalCursor(); });
- vector <byte> keyfileData;
+ vector <byte> keyfileData;
- SecurityToken::GetKeyfileData (keyfile, keyfileData);
+ SecurityToken::GetKeyfileData (keyfile, keyfileData);
- if (keyfileData.empty())
- {
- SetLastError (ERROR_HANDLE_EOF);
- handleWin32Error (hwndDlg);
- return 1;
- }
+ if (keyfileData.empty())
+ {
+ SetLastError (ERROR_HANDLE_EOF);
+ handleWin32Error (hwndDlg);
+ return 1;
+ }
- finally_do_arg (vector <byte> *, &keyfileData, { burn (&finally_arg->front(), finally_arg->size()); });
+ finally_do_arg (vector <byte> *, &keyfileData, { burn (&finally_arg->front(), finally_arg->size()); });
- if (!SaveBufferToFile ((char *) &keyfileData.front(), keyfilePath, keyfileData.size(), FALSE))
- throw SystemException ();
- }
+ if (!SaveBufferToFile ((char *) &keyfileData.front(), keyfilePath, keyfileData.size(), FALSE))
+ throw SystemException ();
+ }
- Info ("KEYFILE_EXPORTED");
+ Info ("KEYFILE_EXPORTED");
+ }
+ }
+ catch (Exception &e)
+ {
+ e.Show (hwndDlg);
}
- }
- catch (Exception &e)
- {
- e.Show (hwndDlg);
- }
-
- return 1;
- }
- case IDC_DELETE:
- {
- if (AskNoYes ("CONFIRM_SEL_FILES_DELETE") == IDNO)
return 1;
+ }
- try
+ case IDC_DELETE:
{
- WaitCursor();
- finally_do ({ NormalCursor(); });
+ if (AskNoYes ("CONFIRM_SEL_FILES_DELETE") == IDNO)
+ return 1;
+
+ try
+ {
+ WaitCursor();
+ finally_do ({ NormalCursor(); });
+
+ foreach (const SecurityTokenKeyfile &keyfile, SecurityTokenKeyfileDlgGetSelected (hwndDlg, keyfiles))
+ {
+ SecurityToken::DeleteKeyfile (keyfile);
+ }
- foreach (const SecurityTokenKeyfile &keyfile, SecurityTokenKeyfileDlgGetSelected (hwndDlg, keyfiles))
+ keyfiles = SecurityToken::GetAvailableKeyfiles();
+ SecurityTokenKeyfileDlgFillList (hwndDlg, keyfiles);
+ }
+ catch (Exception &e)
{
- SecurityToken::DeleteKeyfile (keyfile);
+ e.Show (hwndDlg);
}
- keyfiles = SecurityToken::GetAvailableKeyfiles();
- SecurityTokenKeyfileDlgFillList (hwndDlg, keyfiles);
- }
- catch (Exception &e)
- {
- e.Show (hwndDlg);
+ return 1;
}
-
- return 1;
}
}
-
return 0;
}
return 0;
diff --git a/src/Mount/Hotkeys.c b/src/Mount/Hotkeys.c
index c0829602..34f980eb 100644
--- a/src/Mount/Hotkeys.c
+++ b/src/Mount/Hotkeys.c
@@ -270,25 +270,19 @@ static void DisplayHotkeyList (HWND hwndDlg)
BOOL CALLBACK HotkeysDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
-{
- HWND hList = GetDlgItem (hwndDlg, IDC_HOTKEY_LIST);
- HWND hwndMainDlg = hwndDlg;
+{
WORD lw = LOWORD (wParam);
WORD hw = HIWORD (wParam);
static BOOL bKeyScanOn;
static BOOL bTPlaySoundOnSuccessfulHkDismount;
static BOOL bTDisplayBalloonOnSuccessfulHkDismount;
- while (GetParent (hwndMainDlg) != NULL)
- {
- hwndMainDlg = GetParent (hwndMainDlg);
- }
-
switch (msg)
{
case WM_INITDIALOG:
{
LVCOLUMNW col;
+ HWND hList = GetDlgItem (hwndDlg, IDC_HOTKEY_LIST);
bKeyScanOn = FALSE;
nSelectedHotkeyId = -1;
@@ -354,16 +348,8 @@ BOOL CALLBACK HotkeysDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPar
return 1;
}
- case WM_COMMAND:
case WM_NOTIFY:
-
- if (lw == IDC_HOTKEY_KEY && hw == EN_CHANGE)
- {
- if (!bKeyScanOn && nSelectedHotkeyId < 0 && GetWindowTextLengthW (GetDlgItem (hwndDlg, IDC_HOTKEY_KEY)))
- SetWindowTextW (GetDlgItem (hwndDlg, IDC_HOTKEY_KEY), L"");
- }
-
- if (msg == WM_NOTIFY && wParam == IDC_HOTKEY_LIST)
+ if (wParam == IDC_HOTKEY_LIST)
{
if (((LPNMHDR) lParam)->code == LVN_ITEMACTIVATE
|| ((LPNMHDR) lParam)->code == LVN_ITEMCHANGED && (((LPNMLISTVIEW) lParam)->uNewState & LVIS_FOCUSED))
@@ -381,6 +367,15 @@ BOOL CALLBACK HotkeysDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPar
}
}
+ return 0;
+
+ case WM_COMMAND:
+ if (lw == IDC_HOTKEY_KEY && hw == EN_CHANGE)
+ {
+ if (!bKeyScanOn && nSelectedHotkeyId < 0 && GetWindowTextLengthW (GetDlgItem (hwndDlg, IDC_HOTKEY_KEY)))
+ SetWindowTextW (GetDlgItem (hwndDlg, IDC_HOTKEY_KEY), L"");
+ }
+
if (lw == IDC_HOTKEY_ASSIGN)
{
BOOL bOwnActiveShortcut = FALSE;
@@ -502,6 +497,12 @@ BOOL CALLBACK HotkeysDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPar
if (lw == IDOK)
{
+ HWND hwndMainDlg = hwndDlg;
+
+ while (GetParent (hwndMainDlg) != NULL)
+ {
+ hwndMainDlg = GetParent (hwndMainDlg);
+ }
UnregisterAllHotkeys (hwndMainDlg, Hotkeys);
memcpy (Hotkeys, tmpHotkeys, sizeof(Hotkeys));
RegisterAllHotkeys (hwndMainDlg, Hotkeys);