diff options
author | Mounir IDRASSI <mounir.idrassi@idrix.fr> | 2020-06-21 17:39:40 +0200 |
---|---|---|
committer | Mounir IDRASSI <mounir.idrassi@idrix.fr> | 2020-06-21 17:42:08 +0200 |
commit | bec929ce0308620a88b71e2619e5e5c8ffbfdadb (patch) | |
tree | d6080c756eb48bfe9e5310d762deac45af598531 /src/Driver | |
parent | a4c5f03beedf04fcca0ba6fd354d27e66bb3fcf6 (diff) | |
download | VeraCrypt-bec929ce0308620a88b71e2619e5e5c8ffbfdadb.tar.gz VeraCrypt-bec929ce0308620a88b71e2619e5e5c8ffbfdadb.zip |
Windows Driver: Use real disk sector size instead of generic 512 bytes value when probing disk real size
Diffstat (limited to 'src/Driver')
-rw-r--r-- | src/Driver/Ntdriver.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/Driver/Ntdriver.c b/src/Driver/Ntdriver.c index 2ae17f5a..94a90bed 100644 --- a/src/Driver/Ntdriver.c +++ b/src/Driver/Ntdriver.c @@ -3653,11 +3653,16 @@ NTSTATUS ProbeRealDriveSize (PDEVICE_OBJECT driveDeviceObject, LARGE_INTEGER *dr LARGE_INTEGER offset; byte *sectorBuffer; ULONGLONG startTime; + ULONG sectorSize; if (!UserCanAccessDriveDevice()) return STATUS_ACCESS_DENIED; - sectorBuffer = TCalloc (TC_SECTOR_SIZE_BIOS); + status = GetDeviceSectorSize (driveDeviceObject, §orSize); + if (!NT_SUCCESS (status)) + return status; + + sectorBuffer = TCalloc (sectorSize); if (!sectorBuffer) return STATUS_INSUFFICIENT_RESOURCES; @@ -3672,12 +3677,12 @@ NTSTATUS ProbeRealDriveSize (PDEVICE_OBJECT driveDeviceObject, LARGE_INTEGER *dr } startTime = KeQueryInterruptTime (); - for (offset.QuadPart = sysLength.QuadPart; ; offset.QuadPart += TC_SECTOR_SIZE_BIOS) + for (offset.QuadPart = sysLength.QuadPart; ; offset.QuadPart += sectorSize) { - status = TCReadDevice (driveDeviceObject, sectorBuffer, offset, TC_SECTOR_SIZE_BIOS); + status = TCReadDevice (driveDeviceObject, sectorBuffer, offset, sectorSize); if (NT_SUCCESS (status)) - status = TCWriteDevice (driveDeviceObject, sectorBuffer, offset, TC_SECTOR_SIZE_BIOS); + status = TCWriteDevice (driveDeviceObject, sectorBuffer, offset, sectorSize); if (!NT_SUCCESS (status)) { |