Zebediah Figura : mountmgr: Return the serial and label from IOCTL_MOUNTMGR_QUERY_UNIX_DRIVE.

Alexandre Julliard julliard at winehq.org
Mon Apr 6 15:53:21 CDT 2020


Module: wine
Branch: master
Commit: 19b8aadf4b0071e9b712b80a7c0dfeb197c4f5b3
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=19b8aadf4b0071e9b712b80a7c0dfeb197c4f5b3

Author: Zebediah Figura <z.figura12 at gmail.com>
Date:   Fri Mar 27 10:32:32 2020 -0500

mountmgr: Return the serial and label from IOCTL_MOUNTMGR_QUERY_UNIX_DRIVE.

Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/mountmgr.sys/device.c   | 18 ++++++++++++++++--
 dlls/mountmgr.sys/mountmgr.c | 22 ++++++++++++++++++----
 dlls/mountmgr.sys/mountmgr.h |  7 ++++---
 include/ddk/mountmgr.h       |  2 ++
 4 files changed, 40 insertions(+), 9 deletions(-)

diff --git a/dlls/mountmgr.sys/device.c b/dlls/mountmgr.sys/device.c
index 9d287bd639..8fb984579e 100644
--- a/dlls/mountmgr.sys/device.c
+++ b/dlls/mountmgr.sys/device.c
@@ -152,6 +152,15 @@ static char *strdupA( const char *str )
     return ret;
 }
 
+static WCHAR *strdupW( const WCHAR *str )
+{
+    WCHAR *ret;
+
+    if (!str) return NULL;
+    if ((ret = RtlAllocateHeap( GetProcessHeap(), 0, (strlenW(str) + 1) * sizeof(WCHAR) ))) strcpyW( ret, str );
+    return ret;
+}
+
 static const GUID *get_default_uuid( int letter )
 {
     static GUID guid;
@@ -1631,7 +1640,7 @@ enum mountmgr_fs_type get_mountmgr_fs_type(enum fs_type fs_type)
 
 /* query information about an existing dos drive, by letter or udi */
 NTSTATUS query_dos_device( int letter, enum device_type *type, enum mountmgr_fs_type *fs_type,
-                           char **device, char **mount_point )
+                           DWORD *serial, char **device, char **mount_point, WCHAR **label )
 {
     NTSTATUS status = STATUS_NO_SUCH_DEVICE;
     struct dos_drive *drive;
@@ -1644,8 +1653,10 @@ NTSTATUS query_dos_device( int letter, enum device_type *type, enum mountmgr_fs_
         disk_device = drive->volume->device;
         if (type) *type = disk_device->type;
         if (fs_type) *fs_type = get_mountmgr_fs_type( drive->volume->fs_type );
+        if (serial) *serial = drive->volume->serial;
         if (device) *device = strdupA( disk_device->unix_device );
         if (mount_point) *mount_point = strdupA( disk_device->unix_mount );
+        if (label) *label = strdupW( drive->volume->label );
         status = STATUS_SUCCESS;
         break;
     }
@@ -1655,7 +1666,8 @@ NTSTATUS query_dos_device( int letter, enum device_type *type, enum mountmgr_fs_
 
 /* query information about an existing unix device, by dev_t */
 NTSTATUS query_unix_device( ULONGLONG unix_dev, enum device_type *type,
-                            enum mountmgr_fs_type *fs_type, char **device, char **mount_point )
+                            enum mountmgr_fs_type *fs_type, DWORD *serial, char **device,
+                            char **mount_point, WCHAR **label )
 {
     NTSTATUS status = STATUS_NO_SUCH_DEVICE;
     struct volume *volume;
@@ -1674,8 +1686,10 @@ NTSTATUS query_unix_device( ULONGLONG unix_dev, enum device_type *type,
 
         if (type) *type = disk_device->type;
         if (fs_type) *fs_type = get_mountmgr_fs_type( volume->fs_type );
+        if (serial) *serial = volume->serial;
         if (device) *device = strdupA( disk_device->unix_device );
         if (mount_point) *mount_point = strdupA( disk_device->unix_mount );
+        if (label) *label = strdupW( volume->label );
         status = STATUS_SUCCESS;
         break;
     }
diff --git a/dlls/mountmgr.sys/mountmgr.c b/dlls/mountmgr.sys/mountmgr.c
index 791b0b722d..cf12f03a73 100644
--- a/dlls/mountmgr.sys/mountmgr.c
+++ b/dlls/mountmgr.sys/mountmgr.c
@@ -294,22 +294,25 @@ static NTSTATUS query_unix_drive( void *buff, SIZE_T insize,
     char *device, *mount_point;
     int letter = tolowerW( input->letter );
     NTSTATUS status;
-    DWORD size, type = DEVICE_UNKNOWN;
+    DWORD size, type = DEVICE_UNKNOWN, serial;
     enum mountmgr_fs_type fs_type;
     enum device_type device_type;
     char *ptr;
+    WCHAR *label;
 
     if (!letter)
     {
-        if ((status = query_unix_device( input->unix_dev, &device_type,
-                                         &fs_type, &device, &mount_point )))
+        if ((status = query_unix_device( input->unix_dev, &device_type, &fs_type,
+                                         &serial, &device, &mount_point, &label )))
             return status;
     }
     else
     {
         if (letter < 'a' || letter > 'z') return STATUS_INVALID_PARAMETER;
 
-        if ((status = query_dos_device( letter - 'a', &device_type, &fs_type, &device, &mount_point ))) return status;
+        if ((status = query_dos_device( letter - 'a', &device_type, &fs_type, &serial, &device,
+                                        &mount_point, &label )))
+            return status;
     }
 
     switch (device_type)
@@ -334,8 +337,10 @@ static NTSTATUS query_unix_drive( void *buff, SIZE_T insize,
     output->letter = letter;
     output->type = type;
     output->fs_type = fs_type;
+    output->serial = serial;
     output->mount_point_offset = 0;
     output->device_offset = 0;
+    output->label_offset = 0;
 
     if (size > outsize)
     {
@@ -372,6 +377,14 @@ static NTSTATUS query_unix_drive( void *buff, SIZE_T insize,
     }
     else output->device_offset = 0;
 
+    if (label)
+    {
+        output->label_offset = ptr - (char *)output;
+        strcpyW( (WCHAR *)ptr, label );
+        ptr += (strlenW(label) + 1) * sizeof(WCHAR);
+    }
+    else output->label_offset = 0;
+
     TRACE( "returning %c: dev %s mount %s type %u\n",
            letter, debugstr_a(device), debugstr_a(mount_point), type );
 
@@ -379,6 +392,7 @@ static NTSTATUS query_unix_drive( void *buff, SIZE_T insize,
 done:
     RtlFreeHeap( GetProcessHeap(), 0, device );
     RtlFreeHeap( GetProcessHeap(), 0, mount_point );
+    RtlFreeHeap( GetProcessHeap(), 0, label );
     return status;
 }
 
diff --git a/dlls/mountmgr.sys/mountmgr.h b/dlls/mountmgr.sys/mountmgr.h
index 7171a50a41..82d783a7a0 100644
--- a/dlls/mountmgr.sys/mountmgr.h
+++ b/dlls/mountmgr.sys/mountmgr.h
@@ -57,10 +57,11 @@ extern NTSTATUS add_dos_device( int letter, const char *udi, const char *device,
                                 const char *mount_point, enum device_type type, const GUID *guid,
                                 UNICODE_STRING *devname ) DECLSPEC_HIDDEN;
 extern NTSTATUS remove_dos_device( int letter, const char *udi ) DECLSPEC_HIDDEN;
-extern NTSTATUS query_dos_device( int letter, enum device_type *type, enum mountmgr_fs_type *fs_type,
-                                  char **device, char **mount_point ) DECLSPEC_HIDDEN;
+extern NTSTATUS query_dos_device( int letter, enum device_type *type, enum mountmgr_fs_type *fs_type, DWORD *serial,
+                                  char **device, char **mount_point, WCHAR **label ) DECLSPEC_HIDDEN;
 extern NTSTATUS query_unix_device( ULONGLONG unix_dev, enum device_type *type,
-                                   enum mountmgr_fs_type *fs_type, char **device, char **mount_point ) DECLSPEC_HIDDEN;
+                                   DWORD *serial, enum mountmgr_fs_type *fs_type, char **device,
+                                   char **mount_point, WCHAR **label ) DECLSPEC_HIDDEN;
 extern NTSTATUS WINAPI harddisk_driver_entry( DRIVER_OBJECT *driver, UNICODE_STRING *path ) DECLSPEC_HIDDEN;
 extern NTSTATUS WINAPI serial_driver_entry( DRIVER_OBJECT *driver, UNICODE_STRING *path ) DECLSPEC_HIDDEN;
 extern NTSTATUS WINAPI parallel_driver_entry( DRIVER_OBJECT *driver, UNICODE_STRING *path ) DECLSPEC_HIDDEN;
diff --git a/include/ddk/mountmgr.h b/include/ddk/mountmgr.h
index 5d382a1869..13829a5395 100644
--- a/include/ddk/mountmgr.h
+++ b/include/ddk/mountmgr.h
@@ -66,10 +66,12 @@ struct mountmgr_unix_drive
     ULONG     size;
     ULONG     type;
     ULONG     fs_type;
+    DWORD     serial;
     ULONGLONG unix_dev;
     WCHAR     letter;
     USHORT    mount_point_offset;
     USHORT    device_offset;
+    USHORT    label_offset;
 };
 
 #define IOCTL_MOUNTMGR_QUERY_DHCP_REQUEST_PARAMS CTL_CODE(MOUNTMGRCONTROLTYPE, 64, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)




More information about the wine-cvs mailing list