diff options
author | Mounir IDRASSI <mounir.idrassi@idrix.fr> | 2016-04-08 23:51:29 +0200 |
---|---|---|
committer | Mounir IDRASSI <mounir.idrassi@idrix.fr> | 2016-04-08 23:53:49 +0200 |
commit | 60575d9a496bd4b796bab73888b69c249a1f8048 (patch) | |
tree | dc242c1029d53807c21c6779d68de7e3e83cd597 /src/Mount | |
parent | 409c0f79be069cd2cf3bdb31ddbbafd938f15791 (diff) | |
download | VeraCrypt-60575d9a496bd4b796bab73888b69c249a1f8048.tar.gz VeraCrypt-60575d9a496bd4b796bab73888b69c249a1f8048.zip |
Windows: start implementation of volume ID mechanism that will be used to identify VeraCrypt disk volumes instead of device name.
Diffstat (limited to 'src/Mount')
-rw-r--r-- | src/Mount/Favorites.cpp | 42 | ||||
-rw-r--r-- | src/Mount/Favorites.h | 6 | ||||
-rw-r--r-- | src/Mount/Mount.c | 10 | ||||
-rw-r--r-- | src/Mount/Mount.rc | 44 | ||||
-rw-r--r-- | src/Mount/Resource.h | 5 |
5 files changed, 83 insertions, 24 deletions
diff --git a/src/Mount/Favorites.cpp b/src/Mount/Favorites.cpp index 825562f2..5dde8da0 100644 --- a/src/Mount/Favorites.cpp +++ b/src/Mount/Favorites.cpp @@ -98,6 +98,7 @@ namespace VeraCrypt favorite.SystemEncryption = prop.partitionInInactiveSysEncScope ? true : false;
favorite.OpenExplorerWindow = (bExplore == TRUE);
favorite.Pim = prop.volumePim;
+ memcpy (favorite.VolumeID, prop.volumeID, SHA512_DIGESTSIZE);
if (favorite.VolumePathId.empty()
&& IsVolumeDeviceHosted (favorite.Path.c_str())
@@ -416,6 +417,19 @@ namespace VeraCrypt case WM_CLOSE:
EndDialog (hwndDlg, IDCLOSE);
return 1;
+ case WM_CTLCOLORSTATIC:
+ {
+ HDC hdc = (HDC) wParam;
+ HWND hw = (HWND) lParam;
+ if (hw == GetDlgItem(hwndDlg, IDC_FAVORITE_ID))
+ {
+ // This the favorite ID field. Make its background like normal edit
+ HBRUSH hbr = GetSysColorBrush (COLOR_WINDOW);
+ ::SelectObject(hdc, hbr);
+ return (BOOL) hbr;
+ }
+ }
+ break;
}
return 0;
@@ -566,6 +580,17 @@ namespace VeraCrypt favorite.Path = Utf8StringToWide (volume);
char label[1024];
+
+ XmlGetAttributeText (xml, "ID", label, sizeof (label));
+ if (strlen (label) == 128)
+ {
+ std::vector<byte> arr;
+ if (HexWideStringToArray (Utf8StringToWide (label).c_str(), arr) && arr.size() == SHA512_DIGEST_SIZE)
+ {
+ memcpy (favorite.VolumeID, &arr[0], SHA512_DIGEST_SIZE);
+ }
+ }
+
XmlGetAttributeText (xml, "label", label, sizeof (label));
favorite.Label = Utf8StringToWide (label);
@@ -612,6 +637,10 @@ namespace VeraCrypt if (boolVal[0])
favorite.UseLabelInExplorer = (boolVal[0] == '1') && !favorite.ReadOnly;
+ XmlGetAttributeText (xml, "useVolumeID", boolVal, sizeof (boolVal));
+ if (boolVal[0])
+ favorite.UseVolumeID = (boolVal[0] == '1') && !IsRepeatedByteArray (0, favorite.VolumeID, SHA512_DIGEST_SIZE);
+
if (favorite.Path.find (L"\\\\?\\Volume{") == 0 && favorite.Path.rfind (L"}\\") == favorite.Path.size() - 2)
{
wstring resolvedPath = VolumeGuidPathToDevicePath (favorite.Path);
@@ -709,6 +738,9 @@ namespace VeraCrypt wstring s = L"\n\t\t<volume mountpoint=\"" + favorite.MountPoint + L"\"";
+ if (!IsRepeatedByteArray (0, favorite.VolumeID, SHA512_DIGEST_SIZE))
+ s += L" ID=\"" + ArrayToHexWideString (favorite.VolumeID, SHA512_DIGEST_SIZE) + L"\"";
+
if (!favorite.Label.empty())
s += L" label=\"" + favorite.Label + L"\"";
@@ -739,6 +771,9 @@ namespace VeraCrypt if (favorite.UseLabelInExplorer && !favorite.ReadOnly)
s += L" useLabelInExplorer=\"1\"";
+ if (favorite.UseVolumeID && !IsRepeatedByteArray (0, favorite.VolumeID, SHA512_DIGEST_SIZE))
+ s += L" useVolumeID=\"1\"";
+
s += L">" + wstring (tq) + L"</volume>";
fwprintf (f, L"%ws", s.c_str());
@@ -819,6 +854,12 @@ namespace VeraCrypt SetCheckBox (hwndDlg, IDC_FAVORITE_MOUNT_ON_ARRIVAL, favorite.MountOnArrival);
SetCheckBox (hwndDlg, IDC_FAVORITE_MOUNT_READONLY, favorite.ReadOnly);
SetCheckBox (hwndDlg, IDC_FAVORITE_MOUNT_REMOVABLE, favorite.Removable);
+ SetCheckBox (hwndDlg, IDC_FAVORITE_USE_VOLUME_ID, favorite.UseVolumeID);
+
+ if (!IsRepeatedByteArray (0, favorite.VolumeID, SHA512_DIGESTSIZE))
+ {
+ SetDlgItemText (hwndDlg, IDC_FAVORITE_ID, ArrayToHexWideString (favorite.VolumeID, SHA512_DIGESTSIZE).c_str());
+ }
if (systemFavoritesMode)
{
@@ -873,6 +914,7 @@ namespace VeraCrypt favorite.Pim = GetPim (hwndDlg, IDC_PIM);
favorite.UseLabelInExplorer = (IsDlgButtonChecked (hwndDlg, IDC_FAVORITE_USE_LABEL_IN_EXPLORER) != 0);
+ favorite.UseVolumeID = (IsDlgButtonChecked (hwndDlg, IDC_FAVORITE_USE_VOLUME_ID) != 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 8195eb7b..538ec1db 100644 --- a/src/Mount/Favorites.h +++ b/src/Mount/Favorites.h @@ -30,8 +30,10 @@ namespace VeraCrypt ReadOnly (false),
Removable (false),
SystemEncryption (false),
- UseLabelInExplorer (false)
+ UseLabelInExplorer (false),
+ UseVolumeID (false)
{
+ memset (VolumeID, 0, SHA512_DIGESTSIZE);
}
wstring Path;
@@ -39,6 +41,7 @@ namespace VeraCrypt wstring VolumePathId;
wstring Label;
int Pim;
+ BYTE VolumeID[SHA512_DIGESTSIZE];
bool DisableHotkeyMount;
bool DisconnectedDevice;
@@ -49,6 +52,7 @@ namespace VeraCrypt bool Removable;
bool SystemEncryption;
bool UseLabelInExplorer;
+ bool UseVolumeID;
};
struct FavoriteVolumesDlgProcArguments
diff --git a/src/Mount/Mount.c b/src/Mount/Mount.c index 0acf58dd..dc7d825d 100644 --- a/src/Mount/Mount.c +++ b/src/Mount/Mount.c @@ -7065,7 +7065,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa {
OPEN_TEST_STRUCT ots = {0};
- if (!OpenDevice (vol, &ots, FALSE))
+ if (!OpenDevice (vol, &ots, FALSE, FALSE, NULL))
{
UnmountVolume (hwndDlg, m, TRUE);
WarningBalloon ("HOST_DEVICE_REMOVAL_DISMOUNT_WARN_TITLE", "HOST_DEVICE_REMOVAL_DISMOUNT_WARN", hwndDlg);
@@ -8899,6 +8899,7 @@ static BOOL MountFavoriteVolumeBase (HWND hwnd, const FavoriteVolume &favorite, {
BOOL status = TRUE;
int drive;
+ std::wstring effectiveVolumePath;
drive = towupper (favorite.MountPoint[0]) - L'A';
if ((drive < MIN_MOUNTED_VOLUME_DRIVE_NUMBER) || (drive > MAX_MOUNTED_VOLUME_DRIVE_NUMBER))
@@ -8919,6 +8920,11 @@ static BOOL MountFavoriteVolumeBase (HWND hwnd, const FavoriteVolume &favorite, else
ZeroMemory (mountOptions.Label, sizeof (mountOptions.Label));
+ if (favorite.UseVolumeID && !IsRepeatedByteArray (0, favorite.VolumeID, SHA512_DIGEST_SIZE))
+ effectiveVolumePath = L"ID:" + ArrayToHexWideString (favorite.VolumeID, SHA512_DIGEST_SIZE);
+ else
+ effectiveVolumePath = favorite.Path;
+
if (favorite.SystemEncryption)
{
mountOptions.PartitionInInactiveSysEncScope = TRUE;
@@ -8978,7 +8984,7 @@ static BOOL MountFavoriteVolumeBase (HWND hwnd, const FavoriteVolume &favorite, if (ServiceMode)
SystemFavoritesServiceLogInfo (wstring (L"Mounting system favorite \"") + favorite.Path + L"\"");
- status = Mount (hwnd, drive, (wchar_t *) favorite.Path.c_str(), favorite.Pim);
+ status = Mount (hwnd, drive, (wchar_t *) effectiveVolumePath.c_str(), favorite.Pim);
if (ServiceMode)
{
diff --git a/src/Mount/Mount.rc b/src/Mount/Mount.rc index f7f927e3..eb3178a0 100644 --- a/src/Mount/Mount.rc +++ b/src/Mount/Mount.rc @@ -330,7 +330,7 @@ BEGIN "Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,198,337,10
END
-IDD_FAVORITE_VOLUMES DIALOGEX 0, 0, 380, 339
+IDD_FAVORITE_VOLUMES DIALOGEX 0, 0, 380, 368
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
@@ -339,31 +339,35 @@ 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,18,185,204,13,ES_AUTOHSCROLL
+ EDITTEXT IDC_FAVORITE_LABEL,18,225,204,13,ES_AUTOHSCROLL
CONTROL "Mount selected volume as read-o&nly",IDC_FAVORITE_MOUNT_READONLY,
- "Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,215,349,10
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,255,349,10
CONTROL "Mount selected volume as remo&vable medium",IDC_FAVORITE_MOUNT_REMOVABLE,
- "Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,229,349,10
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,269,349,10
CONTROL "Mount selected volume upon log&on",IDC_FAVORITE_MOUNT_ON_LOGON,
- "Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,243,349,10
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,283,349,10
CONTROL "Mount selected volume when its host device gets &connected",IDC_FAVORITE_MOUNT_ON_ARRIVAL,
- "Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,257,349,10
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,297,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,271,349,11
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,311,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,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,180
- LTEXT "Label of selected favorite volume:",IDT_FAVORITE_LABEL,18,175,202,8
- GROUPBOX "Global Settings",IDC_FAV_VOL_OPTIONS_GLOBAL_SETTINGS_BOX,7,260,366,42
- 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
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,326,349,11
+ LTEXT "Help on favorite volumes",IDC_FAVORITES_HELP_LINK,17,351,237,10,SS_NOTIFY
+ DEFPUSHBUTTON "OK",IDOK,269,347,50,14
+ PUSHBUTTON "Cancel",IDCANCEL,323,347,50,14
+ GROUPBOX "",IDC_FAV_VOL_OPTIONS_GROUP_BOX,7,123,366,219
+ LTEXT "Label of selected favorite volume:",IDT_FAVORITE_LABEL,18,215,202,8
+ GROUPBOX "Global Settings",IDC_FAV_VOL_OPTIONS_GLOBAL_SETTINGS_BOX,7,300,366,42
+ EDITTEXT IDC_PIM,18,183,42,13,ES_RIGHT | ES_PASSWORD | ES_AUTOHSCROLL | ES_NUMBER
+ LTEXT "(Empty or 0 for default iterations)",IDC_PIM_HELP,64,185,189,8
+ LTEXT "Volume PIM:",IDT_PIM,18,173,65,8
+ CONTROL "Display PIM",IDC_SHOW_PIM,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,199,150,10
CONTROL "Use favorite label as Explorer drive label",IDC_FAVORITE_USE_LABEL_IN_EXPLORER,
- "Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,202,349,10
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,242,349,10
+ LTEXT "Volume ID:",IDT_FAVORITE_ID,18,131,57,8
+ EDITTEXT IDC_FAVORITE_ID,18,141,204,14,ES_AUTOHSCROLL | ES_READONLY
+ CONTROL "Use Volume ID to mount favorite",IDC_FAVORITE_USE_VOLUME_ID,
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,159,337,10
END
IDD_DEFAULT_MOUNT_PARAMETERS DIALOGEX 0, 0, 167, 65
@@ -468,7 +472,7 @@ BEGIN LEFTMARGIN, 7
RIGHTMARGIN, 373
TOPMARGIN, 7
- BOTTOMMARGIN, 332
+ BOTTOMMARGIN, 361
END
IDD_DEFAULT_MOUNT_PARAMETERS, DIALOG
diff --git a/src/Mount/Resource.h b/src/Mount/Resource.h index 1a3bc9b4..1cacfcd7 100644 --- a/src/Mount/Resource.h +++ b/src/Mount/Resource.h @@ -176,6 +176,9 @@ #define IDC_PREF_CACHE_PIM 1154
#define IDC_BOOT_LOADER_CACHE_PIM 1155
#define IDC_SHOW_DISCONNECTED_NETWORK_DRIVES 1156
+#define IDT_FAVORITE_ID 1157
+#define IDC_FAVORITE_ID 1158
+#define IDC_FAVORITE_USE_VOLUME_ID 1159
#define IDM_HELP 40001
#define IDM_ABOUT 40002
#define IDM_UNMOUNT_VOLUME 40003
@@ -252,7 +255,7 @@ #define _APS_NO_MFC 1
#define _APS_NEXT_RESOURCE_VALUE 119
#define _APS_NEXT_COMMAND_VALUE 40069
-#define _APS_NEXT_CONTROL_VALUE 1157
+#define _APS_NEXT_CONTROL_VALUE 1160
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
|