mirror of
https://github.com/veracrypt/VeraCrypt.git
synced 2025-11-11 19:08:26 -06:00
Windows Driver: Use real disk sector size instead of generic 512 bytes value when probing disk real size
This commit is contained in:
@@ -3653,11 +3653,16 @@ NTSTATUS ProbeRealDriveSize (PDEVICE_OBJECT driveDeviceObject, LARGE_INTEGER *dr
|
|||||||
LARGE_INTEGER offset;
|
LARGE_INTEGER offset;
|
||||||
byte *sectorBuffer;
|
byte *sectorBuffer;
|
||||||
ULONGLONG startTime;
|
ULONGLONG startTime;
|
||||||
|
ULONG sectorSize;
|
||||||
|
|
||||||
if (!UserCanAccessDriveDevice())
|
if (!UserCanAccessDriveDevice())
|
||||||
return STATUS_ACCESS_DENIED;
|
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)
|
if (!sectorBuffer)
|
||||||
return STATUS_INSUFFICIENT_RESOURCES;
|
return STATUS_INSUFFICIENT_RESOURCES;
|
||||||
|
|
||||||
@@ -3672,12 +3677,12 @@ NTSTATUS ProbeRealDriveSize (PDEVICE_OBJECT driveDeviceObject, LARGE_INTEGER *dr
|
|||||||
}
|
}
|
||||||
|
|
||||||
startTime = KeQueryInterruptTime ();
|
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))
|
if (NT_SUCCESS (status))
|
||||||
status = TCWriteDevice (driveDeviceObject, sectorBuffer, offset, TC_SECTOR_SIZE_BIOS);
|
status = TCWriteDevice (driveDeviceObject, sectorBuffer, offset, sectorSize);
|
||||||
|
|
||||||
if (!NT_SUCCESS (status))
|
if (!NT_SUCCESS (status))
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user