VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/ExpandVolume/WinMain.cpp
diff options
context:
space:
mode:
authorMounir IDRASSI <mounir.idrassi@idrix.fr>2016-05-10 22:34:27 +0200
committerMounir IDRASSI <mounir.idrassi@idrix.fr>2016-05-10 22:34:27 +0200
commit268ef2d8e904db5068dbdc0fdc7ce3940d6452ea (patch)
treeb1afa687c97fbf5e1ba2c92c5a10479ae5f832f5 /src/ExpandVolume/WinMain.cpp
parent6d61f06a5348aebe7dbc0bf44d3e2729c20f7fd0 (diff)
parent5f47d8b6f11cdb3c4c2f43e04e5acfc6ffcb3035 (diff)
downloadVeraCrypt-268ef2d8e904db5068dbdc0fdc7ce3940d6452ea.tar.gz
VeraCrypt-268ef2d8e904db5068dbdc0fdc7ce3940d6452ea.zip
Merge pull request #61 from davidfoerster/normalize-line-terminators
Normalize line terminators
Diffstat (limited to 'src/ExpandVolume/WinMain.cpp')
-rw-r--r--src/ExpandVolume/WinMain.cpp846
1 files changed, 423 insertions, 423 deletions
diff --git a/src/ExpandVolume/WinMain.cpp b/src/ExpandVolume/WinMain.cpp
index fb9d52af..ad0d2f50 100644
--- a/src/ExpandVolume/WinMain.cpp
+++ b/src/ExpandVolume/WinMain.cpp
@@ -1,17 +1,17 @@
-/*
- Legal Notice: Some portions of the source code contained in this file were
- derived from the source code of TrueCrypt 7.1a, which is
- Copyright (c) 2003-2012 TrueCrypt Developers Association and which is
- governed by the TrueCrypt License 3.0, also from the source code of
- Encryption for the Masses 2.02a, which is Copyright (c) 1998-2000 Paul Le Roux
- and which is governed by the 'License Agreement for Encryption for the Masses'
+/*
+ Legal Notice: Some portions of the source code contained in this file were
+ derived from the source code of TrueCrypt 7.1a, which is
+ Copyright (c) 2003-2012 TrueCrypt Developers Association and which is
+ governed by the TrueCrypt License 3.0, also from the source code of
+ Encryption for the Masses 2.02a, which is Copyright (c) 1998-2000 Paul Le Roux
+ and which is governed by the 'License Agreement for Encryption for the Masses'
and also from the source code of extcv, which is Copyright (c) 2009-2010 Kih-Oskh
- or Copyright (c) 2012-2013 Josef Schneider <josef@netpage.dk>
-
- Modifications and additions to the original source code (contained in this file)
- and all other portions of this file are Copyright (c) 2013-2016 IDRIX
- and are governed by the Apache License 2.0 the full text of which is
- contained in the file License.txt included in VeraCrypt binary and source
+ or Copyright (c) 2012-2013 Josef Schneider <josef@netpage.dk>
+
+ Modifications and additions to the original source code (contained in this file)
+ and all other portions of this file are Copyright (c) 2013-2016 IDRIX
+ and are governed by the Apache License 2.0 the full text of which is
+ contained in the file License.txt included in VeraCrypt binary and source
code distribution packages. */
#include "Tcdefs.h"
@@ -383,32 +383,32 @@ static char *PasswordDialogTitleStringId;
/* Except in response to the WM_INITDIALOG message, the dialog box procedure
should return nonzero if it processes the message, and zero if it does
not. - see DialogProc */
-BOOL CALLBACK ExtcvPasswordDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
-{
- WORD lw = LOWORD (wParam);
- static Password *szXPwd;
- static int *pkcs5;
- static int *pim;
- static BOOL* truecryptMode;
-
- switch (msg)
- {
- case WM_INITDIALOG:
- {
- int i, nIndex;
- szXPwd = ((PasswordDlgParam *) lParam) -> password;
- pkcs5 = ((PasswordDlgParam *) lParam) -> pkcs5;
- pim = ((PasswordDlgParam *) lParam) -> pim;
- truecryptMode = ((PasswordDlgParam *) lParam) -> truecryptMode;
- LocalizeDialog (hwndDlg, "IDD_PASSWORD_DLG");
- DragAcceptFiles (hwndDlg, TRUE);
-
- if (PasswordDialogTitleStringId)
- {
- SetWindowTextW (hwndDlg, GetString (PasswordDialogTitleStringId));
- }
- else if (wcslen (PasswordDlgVolume) > 0)
- {
+BOOL CALLBACK ExtcvPasswordDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ WORD lw = LOWORD (wParam);
+ static Password *szXPwd;
+ static int *pkcs5;
+ static int *pim;
+ static BOOL* truecryptMode;
+
+ switch (msg)
+ {
+ case WM_INITDIALOG:
+ {
+ int i, nIndex;
+ szXPwd = ((PasswordDlgParam *) lParam) -> password;
+ pkcs5 = ((PasswordDlgParam *) lParam) -> pkcs5;
+ pim = ((PasswordDlgParam *) lParam) -> pim;
+ truecryptMode = ((PasswordDlgParam *) lParam) -> truecryptMode;
+ LocalizeDialog (hwndDlg, "IDD_PASSWORD_DLG");
+ DragAcceptFiles (hwndDlg, TRUE);
+
+ if (PasswordDialogTitleStringId)
+ {
+ SetWindowTextW (hwndDlg, GetString (PasswordDialogTitleStringId));
+ }
+ else if (wcslen (PasswordDlgVolume) > 0)
+ {
wchar_t s[1024];
const int maxVisibleLen = 40;
@@ -420,359 +420,359 @@ BOOL CALLBACK ExtcvPasswordDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
else
StringCbPrintfW (s, sizeof(s), GetString ("ENTER_PASSWORD_FOR"), PasswordDlgVolume);
- SetWindowTextW (hwndDlg, s);
- }
-
- /* Populate the PRF algorithms list */
- HWND hComboBox = GetDlgItem (hwndDlg, IDC_PKCS5_PRF_ID);
- SendMessage (hComboBox, CB_RESETCONTENT, 0, 0);
-
- nIndex = SendMessageW (hComboBox, CB_ADDSTRING, 0, (LPARAM) GetString ("AUTODETECTION"));
- SendMessage (hComboBox, CB_SETITEMDATA, nIndex, (LPARAM) 0);
-
- for (i = FIRST_PRF_ID; i <= LAST_PRF_ID; i++)
- {
- nIndex = SendMessage (hComboBox, CB_ADDSTRING, 0, (LPARAM) get_pkcs5_prf_name(i));
- SendMessage (hComboBox, CB_SETITEMDATA, nIndex, (LPARAM) i);
- }
-
- /* make autodetection the default */
- SendMessage (hComboBox, CB_SETCURSEL, 0, 0);
-
- SendMessage (GetDlgItem (hwndDlg, IDC_PASSWORD), EM_LIMITTEXT, MAX_PASSWORD, 0);
- SendMessage (GetDlgItem (hwndDlg, IDC_CACHE), BM_SETCHECK, bCacheInDriver ? BST_CHECKED:BST_UNCHECKED, 0);
- SendMessage (GetDlgItem (hwndDlg, IDC_PIM), EM_LIMITTEXT, MAX_PIM, 0);
-
- SetPim (hwndDlg, IDC_PIM, *pim);
-
- /* make PIM field visible if a PIM value has been explicitely specified */
- if (*pim > 0)
- {
- ShowWindow (GetDlgItem (hwndDlg, IDC_PIM_ENABLE), SW_HIDE);
- ShowWindow (GetDlgItem( hwndDlg, IDT_PIM), SW_SHOW);
- ShowWindow (GetDlgItem( hwndDlg, IDC_PIM), SW_SHOW);
- ShowWindow (GetDlgItem( hwndDlg, IDC_PIM_HELP), SW_SHOW);
- }
-
- SetCheckBox (hwndDlg, IDC_KEYFILES_ENABLE, KeyFilesEnable);
-
- mountOptions.PartitionInInactiveSysEncScope = bPrebootPasswordDlgMode;
-
- if (bPrebootPasswordDlgMode)
- {
- SendMessage (hwndDlg, TC_APPMSG_PREBOOT_PASSWORD_MODE, 0, 0);
- }
-
- if (PasswordDialogDisableMountOptions)
- {
- EnableWindow (GetDlgItem (hwndDlg, IDC_CACHE), FALSE);
- EnableWindow (GetDlgItem (hwndDlg, IDC_MOUNT_OPTIONS), FALSE);
- }
-
- /* No support for mounting TrueCrypt volumes */
- SetCheckBox (hwndDlg, IDC_TRUECRYPT_MODE, FALSE);
- EnableWindow (GetDlgItem (hwndDlg, IDC_TRUECRYPT_MODE), FALSE);
-
- if (!SetForegroundWindow (hwndDlg) && (FavoriteMountOnArrivalInProgress))
- {
- SetWindowPos (hwndDlg, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
-
- FLASHWINFO flash;
- flash.cbSize = sizeof (flash);
- flash.dwFlags = FLASHW_ALL | FLASHW_TIMERNOFG;
- flash.dwTimeout = 0;
- flash.hwnd = hwndDlg;
- flash.uCount = 0;
-
- FlashWindowEx (&flash);
-
- SetWindowPos (hwndDlg, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
- }
- }
- return 0;
-
- case TC_APPMSG_PREBOOT_PASSWORD_MODE:
- {
- /* No support for mounting TrueCrypt system partition */
- SetCheckBox (hwndDlg, IDC_TRUECRYPT_MODE, FALSE);
- EnableWindow (GetDlgItem (hwndDlg, IDC_TRUECRYPT_MODE), FALSE);
-
- /* Repopulate the PRF algorithms list with algorithms that support system encryption */
- HWND hComboBox = GetDlgItem (hwndDlg, IDC_PKCS5_PRF_ID);
- SendMessage (hComboBox, CB_RESETCONTENT, 0, 0);
-
- int i, nIndex = SendMessageW (hComboBox, CB_ADDSTRING, 0, (LPARAM) GetString ("AUTODETECTION"));
- SendMessage (hComboBox, CB_SETITEMDATA, nIndex, (LPARAM) 0);
-
- for (i = FIRST_PRF_ID; i <= LAST_PRF_ID; i++)
- {
- if (HashForSystemEncryption(i))
- {
- nIndex = SendMessage (hComboBox, CB_ADDSTRING, 0, (LPARAM) get_pkcs5_prf_name(i));
- SendMessage (hComboBox, CB_SETITEMDATA, nIndex, (LPARAM) i);
- }
- }
-
- /* make autodetection the default */
- SendMessage (hComboBox, CB_SETCURSEL, 0, 0);
-
- ToBootPwdField (hwndDlg, IDC_PASSWORD);
-
- // Attempt to wipe the password stored in the input field buffer
- wchar_t tmp[MAX_PASSWORD+1];
- wmemset (tmp, L'X', MAX_PASSWORD);
- tmp [MAX_PASSWORD] = 0;
- SetWindowText (GetDlgItem (hwndDlg, IDC_PASSWORD), tmp);
- SetWindowText (GetDlgItem (hwndDlg, IDC_PASSWORD), L"");
-
- StringCbPrintfW (OrigKeyboardLayout, sizeof(OrigKeyboardLayout),L"%08X", (DWORD) GetKeyboardLayout (NULL) & 0xFFFF);
-
- DWORD keybLayout = (DWORD) LoadKeyboardLayout (L"00000409", KLF_ACTIVATE);
-
- if (keybLayout != 0x00000409 && keybLayout != 0x04090409)
- {
- Error ("CANT_CHANGE_KEYB_LAYOUT_FOR_SYS_ENCRYPTION", hwndDlg);
- EndDialog (hwndDlg, IDCANCEL);
- return 1;
- }
-
- if (SetTimer (hwndDlg, TIMER_ID_KEYB_LAYOUT_GUARD, TIMER_INTERVAL_KEYB_LAYOUT_GUARD, NULL) == 0)
- {
- Error ("CANNOT_SET_TIMER", hwndDlg);
- EndDialog (hwndDlg, IDCANCEL);
- return 1;
- }
-
- if (GetCheckBox (hwndDlg, IDC_SHOW_PASSWORD))
- {
- // simulate hiding password
- SetCheckBox (hwndDlg, IDC_SHOW_PASSWORD, FALSE);
-
- HandleShowPasswordFieldAction (hwndDlg, IDC_SHOW_PASSWORD, IDC_PASSWORD, IDC_PIM);
- }
-
- SetCheckBox (hwndDlg, IDC_KEYFILES_ENABLE, FALSE);
- EnableWindow (GetDlgItem (hwndDlg, IDC_KEYFILES_ENABLE), FALSE);
- EnableWindow (GetDlgItem (hwndDlg, IDC_KEY_FILES), FALSE);
-
- SetPim (hwndDlg, IDC_PIM, *pim);
-
- bPrebootPasswordDlgMode = TRUE;
- }
- return 1;
-
- case WM_TIMER:
- switch (wParam)
- {
- case TIMER_ID_KEYB_LAYOUT_GUARD:
- if (bPrebootPasswordDlgMode)
- {
- DWORD keybLayout = (DWORD) GetKeyboardLayout (NULL);
-
- if (keybLayout != 0x00000409 && keybLayout != 0x04090409)
- {
- // Keyboard layout is not standard US
-
- // Attempt to wipe the password stored in the input field buffer
- wchar_t tmp[MAX_PASSWORD+1];
- wmemset (tmp, L'X', MAX_PASSWORD);
- tmp [MAX_PASSWORD] = 0;
- SetWindowText (GetDlgItem (hwndDlg, IDC_PASSWORD), tmp);
- SetWindowText (GetDlgItem (hwndDlg, IDC_PASSWORD), L"");
-
- keybLayout = (DWORD) LoadKeyboardLayout (L"00000409", KLF_ACTIVATE);
-
- if (keybLayout != 0x00000409 && keybLayout != 0x04090409)
- {
- KillTimer (hwndDlg, TIMER_ID_KEYB_LAYOUT_GUARD);
- Error ("CANT_CHANGE_KEYB_LAYOUT_FOR_SYS_ENCRYPTION", hwndDlg);
- EndDialog (hwndDlg, IDCANCEL);
- return 1;
- }
-
- wchar_t szTmp [4096];
- StringCbCopyW (szTmp, sizeof(szTmp), GetString ("KEYB_LAYOUT_CHANGE_PREVENTED"));
- StringCbCatW (szTmp, sizeof(szTmp), L"\n\n");
- StringCbCatW (szTmp, sizeof(szTmp), GetString ("KEYB_LAYOUT_SYS_ENC_EXPLANATION"));
- MessageBoxW (MainDlg, szTmp, lpszTitle, MB_ICONWARNING | MB_SETFOREGROUND | MB_TOPMOST);
- }
- }
- return 1;
- }
- return 0;
-
- case WM_COMMAND:
-
- if (lw == IDC_MOUNT_OPTIONS)
- {
- DialogBoxParamW (hInst,
- MAKEINTRESOURCEW (IDD_MOUNT_OPTIONS), hwndDlg,
- (DLGPROC) MountOptionsDlgProc, (LPARAM) &mountOptions);
-
- if (!bPrebootPasswordDlgMode && mountOptions.PartitionInInactiveSysEncScope)
- SendMessage (hwndDlg, TC_APPMSG_PREBOOT_PASSWORD_MODE, 0, 0);
-
- return 1;
- }
-
- if (lw == IDC_PIM_ENABLE)
- {
- ShowWindow (GetDlgItem (hwndDlg, IDC_PIM_ENABLE), SW_HIDE);
- ShowWindow (GetDlgItem( hwndDlg, IDT_PIM), SW_SHOW);
- ShowWindow (GetDlgItem( hwndDlg, IDC_PIM), SW_SHOW);
- ShowWindow (GetDlgItem( hwndDlg, IDC_PIM_HELP), SW_SHOW);
-
- SetFocus (GetDlgItem (hwndDlg, IDC_PIM));
- return 1;
- }
-
- if (lw == IDC_SHOW_PASSWORD)
- {
- HandleShowPasswordFieldAction (hwndDlg, IDC_SHOW_PASSWORD, IDC_PASSWORD, IDC_PIM);
- return 1;
- }
-
- if (lw == IDC_KEY_FILES)
- {
- KeyFilesDlgParam param;
- param.EnableKeyFiles = KeyFilesEnable;
- param.FirstKeyFile = FirstKeyFile;
-
- if (IDOK == DialogBoxParamW (hInst,
- MAKEINTRESOURCEW (IDD_KEYFILES), hwndDlg,
- (DLGPROC) KeyFilesDlgProc, (LPARAM) &param))
- {
- KeyFilesEnable = param.EnableKeyFiles;
- FirstKeyFile = param.FirstKeyFile;
-
- SetCheckBox (hwndDlg, IDC_KEYFILES_ENABLE, KeyFilesEnable);
- }
-
- return 1;
- }
-
- if (lw == IDC_KEYFILES_ENABLE)
- {
- KeyFilesEnable = GetCheckBox (hwndDlg, IDC_KEYFILES_ENABLE);
-
- return 1;
- }
-
- if (lw == IDCANCEL || lw == IDOK)
- {
- wchar_t tmp[MAX_PASSWORD+1];
-
- if (lw == IDOK)
- {
- if (mountOptions.ProtectHiddenVolume && hidVolProtKeyFilesParam.EnableKeyFiles)
- KeyFilesApply (hwndDlg, &mountOptions.ProtectedHidVolPassword, hidVolProtKeyFilesParam.FirstKeyFile, PasswordDlgVolume);
-
- if (GetPassword (hwndDlg, IDC_PASSWORD, (LPSTR) szXPwd->Text, MAX_PASSWORD + 1, TRUE))
- szXPwd->Length = strlen ((char *) szXPwd->Text);
- else
- return 1;
-
- bCacheInDriver = IsButtonChecked (GetDlgItem (hwndDlg, IDC_CACHE));
- *pkcs5 = (int) SendMessage (GetDlgItem (hwndDlg, IDC_PKCS5_PRF_ID), CB_GETITEMDATA, SendMessage (GetDlgItem (hwndDlg, IDC_PKCS5_PRF_ID), CB_GETCURSEL, 0, 0), 0);
- *truecryptMode = GetCheckBox (hwndDlg, IDC_TRUECRYPT_MODE);
-
- *pim = GetPim (hwndDlg, IDC_PIM);
-
- /* SHA-256 is not supported by TrueCrypt */
- if ( (*truecryptMode)
- && ((*pkcs5 == SHA256) || (mountOptions.ProtectHiddenVolume && mountOptions.ProtectedHidVolPkcs5Prf == SHA256))
- )
- {
- Error ("ALGO_NOT_SUPPORTED_FOR_TRUECRYPT_MODE", hwndDlg);
- return 1;
- }
-
- if ( (*truecryptMode)
- && (*pim != 0)
- )
- {
- Error ("PIM_NOT_SUPPORTED_FOR_TRUECRYPT_MODE", hwndDlg);
- return 1;
- }
- }
-
- // Attempt to wipe password stored in the input field buffer
- wmemset (tmp, L'X', MAX_PASSWORD);
- tmp[MAX_PASSWORD] = 0;
- SetWindowText (GetDlgItem (hwndDlg, IDC_PASSWORD), tmp);
- SetWindowText (GetDlgItem (hwndDlg, IDC_PASSWORD_PROT_HIDVOL), tmp);
-
- if (hidVolProtKeyFilesParam.FirstKeyFile != NULL)
- {
- KeyFileRemoveAll (&hidVolProtKeyFilesParam.FirstKeyFile);
- hidVolProtKeyFilesParam.EnableKeyFiles = FALSE;
- }
-
- if (bPrebootPasswordDlgMode)
- {
- KillTimer (hwndDlg, TIMER_ID_KEYB_LAYOUT_GUARD);
-
- // Restore the original keyboard layout
- if (LoadKeyboardLayout (OrigKeyboardLayout, KLF_ACTIVATE | KLF_SUBSTITUTE_OK) == NULL)
- Warning ("CANNOT_RESTORE_KEYBOARD_LAYOUT", hwndDlg);
- }
-
- EndDialog (hwndDlg, lw);
- return 1;
- }
- return 0;
-
- case WM_CONTEXTMENU:
- {
- RECT buttonRect;
- GetWindowRect (GetDlgItem (hwndDlg, IDC_KEY_FILES), &buttonRect);
-
- if (LOWORD (lParam) >= buttonRect.left && LOWORD (lParam) <= buttonRect.right
- && HIWORD (lParam) >= buttonRect.top && HIWORD (lParam) <= buttonRect.bottom)
- {
- // The "Keyfiles" button has been right-clicked
-
- KeyFilesDlgParam param;
- param.EnableKeyFiles = KeyFilesEnable;
- param.FirstKeyFile = FirstKeyFile;
-
- POINT popupPos;
- popupPos.x = buttonRect.left + 2;
- popupPos.y = buttonRect.top + 2;
-
- if (KeyfilesPopupMenu (hwndDlg, popupPos, &param))
- {
- KeyFilesEnable = param.EnableKeyFiles;
- FirstKeyFile = param.FirstKeyFile;
- SetCheckBox (hwndDlg, IDC_KEYFILES_ENABLE, KeyFilesEnable);
- }
- }
- }
- break;
-
- case WM_DROPFILES:
- {
- HDROP hdrop = (HDROP) wParam;
- int i = 0, count = DragQueryFile (hdrop, 0xFFFFFFFF, NULL, 0);
-
- while (count-- > 0)
- {
- KeyFile *kf = (KeyFile *) malloc (sizeof (KeyFile));
- if (kf)
- {
- DragQueryFile (hdrop, i++, kf->FileName, ARRAYSIZE (kf->FileName));
- FirstKeyFile = KeyFileAdd (FirstKeyFile, kf);
- KeyFilesEnable = TRUE;
- }
- }
-
- SetCheckBox (hwndDlg, IDC_KEYFILES_ENABLE, KeyFilesEnable);
- DragFinish (hdrop);
- }
- return 1;
- }
-
- return 0;
+ SetWindowTextW (hwndDlg, s);
+ }
+
+ /* Populate the PRF algorithms list */
+ HWND hComboBox = GetDlgItem (hwndDlg, IDC_PKCS5_PRF_ID);
+ SendMessage (hComboBox, CB_RESETCONTENT, 0, 0);
+
+ nIndex = SendMessageW (hComboBox, CB_ADDSTRING, 0, (LPARAM) GetString ("AUTODETECTION"));
+ SendMessage (hComboBox, CB_SETITEMDATA, nIndex, (LPARAM) 0);
+
+ for (i = FIRST_PRF_ID; i <= LAST_PRF_ID; i++)
+ {
+ nIndex = SendMessage (hComboBox, CB_ADDSTRING, 0, (LPARAM) get_pkcs5_prf_name(i));
+ SendMessage (hComboBox, CB_SETITEMDATA, nIndex, (LPARAM) i);
+ }
+
+ /* make autodetection the default */
+ SendMessage (hComboBox, CB_SETCURSEL, 0, 0);
+
+ SendMessage (GetDlgItem (hwndDlg, IDC_PASSWORD), EM_LIMITTEXT, MAX_PASSWORD, 0);
+ SendMessage (GetDlgItem (hwndDlg, IDC_CACHE), BM_SETCHECK, bCacheInDriver ? BST_CHECKED:BST_UNCHECKED, 0);
+ SendMessage (GetDlgItem (hwndDlg, IDC_PIM), EM_LIMITTEXT, MAX_PIM, 0);
+
+ SetPim (hwndDlg, IDC_PIM, *pim);
+
+ /* make PIM field visible if a PIM value has been explicitely specified */
+ if (*pim > 0)
+ {
+ ShowWindow (GetDlgItem (hwndDlg, IDC_PIM_ENABLE), SW_HIDE);
+ ShowWindow (GetDlgItem( hwndDlg, IDT_PIM), SW_SHOW);
+ ShowWindow (GetDlgItem( hwndDlg, IDC_PIM), SW_SHOW);
+ ShowWindow (GetDlgItem( hwndDlg, IDC_PIM_HELP), SW_SHOW);
+ }
+
+ SetCheckBox (hwndDlg, IDC_KEYFILES_ENABLE, KeyFilesEnable);
+
+ mountOptions.PartitionInInactiveSysEncScope = bPrebootPasswordDlgMode;
+
+ if (bPrebootPasswordDlgMode)
+ {
+ SendMessage (hwndDlg, TC_APPMSG_PREBOOT_PASSWORD_MODE, 0, 0);
+ }
+
+ if (PasswordDialogDisableMountOptions)
+ {
+ EnableWindow (GetDlgItem (hwndDlg, IDC_CACHE), FALSE);
+ EnableWindow (GetDlgItem (hwndDlg, IDC_MOUNT_OPTIONS), FALSE);
+ }
+
+ /* No support for mounting TrueCrypt volumes */
+ SetCheckBox (hwndDlg, IDC_TRUECRYPT_MODE, FALSE);
+ EnableWindow (GetDlgItem (hwndDlg, IDC_TRUECRYPT_MODE), FALSE);
+
+ if (!SetForegroundWindow (hwndDlg) && (FavoriteMountOnArrivalInProgress))
+ {
+ SetWindowPos (hwndDlg, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
+
+ FLASHWINFO flash;
+ flash.cbSize = sizeof (flash);
+ flash.dwFlags = FLASHW_ALL | FLASHW_TIMERNOFG;
+ flash.dwTimeout = 0;
+ flash.hwnd = hwndDlg;
+ flash.uCount = 0;
+
+ FlashWindowEx (&flash);
+
+ SetWindowPos (hwndDlg, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
+ }
+ }
+ return 0;
+
+ case TC_APPMSG_PREBOOT_PASSWORD_MODE:
+ {
+ /* No support for mounting TrueCrypt system partition */
+ SetCheckBox (hwndDlg, IDC_TRUECRYPT_MODE, FALSE);
+ EnableWindow (GetDlgItem (hwndDlg, IDC_TRUECRYPT_MODE), FALSE);
+
+ /* Repopulate the PRF algorithms list with algorithms that support system encryption */
+ HWND hComboBox = GetDlgItem (hwndDlg, IDC_PKCS5_PRF_ID);
+ SendMessage (hComboBox, CB_RESETCONTENT, 0, 0);
+
+ int i, nIndex = SendMessageW (hComboBox, CB_ADDSTRING, 0, (LPARAM) GetString ("AUTODETECTION"));
+ SendMessage (hComboBox, CB_SETITEMDATA, nIndex, (LPARAM) 0);
+
+ for (i = FIRST_PRF_ID; i <= LAST_PRF_ID; i++)
+ {
+ if (HashForSystemEncryption(i))
+ {
+ nIndex = SendMessage (hComboBox, CB_ADDSTRING, 0, (LPARAM) get_pkcs5_prf_name(i));
+ SendMessage (hComboBox, CB_SETITEMDATA, nIndex, (LPARAM) i);
+ }
+ }
+
+ /* make autodetection the default */
+ SendMessage (hComboBox, CB_SETCURSEL, 0, 0);
+
+ ToBootPwdField (hwndDlg, IDC_PASSWORD);
+
+ // Attempt to wipe the password stored in the input field buffer
+ wchar_t tmp[MAX_PASSWORD+1];
+ wmemset (tmp, L'X', MAX_PASSWORD);
+ tmp [MAX_PASSWORD] = 0;
+ SetWindowText (GetDlgItem (hwndDlg, IDC_PASSWORD), tmp);
+ SetWindowText (GetDlgItem (hwndDlg, IDC_PASSWORD), L"");
+
+ StringCbPrintfW (OrigKeyboardLayout, sizeof(OrigKeyboardLayout),L"%08X", (DWORD) GetKeyboardLayout (NULL) & 0xFFFF);
+
+ DWORD keybLayout = (DWORD) LoadKeyboardLayout (L"00000409", KLF_ACTIVATE);
+
+ if (keybLayout != 0x00000409 && keybLayout != 0x04090409)
+ {
+ Error ("CANT_CHANGE_KEYB_LAYOUT_FOR_SYS_ENCRYPTION", hwndDlg);
+ EndDialog (hwndDlg, IDCANCEL);
+ return 1;
+ }
+
+ if (SetTimer (hwndDlg, TIMER_ID_KEYB_LAYOUT_GUARD, TIMER_INTERVAL_KEYB_LAYOUT_GUARD, NULL) == 0)
+ {
+ Error ("CANNOT_SET_TIMER", hwndDlg);
+ EndDialog (hwndDlg, IDCANCEL);
+ return 1;
+ }
+
+ if (GetCheckBox (hwndDlg, IDC_SHOW_PASSWORD))
+ {
+ // simulate hiding password
+ SetCheckBox (hwndDlg, IDC_SHOW_PASSWORD, FALSE);
+
+ HandleShowPasswordFieldAction (hwndDlg, IDC_SHOW_PASSWORD, IDC_PASSWORD, IDC_PIM);
+ }
+
+ SetCheckBox (hwndDlg, IDC_KEYFILES_ENABLE, FALSE);
+ EnableWindow (GetDlgItem (hwndDlg, IDC_KEYFILES_ENABLE), FALSE);
+ EnableWindow (GetDlgItem (hwndDlg, IDC_KEY_FILES), FALSE);
+
+ SetPim (hwndDlg, IDC_PIM, *pim);
+
+ bPrebootPasswordDlgMode = TRUE;
+ }
+ return 1;
+
+ case WM_TIMER:
+ switch (wParam)
+ {
+ case TIMER_ID_KEYB_LAYOUT_GUARD:
+ if (bPrebootPasswordDlgMode)
+ {
+ DWORD keybLayout = (DWORD) GetKeyboardLayout (NULL);
+
+ if (keybLayout != 0x00000409 && keybLayout != 0x04090409)
+ {
+ // Keyboard layout is not standard US
+
+ // Attempt to wipe the password stored in the input field buffer
+ wchar_t tmp[MAX_PASSWORD+1];
+ wmemset (tmp, L'X', MAX_PASSWORD);
+ tmp [MAX_PASSWORD] = 0;
+ SetWindowText (GetDlgItem (hwndDlg, IDC_PASSWORD), tmp);
+ SetWindowText (GetDlgItem (hwndDlg, IDC_PASSWORD), L"");
+
+ keybLayout = (DWORD) LoadKeyboardLayout (L"00000409", KLF_ACTIVATE);
+
+ if (keybLayout != 0x00000409 && keybLayout != 0x04090409)
+ {
+ KillTimer (hwndDlg, TIMER_ID_KEYB_LAYOUT_GUARD);
+ Error ("CANT_CHANGE_KEYB_LAYOUT_FOR_SYS_ENCRYPTION", hwndDlg);
+ EndDialog (hwndDlg, IDCANCEL);
+ return 1;
+ }
+
+ wchar_t szTmp [4096];
+ StringCbCopyW (szTmp, sizeof(szTmp), GetString ("KEYB_LAYOUT_CHANGE_PREVENTED"));
+ StringCbCatW (szTmp, sizeof(szTmp), L"\n\n");
+ StringCbCatW (szTmp, sizeof(szTmp), GetString ("KEYB_LAYOUT_SYS_ENC_EXPLANATION"));
+ MessageBoxW (MainDlg, szTmp, lpszTitle, MB_ICONWARNING | MB_SETFOREGROUND | MB_TOPMOST);
+ }
+ }
+ return 1;
+ }
+ return 0;
+
+ case WM_COMMAND:
+
+ if (lw == IDC_MOUNT_OPTIONS)
+ {
+ DialogBoxParamW (hInst,
+ MAKEINTRESOURCEW (IDD_MOUNT_OPTIONS), hwndDlg,
+ (DLGPROC) MountOptionsDlgProc, (LPARAM) &mountOptions);
+
+ if (!bPrebootPasswordDlgMode && mountOptions.PartitionInInactiveSysEncScope)
+ SendMessage (hwndDlg, TC_APPMSG_PREBOOT_PASSWORD_MODE, 0, 0);
+
+ return 1;
+ }
+
+ if (lw == IDC_PIM_ENABLE)
+ {
+ ShowWindow (GetDlgItem (hwndDlg, IDC_PIM_ENABLE), SW_HIDE);
+ ShowWindow (GetDlgItem( hwndDlg, IDT_PIM), SW_SHOW);
+ ShowWindow (GetDlgItem( hwndDlg, IDC_PIM), SW_SHOW);
+ ShowWindow (GetDlgItem( hwndDlg, IDC_PIM_HELP), SW_SHOW);
+
+ SetFocus (GetDlgItem (hwndDlg, IDC_PIM));
+ return 1;
+ }
+
+ if (lw == IDC_SHOW_PASSWORD)
+ {
+ HandleShowPasswordFieldAction (hwndDlg, IDC_SHOW_PASSWORD, IDC_PASSWORD, IDC_PIM);
+ return 1;
+ }
+
+ if (lw == IDC_KEY_FILES)
+ {
+ KeyFilesDlgParam param;
+ param.EnableKeyFiles = KeyFilesEnable;
+ param.FirstKeyFile = FirstKeyFile;
+
+ if (IDOK == DialogBoxParamW (hInst,
+ MAKEINTRESOURCEW (IDD_KEYFILES), hwndDlg,
+ (DLGPROC) KeyFilesDlgProc, (LPARAM) &param))
+ {
+ KeyFilesEnable = param.EnableKeyFiles;
+ FirstKeyFile = param.FirstKeyFile;
+
+ SetCheckBox (hwndDlg, IDC_KEYFILES_ENABLE, KeyFilesEnable);
+ }
+
+ return 1;
+ }
+
+ if (lw == IDC_KEYFILES_ENABLE)
+ {
+ KeyFilesEnable = GetCheckBox (hwndDlg, IDC_KEYFILES_ENABLE);
+
+ return 1;
+ }
+
+ if (lw == IDCANCEL || lw == IDOK)
+ {
+ wchar_t tmp[MAX_PASSWORD+1];
+
+ if (lw == IDOK)
+ {
+ if (mountOptions.ProtectHiddenVolume && hidVolProtKeyFilesParam.EnableKeyFiles)
+ KeyFilesApply (hwndDlg, &mountOptions.ProtectedHidVolPassword, hidVolProtKeyFilesParam.FirstKeyFile, PasswordDlgVolume);
+
+ if (GetPassword (hwndDlg, IDC_PASSWORD, (LPSTR) szXPwd->Text, MAX_PASSWORD + 1, TRUE))
+ szXPwd->Length = strlen ((char *) szXPwd->Text);
+ else
+ return 1;
+
+ bCacheInDriver = IsButtonChecked (GetDlgItem (hwndDlg, IDC_CACHE));
+ *pkcs5 = (int) SendMessage (GetDlgItem (hwndDlg, IDC_PKCS5_PRF_ID), CB_GETITEMDATA, SendMessage (GetDlgItem (hwndDlg, IDC_PKCS5_PRF_ID), CB_GETCURSEL, 0, 0), 0);
+ *truecryptMode = GetCheckBox (hwndDlg, IDC_TRUECRYPT_MODE);
+
+ *pim = GetPim (hwndDlg, IDC_PIM);
+
+ /* SHA-256 is not supported by TrueCrypt */
+ if ( (*truecryptMode)
+ && ((*pkcs5 == SHA256) || (mountOptions.ProtectHiddenVolume && mountOptions.ProtectedHidVolPkcs5Prf == SHA256))
+ )
+ {
+ Error ("ALGO_NOT_SUPPORTED_FOR_TRUECRYPT_MODE", hwndDlg);
+ return 1;
+ }
+
+ if ( (*truecryptMode)
+ && (*pim != 0)
+ )
+ {
+ Error ("PIM_NOT_SUPPORTED_FOR_TRUECRYPT_MODE", hwndDlg);
+ return 1;
+ }
+ }
+
+ // Attempt to wipe password stored in the input field buffer
+ wmemset (tmp, L'X', MAX_PASSWORD);
+ tmp[MAX_PASSWORD] = 0;
+ SetWindowText (GetDlgItem (hwndDlg, IDC_PASSWORD), tmp);
+ SetWindowText (GetDlgItem (hwndDlg, IDC_PASSWORD_PROT_HIDVOL), tmp);
+
+ if (hidVolProtKeyFilesParam.FirstKeyFile != NULL)
+ {
+ KeyFileRemoveAll (&hidVolProtKeyFilesParam.FirstKeyFile);
+ hidVolProtKeyFilesParam.EnableKeyFiles = FALSE;
+ }
+
+ if (bPrebootPasswordDlgMode)
+ {
+ KillTimer (hwndDlg, TIMER_ID_KEYB_LAYOUT_GUARD);
+
+ // Restore the original keyboard layout
+ if (LoadKeyboardLayout (OrigKeyboardLayout, KLF_ACTIVATE | KLF_SUBSTITUTE_OK) == NULL)
+ Warning ("CANNOT_RESTORE_KEYBOARD_LAYOUT", hwndDlg);
+ }
+
+ EndDialog (hwndDlg, lw);
+ return 1;
+ }
+ return 0;
+
+ case WM_CONTEXTMENU:
+ {
+ RECT buttonRect;
+ GetWindowRect (GetDlgItem (hwndDlg, IDC_KEY_FILES), &buttonRect);
+
+ if (LOWORD (lParam) >= buttonRect.left && LOWORD (lParam) <= buttonRect.right
+ && HIWORD (lParam) >= buttonRect.top && HIWORD (lParam) <= buttonRect.bottom)
+ {
+ // The "Keyfiles" button has been right-clicked
+
+ KeyFilesDlgParam param;
+ param.EnableKeyFiles = KeyFilesEnable;
+ param.FirstKeyFile = FirstKeyFile;
+
+ POINT popupPos;
+ popupPos.x = buttonRect.left + 2;
+ popupPos.y = buttonRect.top + 2;
+
+ if (KeyfilesPopupMenu (hwndDlg, popupPos, &param))
+ {
+ KeyFilesEnable = param.EnableKeyFiles;
+ FirstKeyFile = param.FirstKeyFile;
+ SetCheckBox (hwndDlg, IDC_KEYFILES_ENABLE, KeyFilesEnable);
+ }
+ }
+ }
+ break;
+
+ case WM_DROPFILES:
+ {
+ HDROP hdrop = (HDROP) wParam;
+ int i = 0, count = DragQueryFile (hdrop, 0xFFFFFFFF, NULL, 0);
+
+ while (count-- > 0)
+ {
+ KeyFile *kf = (KeyFile *) malloc (sizeof (KeyFile));
+ if (kf)
+ {
+ DragQueryFile (hdrop, i++, kf->FileName, ARRAYSIZE (kf->FileName));
+ FirstKeyFile = KeyFileAdd (FirstKeyFile, kf);
+ KeyFilesEnable = TRUE;
+ }
+ }
+
+ SetCheckBox (hwndDlg, IDC_KEYFILES_ENABLE, KeyFilesEnable);
+ DragFinish (hdrop);
+ }
+ return 1;
+ }
+
+ return 0;
}
void SaveSettings (HWND hwndDlg)
@@ -792,36 +792,36 @@ int RestoreVolumeHeader (HWND hwndDlg, char *lpszVolume)
return 0;
}
-int ExtcvAskVolumePassword (HWND hwndDlg, const wchar_t* fileName, Password *password, int *pkcs5, int *pim, BOOL* truecryptMode, char *titleStringId, BOOL enableMountOptions)
-{
- int result;
- PasswordDlgParam dlgParam;
-
- PasswordDialogTitleStringId = titleStringId;
- PasswordDialogDisableMountOptions = !enableMountOptions;
-
- dlgParam.password = password;
- dlgParam.pkcs5 = pkcs5;
- dlgParam.pim = pim;
- dlgParam.truecryptMode = truecryptMode;
-
- StringCbCopyW (PasswordDlgVolume, sizeof(PasswordDlgVolume), fileName);
-
- result = DialogBoxParamW (hInst,
- MAKEINTRESOURCEW (IDD_PASSWORD_DLG), hwndDlg,
- (DLGPROC) ExtcvPasswordDlgProc, (LPARAM) &dlgParam);
-
- if (result != IDOK)
- {
- password->Length = 0;
- *pkcs5 = 0;
- *pim = 0;
- *truecryptMode = FALSE;
- burn (&mountOptions.ProtectedHidVolPassword, sizeof (mountOptions.ProtectedHidVolPassword));
- burn (&mountOptions.ProtectedHidVolPkcs5Prf, sizeof (mountOptions.ProtectedHidVolPkcs5Prf));
- }
-
- return result == IDOK;
+int ExtcvAskVolumePassword (HWND hwndDlg, const wchar_t* fileName, Password *password, int *pkcs5, int *pim, BOOL* truecryptMode, char *titleStringId, BOOL enableMountOptions)
+{
+ int result;
+ PasswordDlgParam dlgParam;
+
+ PasswordDialogTitleStringId = titleStringId;
+ PasswordDialogDisableMountOptions = !enableMountOptions;
+
+ dlgParam.password = password;
+ dlgParam.pkcs5 = pkcs5;
+ dlgParam.pim = pim;
+ dlgParam.truecryptMode = truecryptMode;
+
+ StringCbCopyW (PasswordDlgVolume, sizeof(PasswordDlgVolume), fileName);
+
+ result = DialogBoxParamW (hInst,
+ MAKEINTRESOURCEW (IDD_PASSWORD_DLG), hwndDlg,
+ (DLGPROC) ExtcvPasswordDlgProc, (LPARAM) &dlgParam);
+
+ if (result != IDOK)
+ {
+ password->Length = 0;
+ *pkcs5 = 0;
+ *pim = 0;
+ *truecryptMode = FALSE;
+ burn (&mountOptions.ProtectedHidVolPassword, sizeof (mountOptions.ProtectedHidVolPassword));
+ burn (&mountOptions.ProtectedHidVolPkcs5Prf, sizeof (mountOptions.ProtectedHidVolPkcs5Prf));
+ }
+
+ return result == IDOK;
}
// GUI actions
@@ -839,7 +839,7 @@ static BOOL SelectContainer (HWND hwndDlg)
static BOOL SelectPartition (HWND hwndDlg)
{
- RawDevicesDlgParam param;
+ RawDevicesDlgParam param;
param.pszFileName = szFileName;
int nResult = DialogBoxParamW (hInst, MAKEINTRESOURCEW (IDD_RAWDEVICES_DLG), hwndDlg,
(DLGPROC) RawDevicesDlgProc, (LPARAM) & param);