VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Boot/Windows/BootMain.cpp9
-rw-r--r--src/Common/Apidrvr.h6
-rw-r--r--src/Common/Common.h1
-rw-r--r--src/Common/Common.rc34
-rw-r--r--src/Common/Dlgcode.c168
-rw-r--r--src/Common/Dlgcode.h5
-rw-r--r--src/Common/Keyfiles.c31
-rw-r--r--src/Common/Keyfiles.h3
-rw-r--r--src/Common/Language.xml3
-rw-r--r--src/Common/Resource.h4
-rw-r--r--src/Driver/Ntdriver.c62
-rw-r--r--src/Driver/Ntdriver.h3
-rw-r--r--src/Driver/Ntvol.c3
-rw-r--r--src/ExpandVolume/DlgExpandVolume.cpp6
-rw-r--r--src/ExpandVolume/WinMain.cpp23
-rw-r--r--src/Format/Format.rc11
-rw-r--r--src/Format/Resource.h3
-rw-r--r--src/Format/Tcformat.c54
-rw-r--r--src/Mount/Favorites.cpp28
-rw-r--r--src/Mount/Favorites.h6
-rw-r--r--src/Mount/Hotkeys.c76
-rw-r--r--src/Mount/Mount.c208
-rw-r--r--src/Mount/Mount.rc39
-rw-r--r--src/Mount/Resource.h4
24 files changed, 566 insertions, 224 deletions
diff --git a/src/Boot/Windows/BootMain.cpp b/src/Boot/Windows/BootMain.cpp
index d2494e8f..7101139d 100644
--- a/src/Boot/Windows/BootMain.cpp
+++ b/src/Boot/Windows/BootMain.cpp
@@ -64,7 +64,7 @@ static void PrintMainMenu ()
return;
Print (" Keyboard Controls:\r\n");
- Print (" [F5] Hide/Show Password\r\n");
+ Print (" [F5] Hide/Show Password and PIM\r\n");
Print (" [Esc] ");
#ifndef TC_WINDOWS_BOOT_RESCUE_DISK_MODE
@@ -246,6 +246,10 @@ static byte AskPassword (Password &password, int& pim)
}
continue;
+ case TC_BIOS_KEY_F5:
+ hidePassword ^= 0x01;
+ continue;
+
default:
if (scanCode == TC_BIOS_KEY_ESC || IsMenuKey (scanCode))
{
@@ -265,7 +269,8 @@ static byte AskPassword (Password &password, int& pim)
pim = 10*pim + (asciiCode - '0');
pos++;
-
+
+ if (hidePassword) asciiCode = '*';
if (pos < MAX_PIM)
PrintChar (asciiCode);
else
diff --git a/src/Common/Apidrvr.h b/src/Common/Apidrvr.h
index 750201da..c49eafa9 100644
--- a/src/Common/Apidrvr.h
+++ b/src/Common/Apidrvr.h
@@ -109,6 +109,9 @@ typedef struct
uint32 BytesPerPhysicalSector;
int VolumePim;
int ProtectedHidVolPim;
+ wchar_t wszLabel[33]; // maximum label length is 32 for NTFS and 11 for FAT32
+ BOOL bIsNTFS; // output only
+ BOOL bDriverSetLabel;
} MOUNT_STRUCT;
typedef struct
@@ -123,6 +126,7 @@ typedef struct
{
unsigned __int32 ulMountedDrives; /* Bitfield of all mounted drive letters */
wchar_t wszVolume[26][TC_MAX_PATH]; /* Volume names of mounted volumes */
+ wchar_t wszLabel[26][33]; /* Labels of mounted volumes */
unsigned __int64 diskLength[26];
int ea[26];
int volumeType[26]; /* Volume type (e.g. PROP_VOL_TYPE_OUTER, PROP_VOL_TYPE_OUTER_VOL_WRITE_PREVENTED, etc.) */
@@ -149,6 +153,8 @@ typedef struct
int hiddenVolProtection; /* Hidden volume protection status (e.g. HIDVOL_PROT_STATUS_NONE, HIDVOL_PROT_STATUS_ACTIVE, etc.) */
int volFormatVersion;
int volumePim;
+ wchar_t wszLabel[33];
+ BOOL bDriverSetLabel;
} VOLUME_PROPERTIES_STRUCT;
typedef struct
diff --git a/src/Common/Common.h b/src/Common/Common.h
index 6f8a2dca..e930e253 100644
--- a/src/Common/Common.h
+++ b/src/Common/Common.h
@@ -81,6 +81,7 @@ typedef struct
BOOL RecoveryMode;
int ProtectedHidVolPkcs5Prf;
int ProtectedHidVolPim;
+ wchar_t Label[33]; /* maximum label length is 32 for NTFS and 11 for FAT32 */
} MountOptions;
#endif
diff --git a/src/Common/Common.rc b/src/Common/Common.rc
index 652b407f..5ed6c7c4 100644
--- a/src/Common/Common.rc
+++ b/src/Common/Common.rc
@@ -65,7 +65,7 @@ BEGIN
PUSHBUTTON "Cancel",IDCANCEL,248,190,50,14
END
-IDD_MOUNT_OPTIONS DIALOGEX 0, 0, 277, 224
+IDD_MOUNT_OPTIONS DIALOGEX 0, 0, 277, 231
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "VeraCrypt - Mount Options"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
@@ -78,22 +78,24 @@ BEGIN
CONTROL "Mount partition &using system encryption without pre-boot authentication",IDC_MOUNT_SYSENC_PART_WITHOUT_PBA,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,53,259,11
CONTROL "&Protect hidden volume against damage caused by writing to outer volume",IDC_PROTECT_HIDDEN_VOL,
- "Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,86,252,10
- EDITTEXT IDC_PASSWORD_PROT_HIDVOL,112,104,151,14,ES_PASSWORD | ES_AUTOHSCROLL
- COMBOBOX IDC_PKCS5_PRF_ID,112,125,91,90,CBS_DROPDOWNLIST | WS_TABSTOP
- EDITTEXT IDC_PIM,112,145,42,14,ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER | NOT WS_VISIBLE
- LTEXT "(Empty or 0 for default iterations)",IDC_PIM_HELP,158,148,112,8,NOT WS_VISIBLE
- CONTROL "&Display password",IDC_SHOW_PASSWORD_MO,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,112,165,90,10
- CONTROL "U&se keyfiles",IDC_KEYFILES_ENABLE_HIDVOL_PROT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,112,178,90,10
- PUSHBUTTON "&Keyfiles...",IDC_KEYFILES_HIDVOL_PROT,204,174,60,14
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,97,252,10
+ EDITTEXT IDC_PASSWORD_PROT_HIDVOL,112,115,151,14,ES_PASSWORD | ES_AUTOHSCROLL
+ COMBOBOX IDC_PKCS5_PRF_ID,112,136,91,90,CBS_DROPDOWNLIST | WS_TABSTOP
+ EDITTEXT IDC_PIM,112,156,42,14,ES_RIGHT | ES_PASSWORD | ES_AUTOHSCROLL | ES_NUMBER | NOT WS_VISIBLE
+ LTEXT "(Empty or 0 for default iterations)",IDC_PIM_HELP,158,159,112,8,NOT WS_VISIBLE
+ CONTROL "&Display password",IDC_SHOW_PASSWORD_MO,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,112,174,90,10
+ CONTROL "U&se keyfiles",IDC_KEYFILES_ENABLE_HIDVOL_PROT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,112,187,90,10
+ PUSHBUTTON "&Keyfiles...",IDC_KEYFILES_HIDVOL_PROT,204,183,60,14
DEFPUSHBUTTON "OK",IDOK,211,7,60,14
PUSHBUTTON "Cancel",IDCANCEL,211,24,60,14
- LTEXT "What is hidden volume protection?",IDC_LINK_HIDVOL_PROTECTION_INFO,16,193,247,10,SS_NOTIFY
- RTEXT "P&assword to hidden volume:\n(if empty, cache is used)",IDT_HIDDEN_PROT_PASSWD,15,103,91,17,0,WS_EX_RIGHT
- GROUPBOX "Hidden Volume Protection",IDT_HIDDEN_VOL_PROTECTION,6,72,265,139
- RTEXT "PKCS-5 PRF:",IDT_PKCS5_PRF,15,126,91,17
- RTEXT "Volume PIM:",IDT_PIM,15,148,91,17,NOT WS_VISIBLE
- CONTROL "Use PIM",IDC_PIM_ENABLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,112,152,97,10
+ LTEXT "What is hidden volume protection?",IDC_LINK_HIDVOL_PROTECTION_INFO,16,202,247,10,SS_NOTIFY
+ RTEXT "P&assword to hidden volume:\n(if empty, cache is used)",IDT_HIDDEN_PROT_PASSWD,15,114,91,17,0,WS_EX_RIGHT
+ GROUPBOX "Hidden Volume Protection",IDT_HIDDEN_VOL_PROTECTION,6,83,265,136
+ RTEXT "PKCS-5 PRF:",IDT_PKCS5_PRF,15,137,91,17
+ RTEXT "Volume PIM:",IDT_PIM,15,159,91,17,NOT WS_VISIBLE
+ CONTROL "Use PIM",IDC_PIM_ENABLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,112,161,97,10
+ LTEXT "Volume Label in Windows:",IDT_VOLUME_LABEL,12,70,95,8
+ EDITTEXT IDC_VOLUME_LABEL,112,67,150,14,ES_AUTOHSCROLL
END
IDD_KEYFILES DIALOGEX 0, 0, 345, 237
@@ -352,7 +354,7 @@ BEGIN
BEGIN
LEFTMARGIN, 7
TOPMARGIN, 7
- BOTTOMMARGIN, 218
+ BOTTOMMARGIN, 225
END
IDD_KEYFILES, DIALOG
diff --git a/src/Common/Dlgcode.c b/src/Common/Dlgcode.c
index 74a2c831..02b67c5f 100644
--- a/src/Common/Dlgcode.c
+++ b/src/Common/Dlgcode.c
@@ -88,6 +88,8 @@ HFONT hUserUnderlineBoldFont = NULL;
HFONT WindowTitleBarFont;
+WCHAR EditPasswordChar = 0;
+
int ScreenDPI = USER_DEFAULT_SCREEN_DPI;
double DPIScaleFactorX = 1;
double DPIScaleFactorY = 1;
@@ -873,7 +875,7 @@ static LRESULT CALLBACK BootPwdFieldProc (HWND hwnd, UINT message, WPARAM wParam
return 1;
}
- return CallWindowProc (wp, hwnd, message, wParam, lParam);
+ return CallWindowProcW (wp, hwnd, message, wParam, lParam);
}
@@ -884,8 +886,8 @@ void ToBootPwdField (HWND hwndDlg, UINT ctrlId)
{
HWND hwndCtrl = GetDlgItem (hwndDlg, ctrlId);
- SetWindowLongPtr (hwndCtrl, GWLP_USERDATA, (LONG_PTR) GetWindowLongPtr (hwndCtrl, GWLP_WNDPROC));
- SetWindowLongPtr (hwndCtrl, GWLP_WNDPROC, (LONG_PTR) BootPwdFieldProc);
+ SetWindowLongPtrW (hwndCtrl, GWLP_USERDATA, (LONG_PTR) GetWindowLongPtrW (hwndCtrl, GWLP_WNDPROC));
+ SetWindowLongPtrW (hwndCtrl, GWLP_WNDPROC, (LONG_PTR) BootPwdFieldProc);
}
@@ -3214,7 +3216,8 @@ BOOL CALLBACK RawDevicesDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l
#ifdef TCMOUNT
else
{
- wstring favoriteLabel = GetFavoriteVolumeLabel (device.Path);
+ bool useInExplorer = false;
+ wstring favoriteLabel = GetFavoriteVolumeLabel (device.Path, useInExplorer);
if (!favoriteLabel.empty())
ListSubItemSetW (hList, item.iItem, 3, (wchar_t *) favoriteLabel.c_str());
}
@@ -3223,6 +3226,11 @@ BOOL CALLBACK RawDevicesDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l
item.iItem = line++;
}
+ SendMessageW(hList, LVM_SETCOLUMNWIDTH, 0, MAKELPARAM(LVSCW_AUTOSIZE_USEHEADER, 0));
+ SendMessageW(hList, LVM_SETCOLUMNWIDTH, 1, MAKELPARAM(LVSCW_AUTOSIZE_USEHEADER, 0));
+ SendMessageW(hList, LVM_SETCOLUMNWIDTH, 2, MAKELPARAM(LVSCW_AUTOSIZE_USEHEADER, 0));
+ SendMessageW(hList, LVM_SETCOLUMNWIDTH, 3, MAKELPARAM(LVSCW_AUTOSIZE_USEHEADER, 0));
+
lpszFileName = pDlgParam->pszFileName;
#ifdef VOLFORMAT
@@ -4342,6 +4350,58 @@ BOOL CloseVolumeExplorerWindows (HWND hwnd, int driveNo)
return explorerCloseSent;
}
+BOOL UpdateDriveCustomLabel (int driveNo, wchar_t* effectiveLabel, BOOL bSetValue)
+{
+ wchar_t wszRegPath[MAX_PATH];
+ wchar_t driveStr[] = {L'A' + (wchar_t) driveNo, 0};
+ HKEY hKey;
+ LSTATUS lStatus;
+ DWORD cbLabelLen = (DWORD) ((wcslen (effectiveLabel) + 1) * sizeof (wchar_t));
+ BOOL bToBeDeleted = FALSE;
+
+ StringCbPrintfW (wszRegPath, sizeof (wszRegPath), L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\DriveIcons\\%s\\DefaultLabel", driveStr);
+
+ if (bSetValue)
+ lStatus = RegCreateKeyExW (HKEY_CURRENT_USER, wszRegPath, NULL, NULL, 0,
+ KEY_READ | KEY_WRITE | KEY_SET_VALUE, NULL, &hKey, NULL);
+ else
+ lStatus = RegOpenKeyExW (HKEY_CURRENT_USER, wszRegPath, 0, KEY_READ | KEY_WRITE | KEY_SET_VALUE, &hKey);
+ if (ERROR_SUCCESS == lStatus)
+ {
+ if (bSetValue)
+ lStatus = RegSetValueExW (hKey, NULL, NULL, REG_SZ, (LPCBYTE) effectiveLabel, cbLabelLen);
+ else
+ {
+ wchar_t storedLabel[34] = {0};
+ DWORD cbStoredLen = sizeof (storedLabel) - 1, dwType;
+ lStatus = RegQueryValueExW (hKey, NULL, NULL, &dwType, (LPBYTE) storedLabel, &cbStoredLen);
+ if ((ERROR_SUCCESS == lStatus) && (REG_SZ == dwType) && (0 == wcscmp(storedLabel, effectiveLabel)))
+ {
+ // same label stored. mark key for deletion
+ bToBeDeleted = TRUE;
+ }
+ }
+ RegCloseKey (hKey);
+ }
+
+ if (bToBeDeleted)
+ {
+ StringCbPrintfW (wszRegPath, sizeof (wszRegPath), L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\DriveIcons\\%s", driveStr);
+ lStatus = RegOpenKeyExW (HKEY_CURRENT_USER, wszRegPath, 0, KEY_READ | KEY_WRITE | KEY_SET_VALUE, &hKey);
+ if (ERROR_SUCCESS == lStatus)
+ {
+ lStatus = RegDeleteKeyExW (hKey, L"DefaultLabel", 0, NULL);
+ RegCloseKey (hKey);
+ }
+
+ // delete drive letter of nothing else is present under it
+ RegDeleteKeyExW (HKEY_CURRENT_USER, wszRegPath, 0, NULL);
+
+ }
+
+ return (ERROR_SUCCESS == lStatus)? TRUE : FALSE;
+}
+
string GetUserFriendlyVersionString (int version)
{
char szTmp [64];
@@ -4547,6 +4607,9 @@ static void DisplayBenchmarkResults (HWND hwndDlg)
}
SendMessageW(hList, LVM_SETCOLUMNWIDTH, 0, MAKELPARAM(LVSCW_AUTOSIZE_USEHEADER, 0));
+ SendMessageW(hList, LVM_SETCOLUMNWIDTH, 1, MAKELPARAM(LVSCW_AUTOSIZE_USEHEADER, 0));
+ SendMessageW(hList, LVM_SETCOLUMNWIDTH, 2, MAKELPARAM(LVSCW_AUTOSIZE_USEHEADER, 0));
+ SendMessageW(hList, LVM_SETCOLUMNWIDTH, 3, MAKELPARAM(LVSCW_AUTOSIZE_USEHEADER, 0));
}
// specific implementation for support of benchmark operation in wait dialog mechanism
@@ -6184,6 +6247,16 @@ BOOL CheckFileExtension (char *fileName)
return FALSE;
}
+void CorrectFileName (char* fileName)
+{
+ /* replace '/' by '\' */
+ size_t i, len = strlen (fileName);
+ for (i = 0; i < len; i++)
+ {
+ if (fileName [i] == '/')
+ fileName [i] = '\\';
+ }
+}
void IncreaseWrongPwdRetryCount (int count)
{
@@ -6264,8 +6337,21 @@ int DriverUnmountVolume (HWND hwndDlg, int nDosDriveNo, BOOL forced)
{
UNMOUNT_STRUCT unmount;
DWORD dwResult;
-
+ VOLUME_PROPERTIES_STRUCT prop;
BOOL bResult;
+ WCHAR wszLabel[33] = {0};
+ BOOL bDriverSetLabel = FALSE;
+
+ memset (&prop, 0, sizeof(prop));
+ prop.driveNo = nDosDriveNo;
+
+ if ( DeviceIoControl (hDriver, TC_IOCTL_GET_VOLUME_PROPERTIES, &prop, sizeof (prop), &prop, sizeof (prop), &dwResult, NULL)
+ && prop.driveNo == nDosDriveNo
+ )
+ {
+ memcpy (wszLabel, prop.wszLabel, sizeof (wszLabel));
+ bDriverSetLabel = prop.bDriverSetLabel;
+ }
unmount.nDosDriveNo = nDosDriveNo;
unmount.ignoreOpenFiles = forced;
@@ -6278,6 +6364,8 @@ int DriverUnmountVolume (HWND hwndDlg, int nDosDriveNo, BOOL forced)
handleWin32Error (hwndDlg, SRC_POS);
return 1;
}
+ else if ((unmount.nReturnCode == ERR_SUCCESS) && bDriverSetLabel && wszLabel[0])
+ UpdateDriveCustomLabel (nDosDriveNo, wszLabel, FALSE);
#ifdef TCMOUNT
@@ -6593,6 +6681,7 @@ int MountVolume (HWND hwndDlg,
mount.SystemFavorite = MountVolumesAsSystemFavorite;
mount.UseBackupHeader = mountOptions->UseBackupHeader;
mount.RecoveryMode = mountOptions->RecoveryMode;
+ StringCbCopyW (mount.wszLabel, sizeof (mount.wszLabel), mountOptions->Label);
retry:
mount.nDosDriveNo = driveNo;
@@ -6899,6 +6988,12 @@ retry:
}
}
+ if (mount.wszLabel[0] && !mount.bDriverSetLabel)
+ {
+ // try setting the drive label on user-mode using registry
+ UpdateDriveCustomLabel (driveNo, mount.wszLabel, TRUE);
+ }
+
ResetWrongPwdRetryCount ();
BroadcastDeviceChange (DBT_DEVICEARRIVAL, driveNo, 0);
@@ -8713,9 +8808,50 @@ char *ConfigReadString (char *configKey, char *defaultValue, char *str, int maxL
if (ConfigRead (configKey, str, maxLen))
return str;
else
+ {
+ StringCbCopyA (str, maxLen, defaultValue);
return defaultValue;
+ }
}
+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;
+ }
+}
+
+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 OpenPageHelp (HWND hwndDlg, int nPage)
{
@@ -10800,3 +10936,25 @@ void SetPim (HWND hwndDlg, UINT ctrlId, int pim)
SetDlgItemText (hwndDlg, ctrlId, "");
}
+void HandleShowPasswordFieldAction (HWND hwndDlg, UINT checkBoxId, UINT edit1Id, UINT edit2Id)
+{
+ if ((EditPasswordChar == 0) && GetCheckBox (hwndDlg, checkBoxId))
+ {
+ EditPasswordChar = (WCHAR) SendMessageW (GetDlgItem (hwndDlg, edit1Id), EM_GETPASSWORDCHAR, 0, 0);
+ }
+
+ SendMessageW (GetDlgItem (hwndDlg, edit1Id),
+ EM_SETPASSWORDCHAR,
+ GetCheckBox (hwndDlg, checkBoxId) ? 0 : EditPasswordChar,
+ 0);
+ InvalidateRect (GetDlgItem (hwndDlg, edit1Id), NULL, TRUE);
+
+ if (edit2Id)
+ {
+ SendMessageW (GetDlgItem (hwndDlg, edit2Id),
+ EM_SETPASSWORDCHAR,
+ GetCheckBox (hwndDlg, checkBoxId) ? 0 : EditPasswordChar,
+ 0);
+ InvalidateRect (GetDlgItem (hwndDlg, edit2Id), NULL, TRUE);
+ }
+} \ No newline at end of file
diff --git a/src/Common/Dlgcode.h b/src/Common/Dlgcode.h
index 752b0cb1..dec482bf 100644
--- a/src/Common/Dlgcode.h
+++ b/src/Common/Dlgcode.h
@@ -326,8 +326,10 @@ void LocalizeDialog ( HWND hwnd, char *stringId );
void OpenVolumeExplorerWindow (int driveNo);
static BOOL CALLBACK CloseVolumeExplorerWindowsEnum( HWND hwnd, LPARAM driveNo);
BOOL CloseVolumeExplorerWindows (HWND hwnd, int driveNo);
+BOOL UpdateDriveCustomLabel (int driveNo, wchar_t* effectiveLabel, BOOL bSetValue);
BOOL CheckCapsLock (HWND hwnd, BOOL quiet);
BOOL CheckFileExtension (char *fileName);
+void CorrectFileName (char* fileName);
void IncreaseWrongPwdRetryCount (int count);
void ResetWrongPwdRetryCount (void);
BOOL WrongPwdRetryCountOverLimit (void);
@@ -425,6 +427,8 @@ BOOL ConfigWriteString (char *configKey, char *configValue);
BOOL ConfigWriteInt (char *configKey, int configValue);
int ConfigReadInt (char *configKey, int defaultValue);
char *ConfigReadString (char *configKey, char *defaultValue, char *str, int maxLen);
+void ConfigReadCompareInt(char *configKey, int defaultValue, int* pOutputValue, BOOL bOnlyCheckModified, BOOL* pbModified);
+void ConfigReadCompareString (char *configKey, char *defaultValue, char *str, int maxLen, BOOL bOnlyCheckModified, BOOL *pbModified);
void RestoreDefaultKeyFilesParam (void);
BOOL LoadDefaultKeyFilesParam (void);
void Debug (char *format, ...);
@@ -488,6 +492,7 @@ BOOL LaunchWindowsIsoBurner (HWND hwnd, const char *isoPath);
BOOL IsApplicationInstalled (const char *appName);
int GetPim (HWND hwndDlg, UINT ctrlId);
void SetPim (HWND hwndDlg, UINT ctrlId, int pim);
+void HandleShowPasswordFieldAction (HWND hwndDlg, UINT checkBoxId, UINT edit1Id, UINT edit2Id);
#ifdef __cplusplus
}
diff --git a/src/Common/Keyfiles.c b/src/Common/Keyfiles.c
index 26973252..549ffe6e 100644
--- a/src/Common/Keyfiles.c
+++ b/src/Common/Keyfiles.c
@@ -222,7 +222,7 @@ close:
}
-BOOL KeyFilesApply (HWND hwndDlg, Password *password, KeyFile *firstKeyFile)
+BOOL KeyFilesApply (HWND hwndDlg, Password *password, KeyFile *firstKeyFile, const char* volumeFileName)
{
BOOL status = TRUE;
KeyFile kfSubStruct;
@@ -322,7 +322,7 @@ BOOL KeyFilesApply (HWND hwndDlg, Password *password, KeyFile *firstKeyFile)
StringCbPrintfA (kfSub->FileName, sizeof(kfSub->FileName), "%s%c%s", kf->FileName,
'\\',
fBuf.name
- );
+ );
// Determine whether it's a path or a file
if (stat (kfSub->FileName, &statStruct) != 0)
@@ -346,6 +346,13 @@ BOOL KeyFilesApply (HWND hwndDlg, Password *password, KeyFile *firstKeyFile)
continue;
}
+ CorrectFileName (kfSub->FileName);
+ if (volumeFileName && (_stricmp (volumeFileName, kfSub->FileName) == 0))
+ {
+ // skip if it is the current container file name
+ continue;
+ }
+
++keyfileCount;
// Apply keyfile to the pool
@@ -474,13 +481,25 @@ BOOL CALLBACK KeyFilesDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa
{
if (SelectMultipleFiles (hwndDlg, "SELECT_KEYFILE", kf->FileName, sizeof(kf->FileName),bHistory))
{
+ bool containerFileSkipped = false;
do
{
- param->FirstKeyFile = KeyFileAdd (param->FirstKeyFile, kf);
- LoadKeyList (hwndDlg, param->FirstKeyFile);
-
- kf = (KeyFile *) malloc (sizeof (KeyFile));
+ CorrectFileName (kf->FileName);
+ if (_stricmp (param->VolumeFileName, kf->FileName) == 0)
+ containerFileSkipped = true;
+ else
+ {
+ param->FirstKeyFile = KeyFileAdd (param->FirstKeyFile, kf);
+ LoadKeyList (hwndDlg, param->FirstKeyFile);
+
+ kf = (KeyFile *) malloc (sizeof (KeyFile));
+ }
} while (SelectMultipleFilesNext (kf->FileName, sizeof(kf->FileName)));
+
+ if (containerFileSkipped)
+ {
+ Warning ("SELECTED_KEYFILE_IS_CONTAINER_FILE", hwndDlg);
+ }
}
free (kf);
diff --git a/src/Common/Keyfiles.h b/src/Common/Keyfiles.h
index 61ca83e6..8400ebc3 100644
--- a/src/Common/Keyfiles.h
+++ b/src/Common/Keyfiles.h
@@ -30,6 +30,7 @@ typedef struct KeyFileStruct
typedef struct
{
+ char VolumeFileName[MAX_PATH + 1];
BOOL EnableKeyFiles;
KeyFile *FirstKeyFile;
} KeyFilesDlgParam;
@@ -38,7 +39,7 @@ KeyFile *KeyFileAdd (KeyFile *firstKeyFile, KeyFile *keyFile);
void KeyFileRemoveAll (KeyFile **firstKeyFile);
KeyFile *KeyFileClone (KeyFile *keyFile);
KeyFile *KeyFileCloneAll (KeyFile *firstKeyFile);
-BOOL KeyFilesApply (HWND hwndDlg, Password *password, KeyFile *firstKeyFile);
+BOOL KeyFilesApply (HWND hwndDlg, Password *password, KeyFile *firstKeyFilem, const char* volumeFileName);
BOOL CALLBACK KeyFilesDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
BOOL KeyfilesPopupMenu (HWND hwndDlg, POINT popupPosition, KeyFilesDlgParam *dialogParam);
diff --git a/src/Common/Language.xml b/src/Common/Language.xml
index 558cc6d6..b590ce58 100644
--- a/src/Common/Language.xml
+++ b/src/Common/Language.xml
@@ -62,6 +62,7 @@
<control lang="en" key="IDC_QUICKFORMAT">Quick Format</control>
<control lang="en" key="IDC_SHOW_PASSWORD">&amp;Display password</control>
<control lang="en" key="IDC_SHOW_PASSWORD_SINGLE">&amp;Display password</control>
+ <control lang="en" key="IDC_SHOW_PIM">&amp;Display PIM</control>
<control lang="en" key="IDC_SINGLE_BOOT">Single-boot</control>
<control lang="en" key="IDC_STD_VOL">Standard VeraCrypt volume</control>
<control lang="en" key="IDC_SYSENC_HIDDEN">Hi&amp;dden</control>
@@ -98,6 +99,7 @@
<control lang="en" key="IDT_SYSENC_KEYS_GEN_INFO">The keys, salt, and other data have been successfully generated. If you want to generate new keys, click Back and then Next. Otherwise, click Next to continue.</control>
<control lang="en" key="IDT_SYS_DEVICE">Encrypts the partition/drive where Windows is installed. Anyone who wants to gain access and use the system, read and write files, etc., will need to enter the correct password each time before Windows boots. Optionally, creates a hidden system.</control>
<control lang="en" key="IDT_SYS_PARTITION">Select this option to encrypt the partition where the currently running Windows operating system is installed.</control>
+ <control lang="en" key="IDT_VOLUME_LABEL">Volume Label in Windows:</control>
<control lang="en" key="IDT_WIPE_MODE">Wipe mode:</control>
<control lang="en" key="IDCLOSE">Close</control>
<control lang="en" key="IDC_ALLOW_ESC_PBA_BYPASS">Allow pre-boot &amp;authentication to be bypassed by pressing the Esc key (enables boot manager)</control>
@@ -647,6 +649,7 @@
<string lang="en" key="SELECT_KEYFILE">Select Keyfile</string>
<string lang="en" key="SELECT_KEYFILE_PATH">Select a keyfile search path. WARNING: Note that only the path will be remembered, not the filenames!</string>
<string lang="en" key="SELECT_KEYFILE_GENERATION_DIRECTORY">Select a directory where to store the keyfiles.</string>
+ <string lang="en" key="SELECTED_KEYFILE_IS_CONTAINER_FILE">The current container file was selected as a keyfile. It will be skipped.</string>
<string lang="en" key="SERPENT_HELP">Designed by Ross Anderson, Eli Biham, and Lars Knudsen. Published in 1998. 256-bit key, 128-bit block. Mode of operation is XTS. Serpent was one of the AES finalists.</string>
<string lang="en" key="SIZE_HELP">Please specify the size of the container you want to create.\n\nIf you create a dynamic (sparse-file) container, this parameter will specify its maximum possible size.\n\nNote that the minimum possible size of a FAT volume is 292 KB. The minimum possible size of an NTFS volume is 3792 KB.</string>
<string lang="en" key="SIZE_HELP_HIDDEN_HOST_VOL">Please specify the size of the outer volume to be created (you will first create the outer volume and then a hidden volume within it). The minimum possible size of a volume within which a hidden volume is intended to be created is 340 KB.</string>
diff --git a/src/Common/Resource.h b/src/Common/Resource.h
index f1c20214..dfad1274 100644
--- a/src/Common/Resource.h
+++ b/src/Common/Resource.h
@@ -192,6 +192,8 @@
#define IDC_PIM 5130
#define IDC_PIM_HELP 5131
#define IDC_PIM_ENABLE 5132
+#define IDC_VOLUME_LABEL 5133
+#define IDT_VOLUME_LABEL 5134
// Next default values for new objects
//
@@ -200,7 +202,7 @@
#define _APS_NO_MFC 1
#define _APS_NEXT_RESOURCE_VALUE 542
#define _APS_NEXT_COMMAND_VALUE 40001
-#define _APS_NEXT_CONTROL_VALUE 5133
+#define _APS_NEXT_CONTROL_VALUE 5135
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
diff --git a/src/Driver/Ntdriver.c b/src/Driver/Ntdriver.c
index d292acb9..9c0a8500 100644
--- a/src/Driver/Ntdriver.c
+++ b/src/Driver/Ntdriver.c
@@ -1199,6 +1199,7 @@ NTSTATUS ProcessMainDeviceControlIrp (PDEVICE_OBJECT DeviceObject, PEXTENSION Ex
{
list->ulMountedDrives |= (1 << ListExtension->nDosDriveNo);
RtlStringCbCopyW (list->wszVolume[ListExtension->nDosDriveNo], sizeof(list->wszVolume[ListExtension->nDosDriveNo]),ListExtension->wszVolume);
+ RtlStringCbCopyW (list->wszLabel[ListExtension->nDosDriveNo], sizeof(list->wszLabel[ListExtension->nDosDriveNo]),ListExtension->wszLabel);
list->diskLength[ListExtension->nDosDriveNo] = ListExtension->DiskLength;
list->ea[ListExtension->nDosDriveNo] = ListExtension->cryptoInfo->ea;
if (ListExtension->cryptoInfo->hiddenVolume)
@@ -1249,6 +1250,8 @@ NTSTATUS ProcessMainDeviceControlIrp (PDEVICE_OBJECT DeviceObject, PEXTENSION Ex
{
prop->uniqueId = ListExtension->UniqueVolumeId;
RtlStringCbCopyW (prop->wszVolume, sizeof(prop->wszVolume),ListExtension->wszVolume);
+ RtlStringCbCopyW (prop->wszLabel, sizeof(prop->wszLabel),ListExtension->wszLabel);
+ prop->bDriverSetLabel = ListExtension->bDriverSetLabel;
prop->diskLength = ListExtension->DiskLength;
prop->ea = ListExtension->cryptoInfo->ea;
prop->mode = ListExtension->cryptoInfo->mode;
@@ -1442,6 +1445,7 @@ NTSTATUS ProcessMainDeviceControlIrp (PDEVICE_OBJECT DeviceObject, PEXTENSION Ex
}
EnsureNullTerminatedString (mount->wszVolume, sizeof (mount->wszVolume));
+ EnsureNullTerminatedString (mount->wszLabel, sizeof (mount->wszLabel));
Irp->IoStatus.Information = sizeof (MOUNT_STRUCT);
Irp->IoStatus.Status = MountDevice (DeviceObject, mount);
@@ -2653,6 +2657,7 @@ NTSTATUS MountDevice (PDEVICE_OBJECT DeviceObject, MOUNT_STRUCT *mount)
PACCESS_TOKEN accessToken;
SeCaptureSubjectContext (&subContext);
+ SeLockSubjectContext(&subContext);
accessToken = SeQuerySubjectContextToken (&subContext);
if (!accessToken)
@@ -2678,6 +2683,7 @@ NTSTATUS MountDevice (PDEVICE_OBJECT DeviceObject, MOUNT_STRUCT *mount)
}
}
+ SeUnlockSubjectContext(&subContext);
SeReleaseSubjectContext (&subContext);
if (NT_SUCCESS (ntStatus))
@@ -2695,6 +2701,9 @@ NTSTATUS MountDevice (PDEVICE_OBJECT DeviceObject, MOUNT_STRUCT *mount)
{
HANDLE volumeHandle;
PFILE_OBJECT volumeFileObject;
+ ULONG labelLen = (ULONG) wcslen (mount->wszLabel);
+ BOOL bIsNTFS = FALSE;
+ ULONG labelMaxLen, labelEffectiveLen;
Dump ("Mount SUCCESS TC code = 0x%08x READ-ONLY = %d\n", mount->nReturnCode, NewExtension->bReadOnly);
@@ -2733,6 +2742,59 @@ NTSTATUS MountDevice (PDEVICE_OBJECT DeviceObject, MOUNT_STRUCT *mount)
mount->FilesystemDirty = TRUE;
}
+ // detect if the filesystem is NTFS or FAT
+ __try
+ {
+ NTFS_VOLUME_DATA_BUFFER ntfsData;
+ if (NT_SUCCESS (TCFsctlCall (volumeFileObject, FSCTL_GET_NTFS_VOLUME_DATA, NULL, 0, &ntfsData, sizeof (ntfsData))))
+ {
+ bIsNTFS = TRUE;
+ }
+ }
+ __except (EXCEPTION_EXECUTE_HANDLER)
+ {
+ bIsNTFS = FALSE;
+ }
+
+ NewExtension->bIsNTFS = bIsNTFS;
+ mount->bIsNTFS = bIsNTFS;
+
+ if (labelLen > 0)
+ {
+ if (bIsNTFS)
+ labelMaxLen = 32; // NTFS maximum label length
+ else
+ labelMaxLen = 11; // FAT maximum label length
+
+ // calculate label effective length
+ labelEffectiveLen = labelLen > labelMaxLen? labelMaxLen : labelLen;
+
+ // correct the label in the device
+ memset (&NewExtension->wszLabel[labelEffectiveLen], 0, 33 - labelEffectiveLen);
+ memcpy (mount->wszLabel, NewExtension->wszLabel, 33);
+
+ // set the volume label
+ __try
+ {
+ IO_STATUS_BLOCK ioblock;
+ ULONG labelInfoSize = sizeof(FILE_FS_LABEL_INFORMATION) + (labelEffectiveLen * sizeof(WCHAR));
+ FILE_FS_LABEL_INFORMATION* labelInfo = (FILE_FS_LABEL_INFORMATION*) TCalloc (labelInfoSize);
+ labelInfo->VolumeLabelLength = labelEffectiveLen * sizeof(WCHAR);
+ memcpy (labelInfo->VolumeLabel, mount->wszLabel, labelInfo->VolumeLabelLength);
+
+ if (STATUS_SUCCESS == ZwSetVolumeInformationFile (volumeHandle, &ioblock, labelInfo, labelInfoSize, FileFsLabelInformation))
+ {
+ mount->bDriverSetLabel = TRUE;
+ NewExtension->bDriverSetLabel = TRUE;
+ }
+
+ TCfree(labelInfo);
+ }
+ __except (EXCEPTION_EXECUTE_HANDLER)
+ {
+
+ }
+ }
TCCloseFsVolume (volumeHandle, volumeFileObject);
}
diff --git a/src/Driver/Ntdriver.h b/src/Driver/Ntdriver.h
index 6a5bf826..8da75c69 100644
--- a/src/Driver/Ntdriver.h
+++ b/src/Driver/Ntdriver.h
@@ -77,6 +77,9 @@ typedef struct EXTENSION
BOOL SystemFavorite;
WCHAR wszVolume[TC_MAX_PATH]; /* DONT change this size without also changing MOUNT_LIST_STRUCT! */
+ WCHAR wszLabel[33];
+ BOOL bIsNTFS;
+ BOOL bDriverSetLabel;
LARGE_INTEGER fileCreationTime;
LARGE_INTEGER fileLastAccessTime;
diff --git a/src/Driver/Ntvol.c b/src/Driver/Ntvol.c
index c42827a8..845961d4 100644
--- a/src/Driver/Ntvol.c
+++ b/src/Driver/Ntvol.c
@@ -669,6 +669,9 @@ NTSTATUS TCOpenVolume (PDEVICE_OBJECT DeviceObject,
{
RtlStringCbCopyW (Extension->wszVolume, sizeof(Extension->wszVolume),pwszMountVolume);
}
+
+ memset (Extension->wszLabel, 0, sizeof (Extension->wszLabel));
+ RtlStringCbCopyW (Extension->wszLabel, sizeof(Extension->wszLabel), mount->wszLabel);
}
// If we are to protect a hidden volume we cannot exit yet, for we must also
diff --git a/src/ExpandVolume/DlgExpandVolume.cpp b/src/ExpandVolume/DlgExpandVolume.cpp
index 1f623bef..267e859e 100644
--- a/src/ExpandVolume/DlgExpandVolume.cpp
+++ b/src/ExpandVolume/DlgExpandVolume.cpp
@@ -59,7 +59,7 @@ BOOL CALLBACK ExpandVolProgressDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, L
namespace VeraCryptExpander
{
/* defined in WinMain.c, referenced by ExpandVolumeWizard() */
-int ExtcvAskVolumePassword (HWND hwndDlg, Password *password, int *pkcs5, int *pim, BOOL* truecryptMode, char *titleStringId, BOOL enableMountOptions);
+int ExtcvAskVolumePassword (HWND hwndDlg, const char* fileName, Password *password, int *pkcs5, int *pim, BOOL* truecryptMode, char *titleStringId, BOOL enableMountOptions);
}
@@ -500,7 +500,7 @@ void ExpandVolumeWizard (HWND hwndDlg, char *lpszVolume)
OpenVolumeContext expandVol;
BOOL truecryptMode = FALSE;
- if (!VeraCryptExpander::ExtcvAskVolumePassword (hwndDlg, &VolumePassword, &VolumePkcs5, &VolumePim, &truecryptMode, "ENTER_NORMAL_VOL_PASSWORD", FALSE))
+ if (!VeraCryptExpander::ExtcvAskVolumePassword (hwndDlg, lpszVolume, &VolumePassword, &VolumePkcs5, &VolumePim, &truecryptMode, "ENTER_NORMAL_VOL_PASSWORD", FALSE))
{
goto ret;
}
@@ -509,7 +509,7 @@ void ExpandVolumeWizard (HWND hwndDlg, char *lpszVolume)
WaitCursor();
if (KeyFilesEnable && FirstKeyFile)
- KeyFilesApply (hwndDlg, &VolumePassword, FirstKeyFile);
+ KeyFilesApply (hwndDlg, &VolumePassword, FirstKeyFile, lpszVolume);
WaitCursor ();
diff --git a/src/ExpandVolume/WinMain.cpp b/src/ExpandVolume/WinMain.cpp
index 6bf40477..d07bc11e 100644
--- a/src/ExpandVolume/WinMain.cpp
+++ b/src/ExpandVolume/WinMain.cpp
@@ -367,7 +367,7 @@ GetItemLong (HWND hTree, int itemNo)
return item.lParam;
}
-static char PasswordDlgVolume[MAX_PATH + 1];
+static char PasswordDlgVolume[MAX_PATH + 1] = {0};
static BOOL PasswordDialogDisableMountOptions;
static char *PasswordDialogTitleStringId;
@@ -534,10 +534,13 @@ BOOL CALLBACK ExtcvPasswordDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
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);
@@ -614,11 +617,7 @@ BOOL CALLBACK ExtcvPasswordDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
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;
}
@@ -655,7 +654,7 @@ BOOL CALLBACK ExtcvPasswordDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
if (lw == IDOK)
{
if (mountOptions.ProtectHiddenVolume && hidVolProtKeyFilesParam.EnableKeyFiles)
- KeyFilesApply (hwndDlg, &mountOptions.ProtectedHidVolPassword, hidVolProtKeyFilesParam.FirstKeyFile);
+ KeyFilesApply (hwndDlg, &mountOptions.ProtectedHidVolPassword, hidVolProtKeyFilesParam.FirstKeyFile, PasswordDlgVolume);
GetWindowText (GetDlgItem (hwndDlg, IDC_PASSWORD), (LPSTR) szXPwd->Text, MAX_PASSWORD + 1);
szXPwd->Length = strlen ((char *) szXPwd->Text);
@@ -780,7 +779,7 @@ int RestoreVolumeHeader (HWND hwndDlg, char *lpszVolume)
return 0;
}
-int ExtcvAskVolumePassword (HWND hwndDlg, Password *password, int *pkcs5, int *pim, BOOL* truecryptMode, char *titleStringId, BOOL enableMountOptions)
+int ExtcvAskVolumePassword (HWND hwndDlg, const char* fileName, Password *password, int *pkcs5, int *pim, BOOL* truecryptMode, char *titleStringId, BOOL enableMountOptions)
{
int result;
PasswordDlgParam dlgParam;
@@ -793,6 +792,8 @@ int ExtcvAskVolumePassword (HWND hwndDlg, Password *password, int *pkcs5, int *p
dlgParam.pim = pim;
dlgParam.truecryptMode = truecryptMode;
+ StringCbCopyA (PasswordDlgVolume, sizeof(PasswordDlgVolume), fileName);
+
result = DialogBoxParamW (hInst,
MAKEINTRESOURCEW (IDD_PASSWORD_DLG), hwndDlg,
(DLGPROC) ExtcvPasswordDlgProc, (LPARAM) &dlgParam);
diff --git a/src/Format/Format.rc b/src/Format/Format.rc
index 66f4ac81..e46292e2 100644
--- a/src/Format/Format.rc
+++ b/src/Format/Format.rc
@@ -225,7 +225,7 @@ FONT 8, "MS Shell Dlg", 0, 0, 0x0
BEGIN
EDITTEXT IDC_PASSWORD_DIRECT,50,2,149,14,ES_PASSWORD | ES_AUTOHSCROLL
COMBOBOX IDC_PKCS5_PRF_ID,50,17,91,90,CBS_DROPDOWNLIST | WS_TABSTOP
- EDITTEXT IDC_PIM,50,32,42,14,ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER | NOT WS_VISIBLE
+ EDITTEXT IDC_PIM,50,32,42,14,ES_RIGHT | ES_PASSWORD | ES_AUTOHSCROLL | ES_NUMBER | NOT WS_VISIBLE
LTEXT "(Empty or 0 for default iterations)",IDC_PIM_HELP,96,34,127,8,NOT WS_VISIBLE
CONTROL "&Display password",IDC_SHOW_PASSWORD_SINGLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,50,46,84,11,WS_EX_TRANSPARENT
CONTROL "U&se keyfiles",IDC_KEYFILES_ENABLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,50,57,82,11
@@ -437,11 +437,12 @@ IDD_PIM_PAGE_DLG DIALOGEX 0, 0, 226, 172
STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
FONT 8, "MS Shell Dlg", 0, 0, 0x0
BEGIN
- EDITTEXT IDC_PIM,53,8,42,14,ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER
- LTEXT "",IDC_BOX_HELP,0,28,225,130
- RTEXT "Volume PIM:",IDT_PIM,1,11,50,8
- LTEXT "(Empty or 0 for default iterations)",IDC_PIM_HELP,97,11,126,8
+ EDITTEXT IDC_PIM,53,0,42,14,ES_RIGHT | ES_PASSWORD | ES_AUTOHSCROLL | ES_NUMBER
+ LTEXT "",IDC_BOX_HELP,0,32,225,126
+ RTEXT "Volume PIM:",IDT_PIM,1,3,50,8
+ LTEXT "(Empty or 0 for default iterations)",IDC_PIM_HELP,97,3,126,8
LTEXT "Information on PIM",IDC_LINK_PIM_INFO,0,161,213,8,SS_NOTIFY
+ CONTROL "Display PIM",IDC_SHOW_PIM,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,53,17,150,10
END
diff --git a/src/Format/Resource.h b/src/Format/Resource.h
index 3b717e84..e7048d66 100644
--- a/src/Format/Resource.h
+++ b/src/Format/Resource.h
@@ -142,6 +142,7 @@
#define IDC_DRIVE_LETTER_LIST 1103
#define IDT_DRIVE_LETTER 1104
#define IDC_LINK_PIM_INFO 1105
+#define IDC_SHOW_PIM 1106
// Next default values for new objects
//
@@ -150,7 +151,7 @@
#define _APS_NO_MFC 1
#define _APS_NEXT_RESOURCE_VALUE 134
#define _APS_NEXT_COMMAND_VALUE 40001
-#define _APS_NEXT_CONTROL_VALUE 1106
+#define _APS_NEXT_CONTROL_VALUE 1107
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
diff --git a/src/Format/Tcformat.c b/src/Format/Tcformat.c
index 797198ac..2ebc70ca 100644
--- a/src/Format/Tcformat.c
+++ b/src/Format/Tcformat.c
@@ -714,33 +714,6 @@ static BOOL CreatingHiddenSysVol (void)
&& bHiddenVol && !bHiddenVolHost);
}
-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);
- memcpy (strValue, str, maxLen);
-
- ConfigReadString (configKey, defaultValue, strValue, maxLen);
-
- if (pbModified && strcmp (str, strValue))
- *pbModified = TRUE;
- if (!bOnlyCheckModified)
- memcpy(str, strValue, maxLen);
-
- free (strValue);
-}
-
static void LoadSettingsAndCheckModified (HWND hwndDlg, BOOL bOnlyCheckModified, BOOL* pbSettingsModified, BOOL* pbHistoryModified)
{
if (!bOnlyCheckModified)
@@ -5436,16 +5409,13 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
if (lw == IDC_SHOW_PASSWORD && nCurPageNo == PASSWORD_PAGE)
{
- SendMessage (GetDlgItem (hwndDlg, IDC_PASSWORD),
- EM_SETPASSWORDCHAR,
- GetCheckBox (hwndDlg, IDC_SHOW_PASSWORD) ? 0 : '*',
- 0);
- SendMessage (GetDlgItem (hwndDlg, IDC_VERIFY),
- EM_SETPASSWORDCHAR,
- GetCheckBox (hwndDlg, IDC_SHOW_PASSWORD) ? 0 : '*',
- 0);
- InvalidateRect (GetDlgItem (hwndDlg, IDC_PASSWORD), NULL, TRUE);
- InvalidateRect (GetDlgItem (hwndDlg, IDC_VERIFY), NULL, TRUE);
+ HandleShowPasswordFieldAction (hwndDlg, IDC_SHOW_PASSWORD, IDC_PASSWORD, IDC_VERIFY);
+ return 1;
+ }
+
+ if (lw == IDC_SHOW_PIM && nCurPageNo == PIM_PAGE)
+ {
+ HandleShowPasswordFieldAction (hwndDlg, IDC_SHOW_PIM, IDC_PIM, 0);
return 1;
}
@@ -5536,11 +5506,7 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
if (lw == IDC_SHOW_PASSWORD_SINGLE)
{
- SendMessage (GetDlgItem (hwndDlg, IDC_PASSWORD_DIRECT),
- EM_SETPASSWORDCHAR,
- GetCheckBox (hwndDlg, IDC_SHOW_PASSWORD_SINGLE) ? 0 : '*',
- 0);
- InvalidateRect (GetDlgItem (hwndDlg, IDC_PASSWORD_DIRECT), NULL, TRUE);
+ HandleShowPasswordFieldAction (hwndDlg, IDC_SHOW_PASSWORD_SINGLE, IDC_PASSWORD_DIRECT, IDC_PIM);
return 1;
}
}
@@ -7139,7 +7105,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
{
WaitCursor ();
- if (!KeyFilesApply (hwndDlg, &volumePassword, FirstKeyFile))
+ if (!KeyFilesApply (hwndDlg, &volumePassword, FirstKeyFile, NULL))
{
NormalCursor ();
return 1;
@@ -7244,7 +7210,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
if (KeyFilesEnable)
{
- KeyFilesApply (hwndDlg, &volumePassword, FirstKeyFile);
+ KeyFilesApply (hwndDlg, &volumePassword, FirstKeyFile, NULL);
}
if (!bInPlaceEncNonSys)
diff --git a/src/Mount/Favorites.cpp b/src/Mount/Favorites.cpp
index 12e744aa..5d56345e 100644
--- a/src/Mount/Favorites.cpp
+++ b/src/Mount/Favorites.cpp
@@ -55,6 +55,12 @@ namespace VeraCrypt
if (favorite.Path.find ("\\??\\") == 0)
favorite.Path = favorite.Path.substr (4);
+ if (wcslen (prop.wszLabel))
+ {
+ favorite.Label = prop.wszLabel;
+ favorite.UseLabelInExplorer = true;
+ }
+
if (IsVolumeDeviceHosted (favorite.Path.c_str()))
{
// Get GUID path
@@ -373,6 +379,9 @@ namespace VeraCrypt
case IDC_FAVORITES_HELP_LINK:
Applink (SystemFavoritesMode ? "sysfavorites" : "favorites", TRUE, "");
return 1;
+ case IDC_SHOW_PIM:
+ HandleShowPasswordFieldAction (hwndDlg, IDC_SHOW_PIM, IDC_PIM, 0);
+ return 1;
}
return 0;
@@ -472,20 +481,27 @@ namespace VeraCrypt
}
- wstring GetFavoriteVolumeLabel (const string &volumePath)
+ wstring GetFavoriteVolumeLabel (const string &volumePath, bool& useInExplorer)
{
foreach (const FavoriteVolume &favorite, FavoriteVolumes)
{
if (favorite.Path == volumePath)
+ {
+ useInExplorer = favorite.UseLabelInExplorer;
return favorite.Label;
+ }
}
foreach (const FavoriteVolume &favorite, SystemFavoriteVolumes)
{
if (favorite.Path == volumePath)
+ {
+ useInExplorer = favorite.UseLabelInExplorer;
return favorite.Label;
+ }
}
+ useInExplorer = false;
return wstring();
}
@@ -592,6 +608,10 @@ namespace VeraCrypt
if (boolVal[0])
favorite.MountOnLogOn = (boolVal[0] == '1');
+ XmlGetAttributeText (xml, "useLabelInExplorer", boolVal, sizeof (boolVal));
+ if (boolVal[0])
+ favorite.UseLabelInExplorer = (boolVal[0] == '1') && !favorite.ReadOnly;
+
if (favorite.Path.find ("\\\\?\\Volume{") == 0 && favorite.Path.rfind ("}\\") == favorite.Path.size() - 2)
{
string resolvedPath = VolumeGuidPathToDevicePath (favorite.Path);
@@ -716,6 +736,9 @@ namespace VeraCrypt
if (favorite.OpenExplorerWindow)
s += L" openExplorerWindow=\"1\"";
+ if (favorite.UseLabelInExplorer && !favorite.ReadOnly)
+ s += L" useLabelInExplorer=\"1\"";
+
s += L">" + SingleStringToWide (tq) + L"</volume>";
fwprintf (f, L"%ws", s.c_str());
@@ -791,6 +814,7 @@ namespace VeraCrypt
else
SetDlgItemText (hwndDlg, IDC_PIM, "");
SetDlgItemTextW (hwndDlg, IDC_FAVORITE_LABEL, favorite.Label.c_str());
+ SetCheckBox (hwndDlg, IDC_FAVORITE_USE_LABEL_IN_EXPLORER, favorite.UseLabelInExplorer);
SetCheckBox (hwndDlg, IDC_FAVORITE_MOUNT_ON_LOGON, favorite.MountOnLogOn);
SetCheckBox (hwndDlg, IDC_FAVORITE_MOUNT_ON_ARRIVAL, favorite.MountOnArrival);
SetCheckBox (hwndDlg, IDC_FAVORITE_MOUNT_READONLY, favorite.ReadOnly);
@@ -820,6 +844,7 @@ namespace VeraCrypt
EnableWindow (GetDlgItem (hwndDlg, IDC_PIM_HELP), enable);
EnableWindow (GetDlgItem (hwndDlg, IDT_FAVORITE_LABEL), enable);
EnableWindow (GetDlgItem (hwndDlg, IDC_FAVORITE_LABEL), enable);
+ EnableWindow (GetDlgItem (hwndDlg, IDC_FAVORITE_USE_LABEL_IN_EXPLORER), enable);
EnableWindow (GetDlgItem (hwndDlg, IDC_FAVORITE_MOUNT_ON_LOGON), enable && !systemFavoritesMode);
EnableWindow (GetDlgItem (hwndDlg, IDC_FAVORITE_MOUNT_ON_ARRIVAL), enable && !systemFavoritesMode);
EnableWindow (GetDlgItem (hwndDlg, IDC_FAVORITE_MOUNT_READONLY), enable);
@@ -846,6 +871,7 @@ namespace VeraCrypt
favorite.Label.clear();
favorite.Pim = GetPim (hwndDlg, IDC_PIM);
+ favorite.UseLabelInExplorer = (IsDlgButtonChecked (hwndDlg, IDC_FAVORITE_USE_LABEL_IN_EXPLORER) != 0);
favorite.ReadOnly = (IsDlgButtonChecked (hwndDlg, IDC_FAVORITE_MOUNT_READONLY) != 0);
favorite.Removable = (IsDlgButtonChecked (hwndDlg, IDC_FAVORITE_MOUNT_REMOVABLE) != 0);
diff --git a/src/Mount/Favorites.h b/src/Mount/Favorites.h
index b7ffc1e7..f82037c4 100644
--- a/src/Mount/Favorites.h
+++ b/src/Mount/Favorites.h
@@ -29,7 +29,8 @@ namespace VeraCrypt
OpenExplorerWindow (false),
ReadOnly (false),
Removable (false),
- SystemEncryption (false)
+ SystemEncryption (false),
+ UseLabelInExplorer (false)
{
}
@@ -47,6 +48,7 @@ namespace VeraCrypt
bool ReadOnly;
bool Removable;
bool SystemEncryption;
+ bool UseLabelInExplorer;
};
struct FavoriteVolumesDlgProcArguments
@@ -67,7 +69,7 @@ namespace VeraCrypt
static void FillFavoriteVolumesMenu ();
static void FillListControl (HWND favoriteListControl, vector <FavoriteVolume> &favorites);
static void FillListControlSubItems (HWND favoriteListControl, int line, const FavoriteVolume &favorite);
- wstring GetFavoriteVolumeLabel (const string &volumePath);
+ wstring GetFavoriteVolumeLabel (const string &volumePath, bool& useInExplorer);
void LoadFavoriteVolumes ();
void LoadFavoriteVolumes (vector <FavoriteVolume> &favorites, bool systemFavorites, bool noUacElevation = false);
static void OnFavoriteVolumesUpdated ();
diff --git a/src/Mount/Hotkeys.c b/src/Mount/Hotkeys.c
index 140c172e..b9d166a9 100644
--- a/src/Mount/Hotkeys.c
+++ b/src/Mount/Hotkeys.c
@@ -30,6 +30,7 @@ static TCHOTKEY tmpHotkeys [NBR_HOTKEYS];
static int nSelectedHotkeyId;
static UINT currentVKeyCode;
+static BYTE vkeysDown[256];
static void ScanAndProcessKey (UINT *vKeyCode, wchar_t *keyName)
@@ -41,9 +42,15 @@ static void ScanAndProcessKey (UINT *vKeyCode, wchar_t *keyName)
{
if (GetAsyncKeyState (vKey) < 0)
{
- if (GetKeyName (vKey, keyName)) // If the key is allowed and its name has been resolved
- *vKeyCode = vKey;
+ if (!vkeysDown [vKey])
+ {
+ vkeysDown [vKey] = 1;
+ if (GetKeyName (vKey, keyName)) // If the key is allowed and its name has been resolved
+ *vKeyCode = vKey;
+ }
}
+ else
+ vkeysDown [vKey] = 0;
}
}
@@ -62,6 +69,56 @@ BOOL GetKeyName (UINT vKey, wchar_t *keyName)
{
// OEM-specific
StringCbPrintfW (keyName, MAX_KEY_COMB_NAME_LEN, L"OEM-%d", vKey);
+
+ // mapping taken from:
+ // http://www.hotkeynet.com/ref/keynames.html
+ // https://mojoware.googlecode.com/svn-history/r3/trunk/mojo_engine/cKeyboard.cpp
+ // http://www.screenio.com/gui_screenio/gs_htmlhelp_subweb/download/SIMKEYS.cob
+ //
+ // These values seem to come from Nokia/Ericsson mobile device keys
+
+ switch (vKey)
+ {
+ case 0xE9: // OEMReset = 0xE9
+ StringCbCatW (keyName, MAX_KEY_COMB_NAME_LEN, L" (OEMReset)");
+ break;
+ case 0xEA: // OEMJump = 0xEA
+ StringCbCatW (keyName, MAX_KEY_COMB_NAME_LEN, L" (OEMJump)");
+ break;
+ case 0xEB: // OEMPA1 = 0xEB
+ StringCbCatW (keyName, MAX_KEY_COMB_NAME_LEN, L" (OEMPA1)");
+ break;
+ case 0xEC: // OEMPA2 = 0xEC
+ StringCbCatW (keyName, MAX_KEY_COMB_NAME_LEN, L" (OEMPA2)");
+ break;
+ case 0xED: // OEMPA3 = 0xED
+ StringCbCatW (keyName, MAX_KEY_COMB_NAME_LEN, L" (OEMPA3)");
+ break;
+ case 0xEE: // OEMWSCtrl = 0xEE
+ StringCbCatW (keyName, MAX_KEY_COMB_NAME_LEN, L" (OEMWSCtrl)");
+ break;
+ case 0xEF: // OEMCUSel = 0xEF
+ StringCbCatW (keyName, MAX_KEY_COMB_NAME_LEN, L" (OEMCUSel)");
+ break;
+ case 0xF0: // OEMATTN = 0xF0
+ StringCbCatW (keyName, MAX_KEY_COMB_NAME_LEN, L" (OEMATTN)");
+ break;
+ case 0xF1: // OEMFinish = 0xF1
+ StringCbCatW (keyName, MAX_KEY_COMB_NAME_LEN, L" (OEMFinish)");
+ break;
+ case 0xF2: // OEMCopy = 0xF2
+ StringCbCatW (keyName, MAX_KEY_COMB_NAME_LEN, L" (OEMCopy)");
+ break;
+ case 0xF3: // OEMAuto = 0xF3
+ StringCbCatW (keyName, MAX_KEY_COMB_NAME_LEN, L" (OEMAuto)");
+ break;
+ case 0xF4: // OEMENLW = 0xF4
+ StringCbCatW (keyName, MAX_KEY_COMB_NAME_LEN, L" (OEMENLW)");
+ break;
+ case 0xF5: // OEMBackTab = 0xF5
+ StringCbCatW (keyName, MAX_KEY_COMB_NAME_LEN, L" (OEMBackTab)");
+ break;
+ }
}
else if (vKey >= VK_F1 && vKey <= VK_F24)
{
@@ -296,6 +353,7 @@ BOOL CALLBACK HotkeysDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPar
nSelectedHotkeyId = -1;
currentVKeyCode = 0;
memcpy (tmpHotkeys, Hotkeys, sizeof(tmpHotkeys));
+ memset (vkeysDown, 0, sizeof(vkeysDown));
SendMessageW (hList,LVM_SETEXTENDEDLISTVIEWSTYLE,0,
LVS_EX_FULLROWSELECT|LVS_EX_HEADERDRAGDROP|LVS_EX_LABELTIP
@@ -337,7 +395,7 @@ BOOL CALLBACK HotkeysDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPar
case WM_TIMER:
{
- if (nSelectedHotkeyId > -1)
+ if ((nSelectedHotkeyId > -1) && (GetFocus () == GetDlgItem (hwndDlg, IDC_HOTKEY_KEY)))
{
wchar_t keyName [MAX_KEY_COMB_NAME_LEN];
UINT tmpVKeyCode;
@@ -352,6 +410,10 @@ BOOL CALLBACK HotkeysDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPar
SetWindowTextW (GetDlgItem (hwndDlg, IDC_HOTKEY_KEY), keyName);
EnableWindow (GetDlgItem (hwndDlg, IDC_HOTKEY_ASSIGN), TRUE);
}
+ else if ((currentVKeyCode != 0) && GetKeyName (currentVKeyCode, keyName))
+ {
+ SetWindowTextW (GetDlgItem (hwndDlg, IDC_HOTKEY_KEY), keyName);
+ }
}
return 1;
}
@@ -365,6 +427,8 @@ BOOL CALLBACK HotkeysDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPar
LVITEM item;
memset(&item,0,sizeof(item));
nSelectedHotkeyId = ((LPNMLISTVIEW) lParam)->iItem;
+ currentVKeyCode = 0;
+ memset (vkeysDown, 0, sizeof(vkeysDown));
SetWindowTextW (GetDlgItem (hwndDlg, IDC_HOTKEY_KEY), GetString ("PRESS_A_KEY_TO_ASSIGN"));
EnableWindow (GetDlgItem (hwndDlg, IDC_HOTKEY_REMOVE), (tmpHotkeys[nSelectedHotkeyId].vKeyCode > 0));
@@ -446,6 +510,8 @@ BOOL CALLBACK HotkeysDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPar
EnableWindow (GetDlgItem (hwndDlg, IDC_HOTKEY_REMOVE), FALSE);
nSelectedHotkeyId = -1;
bKeyScanOn = FALSE;
+ currentVKeyCode = 0;
+ memset (vkeysDown, 0, sizeof(vkeysDown));
}
}
DisplayHotkeyList(hwndDlg);
@@ -463,6 +529,8 @@ BOOL CALLBACK HotkeysDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPar
EnableWindow (GetDlgItem (hwndDlg, IDC_HOTKEY_REMOVE), FALSE);
nSelectedHotkeyId = -1;
bKeyScanOn = FALSE;
+ currentVKeyCode = 0;
+ memset (vkeysDown, 0, sizeof(vkeysDown));
DisplayHotkeyList(hwndDlg);
}
return 1;
@@ -482,6 +550,8 @@ BOOL CALLBACK HotkeysDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPar
EnableWindow (GetDlgItem (hwndDlg, IDC_HOTKEY_REMOVE), FALSE);
nSelectedHotkeyId = -1;
bKeyScanOn = FALSE;
+ currentVKeyCode = 0;
+ memset (vkeysDown, 0, sizeof(vkeysDown));
DisplayHotkeyList(hwndDlg);
return 1;
}
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))
diff --git a/src/Mount/Mount.rc b/src/Mount/Mount.rc
index eb665d47..14283f4e 100644
--- a/src/Mount/Mount.rc
+++ b/src/Mount/Mount.rc
@@ -114,14 +114,14 @@ BEGIN
EDITTEXT IDC_OLD_PASSWORD,89,14,162,13,ES_PASSWORD | ES_AUTOHSCROLL
COMBOBOX IDC_PKCS5_OLD_PRF_ID,89,33,85,90,CBS_DROPDOWNLIST | WS_TABSTOP
CONTROL "TrueCrypt Mode",IDC_TRUECRYPT_MODE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,179,35,78,10
- EDITTEXT IDC_OLD_PIM,89,51,42,14,ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER | NOT WS_VISIBLE
+ EDITTEXT IDC_OLD_PIM,89,51,42,14,ES_RIGHT | ES_PASSWORD | ES_AUTOHSCROLL | ES_NUMBER | NOT WS_VISIBLE
CONTROL "Use PIM",IDC_PIM_ENABLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,89,59,97,10
CONTROL "Use keyfiles",IDC_ENABLE_KEYFILES,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,89,72,98,10
PUSHBUTTON "Keyfiles...",IDC_KEYFILES,192,70,59,14
CONTROL "Display password",IDC_SHOW_PASSWORD_CHPWD_ORI,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,89,85,138,10,WS_EX_TRANSPARENT
EDITTEXT IDC_PASSWORD,89,121,162,13,ES_PASSWORD | ES_AUTOHSCROLL
EDITTEXT IDC_VERIFY,89,137,162,13,ES_PASSWORD | ES_AUTOHSCROLL
- EDITTEXT IDC_PIM,89,154,42,14,ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER | NOT WS_VISIBLE
+ EDITTEXT IDC_PIM,89,154,42,14,ES_RIGHT | ES_PASSWORD | ES_AUTOHSCROLL | ES_NUMBER | NOT WS_VISIBLE
CONTROL "Use PIM",IDC_NEW_PIM_ENABLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,89,161,97,10
CONTROL "Use keyfiles",IDC_ENABLE_NEW_KEYFILES,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,89,172,99,11
PUSHBUTTON "Keyfiles...",IDC_NEW_KEYFILES,192,170,59,14
@@ -182,7 +182,7 @@ BEGIN
EDITTEXT IDC_PASSWORD,69,8,166,14,ES_PASSWORD | ES_AUTOHSCROLL
COMBOBOX IDC_PKCS5_PRF_ID,69,26,86,90,CBS_DROPDOWNLIST | WS_TABSTOP
CONTROL "TrueCrypt Mode",IDC_TRUECRYPT_MODE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,159,28,76,10
- EDITTEXT IDC_PIM,69,43,42,14,ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER | NOT WS_VISIBLE
+ EDITTEXT IDC_PIM,69,43,42,14,ES_RIGHT | ES_PASSWORD | ES_AUTOHSCROLL | ES_NUMBER | NOT WS_VISIBLE
CONTROL "Use PIM",IDC_PIM_ENABLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,70,48,97,10
CONTROL "Cache passwords and keyfil&es in memory",IDC_CACHE,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,70,61,153,10
@@ -315,7 +315,7 @@ BEGIN
LTEXT "",IDT_LIMIT_ENC_THREAD_POOL_NOTE,18,126,334,33
END
-IDD_FAVORITE_VOLUMES DIALOGEX 0, 0, 380, 315
+IDD_FAVORITE_VOLUMES DIALOGEX 0, 0, 380, 339
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "VeraCrypt - Favorite Volumes"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
@@ -324,28 +324,31 @@ BEGIN
PUSHBUTTON "Move &Up",IDC_FAVORITE_MOVE_UP,7,104,63,14
PUSHBUTTON "Move &Down",IDC_FAVORITE_MOVE_DOWN,74,104,63,14
PUSHBUTTON "&Remove",IDC_FAVORITE_REMOVE,310,104,63,14
- EDITTEXT IDC_FAVORITE_LABEL,16,173,204,13,ES_AUTOHSCROLL
+ EDITTEXT IDC_FAVORITE_LABEL,18,185,204,13,ES_AUTOHSCROLL
CONTROL "Mount selected volume as read-o&nly",IDC_FAVORITE_MOUNT_READONLY,
- "Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,193,349,10
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,215,349,10
CONTROL "Mount selected volume as remo&vable medium",IDC_FAVORITE_MOUNT_REMOVABLE,
- "Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,207,349,10
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,229,349,10
CONTROL "Mount selected volume upon log&on",IDC_FAVORITE_MOUNT_ON_LOGON,
- "Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,221,349,10
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,243,349,10
CONTROL "Mount selected volume when its host device gets &connected",IDC_FAVORITE_MOUNT_ON_ARRIVAL,
- "Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,235,349,10
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,257,349,10
CONTROL "Open &Explorer window for selected volume when successfully mounted",IDC_FAVORITE_OPEN_EXPLORER_WIN_ON_MOUNT,
- "Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,249,349,11
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,271,349,11
CONTROL "Do not mount selected volume when 'Mount Favorite Volumes' &hot key is pressed",IDC_FAVORITE_DISABLE_HOTKEY,
- "Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,264,349,11
- LTEXT "Help on favorite volumes",IDC_FAVORITES_HELP_LINK,17,298,237,10,SS_NOTIFY
- DEFPUSHBUTTON "OK",IDOK,269,296,50,14
- PUSHBUTTON "Cancel",IDCANCEL,323,296,50,14
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,286,349,11
+ LTEXT "Help on favorite volumes",IDC_FAVORITES_HELP_LINK,17,322,237,10,SS_NOTIFY
+ DEFPUSHBUTTON "OK",IDOK,269,318,50,14
+ PUSHBUTTON "Cancel",IDCANCEL,323,318,50,14
GROUPBOX "",IDC_FAV_VOL_OPTIONS_GROUP_BOX,7,122,366,159
- LTEXT "Label of selected favorite volume:",IDT_FAVORITE_LABEL,18,163,202,8
- GROUPBOX "Global Settings",IDC_FAV_VOL_OPTIONS_GLOBAL_SETTINGS_BOX,7,230,366,57
- EDITTEXT IDC_PIM,16,143,42,14,ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER
+ LTEXT "Label of selected favorite volume:",IDT_FAVORITE_LABEL,18,175,202,8
+ GROUPBOX "Global Settings",IDC_FAV_VOL_OPTIONS_GLOBAL_SETTINGS_BOX,7,252,366,57
+ EDITTEXT IDC_PIM,18,143,42,13,ES_RIGHT | ES_PASSWORD | ES_AUTOHSCROLL | ES_NUMBER
LTEXT "(Empty or 0 for default iterations)",IDC_PIM_HELP,64,145,189,8
LTEXT "Volume PIM:",IDT_PIM,18,133,65,8
+ CONTROL "Display PIM",IDC_SHOW_PIM,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,159,150,10
+ CONTROL "Use favorite label as Explorer drive label",IDC_FAVORITE_USE_LABEL_IN_EXPLORER,
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,202,203,10
END
IDD_DEFAULT_MOUNT_PARAMETERS DIALOGEX 0, 0, 167, 65
@@ -449,7 +452,7 @@ BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 373
TOPMARGIN, 7
- BOTTOMMARGIN, 308
+ BOTTOMMARGIN, 332
END
IDD_DEFAULT_MOUNT_PARAMETERS, DIALOG
diff --git a/src/Mount/Resource.h b/src/Mount/Resource.h
index 81c64dc0..adc116e0 100644
--- a/src/Mount/Resource.h
+++ b/src/Mount/Resource.h
@@ -167,6 +167,8 @@
#define IDC_OLD_PIM 1143
#define IDC_OLD_PIM_HELP 1144
#define IDC_NEW_PIM_ENABLE 1145
+#define IDC_SHOW_PIM 1146
+#define IDC_FAVORITE_USE_LABEL_IN_EXPLORER 1147
#define IDM_HELP 40001
#define IDM_ABOUT 40002
#define IDM_UNMOUNT_VOLUME 40003
@@ -242,7 +244,7 @@
#define _APS_NO_MFC 1
#define _APS_NEXT_RESOURCE_VALUE 119
#define _APS_NEXT_COMMAND_VALUE 40068
-#define _APS_NEXT_CONTROL_VALUE 1146
+#define _APS_NEXT_CONTROL_VALUE 1148
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif