VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Common
diff options
context:
space:
mode:
Diffstat (limited to 'src/Common')
-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
9 files changed, 226 insertions, 29 deletions
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