VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Driver/Ntvol.c
diff options
context:
space:
mode:
authorMounir IDRASSI <mounir.idrassi@idrix.fr>2018-08-18 11:13:20 +0200
committerMounir IDRASSI <mounir.idrassi@idrix.fr>2018-08-18 16:47:23 +0200
commit20889d4553a132cd8749a73853715fd3a0f237e5 (patch)
tree59a10b0fff93d43fcde3cb0e1a0123939d5351d3 /src/Driver/Ntvol.c
parent2fea18c3f50599e0b51a731cc8f89a8d99c9df86 (diff)
downloadVeraCrypt-20889d4553a132cd8749a73853715fd3a0f237e5.tar.gz
VeraCrypt-20889d4553a132cd8749a73853715fd3a0f237e5.zip
Windows: Implement workaround on Windows 10 to make VeraCrypt encrypted disks visible to Windows defragmenter
Diffstat (limited to 'src/Driver/Ntvol.c')
-rw-r--r--src/Driver/Ntvol.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/Driver/Ntvol.c b/src/Driver/Ntvol.c
index c8552ab3..852aafd0 100644
--- a/src/Driver/Ntvol.c
+++ b/src/Driver/Ntvol.c
@@ -72,6 +72,8 @@ NTSTATUS TCOpenVolume (PDEVICE_OBJECT DeviceObject,
Extension->IncursSeekPenalty = TRUE;
Extension->TrimEnabled = FALSE;
+ Extension->DeviceNumber = (ULONG) -1;
+
RtlInitUnicodeString (&FullFileName, pwszMountVolume);
InitializeObjectAttributes (&oaFileAttributes, &FullFileName, OBJ_CASE_INSENSITIVE | (forceAccessCheck ? OBJ_FORCE_ACCESS_CHECK : 0) | OBJ_KERNEL_HANDLE, NULL, NULL);
KeInitializeEvent (&Extension->keVolumeEvent, NotificationEvent, FALSE);
@@ -94,6 +96,7 @@ NTSTATUS TCOpenVolume (PDEVICE_OBJECT DeviceObject,
DISK_GEOMETRY_EX dg;
STORAGE_PROPERTY_QUERY storagePropertyQuery = {0};
byte* dgBuffer;
+ STORAGE_DEVICE_NUMBER storageDeviceNumber;
ntStatus = IoGetDeviceObjectPointer (&FullFileName,
FILE_READ_DATA | FILE_READ_ATTRIBUTES,
@@ -147,6 +150,13 @@ NTSTATUS TCOpenVolume (PDEVICE_OBJECT DeviceObject,
TCfree (dgBuffer);
+ if (NT_SUCCESS (TCSendHostDeviceIoControlRequest (DeviceObject, Extension,
+ IOCTL_STORAGE_GET_DEVICE_NUMBER,
+ (char*) &storageDeviceNumber, sizeof (storageDeviceNumber))))
+ {
+ Extension->DeviceNumber = storageDeviceNumber.DeviceNumber;
+ }
+
lDiskLength.QuadPart = dg.DiskSize.QuadPart;
Extension->HostBytesPerSector = dg.Geometry.BytesPerSector;
Extension->HostBytesPerPhysicalSector = dg.Geometry.BytesPerSector;