[PATCH] mountmgr: Symlink WoW64 Wine ports key to regular Wine ports key.

Alex Henrie alexhenrie24 at gmail.com
Sun Oct 29 15:58:52 CDT 2017


Signed-off-by: Alex Henrie <alexhenrie24 at gmail.com>
---
Fixes https://bugs.winehq.org/show_bug.cgi?id=43750

Thanks to Zebediah Figura and Austin English for helping me understand
how the WoW64 registry works.
---
 dlls/mountmgr.sys/device.c   |  3 ++-
 dlls/mountmgr.sys/mountmgr.c | 20 ++++++++++++++++++++
 2 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/dlls/mountmgr.sys/device.c b/dlls/mountmgr.sys/device.c
index 5101f2b565..20c96d002b 100644
--- a/dlls/mountmgr.sys/device.c
+++ b/dlls/mountmgr.sys/device.c
@@ -1136,7 +1136,8 @@ static void create_port_devices( DRIVER_OBJECT *driver )
     }
     p += 3;
 
-    RegOpenKeyExW( HKEY_LOCAL_MACHINE, ports_keyW, 0, KEY_QUERY_VALUE, &wine_ports_key );
+    RegCreateKeyExW( HKEY_LOCAL_MACHINE, ports_keyW, 0, NULL, 0,
+                     KEY_QUERY_VALUE, NULL, &wine_ports_key, NULL );
     RegCreateKeyExW( HKEY_LOCAL_MACHINE, windows_ports_key_name, 0, NULL, REG_OPTION_VOLATILE,
                      KEY_ALL_ACCESS, NULL, &windows_ports_key, NULL );
 
diff --git a/dlls/mountmgr.sys/mountmgr.c b/dlls/mountmgr.sys/mountmgr.c
index 1eb0a78cd6..b792be4bea 100644
--- a/dlls/mountmgr.sys/mountmgr.c
+++ b/dlls/mountmgr.sys/mountmgr.c
@@ -422,6 +422,17 @@ NTSTATUS WINAPI DriverEntry( DRIVER_OBJECT *driver, UNICODE_STRING *path )
     static const WCHAR driver_serialW[] = {'\\','D','r','i','v','e','r','\\','S','e','r','i','a','l',0};
     static const WCHAR driver_parallelW[] = {'\\','D','r','i','v','e','r','\\','P','a','r','a','l','l','e','l',0};
 
+#ifdef _WIN64
+    static const WCHAR qualified_ports_keyW[] = {'\\','R','E','G','I','S','T','R','Y','\\',
+                                                 'M','A','C','H','I','N','E','\\','S','o','f','t','w','a','r','e','\\',
+                                                 'W','i','n','e','\\','P','o','r','t','s'}; /* no null terminator */
+    static const WCHAR wow64_ports_keyW[] = {'S','o','f','t','w','a','r','e','\\',
+                                             'W','o','w','6','4','3','2','N','o','d','e','\\','W','i','n','e','\\',
+                                             'P','o','r','t','s',0};
+    static const WCHAR symbolic_link_valueW[] = {'S','y','m','b','o','l','i','c','L','i','n','k','V','a','l','u','e',0};
+    HKEY wow64_ports_key = NULL;
+#endif
+
     UNICODE_STRING nameW, linkW;
     DEVICE_OBJECT *device;
     NTSTATUS status;
@@ -449,6 +460,15 @@ NTSTATUS WINAPI DriverEntry( DRIVER_OBJECT *driver, UNICODE_STRING *path )
     initialize_dbus();
     initialize_diskarbitration();
 
+#ifdef _WIN64
+    /* create a symlink so that the Wine port overrides key can be edited with 32-bit reg or regedit */
+    RegCreateKeyExW( HKEY_LOCAL_MACHINE, wow64_ports_keyW, 0, NULL, REG_OPTION_CREATE_LINK,
+                     KEY_SET_VALUE, NULL, &wow64_ports_key, NULL );
+    RegSetValueExW( wow64_ports_key, symbolic_link_valueW, 0, REG_LINK,
+                    (BYTE *)qualified_ports_keyW, sizeof(qualified_ports_keyW) );
+    RegCloseKey( wow64_ports_key );
+#endif
+
     RtlInitUnicodeString( &nameW, driver_serialW );
     IoCreateDriver( &nameW, serial_driver_entry );
 
-- 
2.14.2




More information about the wine-patches mailing list