VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Common/Dlgcode.c48
-rw-r--r--src/Common/Dlgcode.h6
-rw-r--r--src/Common/Language.xml2
-rw-r--r--src/ExpandVolume/WinMain.cpp4
-rw-r--r--src/Format/Tcformat.c81
-rw-r--r--src/Format/Tcformat.h1
-rw-r--r--src/Mount/Mount.c4
7 files changed, 120 insertions, 26 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
@@ -3016,6 +3016,7 @@ BOOL CALLBACK RawDevicesDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l
{
LVCOLUMNW LvCol;
HWND hList = GetDlgItem (hwndDlg, IDC_DEVICELIST);
+ RawDevicesDlgParam* pDlgParam = (RawDevicesDlgParam *) lParam;
LocalizeDialog (hwndDlg, "IDD_RAWDEVICES_DLG");
@@ -3048,9 +3049,14 @@ 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())
{
@@ -3140,7 +3146,7 @@ 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);
@@ -3153,15 +3159,33 @@ BOOL CALLBACK RawDevicesDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l
// 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;
}
@@ -3181,6 +3205,12 @@ BOOL CALLBACK RawDevicesDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l
{
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);
@@ -3243,6 +3273,12 @@ BOOL CALLBACK RawDevicesDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l
{
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 ();
diff --git a/src/Common/Dlgcode.h b/src/Common/Dlgcode.h
index 96d5e865..1c792e7c 100644
--- a/src/Common/Dlgcode.h
+++ b/src/Common/Dlgcode.h
@@ -514,6 +514,12 @@ struct HostDevice
std::vector <HostDevice> Partitions;
};
+struct RawDevicesDlgParam
+{
+ std::vector <HostDevice> devices;
+ char *pszFileName;
+};
+
BOOL BrowseFilesInDir (HWND hwndDlg, char *stringId, char *initialDir, char *lpszFileName, BOOL keepHistory, BOOL saveMode, wchar_t *browseFilter, const wchar_t *initialFileName = NULL, const wchar_t *defaultExtension = NULL);
std::wstring SingleStringToWide (const std::string &singleString);
std::wstring Utf8StringToWide (const std::string &utf8String);
diff --git a/src/Common/Language.xml b/src/Common/Language.xml
index c4d93f22..32fab4c4 100644
--- a/src/Common/Language.xml
+++ b/src/Common/Language.xml
@@ -606,6 +606,8 @@
<string lang="en" key="HIDDEN_FILES_PRESENT_IN_KEYFILE_PATH">\n\nWARNING: Hidden file(s) have been found in a keyfile search path. Such hidden files cannot be used as keyfiles. If you need to use them as keyfiles, remove their 'Hidden' attribute (right-click each of them, select 'Properties', uncheck 'Hidden' and click OK). Note: Hidden files are visible only if the corresponding option is enabled (Computer > Organize > 'Folder and search options' > View).</string>
<string lang="en" key="HIDDEN_VOL_PROT_PASSWORD_US_KEYB_LAYOUT">If you are attempting to protect a hidden volume containing a hidden system, please make sure you are using the standard US keyboard layout when typing the password for the hidden volume. This is required due to the fact that the password needs to be typed in the pre-boot environment (before Windows starts) where non-US Windows keyboard layouts are not available.</string>
<string lang="en" key="FOUND_NO_PARTITION_W_DEFERRED_INPLACE_ENC">VeraCrypt has not found any volume where non-system encryption has been interrupted and where the volume header can be decrypted using the supplied password and/or keyfile(s).\n\nPlease make sure the password and/or keyfile(s) are correct and that the partition/volume is not being used by the system or applications (including antivirus software).</string>
+ <string lang="en" key="SELECTED_PARTITION_ALREADY_INPLACE_ENC">The selected partition/device is already fully encrypted.\nHeader Flags = 0x%.8X</string>
+ <string lang="en" key="SELECTED_PARTITION_NOT_INPLACE_ENC">The selected partition/device is not using in-place encryption.\nHeader Flags = 0x%.8X</string>
<string lang="en" key="SYSENC_MOUNT_WITHOUT_PBA_NOTE">\n\nNote: If you are attempting to mount a partition located on an encrypted system drive without pre-boot authentication or to mount the encrypted system partition of an operating system that is not running, you can do so by selecting 'System' > 'Mount Without Pre-Boot Authentication'.</string>
<string lang="en" key="MOUNT_WITHOUT_PBA_VOL_ON_ACTIVE_SYSENC_DRIVE">In this mode, you cannot mount a partition located on a drive whose portion is within the key scope of active system encryption.\n\nBefore you can mount this partition in this mode, you need to either boot an operating system installed on a different drive (encrypted or unencrypted) or boot an unencrypted operating system.</string>
<string lang="en" key="PREV">&lt; &amp;Back</string>
diff --git a/src/ExpandVolume/WinMain.cpp b/src/ExpandVolume/WinMain.cpp
index 658f89ec..68ef281c 100644
--- a/src/ExpandVolume/WinMain.cpp
+++ b/src/ExpandVolume/WinMain.cpp
@@ -796,8 +796,10 @@ static BOOL SelectContainer (HWND hwndDlg)
static BOOL SelectPartition (HWND hwndDlg)
{
+ RawDevicesDlgParam param;
+ param.pszFileName = szFileName;
int nResult = DialogBoxParamW (hInst, MAKEINTRESOURCEW (IDD_RAWDEVICES_DLG), hwndDlg,
- (DLGPROC) RawDevicesDlgProc, (LPARAM) & szFileName[0]);
+ (DLGPROC) RawDevicesDlgProc, (LPARAM) & param);
if (nResult == IDOK)
{
AddComboItem (GetDlgItem (hwndDlg, IDC_VOLUME), szFileName, bHistory);
diff --git a/src/Format/Tcformat.c b/src/Format/Tcformat.c
index 2617d9bd..ba35c47e 100644
--- a/src/Format/Tcformat.c
+++ b/src/Format/Tcformat.c
@@ -259,33 +259,77 @@ vector <HostDevice> DeferredNonSysInPlaceEncDevices;
void CALLBACK ResumeInPlaceEncWaitThreadProc(void* pArg, HWND hwndDlg)
{
char szDevicePath[MAX_PATH] = {0};
+ RawDevicesDlgParam param;
+ param.devices = GetAvailableHostDevices (false, true, false);
+ param.pszFileName = szDevicePath;
DeferredNonSysInPlaceEncDevices.clear();
- if (IDOK != DialogBoxParamW (hInst,
+
+ if ((IDOK == DialogBoxParamW (hInst,
MAKEINTRESOURCEW (IDD_RAWDEVICES_DLG), hwndDlg,
- (DLGPROC) RawDevicesDlgProc, (LPARAM) & szDevicePath[0]))
+ (DLGPROC) RawDevicesDlgProc, (LPARAM) &param)) && strlen(szDevicePath))
{
- szDevicePath[0] = 0;
- }
+ foreach (const HostDevice &device, param.devices)
+ {
+ if (device.Path == szDevicePath)
+ {
+ OpenVolumeContext volume;
+ int status = OpenVolume (&volume, device.Path.c_str(), &volumePassword, hash_algo, FALSE, FALSE, FALSE, TRUE);
+
+ if ( status == ERR_SUCCESS)
+ {
+ if ((volume.CryptoInfo->HeaderFlags & TC_HEADER_FLAG_NONSYS_INPLACE_ENC) != 0
+ && volume.CryptoInfo->EncryptedAreaLength.Value != volume.CryptoInfo->VolumeSize.Value)
+ {
+ DeferredNonSysInPlaceEncDevices.push_back (device);
+ }
+ else if (volume.CryptoInfo->EncryptedAreaLength.Value == volume.CryptoInfo->VolumeSize.Value)
+ {
+ WCHAR szMsg[1024];
+ StringCbPrintfW(szMsg, sizeof(szMsg), GetString ("SELECTED_PARTITION_ALREADY_INPLACE_ENC"),
+ volume.CryptoInfo->HeaderFlags);
+ ErrorDirect(szMsg, hwndDlg);
+ }
+ else
+ {
+ WCHAR szMsg[1024];
+ StringCbPrintfW(szMsg, sizeof(szMsg), GetString ("SELECTED_PARTITION_NOT_INPLACE_ENC"),
+ volume.CryptoInfo->HeaderFlags);
+ ErrorDirect(szMsg, hwndDlg);
+ }
- foreach (const HostDevice &device, GetAvailableHostDevices (true, true))
+ CloseVolume (&volume);
+ }
+ else
+ {
+ handleError(hwndDlg, status);
+ }
+
+ break;
+ }
+ }
+ }
+ else
{
- if (device.IsPartition || device.DynamicVolume)
+ foreach (const HostDevice &device, param.devices)
{
- if ((strlen(szDevicePath) > 0) && (device.Path != szDevicePath))
- continue;
+ if ( !device.ContainsSystem
+ && (device.IsPartition || device.DynamicVolume || device.IsVirtualPartition || device.Partitions.empty())
+ )
+ {
- OpenVolumeContext volume;
+ OpenVolumeContext volume;
- if (OpenVolume (&volume, device.Path.c_str(), &volumePassword, hash_algo, FALSE, FALSE, FALSE, TRUE) == ERR_SUCCESS)
- {
- if ((volume.CryptoInfo->HeaderFlags & TC_HEADER_FLAG_NONSYS_INPLACE_ENC) != 0
- && volume.CryptoInfo->EncryptedAreaLength.Value != volume.CryptoInfo->VolumeSize.Value)
+ if (OpenVolume (&volume, device.Path.c_str(), &volumePassword, hash_algo, FALSE, FALSE, FALSE, TRUE) == ERR_SUCCESS)
{
- DeferredNonSysInPlaceEncDevices.push_back (device);
- }
+ if ((volume.CryptoInfo->HeaderFlags & TC_HEADER_FLAG_NONSYS_INPLACE_ENC) != 0
+ && volume.CryptoInfo->EncryptedAreaLength.Value != volume.CryptoInfo->VolumeSize.Value)
+ {
+ DeferredNonSysInPlaceEncDevices.push_back (device);
+ }
- CloseVolume (&volume);
+ CloseVolume (&volume);
+ }
}
}
}
@@ -5232,10 +5276,11 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
else
{
// Select device
-
+ RawDevicesDlgParam param;
+ param.pszFileName = szFileName;
int nResult = DialogBoxParamW (hInst,
MAKEINTRESOURCEW (IDD_RAWDEVICES_DLG), GetParent (hwndDlg),
- (DLGPROC) RawDevicesDlgProc, (LPARAM) & szFileName[0]);
+ (DLGPROC) RawDevicesDlgProc, (LPARAM) & param);
// Check administrator privileges
if (!strstr (szFileName, "Floppy") && !IsAdmin() && !IsUacSupported ())
diff --git a/src/Format/Tcformat.h b/src/Format/Tcformat.h
index cea36ccd..77579f54 100644
--- a/src/Format/Tcformat.h
+++ b/src/Format/Tcformat.h
@@ -94,6 +94,7 @@ extern __int64 NonSysInplaceEncBytesDone;
extern __int64 NonSysInplaceEncTotalSize;
extern int nPbar;
extern volatile int WizardMode;
+extern volatile BOOL bInPlaceEncNonSysResumed;
extern char HeaderKeyGUIView [KEY_GUI_VIEW_SIZE];
extern char MasterKeyGUIView [KEY_GUI_VIEW_SIZE];
diff --git a/src/Mount/Mount.c b/src/Mount/Mount.c
index f27c2d50..716f7926 100644
--- a/src/Mount/Mount.c
+++ b/src/Mount/Mount.c
@@ -4823,8 +4823,10 @@ BOOL SelectContainer (HWND hwndDlg)
BOOL SelectPartition (HWND hwndDlg)
{
+ RawDevicesDlgParam param;
+ param.pszFileName = szFileName;
int nResult = DialogBoxParamW (hInst, MAKEINTRESOURCEW (IDD_RAWDEVICES_DLG), hwndDlg,
- (DLGPROC) RawDevicesDlgProc, (LPARAM) & szFileName[0]);
+ (DLGPROC) RawDevicesDlgProc, (LPARAM) & param);
if (nResult == IDOK)
{
AddComboItem (GetDlgItem (hwndDlg, IDC_VOLUME), szFileName, bHistory);