mirror of
https://github.com/veracrypt/VeraCrypt.git
synced 2026-10-21 22:02:37 +00:00
Windows: handle failed mount queries after dismount
Require a complete, valid mount list before reporting removals or success. Skip empty removal masks to avoid a spurious notification for A:.
This commit is contained in:
+9
-6
@@ -6328,9 +6328,10 @@ retry:
|
||||
return FALSE;
|
||||
|
||||
memset (&mountList, 0, sizeof (mountList));
|
||||
if ( DeviceIoControl (hDriver, TC_IOCTL_GET_MOUNTED_VOLUMES, &mountList, sizeof (mountList), &mountList, sizeof (mountList), &dwResult, NULL)
|
||||
&& (mountList.ulMountedDrives < (1 << 26))
|
||||
)
|
||||
status = DeviceIoControl (hDriver, TC_IOCTL_GET_MOUNTED_VOLUMES, &mountList, sizeof (mountList), &mountList, sizeof (mountList), &dwResult, NULL)
|
||||
&& (dwResult == sizeof (mountList))
|
||||
&& (mountList.ulMountedDrives < (1 << 26));
|
||||
if (status)
|
||||
{
|
||||
// remove any custom label from registry
|
||||
if (prevMountList.ulMountedDrives)
|
||||
@@ -6345,14 +6346,16 @@ retry:
|
||||
}
|
||||
}
|
||||
|
||||
BroadcastDeviceChange (DBT_DEVICEREMOVECOMPLETE, 0, prevMountList.ulMountedDrives & ~mountList.ulMountedDrives);
|
||||
// A failed query doesn't mean that every volume was dismounted.
|
||||
DWORD removedDrives = status ? prevMountList.ulMountedDrives & ~mountList.ulMountedDrives : 0;
|
||||
if (removedDrives)
|
||||
BroadcastDeviceChange (DBT_DEVICEREMOVECOMPLETE, 0, removedDrives);
|
||||
|
||||
/* GH #337, GH #1426: Flush shell notifications synchronously in
|
||||
silent/CLI mode to prevent ghost drive letters when the process
|
||||
exits immediately after dismount. */
|
||||
if (Silent && !DeviceChangeBroadcastDisabled)
|
||||
{
|
||||
DWORD removedDrives = prevMountList.ulMountedDrives & ~mountList.ulMountedDrives;
|
||||
for (i = 0; i < 26; i++)
|
||||
{
|
||||
if (removedDrives & (1 << i))
|
||||
@@ -6405,7 +6408,7 @@ retry:
|
||||
}
|
||||
else
|
||||
{
|
||||
if (bBeep)
|
||||
if (bBeep && status)
|
||||
MessageBeep (0xFFFFFFFF);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user