diff options
author | Mounir IDRASSI <mounir.idrassi@idrix.fr> | 2017-05-23 12:23:07 +0200 |
---|---|---|
committer | Mounir IDRASSI <mounir.idrassi@idrix.fr> | 2017-05-25 01:15:16 +0200 |
commit | cda40547fe35b28321f7a00b53cc18eb9cf77cba (patch) | |
tree | c6623de47b0912a0d4f1d95a60e937d85ea078f9 /src/Driver/Ntvol.c | |
parent | a117f040687e307c948bba04a9f98fd713f6de82 (diff) | |
download | VeraCrypt-cda40547fe35b28321f7a00b53cc18eb9cf77cba.tar.gz VeraCrypt-cda40547fe35b28321f7a00b53cc18eb9cf77cba.zip |
Windows: query extra host drive information using IOCTL_STORAGE_QUERY_PROPERTY (StorageAdapterProperty) in both driver and user mode applications.
Diffstat (limited to 'src/Driver/Ntvol.c')
-rw-r--r-- | src/Driver/Ntvol.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/Driver/Ntvol.c b/src/Driver/Ntvol.c index 8fda0bd9..8be0393a 100644 --- a/src/Driver/Ntvol.c +++ b/src/Driver/Ntvol.c @@ -63,6 +63,11 @@ NTSTATUS TCOpenVolume (PDEVICE_OBJECT DeviceObject, Extension->hDeviceFile = NULL; Extension->bTimeStampValid = FALSE; + /* default value for storage alignment */ + Extension->HostMaximumTransferLength = 65536; + Extension->HostMaximumPhysicalPages = 17; + Extension->HostAlignmentMask = 0; + RtlInitUnicodeString (&FullFileName, pwszMountVolume); InitializeObjectAttributes (&oaFileAttributes, &FullFileName, OBJ_CASE_INSENSITIVE | (forceAccessCheck ? OBJ_FORCE_ACCESS_CHECK : 0) | OBJ_KERNEL_HANDLE, NULL, NULL); KeInitializeEvent (&Extension->keVolumeEvent, NotificationEvent, FALSE); @@ -129,6 +134,31 @@ NTSTATUS TCOpenVolume (PDEVICE_OBJECT DeviceObject, TCfree (outputBuffer); } + + storagePropertyQuery.PropertyId = StorageAdapterProperty; + if (NT_SUCCESS (TCSendHostDeviceIoControlRequestEx (DeviceObject, Extension, IOCTL_STORAGE_QUERY_PROPERTY, + (char*) &storagePropertyQuery, sizeof(storagePropertyQuery), + (char *) &storageHeader, sizeof (storageHeader)))) + { + byte* outputBuffer = TCalloc (storageHeader.Size); + if (!outputBuffer) + { + ntStatus = STATUS_INSUFFICIENT_RESOURCES; + goto error; + } + + if (NT_SUCCESS (TCSendHostDeviceIoControlRequestEx (DeviceObject, Extension, IOCTL_STORAGE_QUERY_PROPERTY, + (char*) &storagePropertyQuery, sizeof(storagePropertyQuery), + outputBuffer, storageHeader.Size))) + { + PSTORAGE_ADAPTER_DESCRIPTOR pStorageDescriptor = (PSTORAGE_ADAPTER_DESCRIPTOR) outputBuffer; + Extension->HostMaximumTransferLength = pStorageDescriptor->MaximumTransferLength; + Extension->HostMaximumPhysicalPages = pStorageDescriptor->MaximumPhysicalPages; + Extension->HostAlignmentMask = pStorageDescriptor->AlignmentMask; + } + + TCfree (outputBuffer); + } } // Drive geometry is used only when IOCTL_DISK_GET_PARTITION_INFO fails @@ -179,6 +209,9 @@ NTSTATUS TCOpenVolume (PDEVICE_OBJECT DeviceObject, Extension->HostBytesPerSector = mount->BytesPerSector; Extension->HostBytesPerPhysicalSector = mount->BytesPerPhysicalSector; + Extension->HostMaximumTransferLength = mount->MaximumTransferLength; + Extension->HostMaximumPhysicalPages = mount->MaximumPhysicalPages; + Extension->HostAlignmentMask = mount->AlignmentMask; if (Extension->HostBytesPerSector != TC_SECTOR_SIZE_FILE_HOSTED_VOLUME) disableBuffering = FALSE; |