VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Driver
diff options
context:
space:
mode:
authorMounir IDRASSI <mounir.idrassi@idrix.fr>2025-02-04 00:02:08 +0100
committerMounir IDRASSI <mounir.idrassi@idrix.fr>2025-02-04 00:02:08 +0100
commit2180020cee871866a61fbae45f7516d88be14220 (patch)
tree5424f62dcaa7668bcb4c78cd2fb7ea8b117a9c1c /src/Driver
parente73ea7193e6fed6d347893816a8fd5a0aadec4cc (diff)
downloadVeraCrypt-2180020cee871866a61fbae45f7516d88be14220.tar.gz
VeraCrypt-2180020cee871866a61fbae45f7516d88be14220.zip
Windows driver: Fix regression that always allowed defragmentation and caused other side effects
Now we properly honor the AllowDefrag configuration. This regression introduced other issues because, in order to allow defragmentation, we must provide Windows with an actual physical disk number. As a result, we assign the number of the physical disk where the VeraCrypt volume resides. This, in turn, causes Windows to send IOCTLs directly to this disk instead of to VeraCrypt. If these IOCTLs return values and properties not supported by VeraCrypt, inconsistencies arise, leading to failures.
Diffstat (limited to 'src/Driver')
-rw-r--r--src/Driver/Ntdriver.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/Driver/Ntdriver.c b/src/Driver/Ntdriver.c
index 1b6bab01..148f88b8 100644
--- a/src/Driver/Ntdriver.c
+++ b/src/Driver/Ntdriver.c
@@ -1446,7 +1446,12 @@ NTSTATUS ProcessVolumeDeviceControlIrp (PDEVICE_OBJECT DeviceObject, PEXTENSION
case IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS:
Dump ("ProcessVolumeDeviceControlIrp (IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS)\n");
// Vista's, Windows 8.1 and later filesystem defragmenter fails if IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS does not succeed.
- if (ValidateIOBufferSize(Irp, sizeof(VOLUME_DISK_EXTENTS), ValidateOutput))
+ if (!AllowWindowsDefrag || !Extension->bRawDevice) // We don't support defragmentation for file-hosted volumes
+ {
+ Irp->IoStatus.Status = STATUS_INVALID_DEVICE_REQUEST;
+ Irp->IoStatus.Information = 0;
+ }
+ else if (ValidateIOBufferSize(Irp, sizeof(VOLUME_DISK_EXTENTS), ValidateOutput))
{
VOLUME_DISK_EXTENTS* extents = (VOLUME_DISK_EXTENTS*)Irp->AssociatedIrp.SystemBuffer;