diff options
author | Mounir IDRASSI <mounir.idrassi@idrix.fr> | 2017-05-15 16:22:48 +0200 |
---|---|---|
committer | Mounir IDRASSI <mounir.idrassi@idrix.fr> | 2017-05-17 00:46:41 +0200 |
commit | 74b82118d5f77116ec5f4a1e2438cdc77cead40f (patch) | |
tree | e482a6872cfd4605c1379c469870ea2303273031 /src/Format | |
parent | ce4e7fd64d3d462a523253dd53fb36f3aebd179a (diff) | |
download | VeraCrypt-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/Format')
-rw-r--r-- | src/Format/InPlace.c | 18 | ||||
-rw-r--r-- | src/Format/Tcformat.c | 9 |
2 files changed, 13 insertions, 14 deletions
diff --git a/src/Format/InPlace.c b/src/Format/InPlace.c index f37cb8be..446ae065 100644 --- a/src/Format/InPlace.c +++ b/src/Format/InPlace.c @@ -772,7 +772,7 @@ int EncryptPartitionInPlaceResume (HANDLE dev, Password *password = volParams->password; int pkcs5_prf = volParams->pkcs5; int pim = volParams->pim; - DISK_GEOMETRY driveGeometry; + DISK_GEOMETRY_EX driveGeometry; HWND hwndDlg = volParams->hwndDlg; @@ -855,13 +855,13 @@ int EncryptPartitionInPlaceResume (HANDLE dev, NULL); - if (!DeviceIoControl (dev, IOCTL_DISK_GET_DRIVE_GEOMETRY, NULL, 0, &driveGeometry, sizeof (driveGeometry), &dwResult, NULL)) + if (!DeviceIoControl (dev, IOCTL_DISK_GET_DRIVE_GEOMETRY_EX, NULL, 0, &driveGeometry, sizeof (driveGeometry), &dwResult, NULL)) { nStatus = ERR_OS_ERROR; goto closing_seq; } - sectorSize = driveGeometry.BytesPerSector; + sectorSize = driveGeometry.Geometry.BytesPerSector; nStatus = OpenBackupHeader (dev, devicePath, password, pkcs5_prf, pim, &masterCryptoInfo, headerCryptoInfo, deviceSize); @@ -1282,7 +1282,7 @@ int DecryptPartitionInPlace (volatile FORMAT_VOL_PARAMETERS *volParams, volatile HWND hwndDlg = volParams->hwndDlg; int pkcs5_prf = volParams->pkcs5; int pim = volParams->pim; - DISK_GEOMETRY driveGeometry; + DISK_GEOMETRY_EX driveGeometry; buf = (char *) TCalloc (TC_MAX_NONSYS_INPLACE_ENC_WORK_CHUNK_SIZE); @@ -1357,15 +1357,15 @@ int DecryptPartitionInPlace (volatile FORMAT_VOL_PARAMETERS *volParams, volatile NULL); - if (!DeviceIoControl (dev, IOCTL_DISK_GET_DRIVE_GEOMETRY, NULL, 0, &driveGeometry, sizeof (driveGeometry), &dwResult, NULL)) + if (!DeviceIoControl (dev, IOCTL_DISK_GET_DRIVE_GEOMETRY_EX, NULL, 0, &driveGeometry, sizeof (driveGeometry), &dwResult, NULL)) { nStatus = ERR_OS_ERROR; goto closing_seq; } - if ( (driveGeometry.BytesPerSector == 0) - || (driveGeometry.BytesPerSector > TC_MAX_VOLUME_SECTOR_SIZE) - || (driveGeometry.BytesPerSector % ENCRYPTION_DATA_UNIT_SIZE != 0) + if ( (driveGeometry.Geometry.BytesPerSector == 0) + || (driveGeometry.Geometry.BytesPerSector > TC_MAX_VOLUME_SECTOR_SIZE) + || (driveGeometry.Geometry.BytesPerSector % ENCRYPTION_DATA_UNIT_SIZE != 0) ) { Error ("SECTOR_SIZE_UNSUPPORTED", hwndDlg); @@ -1373,7 +1373,7 @@ int DecryptPartitionInPlace (volatile FORMAT_VOL_PARAMETERS *volParams, volatile goto closing_seq; } - sectorSize = driveGeometry.BytesPerSector; + sectorSize = driveGeometry.Geometry.BytesPerSector; tmpSectorBuf = (byte *) TCalloc (sectorSize); diff --git a/src/Format/Tcformat.c b/src/Format/Tcformat.c index 02210b15..288eeacf 100644 --- a/src/Format/Tcformat.c +++ b/src/Format/Tcformat.c @@ -3416,7 +3416,7 @@ BOOL QueryFreeSpace (HWND hwndDlg, HWND hwndTextBox, BOOL display) } else { - DISK_GEOMETRY driveInfo; + DISK_GEOMETRY_EX driveInfo; PARTITION_INFORMATION diskInfo; BOOL piValid = FALSE; BOOL gValid = FALSE; @@ -3465,8 +3465,7 @@ BOOL QueryFreeSpace (HWND hwndDlg, HWND hwndTextBox, BOOL display) LARGE_INTEGER lDiskFree; // Drive geometry info is used only when GetPartitionInfo() fails - lDiskFree.QuadPart = driveInfo.Cylinders.QuadPart * driveInfo.BytesPerSector * - driveInfo.SectorsPerTrack * driveInfo.TracksPerCylinder; + lDiskFree.QuadPart = driveInfo.DiskSize.QuadPart; nVolumeSize = lDiskFree.QuadPart; @@ -10320,7 +10319,7 @@ static DWORD GetFormatSectorSize () if (!bDevice) return TC_SECTOR_SIZE_FILE_HOSTED_VOLUME; - DISK_GEOMETRY geometry; + DISK_GEOMETRY_EX geometry; if (!GetDriveGeometry (szDiskFile, &geometry)) { @@ -10328,5 +10327,5 @@ static DWORD GetFormatSectorSize () AbortProcessSilent(); } - return geometry.BytesPerSector; + return geometry.Geometry.BytesPerSector; } |