VeraCrypt
aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMounir IDRASSI <mounir.idrassi@idrix.fr>2018-03-30 11:57:00 +0200
committerMounir IDRASSI <mounir.idrassi@idrix.fr>2018-03-30 13:53:59 +0200
commite57ef0229b2007166c9cdab0ea43c93c7bb42db2 (patch)
tree9e8273f9dcfdd0d2de18bc1601abb9afc01e1456
parent8dd58ddf6d23c365b737508f0dce443c6a6baa9e (diff)
downloadVeraCrypt-e57ef0229b2007166c9cdab0ea43c93c7bb42db2.tar.gz
VeraCrypt-e57ef0229b2007166c9cdab0ea43c93c7bb42db2.zip
Windows: workaround for cases where password dialog is not able to get focus.
-rw-r--r--src/Mount/Mount.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/Mount/Mount.c b/src/Mount/Mount.c
index f791d055..00de7856 100644
--- a/src/Mount/Mount.c
+++ b/src/Mount/Mount.c
@@ -64,7 +64,8 @@ enum timer_ids
{
TIMER_ID_MAIN = 0xff,
TIMER_ID_KEYB_LAYOUT_GUARD,
- TIMER_ID_UPDATE_DEVICE_LIST
+ TIMER_ID_UPDATE_DEVICE_LIST,
+ TIMER_ID_CHECK_FOREGROUND
};
enum hidden_os_read_only_notif_mode
@@ -77,6 +78,7 @@ enum hidden_os_read_only_notif_mode
#define TIMER_INTERVAL_MAIN 500
#define TIMER_INTERVAL_KEYB_LAYOUT_GUARD 10
#define TIMER_INTERVAL_UPDATE_DEVICE_LIST 1000
+#define TIMER_INTERVAL_CHECK_FOREGROUND 500
BootEncryption *BootEncObj = NULL;
BootEncryptionStatus BootEncStatus;
@@ -2931,6 +2933,8 @@ BOOL CALLBACK PasswordDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa
SetWindowPos (hwndDlg, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
}
+ SetFocus (GetDlgItem (hwndDlg, IDC_PASSWORD));
+ SetTimer (hwndDlg, TIMER_ID_CHECK_FOREGROUND, TIMER_INTERVAL_CHECK_FOREGROUND, NULL);
}
return 0;
@@ -3005,6 +3009,17 @@ BOOL CALLBACK PasswordDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa
case WM_TIMER:
switch (wParam)
{
+ case TIMER_ID_CHECK_FOREGROUND:
+ if (hwndDlg != ::GetForegroundWindow ())
+ {
+ // we are not foreground after 500ms of creating the dialog
+ // try to force it for be foreground
+ BringToForeground (hwndDlg);
+ SetFocus (GetDlgItem (hwndDlg, IDC_PASSWORD));
+ }
+ // one shot timer: stop it
+ KillTimer (hwndDlg, TIMER_ID_CHECK_FOREGROUND);
+ return 0;
case TIMER_ID_KEYB_LAYOUT_GUARD:
if (bPrebootPasswordDlgMode)
{