mirror of
https://github.com/veracrypt/VeraCrypt
synced 2024-11-24 12:03:28 +01:00
Windows Driver: make IOCTL_DISK_GET_DRIVE_GEOMETRY_EX support optional. Make disk size equal to partition size to avoid compatibility issues with existing software.
This commit is contained in:
parent
1812449906
commit
7cc2a3527d
@ -731,21 +731,25 @@ NTSTATUS ProcessVolumeDeviceControlIrp (PDEVICE_OBJECT DeviceObject, PEXTENSION
|
|||||||
|
|
||||||
case IOCTL_DISK_GET_DRIVE_GEOMETRY_EX:
|
case IOCTL_DISK_GET_DRIVE_GEOMETRY_EX:
|
||||||
Dump ("ProcessVolumeDeviceControlIrp (IOCTL_DISK_GET_DRIVE_GEOMETRY_EX)\n");
|
Dump ("ProcessVolumeDeviceControlIrp (IOCTL_DISK_GET_DRIVE_GEOMETRY_EX)\n");
|
||||||
/* Return the drive geometry for the disk and its size.*/
|
Irp->IoStatus.Status = STATUS_INVALID_DEVICE_REQUEST;
|
||||||
if (ValidateIOBufferSize (Irp, sizeof (DISK_GEOMETRY_EX), ValidateOutput))
|
Irp->IoStatus.Information = 0;
|
||||||
|
if (EnableExtendedIoctlSupport)
|
||||||
{
|
{
|
||||||
PDISK_GEOMETRY_EX outputBuffer = (PDISK_GEOMETRY_EX)
|
/* Return the drive geometry for the disk and its size.*/
|
||||||
Irp->AssociatedIrp.SystemBuffer;
|
if (ValidateIOBufferSize (Irp, sizeof (DISK_GEOMETRY_EX), ValidateOutput))
|
||||||
|
{
|
||||||
|
PDISK_GEOMETRY_EX outputBuffer = (PDISK_GEOMETRY_EX)
|
||||||
|
Irp->AssociatedIrp.SystemBuffer;
|
||||||
|
|
||||||
outputBuffer->Geometry.MediaType = Extension->bRemovable ? RemovableMedia : FixedMedia;
|
outputBuffer->Geometry.MediaType = Extension->bRemovable ? RemovableMedia : FixedMedia;
|
||||||
outputBuffer->Geometry.Cylinders.QuadPart = Extension->NumberOfCylinders;
|
outputBuffer->Geometry.Cylinders.QuadPart = Extension->NumberOfCylinders;
|
||||||
outputBuffer->Geometry.TracksPerCylinder = Extension->TracksPerCylinder;
|
outputBuffer->Geometry.TracksPerCylinder = Extension->TracksPerCylinder;
|
||||||
outputBuffer->Geometry.SectorsPerTrack = Extension->SectorsPerTrack;
|
outputBuffer->Geometry.SectorsPerTrack = Extension->SectorsPerTrack;
|
||||||
outputBuffer->Geometry.BytesPerSector = Extension->BytesPerSector;
|
outputBuffer->Geometry.BytesPerSector = Extension->BytesPerSector;
|
||||||
/* add one sector to DiskLength since our partition size is DiskLength and its offset if BytesPerSector */
|
outputBuffer->DiskSize.QuadPart = Extension->DiskLength;
|
||||||
outputBuffer->DiskSize.QuadPart = Extension->DiskLength + Extension->BytesPerSector;
|
Irp->IoStatus.Status = STATUS_SUCCESS;
|
||||||
Irp->IoStatus.Status = STATUS_SUCCESS;
|
Irp->IoStatus.Information = sizeof (DISK_GEOMETRY_EX);
|
||||||
Irp->IoStatus.Information = sizeof (DISK_GEOMETRY_EX);
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -1162,8 +1166,8 @@ NTSTATUS ProcessVolumeDeviceControlIrp (PDEVICE_OBJECT DeviceObject, PEXTENSION
|
|||||||
capacity->Version = sizeof (STORAGE_READ_CAPACITY);
|
capacity->Version = sizeof (STORAGE_READ_CAPACITY);
|
||||||
capacity->Size = sizeof (STORAGE_READ_CAPACITY);
|
capacity->Size = sizeof (STORAGE_READ_CAPACITY);
|
||||||
capacity->BlockLength = Extension->BytesPerSector;
|
capacity->BlockLength = Extension->BytesPerSector;
|
||||||
capacity->NumberOfBlocks.QuadPart = (Extension->DiskLength / Extension->BytesPerSector) + 1;
|
capacity->NumberOfBlocks.QuadPart = Extension->DiskLength / Extension->BytesPerSector;
|
||||||
capacity->DiskLength.QuadPart = Extension->DiskLength + Extension->BytesPerSector;
|
capacity->DiskLength.QuadPart = Extension->DiskLength;
|
||||||
|
|
||||||
Irp->IoStatus.Status = STATUS_SUCCESS;
|
Irp->IoStatus.Status = STATUS_SUCCESS;
|
||||||
Irp->IoStatus.Information = sizeof (STORAGE_READ_CAPACITY);
|
Irp->IoStatus.Information = sizeof (STORAGE_READ_CAPACITY);
|
||||||
|
@ -704,8 +704,7 @@ NTSTATUS TCOpenVolume (PDEVICE_OBJECT DeviceObject,
|
|||||||
Extension->TracksPerCylinder = 1;
|
Extension->TracksPerCylinder = 1;
|
||||||
Extension->SectorsPerTrack = 1;
|
Extension->SectorsPerTrack = 1;
|
||||||
Extension->BytesPerSector = Extension->cryptoInfo->SectorSize;
|
Extension->BytesPerSector = Extension->cryptoInfo->SectorSize;
|
||||||
// Add extra sector since our virtual partition starts at Extension->BytesPerSector and not 0
|
Extension->NumberOfCylinders = Extension->DiskLength / Extension->BytesPerSector;
|
||||||
Extension->NumberOfCylinders = (Extension->DiskLength / Extension->BytesPerSector) + 1;
|
|
||||||
Extension->PartitionType = 0;
|
Extension->PartitionType = 0;
|
||||||
|
|
||||||
Extension->bRawDevice = bRawDevice;
|
Extension->bRawDevice = bRawDevice;
|
||||||
|
Loading…
Reference in New Issue
Block a user