mountmgr.sys: For loop-mounted devices, use the backing file

Alexandre Goujon ale.goujon at gmail.com
Mon Aug 20 13:21:05 CDT 2012


As part of their copy protection, some games use some ioctl's to check some physical attributes.
Unfortunately, when using the loop device, some ioctl fail (like IOCTL_SCSI_GET_ADDRESS).
A simple fix is to use /path/to/the/file.ISO instead of /dev/loopX.
This patch only modifies UDisks enumerating code (v1 and 2).
The Disk Arbitration library doesn't expose this information and HAL is deprecated.
If needed, HAL support can be added afterward.
---
 dlls/mountmgr.sys/dbus.c   |   15 +++++++++++++--
 dlls/mountmgr.sys/device.c |    4 +++-
 2 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/dlls/mountmgr.sys/dbus.c b/dlls/mountmgr.sys/dbus.c
index ea0341a..8f36c55 100644
--- a/dlls/mountmgr.sys/dbus.c
+++ b/dlls/mountmgr.sys/dbus.c
@@ -237,7 +237,7 @@ static void udisks_new_device( const char *udi )
     const char *mount_point = NULL;
     const char *type = NULL;
     GUID guid, *guid_ptr = NULL;
-    int removable = FALSE;
+    int removable = FALSE, loop = FALSE;
     enum device_type drive_type = DEVICE_UNKNOWN;
 
     request = p_dbus_message_new_method_call( "org.freedesktop.UDisks", udi,
@@ -266,10 +266,13 @@ static void udisks_new_device( const char *udi )
         p_dbus_message_iter_recurse( &iter, &iter );
         while ((name = udisks_next_dict_entry( &iter, &variant )))
         {
-            if (!strcmp( name, "DeviceFile" ))
+            if (!strcmp( name, "DeviceFile" )
+            || (!strcmp( name, "LinuxLoopFilename" ) && loop))
                 p_dbus_message_iter_get_basic( &variant, &device );
             else if (!strcmp( name, "DeviceIsRemovable" ))
                 p_dbus_message_iter_get_basic( &variant, &removable );
+            else if (!strcmp( name, "DeviceIsLinuxLoop" ))
+                p_dbus_message_iter_get_basic( &variant, &loop );
             else if (!strcmp( name, "IdType" ))
                 p_dbus_message_iter_get_basic( &variant, &type );
             else if (!strcmp( name, "DriveMediaCompatibility" ))
@@ -452,6 +455,14 @@ static void udisks2_add_device( const char *udi, DBusMessageIter *dict, DBusMess
                 }
             }
         }
+        if (!strcmp( iface, "org.freedesktop.UDisks2.Loop" ))
+        {
+            while ((name = udisks_next_dict_entry( &iter, &variant )))
+            {
+                if (!strcmp( name, "BackingFile" ))
+                    device = udisks2_string_from_array( &variant );
+            }
+        }
     }
 
     TRACE( "udi %s device %s mount point %s uuid %s type %s removable %u\n",
diff --git a/dlls/mountmgr.sys/device.c b/dlls/mountmgr.sys/device.c
index 8367cba..1ba6f8b 100644
--- a/dlls/mountmgr.sys/device.c
+++ b/dlls/mountmgr.sys/device.c
@@ -551,7 +551,9 @@ static int add_drive( const char *device, enum device_type type )
     struct stat dev_st, drive_st;
     int drive, first, last, avail = 0;
 
-    if (stat( device, &dev_st ) == -1 || !is_valid_device( &dev_st )) return -1;
+    if (stat( device, &dev_st ) == -1
+    || (!strncmp(device, "/dev", 3) && !is_valid_device( &dev_st )))
+        return -1;
 
     if (!(path = get_dosdevices_path( &p ))) return -1;
 
-- 
1.7.9.5




More information about the wine-patches mailing list