sys: IRP_MJ_QUERY_VOLUME_INFORMATION: FileFsDeviceInformation: always return FILE_DEVICE_DISK to avoid problem with GetFileType failures

This commit is contained in:
Bill Zissimopoulos
2016-05-23 22:23:47 -07:00
parent 6be55aa515
commit aa75d412ac
4 changed files with 55 additions and 12 deletions

View File

@ -117,7 +117,15 @@ static NTSTATUS FspFsvolQueryFsDeviceInformation(
PFILE_FS_DEVICE_INFORMATION Info = (PFILE_FS_DEVICE_INFORMATION)*PBuffer;
Info->DeviceType = FsvolDeviceObject->DeviceType;
/*
* The following value MUST be FILE_DEVICE_DISK or GetFileType fails,
* which has all sorts of interesting consequences (like cmd.exe failing
* to redirect to a file when under a network file system).
*
* See also (which explicitly says to use FILE_DEVICE_DISK for our case):
* https://msdn.microsoft.com/en-us/library/cc232109.aspx
*/
Info->DeviceType = FILE_DEVICE_DISK;
Info->Characteristics = FsvolDeviceObject->Characteristics;
*PBuffer += sizeof(FILE_FS_DEVICE_INFORMATION);

View File

@ -188,7 +188,8 @@ static NTSTATUS FspVolumeCreateNoLock(
/* create the volume (and virtual disk) device(s) */
Result = FspDeviceCreate(FspFsvolDeviceExtensionKind, 0,
FsctlDeviceObject->DeviceType, 0,
FsctlDeviceObject->DeviceType,
FILE_DEVICE_DISK_FILE_SYSTEM == FsctlDeviceObject->DeviceType ? 0 : FILE_REMOTE_DEVICE,
&FsvolDeviceObject);
if (!NT_SUCCESS(Result))
return Result;