VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Common/Volumes.c
diff options
context:
space:
mode:
authorMounir IDRASSI <mounir.idrassi@idrix.fr>2017-05-15 16:22:48 +0200
committerMounir IDRASSI <mounir.idrassi@idrix.fr>2017-05-17 00:46:41 +0200
commit74b82118d5f77116ec5f4a1e2438cdc77cead40f (patch)
treee482a6872cfd4605c1379c469870ea2303273031 /src/Common/Volumes.c
parentce4e7fd64d3d462a523253dd53fb36f3aebd179a (diff)
downloadVeraCrypt-74b82118d5f77116ec5f4a1e2438cdc77cead40f.tar.gz
VeraCrypt-74b82118d5f77116ec5f4a1e2438cdc77cead40f.zip
Windows: use IOCTL_DISK_GET_DRIVE_GEOMETRY_EX instead of the deprecated IOCTL_DISK_GET_DRIVE_GEOMETRY in order to get accurate disk size value.
Diffstat (limited to 'src/Common/Volumes.c')
-rw-r--r--src/Common/Volumes.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/Common/Volumes.c b/src/Common/Volumes.c
index d2321769..762adc2b 100644
--- a/src/Common/Volumes.c
+++ b/src/Common/Volumes.c
@@ -1155,21 +1155,21 @@ BOOL ReadEffectiveVolumeHeader (BOOL device, HANDLE fileHandle, byte *header, DW
#endif
byte sectorBuffer[TC_MAX_VOLUME_SECTOR_SIZE];
- DISK_GEOMETRY geometry;
+ DISK_GEOMETRY_EX geometry;
if (!device)
return ReadFile (fileHandle, header, TC_VOLUME_HEADER_EFFECTIVE_SIZE, bytesRead, NULL);
- if (!DeviceIoControl (fileHandle, IOCTL_DISK_GET_DRIVE_GEOMETRY, NULL, 0, &geometry, sizeof (geometry), bytesRead, NULL))
+ if (!DeviceIoControl (fileHandle, IOCTL_DISK_GET_DRIVE_GEOMETRY_EX, NULL, 0, &geometry, sizeof (geometry), bytesRead, NULL))
return FALSE;
- if (geometry.BytesPerSector > sizeof (sectorBuffer) || geometry.BytesPerSector < TC_MIN_VOLUME_SECTOR_SIZE)
+ if (geometry.Geometry.BytesPerSector > sizeof (sectorBuffer) || geometry.Geometry.BytesPerSector < TC_MIN_VOLUME_SECTOR_SIZE)
{
SetLastError (ERROR_INVALID_PARAMETER);
return FALSE;
}
- if (!ReadFile (fileHandle, sectorBuffer, max (TC_VOLUME_HEADER_EFFECTIVE_SIZE, geometry.BytesPerSector), bytesRead, NULL))
+ if (!ReadFile (fileHandle, sectorBuffer, max (TC_VOLUME_HEADER_EFFECTIVE_SIZE, geometry.Geometry.BytesPerSector), bytesRead, NULL))
return FALSE;
memcpy (header, sectorBuffer, min (*bytesRead, TC_VOLUME_HEADER_EFFECTIVE_SIZE));
@@ -1189,7 +1189,7 @@ BOOL WriteEffectiveVolumeHeader (BOOL device, HANDLE fileHandle, byte *header)
byte sectorBuffer[TC_MAX_VOLUME_SECTOR_SIZE];
DWORD bytesDone;
- DISK_GEOMETRY geometry;
+ DISK_GEOMETRY_EX geometry;
if (!device)
{
@@ -1205,23 +1205,23 @@ BOOL WriteEffectiveVolumeHeader (BOOL device, HANDLE fileHandle, byte *header)
return TRUE;
}
- if (!DeviceIoControl (fileHandle, IOCTL_DISK_GET_DRIVE_GEOMETRY, NULL, 0, &geometry, sizeof (geometry), &bytesDone, NULL))
+ if (!DeviceIoControl (fileHandle, IOCTL_DISK_GET_DRIVE_GEOMETRY_EX, NULL, 0, &geometry, sizeof (geometry), &bytesDone, NULL))
return FALSE;
- if (geometry.BytesPerSector > sizeof (sectorBuffer) || geometry.BytesPerSector < TC_MIN_VOLUME_SECTOR_SIZE)
+ if (geometry.Geometry.BytesPerSector > sizeof (sectorBuffer) || geometry.Geometry.BytesPerSector < TC_MIN_VOLUME_SECTOR_SIZE)
{
SetLastError (ERROR_INVALID_PARAMETER);
return FALSE;
}
- if (geometry.BytesPerSector != TC_VOLUME_HEADER_EFFECTIVE_SIZE)
+ if (geometry.Geometry.BytesPerSector != TC_VOLUME_HEADER_EFFECTIVE_SIZE)
{
LARGE_INTEGER seekOffset;
- if (!ReadFile (fileHandle, sectorBuffer, geometry.BytesPerSector, &bytesDone, NULL))
+ if (!ReadFile (fileHandle, sectorBuffer, geometry.Geometry.BytesPerSector, &bytesDone, NULL))
return FALSE;
- if (bytesDone != geometry.BytesPerSector)
+ if (bytesDone != geometry.Geometry.BytesPerSector)
{
SetLastError (ERROR_INVALID_PARAMETER);
return FALSE;
@@ -1234,10 +1234,10 @@ BOOL WriteEffectiveVolumeHeader (BOOL device, HANDLE fileHandle, byte *header)
memcpy (sectorBuffer, header, TC_VOLUME_HEADER_EFFECTIVE_SIZE);
- if (!WriteFile (fileHandle, sectorBuffer, geometry.BytesPerSector, &bytesDone, NULL))
+ if (!WriteFile (fileHandle, sectorBuffer, geometry.Geometry.BytesPerSector, &bytesDone, NULL))
return FALSE;
- if (bytesDone != geometry.BytesPerSector)
+ if (bytesDone != geometry.Geometry.BytesPerSector)
{
SetLastError (ERROR_INVALID_PARAMETER);
return FALSE;