mirror of
https://github.com/veracrypt/VeraCrypt.git
synced 2025-11-11 19:08:26 -06:00
Windows: start implementation of volume ID mechanism that will be used to identify VeraCrypt disk volumes instead of device name.
This commit is contained in:
@@ -128,6 +128,7 @@ typedef struct
|
|||||||
unsigned __int32 ulMountedDrives; /* Bitfield of all mounted drive letters */
|
unsigned __int32 ulMountedDrives; /* Bitfield of all mounted drive letters */
|
||||||
wchar_t wszVolume[26][TC_MAX_PATH]; /* Volume names of mounted volumes */
|
wchar_t wszVolume[26][TC_MAX_PATH]; /* Volume names of mounted volumes */
|
||||||
wchar_t wszLabel[26][33]; /* Labels of mounted volumes */
|
wchar_t wszLabel[26][33]; /* Labels of mounted volumes */
|
||||||
|
wchar_t volumeID[26][SHA512_DIGEST_SIZE]; /* IDs of mounted volumes */
|
||||||
unsigned __int64 diskLength[26];
|
unsigned __int64 diskLength[26];
|
||||||
int ea[26];
|
int ea[26];
|
||||||
int volumeType[26]; /* Volume type (e.g. PROP_VOL_TYPE_OUTER, PROP_VOL_TYPE_OUTER_VOL_WRITE_PREVENTED, etc.) */
|
int volumeType[26]; /* Volume type (e.g. PROP_VOL_TYPE_OUTER, PROP_VOL_TYPE_OUTER_VOL_WRITE_PREVENTED, etc.) */
|
||||||
@@ -156,6 +157,7 @@ typedef struct
|
|||||||
int volumePim;
|
int volumePim;
|
||||||
wchar_t wszLabel[33];
|
wchar_t wszLabel[33];
|
||||||
BOOL bDriverSetLabel;
|
BOOL bDriverSetLabel;
|
||||||
|
unsigned char volumeID[SHA512_DIGESTSIZE];
|
||||||
} VOLUME_PROPERTIES_STRUCT;
|
} VOLUME_PROPERTIES_STRUCT;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
@@ -194,6 +196,9 @@ typedef struct
|
|||||||
BOOL TCBootLoaderDetected;
|
BOOL TCBootLoaderDetected;
|
||||||
BOOL DetectFilesystem;
|
BOOL DetectFilesystem;
|
||||||
BOOL FilesystemDetected;
|
BOOL FilesystemDetected;
|
||||||
|
BOOL bMatchVolumeID;
|
||||||
|
unsigned char volumeID[SHA512_DIGEST_SIZE];
|
||||||
|
BOOL VolumeIDMatched;
|
||||||
} OPEN_TEST_STRUCT;
|
} OPEN_TEST_STRUCT;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -2930,7 +2930,7 @@ void InitHelpFileName (void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL OpenDevice (const wchar_t *lpszPath, OPEN_TEST_STRUCT *driver, BOOL detectFilesystem)
|
BOOL OpenDevice (const wchar_t *lpszPath, OPEN_TEST_STRUCT *driver, BOOL detectFilesystem, BOOL matchVolumeID, BYTE* pbVolumeID)
|
||||||
{
|
{
|
||||||
DWORD dwResult;
|
DWORD dwResult;
|
||||||
BOOL bResult;
|
BOOL bResult;
|
||||||
@@ -2943,6 +2943,9 @@ BOOL OpenDevice (const wchar_t *lpszPath, OPEN_TEST_STRUCT *driver, BOOL detectF
|
|||||||
|
|
||||||
driver->bDetectTCBootLoader = FALSE;
|
driver->bDetectTCBootLoader = FALSE;
|
||||||
driver->DetectFilesystem = detectFilesystem;
|
driver->DetectFilesystem = detectFilesystem;
|
||||||
|
driver->bMatchVolumeID = matchVolumeID;
|
||||||
|
if (matchVolumeID && pbVolumeID)
|
||||||
|
memcpy (driver->volumeID, pbVolumeID, SHA512_DIGEST_SIZE);
|
||||||
|
|
||||||
bResult = DeviceIoControl (hDriver, TC_IOCTL_OPEN_TEST,
|
bResult = DeviceIoControl (hDriver, TC_IOCTL_OPEN_TEST,
|
||||||
driver, sizeof (OPEN_TEST_STRUCT),
|
driver, sizeof (OPEN_TEST_STRUCT),
|
||||||
@@ -4712,6 +4715,55 @@ wstring IntToWideString (int val)
|
|||||||
return szTmp;
|
return szTmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wstring ArrayToHexWideString (const unsigned char* pbData, int cbData)
|
||||||
|
{
|
||||||
|
static wchar_t* hexChar = L"0123456789ABCDEF";
|
||||||
|
wstring result;
|
||||||
|
if (pbData)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < cbData; i++)
|
||||||
|
{
|
||||||
|
result += hexChar[pbData[i] >> 4];
|
||||||
|
result += hexChar[pbData[i] & 0x0F];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool HexToByte (wchar_t c, byte& b)
|
||||||
|
{
|
||||||
|
bool bRet = true;
|
||||||
|
if (c >= L'0' && c <= L'9')
|
||||||
|
b = (byte) (c - L'0');
|
||||||
|
else if (c >= L'a' && c <= L'z')
|
||||||
|
b = (byte) (c - L'a' + 10);
|
||||||
|
else if (c >= L'A' && c <= L'Z')
|
||||||
|
b = (byte) (c - L'A' + 10);
|
||||||
|
else
|
||||||
|
bRet = false;
|
||||||
|
|
||||||
|
return bRet;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool HexWideStringToArray (const wchar_t* hexStr, std::vector<byte>& arr)
|
||||||
|
{
|
||||||
|
byte b1, b2;
|
||||||
|
size_t i, len = wcslen (hexStr);
|
||||||
|
|
||||||
|
arr.clear();
|
||||||
|
if (len %2)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
for (i = 0; i < len/2; i++)
|
||||||
|
{
|
||||||
|
if (!HexToByte (*hexStr++, b1) || !HexToByte (*hexStr++, b2))
|
||||||
|
return false;
|
||||||
|
arr.push_back (b1 << 4 | b2);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
wstring GetTempPathString ()
|
wstring GetTempPathString ()
|
||||||
{
|
{
|
||||||
wchar_t tempPath[MAX_PATH];
|
wchar_t tempPath[MAX_PATH];
|
||||||
@@ -7069,12 +7121,37 @@ void ShowWaitDialog(HWND hwnd, BOOL bUseHwndAsParent, WaitThreadProc callback, v
|
|||||||
|
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
|
|
||||||
|
static BOOL PerformMountIoctl (MOUNT_STRUCT* pmount, LPDWORD pdwResult, BOOL useVolumeID, BYTE volumeID[SHA512_DIGEST_SIZE])
|
||||||
|
{
|
||||||
|
if (useVolumeID)
|
||||||
|
{
|
||||||
|
wstring devicePath = FindDeviceByVolumeID (volumeID);
|
||||||
|
if (devicePath == L"")
|
||||||
|
{
|
||||||
|
if (pdwResult)
|
||||||
|
*pdwResult = 0;
|
||||||
|
SetLastError (ERROR_PATH_NOT_FOUND);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
BOOL bDevice = FALSE;
|
||||||
|
CreateFullVolumePath (pmount->wszVolume, sizeof(pmount->wszVolume), devicePath.c_str(), &bDevice);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return DeviceIoControl (hDriver, TC_IOCTL_MOUNT_VOLUME, pmount,
|
||||||
|
sizeof (MOUNT_STRUCT), pmount, sizeof (MOUNT_STRUCT), pdwResult, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
// specific definitions and implementation for support of mount operation
|
// specific definitions and implementation for support of mount operation
|
||||||
// in wait dialog mechanism
|
// in wait dialog mechanism
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
MOUNT_STRUCT* pmount;
|
MOUNT_STRUCT* pmount;
|
||||||
|
BOOL useVolumeID;
|
||||||
|
BYTE volumeID[SHA512_DIGEST_SIZE];
|
||||||
BOOL* pbResult;
|
BOOL* pbResult;
|
||||||
DWORD* pdwResult;
|
DWORD* pdwResult;
|
||||||
DWORD dwLastError;
|
DWORD dwLastError;
|
||||||
@@ -7084,8 +7161,7 @@ void CALLBACK MountWaitThreadProc(void* pArg, HWND )
|
|||||||
{
|
{
|
||||||
MountThreadParam* pThreadParam = (MountThreadParam*) pArg;
|
MountThreadParam* pThreadParam = (MountThreadParam*) pArg;
|
||||||
|
|
||||||
*(pThreadParam->pbResult) = DeviceIoControl (hDriver, TC_IOCTL_MOUNT_VOLUME, pThreadParam->pmount,
|
*(pThreadParam->pbResult) = PerformMountIoctl (pThreadParam->pmount, pThreadParam->pdwResult, pThreadParam->useVolumeID, pThreadParam->volumeID);
|
||||||
sizeof (MOUNT_STRUCT),pThreadParam->pmount, sizeof (MOUNT_STRUCT), pThreadParam->pdwResult, NULL);
|
|
||||||
|
|
||||||
pThreadParam->dwLastError = GetLastError ();
|
pThreadParam->dwLastError = GetLastError ();
|
||||||
}
|
}
|
||||||
@@ -7122,6 +7198,8 @@ int MountVolume (HWND hwndDlg,
|
|||||||
BOOL bResult, bDevice;
|
BOOL bResult, bDevice;
|
||||||
wchar_t root[MAX_PATH];
|
wchar_t root[MAX_PATH];
|
||||||
int favoriteMountOnArrivalRetryCount = 0;
|
int favoriteMountOnArrivalRetryCount = 0;
|
||||||
|
BOOL useVolumeID = FALSE;
|
||||||
|
BYTE volumeID[SHA512_DIGEST_SIZE] = {0};
|
||||||
|
|
||||||
#ifdef TCMOUNT
|
#ifdef TCMOUNT
|
||||||
if (mountOptions->PartitionInInactiveSysEncScope)
|
if (mountOptions->PartitionInInactiveSysEncScope)
|
||||||
@@ -7208,7 +7286,29 @@ retry:
|
|||||||
StringCchCopyW (volumePath, TC_MAX_PATH, resolvedPath.c_str());
|
StringCchCopyW (volumePath, TC_MAX_PATH, resolvedPath.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
CreateFullVolumePath (mount.wszVolume, sizeof(mount.wszVolume), volumePath, &bDevice);
|
if ((path.length () >= 3) && (_wcsnicmp (path.c_str(), L"ID:", 3) == 0))
|
||||||
|
{
|
||||||
|
std::vector<byte> arr;
|
||||||
|
if ( (path.length() == (3 + 2*SHA512_DIGEST_SIZE))
|
||||||
|
&& HexWideStringToArray (path.c_str() + 3, arr)
|
||||||
|
&& (arr.size() == SHA512_DIGEST_SIZE)
|
||||||
|
)
|
||||||
|
{
|
||||||
|
useVolumeID = TRUE;
|
||||||
|
bDevice = TRUE;
|
||||||
|
memcpy (volumeID, &arr[0], SHA512_DIGEST_SIZE);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!quiet)
|
||||||
|
Error ("VOLUME_ID_INVALID", hwndDlg);
|
||||||
|
|
||||||
|
SetLastError (ERROR_INVALID_PARAMETER);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
CreateFullVolumePath (mount.wszVolume, sizeof(mount.wszVolume), volumePath, &bDevice);
|
||||||
|
|
||||||
if (!bDevice)
|
if (!bDevice)
|
||||||
{
|
{
|
||||||
@@ -7284,6 +7384,8 @@ retry:
|
|||||||
{
|
{
|
||||||
MountThreadParam mountThreadParam;
|
MountThreadParam mountThreadParam;
|
||||||
mountThreadParam.pmount = &mount;
|
mountThreadParam.pmount = &mount;
|
||||||
|
mountThreadParam.useVolumeID = useVolumeID;
|
||||||
|
memcpy (mountThreadParam.volumeID, volumeID, SHA512_DIGESTSIZE);
|
||||||
mountThreadParam.pbResult = &bResult;
|
mountThreadParam.pbResult = &bResult;
|
||||||
mountThreadParam.pdwResult = &dwResult;
|
mountThreadParam.pdwResult = &dwResult;
|
||||||
mountThreadParam.dwLastError = ERROR_SUCCESS;
|
mountThreadParam.dwLastError = ERROR_SUCCESS;
|
||||||
@@ -7294,8 +7396,8 @@ retry:
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
bResult = DeviceIoControl (hDriver, TC_IOCTL_MOUNT_VOLUME, &mount,
|
bResult = PerformMountIoctl (&mount, &dwResult, useVolumeID, volumeID);
|
||||||
sizeof (mount), &mount, sizeof (mount), &dwResult, NULL);
|
|
||||||
dwLastError = GetLastError ();
|
dwLastError = GetLastError ();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -7588,25 +7690,40 @@ BOOL IsMountedVolume (const wchar_t *volname)
|
|||||||
MOUNT_LIST_STRUCT mlist;
|
MOUNT_LIST_STRUCT mlist;
|
||||||
DWORD dwResult;
|
DWORD dwResult;
|
||||||
int i;
|
int i;
|
||||||
wchar_t volume[TC_MAX_PATH*2+16];
|
|
||||||
|
|
||||||
StringCbCopyW (volume, sizeof(volume), volname);
|
|
||||||
|
|
||||||
if (wcsstr (volname, L"\\Device\\") != volname)
|
|
||||||
StringCbPrintfW(volume, sizeof(volume), L"\\??\\%s", volname);
|
|
||||||
|
|
||||||
wstring resolvedPath = VolumeGuidPathToDevicePath (volname);
|
|
||||||
if (!resolvedPath.empty())
|
|
||||||
StringCbCopyW (volume, sizeof (volume), resolvedPath.c_str());
|
|
||||||
|
|
||||||
memset (&mlist, 0, sizeof (mlist));
|
memset (&mlist, 0, sizeof (mlist));
|
||||||
DeviceIoControl (hDriver, TC_IOCTL_GET_MOUNTED_VOLUMES, &mlist,
|
DeviceIoControl (hDriver, TC_IOCTL_GET_MOUNTED_VOLUMES, &mlist,
|
||||||
sizeof (mlist), &mlist, sizeof (mlist), &dwResult,
|
sizeof (mlist), &mlist, sizeof (mlist), &dwResult,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
for (i=0 ; i<26; i++)
|
if ((wcslen (volname) == (3 + 2*SHA512_DIGEST_SIZE)) && _wcsnicmp (volname, L"ID:", 3) == 0)
|
||||||
if (0 == _wcsicmp ((wchar_t *) mlist.wszVolume[i], volume))
|
{
|
||||||
return TRUE;
|
/* Volume ID specified. Use it for matching mounted volumes. */
|
||||||
|
std::vector<byte> arr;
|
||||||
|
if (HexWideStringToArray (&volname[3], arr) && (arr.size() == SHA512_DIGEST_SIZE))
|
||||||
|
{
|
||||||
|
for (i=0 ; i<26; i++)
|
||||||
|
if (0 == memcmp (mlist.volumeID[i], &arr[0], SHA512_DIGEST_SIZE))
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
wchar_t volume[TC_MAX_PATH*2+16];
|
||||||
|
|
||||||
|
StringCbCopyW (volume, sizeof(volume), volname);
|
||||||
|
|
||||||
|
if (wcsstr (volname, L"\\Device\\") != volname)
|
||||||
|
StringCbPrintfW(volume, sizeof(volume), L"\\??\\%s", volname);
|
||||||
|
|
||||||
|
wstring resolvedPath = VolumeGuidPathToDevicePath (volname);
|
||||||
|
if (!resolvedPath.empty())
|
||||||
|
StringCbCopyW (volume, sizeof (volume), resolvedPath.c_str());
|
||||||
|
|
||||||
|
for (i=0 ; i<26; i++)
|
||||||
|
if (0 == _wcsicmp ((wchar_t *) mlist.wszVolume[i], volume))
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
@@ -10875,7 +10992,7 @@ std::vector <HostDevice> GetAvailableHostDevices (bool noDeviceProperties, bool
|
|||||||
const wchar_t *devPath = devPathStr.c_str();
|
const wchar_t *devPath = devPathStr.c_str();
|
||||||
|
|
||||||
OPEN_TEST_STRUCT openTest = {0};
|
OPEN_TEST_STRUCT openTest = {0};
|
||||||
if (!OpenDevice (devPath, &openTest, detectUnencryptedFilesystems && partNumber != 0))
|
if (!OpenDevice (devPath, &openTest, detectUnencryptedFilesystems && partNumber != 0, FALSE, NULL))
|
||||||
{
|
{
|
||||||
if (partNumber == 0)
|
if (partNumber == 0)
|
||||||
break;
|
break;
|
||||||
@@ -10980,7 +11097,7 @@ std::vector <HostDevice> GetAvailableHostDevices (bool noDeviceProperties, bool
|
|||||||
const wchar_t *devPath = devPathStr.c_str();
|
const wchar_t *devPath = devPathStr.c_str();
|
||||||
|
|
||||||
OPEN_TEST_STRUCT openTest = {0};
|
OPEN_TEST_STRUCT openTest = {0};
|
||||||
if (!OpenDevice (devPath, &openTest, detectUnencryptedFilesystems))
|
if (!OpenDevice (devPath, &openTest, detectUnencryptedFilesystems, FALSE, NULL))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
DISK_PARTITION_INFO_STRUCT info;
|
DISK_PARTITION_INFO_STRUCT info;
|
||||||
@@ -11020,6 +11137,30 @@ std::vector <HostDevice> GetAvailableHostDevices (bool noDeviceProperties, bool
|
|||||||
return devices;
|
return devices;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wstring FindDeviceByVolumeID (BYTE volumeID [SHA512_DIGEST_SIZE])
|
||||||
|
{
|
||||||
|
for (int devNumber = 0; devNumber < MAX_HOST_DRIVE_NUMBER; devNumber++)
|
||||||
|
{
|
||||||
|
for (int partNumber = 0; partNumber < MAX_HOST_PARTITION_NUMBER; partNumber++)
|
||||||
|
{
|
||||||
|
wstringstream strm;
|
||||||
|
strm << L"\\Device\\Harddisk" << devNumber << L"\\Partition" << partNumber;
|
||||||
|
wstring devPathStr (strm.str());
|
||||||
|
const wchar_t *devPath = devPathStr.c_str();
|
||||||
|
|
||||||
|
OPEN_TEST_STRUCT openTest = {0};
|
||||||
|
if (!OpenDevice (devPath, &openTest, FALSE, TRUE, volumeID))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (openTest.VolumeIDMatched)
|
||||||
|
return devPath;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return L"";
|
||||||
|
}
|
||||||
|
|
||||||
BOOL FileHasReadOnlyAttribute (const wchar_t *path)
|
BOOL FileHasReadOnlyAttribute (const wchar_t *path)
|
||||||
{
|
{
|
||||||
@@ -11241,8 +11382,25 @@ BOOL VolumePathExists (const wchar_t *volumePath)
|
|||||||
|
|
||||||
UpperCaseCopy (upperCasePath, sizeof(upperCasePath), volumePath);
|
UpperCaseCopy (upperCasePath, sizeof(upperCasePath), volumePath);
|
||||||
|
|
||||||
|
if (wcsstr (upperCasePath, L"ID:") == upperCasePath)
|
||||||
|
{
|
||||||
|
std::vector<byte> arr;
|
||||||
|
if ( (wcslen (upperCasePath) == (3 + 2*SHA512_DIGEST_SIZE))
|
||||||
|
&& HexWideStringToArray (&upperCasePath[3], arr)
|
||||||
|
&& (arr.size() == SHA512_DIGEST_SIZE)
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (FindDeviceByVolumeID (&arr[0]).length() > 0)
|
||||||
|
return TRUE;
|
||||||
|
else
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
if (wcsstr (upperCasePath, L"\\DEVICE\\") == upperCasePath)
|
if (wcsstr (upperCasePath, L"\\DEVICE\\") == upperCasePath)
|
||||||
return OpenDevice (volumePath, &openTest, FALSE);
|
return OpenDevice (volumePath, &openTest, FALSE, FALSE, NULL);
|
||||||
|
|
||||||
wstring path = volumePath;
|
wstring path = volumePath;
|
||||||
if (path.find (L"\\\\?\\Volume{") == 0 && path.rfind (L"}\\") == path.size() - 2)
|
if (path.find (L"\\\\?\\Volume{") == 0 && path.rfind (L"}\\") == path.size() - 2)
|
||||||
@@ -11610,3 +11768,20 @@ void AllowMessageInUIPI (UINT msg)
|
|||||||
ChangeWindowMessageFilterFn (msg, MSGFLT_ADD);
|
ChangeWindowMessageFilterFn (msg, MSGFLT_ADD);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOL IsRepeatedByteArray (byte value, const byte* buffer, size_t bufferSize)
|
||||||
|
{
|
||||||
|
if (buffer && bufferSize)
|
||||||
|
{
|
||||||
|
size_t i;
|
||||||
|
for (i = 0; i < bufferSize; i++)
|
||||||
|
{
|
||||||
|
if (*buffer++ != value)
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -298,7 +298,7 @@ void InitOSVersionInfo ();
|
|||||||
void InitApp ( HINSTANCE hInstance, wchar_t *lpszCommandLine );
|
void InitApp ( HINSTANCE hInstance, wchar_t *lpszCommandLine );
|
||||||
void FinalizeApp (void);
|
void FinalizeApp (void);
|
||||||
void InitHelpFileName (void);
|
void InitHelpFileName (void);
|
||||||
BOOL OpenDevice (const wchar_t *lpszPath, OPEN_TEST_STRUCT *driver, BOOL detectFilesystem);
|
BOOL OpenDevice (const wchar_t *lpszPath, OPEN_TEST_STRUCT *driver, BOOL detectFilesystem, BOOL matchVolumeID, BYTE* pbVolumeID);
|
||||||
void NotifyDriverOfPortableMode (void);
|
void NotifyDriverOfPortableMode (void);
|
||||||
int GetAvailableFixedDisks ( HWND hComboBox , char *lpszRootPath );
|
int GetAvailableFixedDisks ( HWND hComboBox , char *lpszRootPath );
|
||||||
int GetAvailableRemovables ( HWND hComboBox , char *lpszRootPath );
|
int GetAvailableRemovables ( HWND hComboBox , char *lpszRootPath );
|
||||||
@@ -501,6 +501,7 @@ int AddBitmapToImageList(HIMAGELIST himl, HBITMAP hbmImage, HBITMAP hbmMask);
|
|||||||
HRESULT VCStrDupW(LPCWSTR psz, LPWSTR *ppwsz);
|
HRESULT VCStrDupW(LPCWSTR psz, LPWSTR *ppwsz);
|
||||||
void ProcessEntropyEstimate (HWND hProgress, DWORD* pdwInitialValue, DWORD dwCounter, DWORD dwMaxLevel, DWORD* pdwEntropy);
|
void ProcessEntropyEstimate (HWND hProgress, DWORD* pdwInitialValue, DWORD dwCounter, DWORD dwMaxLevel, DWORD* pdwEntropy);
|
||||||
void AllowMessageInUIPI (UINT msg);
|
void AllowMessageInUIPI (UINT msg);
|
||||||
|
BOOL IsRepeatedByteArray (byte value, const byte* buffer, size_t bufferSize);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
@@ -565,6 +566,9 @@ std::wstring HarddiskVolumePathToPartitionPath (const std::wstring &harddiskVolu
|
|||||||
std::wstring FindLatestFileOrDirectory (const std::wstring &directory, const wchar_t *namePattern, bool findDirectory, bool findFile);
|
std::wstring FindLatestFileOrDirectory (const std::wstring &directory, const wchar_t *namePattern, bool findDirectory, bool findFile);
|
||||||
std::wstring GetUserFriendlyVersionString (int version);
|
std::wstring GetUserFriendlyVersionString (int version);
|
||||||
std::wstring IntToWideString (int val);
|
std::wstring IntToWideString (int val);
|
||||||
|
std::wstring ArrayToHexWideString (const unsigned char* pbData, int cbData);
|
||||||
|
bool HexWideStringToArray (const wchar_t* hexStr, std::vector<byte>& arr);
|
||||||
|
std::wstring FindDeviceByVolumeID (BYTE volumeID [SHA512_DIGEST_SIZE]);
|
||||||
void RegisterDriverInf (bool registerFilter, const std::string& filter, const std::string& filterReg, HWND ParentWindow, HKEY regKey);
|
void RegisterDriverInf (bool registerFilter, const std::string& filter, const std::string& filterReg, HWND ParentWindow, HKEY regKey);
|
||||||
std::wstring GetTempPathString ();
|
std::wstring GetTempPathString ();
|
||||||
inline std::wstring AppendSrcPos (const wchar_t* msg, const char* srcPos)
|
inline std::wstring AppendSrcPos (const wchar_t* msg, const char* srcPos)
|
||||||
|
|||||||
@@ -1388,6 +1388,9 @@
|
|||||||
<string lang="en" key="INIT_DLL">Error: Failed to load a system library.</string>
|
<string lang="en" key="INIT_DLL">Error: Failed to load a system library.</string>
|
||||||
<string lang="en" key="ERR_EXFAT_INVALID_VOLUME_SIZE">The volume file size specified in the command line is incompatible with selected exFAT filesystem.</string>
|
<string lang="en" key="ERR_EXFAT_INVALID_VOLUME_SIZE">The volume file size specified in the command line is incompatible with selected exFAT filesystem.</string>
|
||||||
<control lang="en" key="IDT_ENTROPY_BAR">Randomness Collected From Mouse Movements</control>
|
<control lang="en" key="IDT_ENTROPY_BAR">Randomness Collected From Mouse Movements</control>
|
||||||
|
<control lang="en" key="IDT_FAVORITE_ID">Volume ID:</control>
|
||||||
|
<control lang="en" key="IDC_FAVORITE_USE_VOLUME_ID">Use Volume ID to mount favorite</control>
|
||||||
|
<string lang="en" key="VOLUME_ID_INVALID">The Volume ID value is invalid</string>
|
||||||
</localization>
|
</localization>
|
||||||
<!-- XML Schema -->
|
<!-- XML Schema -->
|
||||||
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
|
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
|
||||||
|
|||||||
@@ -975,7 +975,7 @@ NTSTATUS ProcessMainDeviceControlIrp (PDEVICE_OBJECT DeviceObject, PEXTENSION Ex
|
|||||||
|
|
||||||
InitializeObjectAttributes (&ObjectAttributes, &FullFileName, OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE, NULL, NULL);
|
InitializeObjectAttributes (&ObjectAttributes, &FullFileName, OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE, NULL, NULL);
|
||||||
|
|
||||||
if (opentest->bDetectTCBootLoader || opentest->DetectFilesystem)
|
if (opentest->bDetectTCBootLoader || opentest->DetectFilesystem || opentest->bMatchVolumeID)
|
||||||
access |= FILE_READ_DATA;
|
access |= FILE_READ_DATA;
|
||||||
|
|
||||||
ntStatus = ZwCreateFile (&NtFileHandle,
|
ntStatus = ZwCreateFile (&NtFileHandle,
|
||||||
@@ -986,8 +986,9 @@ NTSTATUS ProcessMainDeviceControlIrp (PDEVICE_OBJECT DeviceObject, PEXTENSION Ex
|
|||||||
{
|
{
|
||||||
opentest->TCBootLoaderDetected = FALSE;
|
opentest->TCBootLoaderDetected = FALSE;
|
||||||
opentest->FilesystemDetected = FALSE;
|
opentest->FilesystemDetected = FALSE;
|
||||||
|
opentest->VolumeIDMatched = FALSE;
|
||||||
|
|
||||||
if (opentest->bDetectTCBootLoader || opentest->DetectFilesystem)
|
if (opentest->bDetectTCBootLoader || opentest->DetectFilesystem || opentest->bMatchVolumeID)
|
||||||
{
|
{
|
||||||
byte *readBuffer = TCalloc (TC_MAX_VOLUME_SECTOR_SIZE);
|
byte *readBuffer = TCalloc (TC_MAX_VOLUME_SECTOR_SIZE);
|
||||||
if (!readBuffer)
|
if (!readBuffer)
|
||||||
@@ -996,48 +997,98 @@ NTSTATUS ProcessMainDeviceControlIrp (PDEVICE_OBJECT DeviceObject, PEXTENSION Ex
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Determine if the first sector contains a portion of the VeraCrypt Boot Loader
|
if (opentest->bDetectTCBootLoader || opentest->DetectFilesystem)
|
||||||
|
|
||||||
offset.QuadPart = 0;
|
|
||||||
|
|
||||||
ntStatus = ZwReadFile (NtFileHandle,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
&IoStatus,
|
|
||||||
readBuffer,
|
|
||||||
TC_MAX_VOLUME_SECTOR_SIZE,
|
|
||||||
&offset,
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
if (NT_SUCCESS (ntStatus))
|
|
||||||
{
|
{
|
||||||
size_t i;
|
// Determine if the first sector contains a portion of the VeraCrypt Boot Loader
|
||||||
|
|
||||||
if (opentest->bDetectTCBootLoader && IoStatus.Information >= TC_SECTOR_SIZE_BIOS)
|
offset.QuadPart = 0;
|
||||||
|
|
||||||
|
ntStatus = ZwReadFile (NtFileHandle,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
&IoStatus,
|
||||||
|
readBuffer,
|
||||||
|
TC_MAX_VOLUME_SECTOR_SIZE,
|
||||||
|
&offset,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
if (NT_SUCCESS (ntStatus))
|
||||||
{
|
{
|
||||||
// Search for the string "VeraCrypt"
|
size_t i;
|
||||||
for (i = 0; i < TC_SECTOR_SIZE_BIOS - strlen (TC_APP_NAME); ++i)
|
|
||||||
|
if (opentest->bDetectTCBootLoader && IoStatus.Information >= TC_SECTOR_SIZE_BIOS)
|
||||||
{
|
{
|
||||||
if (memcmp (readBuffer + i, TC_APP_NAME, strlen (TC_APP_NAME)) == 0)
|
// Search for the string "VeraCrypt"
|
||||||
|
for (i = 0; i < TC_SECTOR_SIZE_BIOS - strlen (TC_APP_NAME); ++i)
|
||||||
{
|
{
|
||||||
opentest->TCBootLoaderDetected = TRUE;
|
if (memcmp (readBuffer + i, TC_APP_NAME, strlen (TC_APP_NAME)) == 0)
|
||||||
|
{
|
||||||
|
opentest->TCBootLoaderDetected = TRUE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (opentest->DetectFilesystem && IoStatus.Information >= sizeof (int64))
|
||||||
|
{
|
||||||
|
switch (BE64 (*(uint64 *) readBuffer))
|
||||||
|
{
|
||||||
|
case 0xEB52904E54465320: // NTFS
|
||||||
|
case 0xEB3C904D53444F53: // FAT16
|
||||||
|
case 0xEB58904D53444F53: // FAT32
|
||||||
|
case 0xEB76904558464154: // exFAT
|
||||||
|
|
||||||
|
opentest->FilesystemDetected = TRUE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (opentest->DetectFilesystem && IoStatus.Information >= sizeof (int64))
|
if (opentest->bMatchVolumeID)
|
||||||
|
{
|
||||||
|
int volumeType;
|
||||||
|
BYTE volumeID[SHA512_DIGEST_SIZE];
|
||||||
|
|
||||||
|
// Go through all volume types (e.g., normal, hidden)
|
||||||
|
for (volumeType = TC_VOLUME_TYPE_NORMAL;
|
||||||
|
volumeType < TC_VOLUME_TYPE_COUNT;
|
||||||
|
volumeType++)
|
||||||
{
|
{
|
||||||
switch (BE64 (*(uint64 *) readBuffer))
|
/* Read the volume header */
|
||||||
|
switch (volumeType)
|
||||||
{
|
{
|
||||||
case 0xEB52904E54465320: // NTFS
|
case TC_VOLUME_TYPE_NORMAL:
|
||||||
case 0xEB3C904D53444F53: // FAT16
|
offset.QuadPart = TC_VOLUME_HEADER_OFFSET;
|
||||||
case 0xEB58904D53444F53: // FAT32
|
|
||||||
case 0xEB76904558464154: // exFAT
|
|
||||||
|
|
||||||
opentest->FilesystemDetected = TRUE;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case TC_VOLUME_TYPE_HIDDEN:
|
||||||
|
|
||||||
|
offset.QuadPart = TC_HIDDEN_VOLUME_HEADER_OFFSET;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
ntStatus = ZwReadFile (Extension->hDeviceFile,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
&IoStatus,
|
||||||
|
readBuffer,
|
||||||
|
TC_MAX_VOLUME_SECTOR_SIZE,
|
||||||
|
&offset,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
if (NT_SUCCESS (ntStatus))
|
||||||
|
{
|
||||||
|
/* compute the ID of this volume: SHA-512 of the effective header */
|
||||||
|
sha512 (volumeID, readBuffer, TC_VOLUME_HEADER_EFFECTIVE_SIZE);
|
||||||
|
|
||||||
|
if (0 == memcmp (volumeID, opentest->volumeID, SHA512_DIGEST_SIZE))
|
||||||
|
{
|
||||||
|
opentest->VolumeIDMatched = TRUE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1214,6 +1265,7 @@ NTSTATUS ProcessMainDeviceControlIrp (PDEVICE_OBJECT DeviceObject, PEXTENSION Ex
|
|||||||
list->ulMountedDrives |= (1 << ListExtension->nDosDriveNo);
|
list->ulMountedDrives |= (1 << ListExtension->nDosDriveNo);
|
||||||
RtlStringCbCopyW (list->wszVolume[ListExtension->nDosDriveNo], sizeof(list->wszVolume[ListExtension->nDosDriveNo]),ListExtension->wszVolume);
|
RtlStringCbCopyW (list->wszVolume[ListExtension->nDosDriveNo], sizeof(list->wszVolume[ListExtension->nDosDriveNo]),ListExtension->wszVolume);
|
||||||
RtlStringCbCopyW (list->wszLabel[ListExtension->nDosDriveNo], sizeof(list->wszLabel[ListExtension->nDosDriveNo]),ListExtension->wszLabel);
|
RtlStringCbCopyW (list->wszLabel[ListExtension->nDosDriveNo], sizeof(list->wszLabel[ListExtension->nDosDriveNo]),ListExtension->wszLabel);
|
||||||
|
memcpy (list->volumeID[ListExtension->nDosDriveNo], ListExtension->volumeID, SHA512_DIGEST_SIZE);
|
||||||
list->diskLength[ListExtension->nDosDriveNo] = ListExtension->DiskLength;
|
list->diskLength[ListExtension->nDosDriveNo] = ListExtension->DiskLength;
|
||||||
list->ea[ListExtension->nDosDriveNo] = ListExtension->cryptoInfo->ea;
|
list->ea[ListExtension->nDosDriveNo] = ListExtension->cryptoInfo->ea;
|
||||||
if (ListExtension->cryptoInfo->hiddenVolume)
|
if (ListExtension->cryptoInfo->hiddenVolume)
|
||||||
@@ -1265,6 +1317,7 @@ NTSTATUS ProcessMainDeviceControlIrp (PDEVICE_OBJECT DeviceObject, PEXTENSION Ex
|
|||||||
prop->uniqueId = ListExtension->UniqueVolumeId;
|
prop->uniqueId = ListExtension->UniqueVolumeId;
|
||||||
RtlStringCbCopyW (prop->wszVolume, sizeof(prop->wszVolume),ListExtension->wszVolume);
|
RtlStringCbCopyW (prop->wszVolume, sizeof(prop->wszVolume),ListExtension->wszVolume);
|
||||||
RtlStringCbCopyW (prop->wszLabel, sizeof(prop->wszLabel),ListExtension->wszLabel);
|
RtlStringCbCopyW (prop->wszLabel, sizeof(prop->wszLabel),ListExtension->wszLabel);
|
||||||
|
memcpy (prop->volumeID, ListExtension->volumeID, SHA512_DIGEST_SIZE);
|
||||||
prop->bDriverSetLabel = ListExtension->bDriverSetLabel;
|
prop->bDriverSetLabel = ListExtension->bDriverSetLabel;
|
||||||
prop->diskLength = ListExtension->DiskLength;
|
prop->diskLength = ListExtension->DiskLength;
|
||||||
prop->ea = ListExtension->cryptoInfo->ea;
|
prop->ea = ListExtension->cryptoInfo->ea;
|
||||||
|
|||||||
@@ -81,6 +81,8 @@ typedef struct EXTENSION
|
|||||||
BOOL bIsNTFS;
|
BOOL bIsNTFS;
|
||||||
BOOL bDriverSetLabel;
|
BOOL bDriverSetLabel;
|
||||||
|
|
||||||
|
unsigned char volumeID[SHA512_DIGESTSIZE];
|
||||||
|
|
||||||
LARGE_INTEGER fileCreationTime;
|
LARGE_INTEGER fileCreationTime;
|
||||||
LARGE_INTEGER fileLastAccessTime;
|
LARGE_INTEGER fileLastAccessTime;
|
||||||
LARGE_INTEGER fileLastWriteTime;
|
LARGE_INTEGER fileLastWriteTime;
|
||||||
|
|||||||
@@ -517,6 +517,9 @@ NTSTATUS TCOpenVolume (PDEVICE_OBJECT DeviceObject,
|
|||||||
|
|
||||||
Extension->cryptoInfo->bPartitionInInactiveSysEncScope = mount->bPartitionInInactiveSysEncScope;
|
Extension->cryptoInfo->bPartitionInInactiveSysEncScope = mount->bPartitionInInactiveSysEncScope;
|
||||||
|
|
||||||
|
/* compute the ID of this volume: SHA-512 of the effective header */
|
||||||
|
sha512 (Extension->volumeID, readBuffer, TC_VOLUME_HEADER_EFFECTIVE_SIZE);
|
||||||
|
|
||||||
if (volumeType == TC_VOLUME_TYPE_NORMAL)
|
if (volumeType == TC_VOLUME_TYPE_NORMAL)
|
||||||
{
|
{
|
||||||
if (mount->bPartitionInInactiveSysEncScope)
|
if (mount->bPartitionInInactiveSysEncScope)
|
||||||
|
|||||||
@@ -98,6 +98,7 @@ namespace VeraCrypt
|
|||||||
favorite.SystemEncryption = prop.partitionInInactiveSysEncScope ? true : false;
|
favorite.SystemEncryption = prop.partitionInInactiveSysEncScope ? true : false;
|
||||||
favorite.OpenExplorerWindow = (bExplore == TRUE);
|
favorite.OpenExplorerWindow = (bExplore == TRUE);
|
||||||
favorite.Pim = prop.volumePim;
|
favorite.Pim = prop.volumePim;
|
||||||
|
memcpy (favorite.VolumeID, prop.volumeID, SHA512_DIGESTSIZE);
|
||||||
|
|
||||||
if (favorite.VolumePathId.empty()
|
if (favorite.VolumePathId.empty()
|
||||||
&& IsVolumeDeviceHosted (favorite.Path.c_str())
|
&& IsVolumeDeviceHosted (favorite.Path.c_str())
|
||||||
@@ -416,6 +417,19 @@ namespace VeraCrypt
|
|||||||
case WM_CLOSE:
|
case WM_CLOSE:
|
||||||
EndDialog (hwndDlg, IDCLOSE);
|
EndDialog (hwndDlg, IDCLOSE);
|
||||||
return 1;
|
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;
|
return 0;
|
||||||
@@ -566,6 +580,17 @@ namespace VeraCrypt
|
|||||||
favorite.Path = Utf8StringToWide (volume);
|
favorite.Path = Utf8StringToWide (volume);
|
||||||
|
|
||||||
char label[1024];
|
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));
|
XmlGetAttributeText (xml, "label", label, sizeof (label));
|
||||||
favorite.Label = Utf8StringToWide (label);
|
favorite.Label = Utf8StringToWide (label);
|
||||||
|
|
||||||
@@ -612,6 +637,10 @@ namespace VeraCrypt
|
|||||||
if (boolVal[0])
|
if (boolVal[0])
|
||||||
favorite.UseLabelInExplorer = (boolVal[0] == '1') && !favorite.ReadOnly;
|
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)
|
if (favorite.Path.find (L"\\\\?\\Volume{") == 0 && favorite.Path.rfind (L"}\\") == favorite.Path.size() - 2)
|
||||||
{
|
{
|
||||||
wstring resolvedPath = VolumeGuidPathToDevicePath (favorite.Path);
|
wstring resolvedPath = VolumeGuidPathToDevicePath (favorite.Path);
|
||||||
@@ -709,6 +738,9 @@ namespace VeraCrypt
|
|||||||
|
|
||||||
wstring s = L"\n\t\t<volume mountpoint=\"" + favorite.MountPoint + L"\"";
|
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())
|
if (!favorite.Label.empty())
|
||||||
s += L" label=\"" + favorite.Label + L"\"";
|
s += L" label=\"" + favorite.Label + L"\"";
|
||||||
|
|
||||||
@@ -739,6 +771,9 @@ namespace VeraCrypt
|
|||||||
if (favorite.UseLabelInExplorer && !favorite.ReadOnly)
|
if (favorite.UseLabelInExplorer && !favorite.ReadOnly)
|
||||||
s += L" useLabelInExplorer=\"1\"";
|
s += L" useLabelInExplorer=\"1\"";
|
||||||
|
|
||||||
|
if (favorite.UseVolumeID && !IsRepeatedByteArray (0, favorite.VolumeID, SHA512_DIGEST_SIZE))
|
||||||
|
s += L" useVolumeID=\"1\"";
|
||||||
|
|
||||||
s += L">" + wstring (tq) + L"</volume>";
|
s += L">" + wstring (tq) + L"</volume>";
|
||||||
|
|
||||||
fwprintf (f, L"%ws", s.c_str());
|
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_ON_ARRIVAL, favorite.MountOnArrival);
|
||||||
SetCheckBox (hwndDlg, IDC_FAVORITE_MOUNT_READONLY, favorite.ReadOnly);
|
SetCheckBox (hwndDlg, IDC_FAVORITE_MOUNT_READONLY, favorite.ReadOnly);
|
||||||
SetCheckBox (hwndDlg, IDC_FAVORITE_MOUNT_REMOVABLE, favorite.Removable);
|
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)
|
if (systemFavoritesMode)
|
||||||
{
|
{
|
||||||
@@ -873,6 +914,7 @@ namespace VeraCrypt
|
|||||||
|
|
||||||
favorite.Pim = GetPim (hwndDlg, IDC_PIM);
|
favorite.Pim = GetPim (hwndDlg, IDC_PIM);
|
||||||
favorite.UseLabelInExplorer = (IsDlgButtonChecked (hwndDlg, IDC_FAVORITE_USE_LABEL_IN_EXPLORER) != 0);
|
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.ReadOnly = (IsDlgButtonChecked (hwndDlg, IDC_FAVORITE_MOUNT_READONLY) != 0);
|
||||||
favorite.Removable = (IsDlgButtonChecked (hwndDlg, IDC_FAVORITE_MOUNT_REMOVABLE) != 0);
|
favorite.Removable = (IsDlgButtonChecked (hwndDlg, IDC_FAVORITE_MOUNT_REMOVABLE) != 0);
|
||||||
|
|||||||
@@ -30,8 +30,10 @@ namespace VeraCrypt
|
|||||||
ReadOnly (false),
|
ReadOnly (false),
|
||||||
Removable (false),
|
Removable (false),
|
||||||
SystemEncryption (false),
|
SystemEncryption (false),
|
||||||
UseLabelInExplorer (false)
|
UseLabelInExplorer (false),
|
||||||
|
UseVolumeID (false)
|
||||||
{
|
{
|
||||||
|
memset (VolumeID, 0, SHA512_DIGESTSIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
wstring Path;
|
wstring Path;
|
||||||
@@ -39,6 +41,7 @@ namespace VeraCrypt
|
|||||||
wstring VolumePathId;
|
wstring VolumePathId;
|
||||||
wstring Label;
|
wstring Label;
|
||||||
int Pim;
|
int Pim;
|
||||||
|
BYTE VolumeID[SHA512_DIGESTSIZE];
|
||||||
|
|
||||||
bool DisableHotkeyMount;
|
bool DisableHotkeyMount;
|
||||||
bool DisconnectedDevice;
|
bool DisconnectedDevice;
|
||||||
@@ -49,6 +52,7 @@ namespace VeraCrypt
|
|||||||
bool Removable;
|
bool Removable;
|
||||||
bool SystemEncryption;
|
bool SystemEncryption;
|
||||||
bool UseLabelInExplorer;
|
bool UseLabelInExplorer;
|
||||||
|
bool UseVolumeID;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct FavoriteVolumesDlgProcArguments
|
struct FavoriteVolumesDlgProcArguments
|
||||||
|
|||||||
@@ -7065,7 +7065,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
|
|||||||
{
|
{
|
||||||
OPEN_TEST_STRUCT ots = {0};
|
OPEN_TEST_STRUCT ots = {0};
|
||||||
|
|
||||||
if (!OpenDevice (vol, &ots, FALSE))
|
if (!OpenDevice (vol, &ots, FALSE, FALSE, NULL))
|
||||||
{
|
{
|
||||||
UnmountVolume (hwndDlg, m, TRUE);
|
UnmountVolume (hwndDlg, m, TRUE);
|
||||||
WarningBalloon ("HOST_DEVICE_REMOVAL_DISMOUNT_WARN_TITLE", "HOST_DEVICE_REMOVAL_DISMOUNT_WARN", hwndDlg);
|
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;
|
BOOL status = TRUE;
|
||||||
int drive;
|
int drive;
|
||||||
|
std::wstring effectiveVolumePath;
|
||||||
drive = towupper (favorite.MountPoint[0]) - L'A';
|
drive = towupper (favorite.MountPoint[0]) - L'A';
|
||||||
|
|
||||||
if ((drive < MIN_MOUNTED_VOLUME_DRIVE_NUMBER) || (drive > MAX_MOUNTED_VOLUME_DRIVE_NUMBER))
|
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
|
else
|
||||||
ZeroMemory (mountOptions.Label, sizeof (mountOptions.Label));
|
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)
|
if (favorite.SystemEncryption)
|
||||||
{
|
{
|
||||||
mountOptions.PartitionInInactiveSysEncScope = TRUE;
|
mountOptions.PartitionInInactiveSysEncScope = TRUE;
|
||||||
@@ -8978,7 +8984,7 @@ static BOOL MountFavoriteVolumeBase (HWND hwnd, const FavoriteVolume &favorite,
|
|||||||
if (ServiceMode)
|
if (ServiceMode)
|
||||||
SystemFavoritesServiceLogInfo (wstring (L"Mounting system favorite \"") + favorite.Path + L"\"");
|
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)
|
if (ServiceMode)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -330,7 +330,7 @@ BEGIN
|
|||||||
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,198,337,10
|
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,198,337,10
|
||||||
END
|
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
|
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||||
CAPTION "VeraCrypt - Favorite Volumes"
|
CAPTION "VeraCrypt - Favorite Volumes"
|
||||||
FONT 8, "MS Shell Dlg", 400, 0, 0x1
|
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 &Up",IDC_FAVORITE_MOVE_UP,7,104,63,14
|
||||||
PUSHBUTTON "Move &Down",IDC_FAVORITE_MOVE_DOWN,74,104,63,14
|
PUSHBUTTON "Move &Down",IDC_FAVORITE_MOVE_DOWN,74,104,63,14
|
||||||
PUSHBUTTON "&Remove",IDC_FAVORITE_REMOVE,310,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,
|
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,
|
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,
|
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,
|
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,
|
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,
|
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
|
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,326,349,11
|
||||||
LTEXT "Help on favorite volumes",IDC_FAVORITES_HELP_LINK,17,322,237,10,SS_NOTIFY
|
LTEXT "Help on favorite volumes",IDC_FAVORITES_HELP_LINK,17,351,237,10,SS_NOTIFY
|
||||||
DEFPUSHBUTTON "OK",IDOK,269,318,50,14
|
DEFPUSHBUTTON "OK",IDOK,269,347,50,14
|
||||||
PUSHBUTTON "Cancel",IDCANCEL,323,318,50,14
|
PUSHBUTTON "Cancel",IDCANCEL,323,347,50,14
|
||||||
GROUPBOX "",IDC_FAV_VOL_OPTIONS_GROUP_BOX,7,122,366,180
|
GROUPBOX "",IDC_FAV_VOL_OPTIONS_GROUP_BOX,7,123,366,219
|
||||||
LTEXT "Label of selected favorite volume:",IDT_FAVORITE_LABEL,18,175,202,8
|
LTEXT "Label of selected favorite volume:",IDT_FAVORITE_LABEL,18,215,202,8
|
||||||
GROUPBOX "Global Settings",IDC_FAV_VOL_OPTIONS_GLOBAL_SETTINGS_BOX,7,260,366,42
|
GROUPBOX "Global Settings",IDC_FAV_VOL_OPTIONS_GLOBAL_SETTINGS_BOX,7,300,366,42
|
||||||
EDITTEXT IDC_PIM,18,143,42,13,ES_RIGHT | ES_PASSWORD | ES_AUTOHSCROLL | ES_NUMBER
|
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,145,189,8
|
LTEXT "(Empty or 0 for default iterations)",IDC_PIM_HELP,64,185,189,8
|
||||||
LTEXT "Volume PIM:",IDT_PIM,18,133,65,8
|
LTEXT "Volume PIM:",IDT_PIM,18,173,65,8
|
||||||
CONTROL "Display PIM",IDC_SHOW_PIM,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,159,150,10
|
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,
|
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
|
END
|
||||||
|
|
||||||
IDD_DEFAULT_MOUNT_PARAMETERS DIALOGEX 0, 0, 167, 65
|
IDD_DEFAULT_MOUNT_PARAMETERS DIALOGEX 0, 0, 167, 65
|
||||||
@@ -468,7 +472,7 @@ BEGIN
|
|||||||
LEFTMARGIN, 7
|
LEFTMARGIN, 7
|
||||||
RIGHTMARGIN, 373
|
RIGHTMARGIN, 373
|
||||||
TOPMARGIN, 7
|
TOPMARGIN, 7
|
||||||
BOTTOMMARGIN, 332
|
BOTTOMMARGIN, 361
|
||||||
END
|
END
|
||||||
|
|
||||||
IDD_DEFAULT_MOUNT_PARAMETERS, DIALOG
|
IDD_DEFAULT_MOUNT_PARAMETERS, DIALOG
|
||||||
|
|||||||
@@ -176,6 +176,9 @@
|
|||||||
#define IDC_PREF_CACHE_PIM 1154
|
#define IDC_PREF_CACHE_PIM 1154
|
||||||
#define IDC_BOOT_LOADER_CACHE_PIM 1155
|
#define IDC_BOOT_LOADER_CACHE_PIM 1155
|
||||||
#define IDC_SHOW_DISCONNECTED_NETWORK_DRIVES 1156
|
#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_HELP 40001
|
||||||
#define IDM_ABOUT 40002
|
#define IDM_ABOUT 40002
|
||||||
#define IDM_UNMOUNT_VOLUME 40003
|
#define IDM_UNMOUNT_VOLUME 40003
|
||||||
@@ -252,7 +255,7 @@
|
|||||||
#define _APS_NO_MFC 1
|
#define _APS_NO_MFC 1
|
||||||
#define _APS_NEXT_RESOURCE_VALUE 119
|
#define _APS_NEXT_RESOURCE_VALUE 119
|
||||||
#define _APS_NEXT_COMMAND_VALUE 40069
|
#define _APS_NEXT_COMMAND_VALUE 40069
|
||||||
#define _APS_NEXT_CONTROL_VALUE 1157
|
#define _APS_NEXT_CONTROL_VALUE 1160
|
||||||
#define _APS_NEXT_SYMED_VALUE 101
|
#define _APS_NEXT_SYMED_VALUE 101
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user