This is an automated email from the git hooks/post-receive script.

root pushed a commit to branch master
in repository reactos.

View the commit online:
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=fdb72d7f85a3fd65eb1f51c2ad0be61f46357527

commit fdb72d7f85a3fd65eb1f51c2ad0be61f46357527
Author: Pierre Schweitzer <pie...@reactos.org>
AuthorDate: Tue Oct 3 20:57:50 2017 +0200

    [CLASS2]: - In ScsiClassCreateDeviceObject() don't drop received object 
name and store it in the device extension
    - Implement support for the IOCTL_MOUNTDEV_QUERY_DEVICE_NAME IOCTL; return 
the store device name
---
 drivers/storage/class/class2/class2.c  | 48 +++++++++++++++++++++++++++-------
 drivers/storage/class/include/class2.h |  1 +
 2 files changed, 39 insertions(+), 10 deletions(-)

diff --git a/drivers/storage/class/class2/class2.c 
b/drivers/storage/class/class2/class2.c
index 20f55efc07..48598e37b8 100644
--- a/drivers/storage/class/class2/class2.c
+++ b/drivers/storage/class/class2/class2.c
@@ -4041,9 +4041,9 @@ Return Value:
         goto SetStatusAndReturn;
     }
 
-    if (irpStack->Parameters.DeviceIoControl.IoControlCode == 
IOCTL_MOUNTDEV_QUERY_DEVICE_NAME || 
-        irpStack->Parameters.DeviceIoControl.IoControlCode == 
IOCTL_MOUNTDEV_QUERY_UNIQUE_ID ||
+    if (irpStack->Parameters.DeviceIoControl.IoControlCode == 
IOCTL_MOUNTDEV_QUERY_UNIQUE_ID ||
         irpStack->Parameters.DeviceIoControl.IoControlCode == 
IOCTL_MOUNTDEV_QUERY_SUGGESTED_LINK_NAME) {
+
         UNIMPLEMENTED;
         Irp->IoStatus.Information = 0;
         Irp->IoStatus.Status = STATUS_NOT_IMPLEMENTED;
@@ -4052,6 +4052,40 @@ Return Value:
         goto SetStatusAndReturn;
     }
 
+    if (irpStack->Parameters.DeviceIoControl.IoControlCode == 
IOCTL_MOUNTDEV_QUERY_DEVICE_NAME) {
+
+        PMOUNTDEV_NAME name = Irp->AssociatedIrp.SystemBuffer;
+
+        if (irpStack->Parameters.DeviceIoControl.OutputBufferLength < 
sizeof(MOUNTDEV_NAME)) {
+
+            Irp->IoStatus.Information = 0;
+            Irp->IoStatus.Status = STATUS_BUFFER_TOO_SMALL;
+            IoCompleteRequest(Irp, IO_NO_INCREMENT);
+            status = STATUS_BUFFER_TOO_SMALL;
+            goto SetStatusAndReturn;
+        }
+
+        RtlZeroMemory(name, sizeof(MOUNTDEV_NAME));
+        name->NameLength = deviceExtension->DeviceName.Length;
+
+        if (irpStack->Parameters.DeviceIoControl.OutputBufferLength < 
sizeof(USHORT) + name->NameLength) {
+
+            Irp->IoStatus.Information = sizeof(MOUNTDEV_NAME);
+            Irp->IoStatus.Status = STATUS_BUFFER_OVERFLOW;
+            IoCompleteRequest(Irp, IO_NO_INCREMENT);
+            status = STATUS_BUFFER_OVERFLOW;
+            goto SetStatusAndReturn;
+        }
+
+        RtlCopyMemory(name->Name, deviceExtension->DeviceName.Buffer,
+                      name->NameLength);
+        status = STATUS_SUCCESS;
+        Irp->IoStatus.Status = STATUS_SUCCESS;
+        Irp->IoStatus.Information = sizeof(USHORT) + name->NameLength;
+        IoCompleteRequest(Irp, IO_NO_INCREMENT);
+        goto SetStatusAndReturn;
+    }
+
     srb = ExAllocatePool(NonPagedPool, SCSI_REQUEST_BLOCK_SIZE);
 
     if (srb == NULL) {
@@ -4691,20 +4725,14 @@ Return Value:
         } else {
             deviceExtension->PhysicalDevice = deviceObject;
         }
+
+        deviceExtension->DeviceName = ntUnicodeString;
     }
 
     deviceObject->Flags &= ~DO_DEVICE_INITIALIZING;
 
     *DeviceObject = deviceObject;
 
-    RtlFreeUnicodeString(&ntUnicodeString);
-
-    //
-    // Indicate the ntUnicodeString is free.
-    //
-
-    ntUnicodeString.Buffer = NULL;
-
     return status;
 }
 
diff --git a/drivers/storage/class/include/class2.h 
b/drivers/storage/class/include/class2.h
index 047e48d4ac..e1e0cf01ef 100644
--- a/drivers/storage/class/include/class2.h
+++ b/drivers/storage/class/include/class2.h
@@ -132,6 +132,7 @@ typedef struct _DEVICE_EXTENSION
   HANDLE MediaChangeEventHandle;
   BOOLEAN MediaChangeNoMedia;
   ULONG MediaChangeCount;
+  UNICODE_STRING DeviceName;
 } DEVICE_EXTENSION, *PDEVICE_EXTENSION;
 
 

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.

Reply via email to