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.c79
-rw-r--r--src/Common/Dlgcode.h1
-rw-r--r--src/Common/Language.xml1
-rw-r--r--src/Common/Resource.h4
7 files changed, 107 insertions, 19 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 1a2758f6..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_PASSWORD | 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 6d7aa0d4..02b67c5f 100644
--- a/src/Common/Dlgcode.c
+++ b/src/Common/Dlgcode.c
@@ -3216,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());
}
@@ -4349,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];
@@ -6284,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;
@@ -6298,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
@@ -6613,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;
@@ -6919,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);
diff --git a/src/Common/Dlgcode.h b/src/Common/Dlgcode.h
index 544b8e6e..dec482bf 100644
--- a/src/Common/Dlgcode.h
+++ b/src/Common/Dlgcode.h
@@ -326,6 +326,7 @@ 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);
diff --git a/src/Common/Language.xml b/src/Common/Language.xml
index 431d9745..b590ce58 100644
--- a/src/Common/Language.xml
+++ b/src/Common/Language.xml
@@ -99,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>
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