https://git.reactos.org/?p=reactos.git;a=commitdiff;h=410c6069996abfeb51e13…
commit 410c6069996abfeb51e134bfec940a9a38598682
Author: Pierre Schweitzer <pierre(a)reactos.org>
AuthorDate: Mon Oct 21 16:45:28 2019 +0200
Commit: Pierre Schweitzer <pierre(a)reactos.org>
CommitDate: Mon Oct 21 16:45:28 2019 +0200
[CLASS2] Hackplement support for IOCTL_MOUNTDEV_QUERY_UNIQUE_ID
This is required so that MountMgr can handle devices that are still
using class2 instead of classpnp.
Given we have no unique ID to return, we'll return device path, which
is far from perfect but which is enough for now to have everything
working.
---
drivers/storage/class/class2/class2.c | 67 +++++++++++++++++++++++++++++++++--
1 file changed, 65 insertions(+), 2 deletions(-)
diff --git a/drivers/storage/class/class2/class2.c
b/drivers/storage/class/class2/class2.c
index 2d29f645759..5107c45f7ad 100644
--- a/drivers/storage/class/class2/class2.c
+++ b/drivers/storage/class/class2/class2.c
@@ -4041,8 +4041,7 @@ Return Value:
goto SetStatusAndReturn;
}
- if (irpStack->Parameters.DeviceIoControl.IoControlCode ==
IOCTL_MOUNTDEV_QUERY_UNIQUE_ID ||
- irpStack->Parameters.DeviceIoControl.IoControlCode ==
IOCTL_MOUNTDEV_QUERY_SUGGESTED_LINK_NAME) {
+ if (irpStack->Parameters.DeviceIoControl.IoControlCode ==
IOCTL_MOUNTDEV_QUERY_SUGGESTED_LINK_NAME) {
UNIMPLEMENTED;
Irp->IoStatus.Information = 0;
@@ -4052,6 +4051,70 @@ Return Value:
goto SetStatusAndReturn;
}
+ if (irpStack->Parameters.DeviceIoControl.IoControlCode ==
IOCTL_MOUNTDEV_QUERY_UNIQUE_ID) {
+
+ //
+ // FIXME
+ // This is a HACK. We don't have unique ID.
+ // We'll just return device name as unique ID.
+ // It's unique but may not survive to a reboot,
+ // which is not matching the requirements for
+ // a MountMgr unique ID.
+ //
+
+ PMOUNTDEV_UNIQUE_ID uniqueId = Irp->AssociatedIrp.SystemBuffer;
+
+ //
+ // Check output buffer is big enough.
+ //
+
+ if (irpStack->Parameters.DeviceIoControl.OutputBufferLength <
sizeof(MOUNTDEV_UNIQUE_ID)) {
+
+ Irp->IoStatus.Information = 0;
+ Irp->IoStatus.Status = STATUS_INVALID_PARAMETER;
+ IoCompleteRequest(Irp, IO_NO_INCREMENT);
+ status = STATUS_INVALID_PARAMETER;
+ goto SetStatusAndReturn;
+ }
+
+ //
+ // Set size we'll return so that caller can allocate big enough buffer.
+ //
+
+ RtlZeroMemory(uniqueId, sizeof(MOUNTDEV_UNIQUE_ID));
+ uniqueId->UniqueIdLength = deviceExtension->DeviceName.Length;
+
+ //
+ // Check buffer is big enough to contain device name.
+ //
+
+ if (irpStack->Parameters.DeviceIoControl.OutputBufferLength <
FIELD_OFFSET(MOUNTDEV_UNIQUE_ID, UniqueId) + uniqueId->UniqueIdLength) {
+
+ Irp->IoStatus.Information = sizeof(MOUNTDEV_UNIQUE_ID);
+ Irp->IoStatus.Status = STATUS_BUFFER_OVERFLOW;
+ IoCompleteRequest(Irp, IO_NO_INCREMENT);
+ status = STATUS_BUFFER_OVERFLOW;
+ goto SetStatusAndReturn;
+ }
+
+ //
+ // Copy device name.
+ //
+
+ RtlCopyMemory(uniqueId->UniqueId, deviceExtension->DeviceName.Buffer,
+ uniqueId->UniqueIdLength);
+ status = STATUS_SUCCESS;
+
+ //
+ // And return to the caller.
+ //
+
+ Irp->IoStatus.Status = STATUS_SUCCESS;
+ Irp->IoStatus.Information = FIELD_OFFSET(MOUNTDEV_UNIQUE_ID, UniqueId) +
uniqueId->UniqueIdLength;
+ IoCompleteRequest(Irp, IO_NO_INCREMENT);
+ goto SetStatusAndReturn;
+ }
+
if (irpStack->Parameters.DeviceIoControl.IoControlCode ==
IOCTL_MOUNTDEV_QUERY_DEVICE_NAME) {
PMOUNTDEV_NAME name = Irp->AssociatedIrp.SystemBuffer;