VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Mount/Mount.c
diff options
context:
space:
mode:
authorMounir IDRASSI <mounir.idrassi@idrix.fr>2018-09-01 00:28:27 +0200
committerMounir IDRASSI <mounir.idrassi@idrix.fr>2018-09-01 01:15:30 +0200
commit95748751dfcfce1a885dfa4974ca3761ed0f7dbb (patch)
treedf0acf591180d08ed0eb2536d05cc58a159e1abb /src/Mount/Mount.c
parent36129ec5af14ffb33c7c7124405b336e7c7b6fdb (diff)
downloadVeraCrypt-95748751dfcfce1a885dfa4974ca3761ed0f7dbb.tar.gz
VeraCrypt-95748751dfcfce1a885dfa4974ca3761ed0f7dbb.zip
Windows: handle case of some disk drivers not supporting IOCTL_DISK_GET_DRIVE_GEOMETRY_EX IOCTL.
Diffstat (limited to 'src/Mount/Mount.c')
-rw-r--r--src/Mount/Mount.c29
1 files changed, 27 insertions, 2 deletions
diff --git a/src/Mount/Mount.c b/src/Mount/Mount.c
index 6e6d601e..b2646017 100644
--- a/src/Mount/Mount.c
+++ b/src/Mount/Mount.c
@@ -10637,9 +10637,34 @@ int RestoreVolumeHeader (HWND hwndDlg, const wchar_t *lpszVolume)
dgBuffer, sizeof (dgBuffer), &dwResult, NULL);
if (!bResult)
- goto error;
+ {
+ DISK_GEOMETRY geo;
+ if (DeviceIoControl (dev, IOCTL_DISK_GET_DRIVE_GEOMETRY, NULL, 0, (LPVOID) &geo, sizeof (geo), &dwResult, NULL))
+ {
+ hostSize = geo.Cylinders.QuadPart * geo.SectorsPerTrack * geo.TracksPerCylinder * geo.BytesPerSector;
- hostSize = ((PDISK_GEOMETRY_EX) dgBuffer)->DiskSize.QuadPart;
+ if (CurrentOSMajor >= 6)
+ {
+ STORAGE_READ_CAPACITY storage = {0};
+
+ storage.Version = sizeof (STORAGE_READ_CAPACITY);
+ storage.Size = sizeof (STORAGE_READ_CAPACITY);
+ if (DeviceIoControl (dev, IOCTL_STORAGE_READ_CAPACITY, NULL, 0, (LPVOID) &storage, sizeof (storage), &dwResult, NULL)
+ && (dwResult >= sizeof (storage))
+ && (storage.Size == sizeof (STORAGE_READ_CAPACITY))
+ )
+ {
+ hostSize = storage.DiskLength.QuadPart;
+ }
+ }
+ }
+ else
+ {
+ goto error;
+ }
+ }
+ else
+ hostSize = ((PDISK_GEOMETRY_EX) dgBuffer)->DiskSize.QuadPart;
}
if (hostSize == 0)