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.c48
1 files changed, 42 insertions, 6 deletions
diff --git a/src/Common/Dlgcode.c b/src/Common/Dlgcode.c
index cf85682d..673da461 100644
--- a/src/Common/Dlgcode.c
+++ b/src/Common/Dlgcode.c
@@ -3015,8 +3015,9 @@ BOOL CALLBACK RawDevicesDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l
case WM_INITDIALOG:
{
LVCOLUMNW LvCol;
HWND hList = GetDlgItem (hwndDlg, IDC_DEVICELIST);
+ RawDevicesDlgParam* pDlgParam = (RawDevicesDlgParam *) lParam;
LocalizeDialog (hwndDlg, "IDD_RAWDEVICES_DLG");
SendMessage (hList,LVM_SETEXTENDEDLISTVIEWSTYLE,0,
@@ -3047,11 +3048,16 @@ BOOL CALLBACK RawDevicesDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l
devices.clear();
itemToDeviceMap.clear();
- WaitCursor();
- devices = GetAvailableHostDevices (false, true, false);
- NormalCursor();
+ if (pDlgParam->devices.empty())
+ {
+ WaitCursor();
+ devices = GetAvailableHostDevices (false, true, false);
+ NormalCursor();
+ }
+ else
+ devices = pDlgParam->devices;
if (devices.empty())
{
MessageBoxW (hwndDlg, GetString ("RAWDEVICES"), lpszTitle, ICON_HAND);
@@ -3139,9 +3145,9 @@ BOOL CALLBACK RawDevicesDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l
item.iItem = line++;
}
- lpszFileName = (char *) lParam;
+ lpszFileName = pDlgParam->pszFileName;
#ifdef VOLFORMAT
EnableWindow (GetDlgItem (hwndDlg, IDOK), FALSE);
#endif
@@ -3152,17 +3158,35 @@ BOOL CALLBACK RawDevicesDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l
case WM_NOTIFY:
// catch non-device line selected
if (msg == WM_NOTIFY && ((LPNMHDR) lParam)->code == LVN_ITEMCHANGED && (((LPNMLISTVIEW) lParam)->uNewState & LVIS_FOCUSED ))
{
+ BOOL bEnableOkButton = FALSE;
LVITEM LvItem;
- memset(&LvItem,0,sizeof(LvItem));
+ memset(&LvItem,0,sizeof(LvItem));
LvItem.mask = LVIF_TEXT | LVIF_PARAM;
LvItem.iItem = ((LPNMLISTVIEW) lParam)->iItem;
LvItem.pszText = lpszFileName;
LvItem.cchTextMax = TC_MAX_PATH;
+ lpszFileName[0] = 0;
SendMessage (GetDlgItem (hwndDlg, IDC_DEVICELIST), LVM_GETITEM, LvItem.iItem, (LPARAM) &LvItem);
- EnableWindow (GetDlgItem ((HWND) hwndDlg, IDOK), lpszFileName[0] != 0 && lpszFileName[0] != ' ');
+ if (lpszFileName[0] != 0 && lpszFileName[0] != ' ')
+ {
+ bEnableOkButton = TRUE;
+#ifdef VOLFORMAT
+ if ( bInPlaceEncNonSysResumed && (WizardMode == WIZARD_MODE_NONSYS_DEVICE)
+ && LvItem.iItem != -1 && itemToDeviceMap.find (LvItem.iItem) != itemToDeviceMap.end()
+ )
+ {
+ const HostDevice selectedDevice = itemToDeviceMap[LvItem.iItem];
+ if (selectedDevice.ContainsSystem)
+ {
+ bEnableOkButton = FALSE;
+ }
+ }
+#endif
+ }
+ EnableWindow (GetDlgItem ((HWND) hwndDlg, IDOK), bEnableOkButton);
return 1;
}
@@ -3180,8 +3204,14 @@ BOOL CALLBACK RawDevicesDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l
if (selectedDevice.ContainsSystem && selectedDevice.IsPartition)
{
if (WizardMode != WIZARD_MODE_SYS_DEVICE)
{
+ if (bInPlaceEncNonSysResumed && (WizardMode == WIZARD_MODE_NONSYS_DEVICE))
+ {
+ // disable selection
+ return 1;
+ }
+
if (AskYesNo ("CONFIRM_SYSTEM_ENCRYPTION_MODE", hwndDlg) == IDNO)
{
EndDialog (hwndDlg, IDCANCEL);
return 1;
@@ -3242,8 +3272,14 @@ BOOL CALLBACK RawDevicesDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l
if (selectedDevice.ContainsSystem && !selectedDevice.IsPartition)
{
if (WizardMode != WIZARD_MODE_SYS_DEVICE)
{
+ if (bInPlaceEncNonSysResumed && (WizardMode == WIZARD_MODE_NONSYS_DEVICE))
+ {
+ // disable selection
+ return 1;
+ }
+
if (AskYesNo ("CONFIRM_SYSTEM_ENCRYPTION_MODE", hwndDlg) == IDNO)
{
NormalCursor ();
EndDialog (hwndDlg, IDCANCEL);