[FLOPPY] Implement IOCTL_MOUNTDEV_QUERY_DEVICE_NAME
authorPierre Schweitzer <pierre@reactos.org>
Sat, 14 Sep 2019 08:48:19 +0000 (10:48 +0200)
committerPierre Schweitzer <pierre@reactos.org>
Sat, 14 Sep 2019 08:48:19 +0000 (10:48 +0200)
drivers/storage/floppy/ioctl.c
drivers/storage/floppy/precomp.h

index 976e02e..74a3517 100644 (file)
@@ -74,6 +74,7 @@ DeviceIoctlPassive(PDRIVE_INFO DriveInfo, PIRP Irp)
     PVOID OutputBuffer = Irp->AssociatedIrp.SystemBuffer;
     ULONG Code = Stack->Parameters.DeviceIoControl.IoControlCode;
     BOOLEAN DiskChanged;
+    PMOUNTDEV_NAME Name;
 
     TRACE_(FLOPPY, "DeviceIoctl called\n");
     Irp->IoStatus.Status = STATUS_SUCCESS;
@@ -255,6 +256,29 @@ DeviceIoctlPassive(PDRIVE_INFO DriveInfo, PIRP Irp)
         Irp->IoStatus.Information = 0;
         break;
 
+    case IOCTL_MOUNTDEV_QUERY_DEVICE_NAME:
+        if (OutputLength < sizeof(MOUNTDEV_NAME)) {
+            Irp->IoStatus.Status = STATUS_BUFFER_TOO_SMALL;
+            Irp->IoStatus.Information = sizeof(MOUNTDEV_NAME);
+            break;
+        }
+
+        Name = Irp->AssociatedIrp.SystemBuffer;
+        Name->NameLength = wcslen(&DriveInfo->SymLinkBuffer[0]) * sizeof(WCHAR);
+
+        if (OutputLength < sizeof(USHORT) + Name->NameLength) {
+            Irp->IoStatus.Status = STATUS_BUFFER_OVERFLOW;
+            Irp->IoStatus.Information = sizeof(MOUNTDEV_NAME);
+            break;
+        }
+
+        RtlCopyMemory(Name->Name, &DriveInfo->SymLinkBuffer[0],
+                      Name->NameLength);
+
+        Irp->IoStatus.Status = STATUS_SUCCESS;
+        Irp->IoStatus.Information = sizeof(USHORT) + Name->NameLength;
+        break;
+
     default:
         ERR_(FLOPPY, "UNKNOWN IOCTL CODE: 0x%x\n", Code);
         Irp->IoStatus.Status = STATUS_NOT_SUPPORTED;
index 47af755..bb0c015 100644 (file)
@@ -2,6 +2,7 @@
 #define _FLOPPY_PCH_
 
 #include <wdm.h>
+#include <mountdev.h>
 
 #include "floppy.h"
 #include "csqrtns.h"