VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Mount/Mount.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/Mount/Mount.c')
-rw-r--r--src/Mount/Mount.c208
1 files changed, 104 insertions, 104 deletions
diff --git a/src/Mount/Mount.c b/src/Mount/Mount.c
index 63f593ed..5e5719c5 100644
--- a/src/Mount/Mount.c
+++ b/src/Mount/Mount.c
@@ -429,6 +429,12 @@ BOOL VolumeSelected (HWND hwndDlg)
return (GetWindowTextLength (GetDlgItem (hwndDlg, IDC_VOLUME)) > 0);
}
+void GetVolumePath (HWND hwndDlg, LPSTR szPath, int nMaxCount)
+{
+ GetWindowText (GetDlgItem (hwndDlg, IDC_VOLUME), szPath, nMaxCount);
+ CorrectFileName (szPath);
+}
+
/* Returns TRUE if the last partition/drive selected via the Select Device dialog box was the system
partition/drive and if it is encrypted.
WARNING: This function is very fast but not always reliable (for example, if the user manually types
@@ -447,7 +453,7 @@ BOOL ActiveSysEncDeviceSelected (void)
{
int retCode = 0;
- GetWindowText (GetDlgItem (MainDlg, IDC_VOLUME), szFileName, sizeof (szFileName));
+ GetVolumePath (MainDlg, szFileName, sizeof (szFileName));
retCode = IsSystemDevicePath (szFileName, MainDlg, FALSE);
@@ -496,7 +502,7 @@ static string ResolveAmbiguousSelection (HWND hwndDlg, int *driveNoPtr)
if (VolumeSelected (MainDlg))
{
// volPathInputField will contain the volume path (if any) from the input field below the drive list
- GetWindowText (GetDlgItem (MainDlg, IDC_VOLUME), volPathInputField, sizeof (volPathInputField));
+ GetVolumePath (MainDlg, volPathInputField, sizeof (volPathInputField));
if (!ambig)
retPath = (string) volPathInputField;
@@ -639,45 +645,6 @@ static string ResolveAmbiguousSelection (HWND hwndDlg, int *driveNoPtr)
return retPath;
}
-static void ConfigReadCompareInt(char *configKey, int defaultValue, int* pOutputValue, BOOL bOnlyCheckModified, BOOL* pbModified)
-{
- int intValue = ConfigReadInt (configKey, defaultValue);
- if (pOutputValue)
- {
- if (pbModified && (*pOutputValue != intValue))
- *pbModified = TRUE;
- if (!bOnlyCheckModified)
- *pOutputValue = intValue;
- }
-}
-
-static void ConfigReadCompareString (char *configKey, char *defaultValue, char *str, int maxLen, BOOL bOnlyCheckModified, BOOL *pbModified)
-{
- char *strValue = (char*) malloc (maxLen);
- if (strValue)
- {
- memcpy (strValue, str, maxLen);
-
- ConfigReadString (configKey, defaultValue, strValue, maxLen);
-
- if (pbModified && strcmp (str, strValue))
- *pbModified = TRUE;
- if (!bOnlyCheckModified)
- memcpy(str, strValue, maxLen);
-
- free (strValue);
- }
- else
- {
- /* allocation failed. Suppose that value changed */
- if (pbModified)
- *pbModified = TRUE;
- if (!bOnlyCheckModified)
- ConfigReadString (configKey, defaultValue, str, maxLen);
-
- }
-}
-
void LoadSettingsAndCheckModified (HWND hwndDlg, BOOL bOnlyCheckModified, BOOL* pbSettingsModified, BOOL* pbHistoryModified)
{
char langid[6] = {0};
@@ -767,7 +734,7 @@ void LoadSettingsAndCheckModified (HWND hwndDlg, BOOL bOnlyCheckModified, BOOL*
if (LOWORD (lLetter) != 0xffff)
StringCbPrintfA (szTmp, sizeof(szTmp), "%c:", (char) HIWORD (lLetter));
- ConfigReadCompareString ("LastSelectedDrive", "", szDriveLetter, sizeof (szDriveLetter), bOnlyCheckModified, pbSettingsModified);
+ ConfigReadCompareString ("LastSelectedDrive", "", szTmp, sizeof (szTmp), bOnlyCheckModified, pbSettingsModified);
}
ConfigReadCompareString ("SecurityTokenLibrary", "", SecurityTokenLibraryPath, sizeof (SecurityTokenLibraryPath) - 1, bOnlyCheckModified, pbSettingsModified);
@@ -1135,7 +1102,7 @@ BOOL CheckSysEncMountWithoutPBA (HWND hwndDlg, const char *devicePath, BOOL quie
if (strlen (devicePath) < 2)
{
- GetWindowText (GetDlgItem (MainDlg, IDC_VOLUME), szDevicePath, sizeof (szDevicePath));
+ GetVolumePath (MainDlg, szDevicePath, sizeof (szDevicePath));
CreateFullVolumePath (szDiskFile, sizeof(szDiskFile), szDevicePath, &tmpbDevice);
if (!tmpbDevice)
@@ -1622,7 +1589,11 @@ void LoadDriveLetters (HWND hwndDlg, HWND hTree, int drive)
listItem.iSubItem = 1;
- wstring label = GetFavoriteVolumeLabel (path);
+ // first check label used for mounting. If empty, look for it in favorites.
+ bool useInExplorer = false;
+ wstring label = (wchar_t *) driver.wszLabel[i];
+ if (label.empty())
+ label = GetFavoriteVolumeLabel (path, useInExplorer);
if (!label.empty())
ListSubItemSetW (hTree, listItem.iItem, 1, (wchar_t *) label.c_str());
else
@@ -1898,6 +1869,13 @@ BOOL CALLBACK PasswordChangeDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
PimValueChangedWarning = FALSE;
ZeroMemory (&newKeyFilesParam, sizeof (newKeyFilesParam));
+ if (NewPimValuePtr)
+ {
+ /* we are in the case of a volume. Store its name to use it in the key file dialog
+ * this will help avoid using the current container file as a key file
+ */
+ StringCbCopyA (newKeyFilesParam.VolumeFileName, sizeof (newKeyFilesParam.VolumeFileName), szFileName);
+ }
SetWindowTextW (hwndDlg, GetString ("IDD_PASSWORDCHANGE_DLG"));
LocalizeDialog (hwndDlg, "IDD_PASSWORDCHANGE_DLG");
@@ -1979,7 +1957,7 @@ BOOL CALLBACK PasswordChangeDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
EnableWindow (GetDlgItem (hwndDlg, IDC_SHOW_PASSWORD_CHPWD_NEW), FALSE);
EnableWindow (GetDlgItem (hwndDlg, IDT_NEW_PASSWORD), FALSE);
EnableWindow (GetDlgItem (hwndDlg, IDT_CONFIRM_PASSWORD), FALSE);
- EnableWindow (GetDlgItem (hwndDlg, IDT_PKCS5_PRF), FALSE);
+ EnableWindow (GetDlgItem (hwndDlg, IDT_NEW_PKCS5_PRF), FALSE);
EnableWindow (GetDlgItem (hwndDlg, IDC_PKCS5_PRF_ID), FALSE);
break;
@@ -2002,7 +1980,7 @@ BOOL CALLBACK PasswordChangeDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
EnableWindow (GetDlgItem (hwndDlg, IDC_NEW_KEYFILES), FALSE);
EnableWindow (GetDlgItem (hwndDlg, IDT_NEW_PASSWORD), FALSE);
EnableWindow (GetDlgItem (hwndDlg, IDT_CONFIRM_PASSWORD), FALSE);
- EnableWindow (GetDlgItem (hwndDlg, IDT_PKCS5_PRF), FALSE);
+ EnableWindow (GetDlgItem (hwndDlg, IDT_NEW_PKCS5_PRF), FALSE);
EnableWindow (GetDlgItem (hwndDlg, IDC_PKCS5_PRF_ID), FALSE);
break;
@@ -2340,26 +2318,14 @@ BOOL CALLBACK PasswordChangeDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
if (lw == IDC_SHOW_PASSWORD_CHPWD_ORI)
{
- SendMessage (GetDlgItem (hwndDlg, IDC_OLD_PASSWORD),
- EM_SETPASSWORDCHAR,
- GetCheckBox (hwndDlg, IDC_SHOW_PASSWORD_CHPWD_ORI) ? 0 : '*',
- 0);
- InvalidateRect (GetDlgItem (hwndDlg, IDC_OLD_PASSWORD), NULL, TRUE);
+ HandleShowPasswordFieldAction (hwndDlg, IDC_SHOW_PASSWORD_CHPWD_ORI, IDC_OLD_PASSWORD, IDC_OLD_PIM);
return 1;
}
if (lw == IDC_SHOW_PASSWORD_CHPWD_NEW)
{
- SendMessage (GetDlgItem (hwndDlg, IDC_PASSWORD),
- EM_SETPASSWORDCHAR,
- GetCheckBox (hwndDlg, IDC_SHOW_PASSWORD_CHPWD_NEW) ? 0 : '*',
- 0);
- SendMessage (GetDlgItem (hwndDlg, IDC_VERIFY),
- EM_SETPASSWORDCHAR,
- GetCheckBox (hwndDlg, IDC_SHOW_PASSWORD_CHPWD_NEW) ? 0 : '*',
- 0);
- InvalidateRect (GetDlgItem (hwndDlg, IDC_PASSWORD), NULL, TRUE);
- InvalidateRect (GetDlgItem (hwndDlg, IDC_VERIFY), NULL, TRUE);
+ HandleShowPasswordFieldAction (hwndDlg, IDC_SHOW_PASSWORD_CHPWD_NEW, IDC_PASSWORD, IDC_VERIFY);
+ HandleShowPasswordFieldAction (hwndDlg, IDC_SHOW_PASSWORD_CHPWD_NEW, IDC_PIM, 0);
return 1;
}
@@ -2418,7 +2384,7 @@ BOOL CALLBACK PasswordChangeDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
return 1;
}
- GetWindowText (GetDlgItem (hParent, IDC_VOLUME), szFileName, sizeof (szFileName));
+ GetVolumePath (hParent, szFileName, sizeof (szFileName));
GetWindowText (GetDlgItem (hwndDlg, IDC_OLD_PASSWORD), (LPSTR) oldPassword.Text, sizeof (oldPassword.Text));
oldPassword.Length = (unsigned __int32) strlen ((char *) oldPassword.Text);
@@ -2441,11 +2407,11 @@ BOOL CALLBACK PasswordChangeDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
WaitCursor ();
if (KeyFilesEnable)
- KeyFilesApply (hwndDlg, &oldPassword, FirstKeyFile);
+ KeyFilesApply (hwndDlg, &oldPassword, FirstKeyFile, szFileName);
if (newKeyFilesParam.EnableKeyFiles)
{
- if (!KeyFilesApply (hwndDlg, &newPassword, pwdChangeDlgMode == PCDM_CHANGE_PKCS5_PRF ? FirstKeyFile : newKeyFilesParam.FirstKeyFile))
+ if (!KeyFilesApply (hwndDlg, &newPassword, pwdChangeDlgMode == PCDM_CHANGE_PKCS5_PRF ? FirstKeyFile : newKeyFilesParam.FirstKeyFile, szFileName))
{
nStatus = ERR_DONT_REPORT;
goto err;
@@ -2547,10 +2513,13 @@ BOOL CALLBACK PasswordDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa
RECT rect;
GetWindowRect (hwndDlg, &rect);
- wstring label = GetFavoriteVolumeLabel (PasswordDlgVolume);
+ bool useInExplorer = false;
+ wstring label = GetFavoriteVolumeLabel (PasswordDlgVolume, useInExplorer);
if (!label.empty())
{
StringCbPrintfW (s, sizeof(s), GetString ("ENTER_PASSWORD_FOR_LABEL"), label.c_str());
+ if (useInExplorer)
+ StringCbCopyW (mountOptions.Label, sizeof (mountOptions.Label), label.c_str());
}
else
{
@@ -2686,10 +2655,13 @@ BOOL CALLBACK PasswordDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa
return 1;
}
- SetCheckBox (hwndDlg, IDC_SHOW_PASSWORD, FALSE);
+ if (GetCheckBox (hwndDlg, IDC_SHOW_PASSWORD))
+ {
+ // simulate hiding password
+ SetCheckBox (hwndDlg, IDC_SHOW_PASSWORD, FALSE);
- SendMessage (GetDlgItem (hwndDlg, IDC_PASSWORD), EM_SETPASSWORDCHAR, '*', 0);
- InvalidateRect (GetDlgItem (hwndDlg, IDC_PASSWORD), NULL, TRUE);
+ HandleShowPasswordFieldAction (hwndDlg, IDC_SHOW_PASSWORD, IDC_PASSWORD, IDC_PIM);
+ }
SetCheckBox (hwndDlg, IDC_KEYFILES_ENABLE, FALSE);
EnableWindow (GetDlgItem (hwndDlg, IDC_KEYFILES_ENABLE), FALSE);
@@ -2771,11 +2743,7 @@ BOOL CALLBACK PasswordDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa
if (lw == IDC_SHOW_PASSWORD)
{
- SendMessage (GetDlgItem (hwndDlg, IDC_PASSWORD),
- EM_SETPASSWORDCHAR,
- GetCheckBox (hwndDlg, IDC_SHOW_PASSWORD) ? 0 : '*',
- 0);
- InvalidateRect (GetDlgItem (hwndDlg, IDC_PASSWORD), NULL, TRUE);
+ HandleShowPasswordFieldAction (hwndDlg, IDC_SHOW_PASSWORD, IDC_PASSWORD, IDC_PIM);
return 1;
}
@@ -2820,7 +2788,7 @@ BOOL CALLBACK PasswordDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa
if (lw == IDOK)
{
if (mountOptions.ProtectHiddenVolume && hidVolProtKeyFilesParam.EnableKeyFiles)
- KeyFilesApply (hwndDlg, &mountOptions.ProtectedHidVolPassword, hidVolProtKeyFilesParam.FirstKeyFile);
+ KeyFilesApply (hwndDlg, &mountOptions.ProtectedHidVolPassword, hidVolProtKeyFilesParam.FirstKeyFile, strlen (PasswordDlgVolume) > 0 ? PasswordDlgVolume : NULL);
GetWindowText (GetDlgItem (hwndDlg, IDC_PASSWORD), (LPSTR) szXPwd->Text, MAX_PASSWORD + 1);
szXPwd->Length = (unsigned __int32) strlen ((char *) szXPwd->Text);
@@ -3199,6 +3167,9 @@ BOOL CALLBACK MountOptionsDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM
EnableWindow (GetDlgItem (hwndDlg, IDC_MOUNT_SYSENC_PART_WITHOUT_PBA), !bPrebootPasswordDlgMode);
+ SetDlgItemTextW (hwndDlg, IDC_VOLUME_LABEL, mountOptions->Label);
+ SendDlgItemMessage (hwndDlg, IDC_VOLUME_LABEL, EM_LIMITTEXT, 32, 0); // 32 is the maximum possible length for a drive label in Windows
+
/* Add PRF algorithm list for hidden volume password */
HWND hComboBox = GetDlgItem (hwndDlg, IDC_PKCS5_PRF_ID);
SendMessage (hComboBox, CB_RESETCONTENT, 0, 0);
@@ -3300,11 +3271,7 @@ BOOL CALLBACK MountOptionsDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM
if (lw == IDC_SHOW_PASSWORD_MO)
{
- SendMessage (GetDlgItem (hwndDlg, IDC_PASSWORD_PROT_HIDVOL),
- EM_SETPASSWORDCHAR,
- GetCheckBox (hwndDlg, IDC_SHOW_PASSWORD_MO) ? 0 : '*',
- 0);
- InvalidateRect (GetDlgItem (hwndDlg, IDC_PASSWORD_PROT_HIDVOL), NULL, TRUE);
+ HandleShowPasswordFieldAction (hwndDlg, IDC_SHOW_PASSWORD_MO, IDC_PASSWORD_PROT_HIDVOL, IDC_PIM);
return 1;
}
@@ -3344,6 +3311,8 @@ BOOL CALLBACK MountOptionsDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM
mountOptions->ProtectHiddenVolume = IsButtonChecked (GetDlgItem (hwndDlg, IDC_PROTECT_HIDDEN_VOL));
mountOptions->PartitionInInactiveSysEncScope = IsButtonChecked (GetDlgItem (hwndDlg, IDC_MOUNT_SYSENC_PART_WITHOUT_PBA));
mountOptions->UseBackupHeader = IsButtonChecked (GetDlgItem (hwndDlg, IDC_USE_EMBEDDED_HEADER_BAK));
+
+ GetDlgItemTextW (hwndDlg, IDC_VOLUME_LABEL, mountOptions->Label, sizeof (mountOptions->Label) /sizeof (wchar_t));
if (mountOptions->ProtectHiddenVolume)
{
@@ -4241,7 +4210,7 @@ static BOOL Mount (HWND hwndDlg, int nDosDriveNo, char *szFileName, int pim)
if (szFileName == NULL)
{
- GetWindowText (GetDlgItem (hwndDlg, IDC_VOLUME), fileName, sizeof (fileName));
+ GetVolumePath (hwndDlg, fileName, sizeof (fileName));
szFileName = fileName;
}
@@ -4284,7 +4253,7 @@ static BOOL Mount (HWND hwndDlg, int nDosDriveNo, char *szFileName, int pim)
Password emptyPassword;
emptyPassword.Length = 0;
- KeyFilesApply (hwndDlg, &emptyPassword, FirstKeyFile);
+ KeyFilesApply (hwndDlg, &emptyPassword, FirstKeyFile, szFileName);
// try TrueCrypt mode first since it is quick, only if pim = 0
if (EffectiveVolumePim == 0)
mounted = MountVolume (hwndDlg, nDosDriveNo, szFileName, &emptyPassword, 0, 0, TRUE, bCacheInDriver, bForceMount, &mountOptions, Silent, FALSE);
@@ -4346,7 +4315,7 @@ static BOOL Mount (HWND hwndDlg, int nDosDriveNo, char *szFileName, int pim)
WaitCursor ();
if (KeyFilesEnable)
- KeyFilesApply (hwndDlg, &VolumePassword, FirstKeyFile);
+ KeyFilesApply (hwndDlg, &VolumePassword, FirstKeyFile, szFileName);
mounted = MountVolume (hwndDlg, nDosDriveNo, szFileName, &VolumePassword, VolumePkcs5, VolumePim, VolumeTrueCryptMode, bCacheInDriver, bForceMount, &mountOptions, Silent, !Silent);
NormalCursor ();
@@ -4464,7 +4433,7 @@ static BOOL DismountAll (HWND hwndDlg, BOOL forceUnmount, BOOL interact, int dis
DWORD dwResult;
UNMOUNT_STRUCT unmount = {0};
BOOL bResult;
- unsigned __int32 prevMountedDrives = 0;
+ MOUNT_LIST_STRUCT prevMountList = {0};
int i;
retry:
@@ -4480,7 +4449,7 @@ retry:
BroadcastDeviceChange (DBT_DEVICEREMOVEPENDING, 0, mountList.ulMountedDrives);
- prevMountedDrives = mountList.ulMountedDrives;
+ memcpy (&prevMountList, &mountList, sizeof (mountList));
for (i = 0; i < 26; i++)
{
@@ -4541,7 +4510,17 @@ retry:
memset (&mountList, 0, sizeof (mountList));
DeviceIoControl (hDriver, TC_IOCTL_GET_MOUNTED_VOLUMES, &mountList, sizeof (mountList), &mountList, sizeof (mountList), &dwResult, NULL);
- BroadcastDeviceChange (DBT_DEVICEREMOVECOMPLETE, 0, prevMountedDrives & ~mountList.ulMountedDrives);
+
+ // remove any custom label from registry
+ for (i = 0; i < 26; i++)
+ {
+ if ((prevMountList.ulMountedDrives & (1 << i)) && (!(mountList.ulMountedDrives & (1 << i))) && wcslen (prevMountList.wszLabel[i]))
+ {
+ UpdateDriveCustomLabel (i, prevMountList.wszLabel[i], FALSE);
+ }
+ }
+
+ BroadcastDeviceChange (DBT_DEVICEREMOVECOMPLETE, 0, prevMountList.ulMountedDrives & ~mountList.ulMountedDrives);
RefreshMainDlg (hwndDlg);
@@ -4656,9 +4635,9 @@ static BOOL MountAllDevicesThreadCode (HWND hwndDlg, BOOL bPasswordPrompt)
WaitCursor();
if (FirstCmdKeyFile)
- KeyFilesApply (hwndDlg, &VolumePassword, FirstCmdKeyFile);
+ KeyFilesApply (hwndDlg, &VolumePassword, FirstCmdKeyFile, NULL);
else if (KeyFilesEnable)
- KeyFilesApply (hwndDlg, &VolumePassword, FirstKeyFile);
+ KeyFilesApply (hwndDlg, &VolumePassword, FirstKeyFile, NULL);
}
@@ -4871,7 +4850,7 @@ static void ChangePassword (HWND hwndDlg)
INT_PTR result;
int newPimValue = -1;
- GetWindowText (GetDlgItem (hwndDlg, IDC_VOLUME), szFileName, sizeof (szFileName));
+ GetVolumePath (hwndDlg, szFileName, sizeof (szFileName));
if (IsMountedVolume (szFileName))
{
Warning (pwdChangeDlgMode == PCDM_CHANGE_PKCS5_PRF ? "MOUNTED_NO_PKCS5_PRF_CHANGE" : "MOUNTED_NOPWCHANGE", hwndDlg);
@@ -5216,7 +5195,7 @@ static void DecryptNonSysDevice (HWND hwndDlg, BOOL bResolveAmbiguousSelection,
char volPath [TC_MAX_PATH];
- GetWindowText (GetDlgItem (MainDlg, IDC_VOLUME), volPath, sizeof (volPath));
+ GetVolumePath (MainDlg, volPath, sizeof (volPath));
scPath = volPath;
}
@@ -5895,7 +5874,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
BOOL reportBadPasswd = CmdVolumePassword.Length > 0;
if (FirstCmdKeyFile)
- KeyFilesApply (hwndDlg, &CmdVolumePassword, FirstCmdKeyFile);
+ KeyFilesApply (hwndDlg, &CmdVolumePassword, FirstCmdKeyFile, szFileName);
mounted = MountVolume (hwndDlg, szDriveLetter[0] - 'A',
szFileName, &CmdVolumePassword, EffectiveVolumePkcs5, CmdVolumePim, EffectiveVolumeTrueCryptMode, bCacheInDriver, bForceMount,
@@ -5934,7 +5913,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
WaitCursor ();
if (KeyFilesEnable && FirstKeyFile)
- KeyFilesApply (hwndDlg, &VolumePassword, FirstKeyFile);
+ KeyFilesApply (hwndDlg, &VolumePassword, FirstKeyFile, szFileName);
mounted = MountVolume (hwndDlg, szDriveLetter[0] - 'A', szFileName, &VolumePassword, VolumePkcs5, VolumePim, VolumeTrueCryptMode, bCacheInDriver, bForceMount, &mountOptions, FALSE, TRUE);
@@ -6438,7 +6417,11 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
if (wcsstr (vol, L"\\??\\")) vol += 4;
- wstring label = GetFavoriteVolumeLabel (WideToSingleString (vol));
+ // first check label used for mounting. If empty, look for it in favorites.
+ bool useInExplorer = false;
+ wstring label = (wchar_t *) LastKnownMountList.wszLabel[i];
+ if (label.empty())
+ label = GetFavoriteVolumeLabel (WideToSingleString (vol), useInExplorer);
StringCbPrintfW (s, sizeof(s), L"%s %c: (%s)",
GetString (n==0 ? "OPEN" : "DISMOUNT"),
@@ -6668,7 +6651,11 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
return 1;
if (mountOptions.ProtectHiddenVolume && hidVolProtKeyFilesParam.EnableKeyFiles)
- KeyFilesApply (hwndDlg, &mountOptions.ProtectedHidVolPassword, hidVolProtKeyFilesParam.FirstKeyFile);
+ {
+ char selectedVolume [TC_MAX_PATH + 1];
+ GetVolumePath (hwndDlg, selectedVolume, sizeof (selectedVolume));
+ KeyFilesApply (hwndDlg, &mountOptions.ProtectedHidVolPassword, hidVolProtKeyFilesParam.FirstKeyFile, selectedVolume);
+ }
}
if (CheckMountList (hwndDlg, FALSE))
@@ -7063,7 +7050,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
}
else
{
- GetWindowText (GetDlgItem (hwndDlg, IDC_VOLUME), volPath, sizeof (volPath));
+ GetVolumePath (hwndDlg, volPath, sizeof (volPath));
WaitCursor ();
@@ -7086,7 +7073,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
}
else
{
- GetWindowText (GetDlgItem (hwndDlg, IDC_VOLUME), volPath, sizeof (volPath));
+ GetVolumePath (hwndDlg, volPath, sizeof (volPath));
WaitCursor ();
@@ -7362,7 +7349,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
wchar_t volPathLowerW[TC_MAX_PATH];
// volPathLower will contain the volume path (if any) from the input field below the drive list
- GetWindowText (GetDlgItem (hwndDlg, IDC_VOLUME), volPathLower, sizeof (volPathLower));
+ GetVolumePath (hwndDlg, volPathLower, sizeof (volPathLower));
if (LOWORD (selectedDrive) != TC_MLIST_ITEM_NONSYS_VOL
&& !(VolumeSelected (hwndDlg) && IsMountedVolume (volPathLower)))
@@ -7508,7 +7495,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
{
char volPath[TC_MAX_PATH]; /* Volume to mount */
- GetWindowText (GetDlgItem (hwndDlg, IDC_VOLUME), volPath, sizeof (volPath));
+ GetVolumePath (hwndDlg, volPath, sizeof (volPath));
WaitCursor ();
@@ -7535,7 +7522,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
{
char volPath[TC_MAX_PATH]; /* Volume to mount */
- GetWindowText (GetDlgItem (hwndDlg, IDC_VOLUME), volPath, sizeof (volPath));
+ GetVolumePath (hwndDlg, volPath, sizeof (volPath));
WaitCursor ();
@@ -7979,7 +7966,7 @@ void ExtractCommandLine (HWND hwndDlg, char *lpszCommandLine)
case OptionMountOption:
{
- char szTmp[16] = {0};
+ char szTmp[64] = {0};
if (HAS_ARGUMENT == GetArgumentValue (lpszCommandLineArgs,
&i, nNoCommandLineArgs, szTmp, sizeof (szTmp)))
{
@@ -8000,7 +7987,12 @@ void ExtractCommandLine (HWND hwndDlg, char *lpszCommandLine)
else if (!_stricmp (szTmp, "recovery"))
mountOptions.RecoveryMode = TRUE;
-
+ else if ((strlen(szTmp) > 6) && (strlen(szTmp) <= 38) && !_strnicmp (szTmp, "label=", 6))
+ {
+ // get the label
+ memmove (szTmp, &szTmp[6], (strlen(szTmp) - 6) + 1);
+ MultiByteToWideChar (CP_ACP, 0, szTmp, -1, mountOptions.Label, sizeof (mountOptions.Label) / sizeof(wchar_t));
+ }
else
AbortProcess ("COMMAND_LINE_ERROR");
@@ -8508,6 +8500,10 @@ static BOOL MountFavoriteVolumeBase (const FavoriteVolume &favorite, BOOL& lastb
mountOptions.ReadOnly = favorite.ReadOnly || userForcedReadOnly;
mountOptions.Removable = favorite.Removable;
+ if (favorite.UseLabelInExplorer && !favorite.Label.empty())
+ StringCbCopyW (mountOptions.Label, sizeof (mountOptions.Label), favorite.Label.c_str());
+ else
+ ZeroMemory (mountOptions.Label, sizeof (mountOptions.Label));
if (favorite.SystemEncryption)
{
@@ -9019,7 +9015,7 @@ int BackupVolumeHeader (HWND hwndDlg, BOOL bRequireConfirmation, const char *lps
WaitCursor();
if (KeyFilesEnable && FirstKeyFile)
- KeyFilesApply (hwndDlg, askPassword, FirstKeyFile);
+ KeyFilesApply (hwndDlg, askPassword, FirstKeyFile, lpszVolume);
nStatus = OpenVolume (askVol, lpszVolume, askPassword, *askPkcs5, *askPim, VolumeTrueCryptMode, FALSE, bPreserveTimestamp, FALSE);
@@ -9290,7 +9286,7 @@ int RestoreVolumeHeader (HWND hwndDlg, const char *lpszVolume)
WaitCursor();
if (KeyFilesEnable && FirstKeyFile)
- KeyFilesApply (hwndDlg, &VolumePassword, FirstKeyFile);
+ KeyFilesApply (hwndDlg, &VolumePassword, FirstKeyFile, lpszVolume);
nStatus = OpenVolume (&volume, lpszVolume, &VolumePassword, VolumePkcs5, VolumePim, VolumeTrueCryptMode,TRUE, bPreserveTimestamp, TRUE);
@@ -9490,7 +9486,7 @@ int RestoreVolumeHeader (HWND hwndDlg, const char *lpszVolume)
}
if (KeyFilesEnable && FirstKeyFile)
- KeyFilesApply (hwndDlg, &VolumePassword, FirstKeyFile);
+ KeyFilesApply (hwndDlg, &VolumePassword, FirstKeyFile, bDevice? NULL : lpszVolume);
// Decrypt volume header
headerOffsetBackupFile = 0;
@@ -10172,7 +10168,11 @@ void MountSelectedVolume (HWND hwndDlg, BOOL mountWithOptions)
return;
if (mountOptions.ProtectHiddenVolume && hidVolProtKeyFilesParam.EnableKeyFiles)
- KeyFilesApply (hwndDlg, &mountOptions.ProtectedHidVolPassword, hidVolProtKeyFilesParam.FirstKeyFile);
+ {
+ char selectedVolume [TC_MAX_PATH + 1];
+ GetVolumePath (hwndDlg, selectedVolume, sizeof (selectedVolume));
+ KeyFilesApply (hwndDlg, &mountOptions.ProtectedHidVolPassword, hidVolProtKeyFilesParam.FirstKeyFile, selectedVolume);
+ }
}
if (CheckMountList (hwndDlg, FALSE))