[PATCH 4/5] winemenubuilder: Skip desktop integration for certain associations

Alex Henrie alexhenrie24 at gmail.com
Mon Oct 4 00:51:25 CDT 2021


Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=41275
Signed-off-by: Alex Henrie <alexhenrie24 at gmail.com>
---
An old version of this patch has been in Wine Staging for over a year.
---
 dlls/mshtml/mshtml.inf                     |  6 +++
 loader/wine.inf.in                         | 10 +++++
 programs/winemenubuilder/winemenubuilder.c | 50 +++++++++++++++++++---
 3 files changed, 61 insertions(+), 5 deletions(-)

diff --git a/dlls/mshtml/mshtml.inf b/dlls/mshtml/mshtml.inf
index 4a650b444fc..183d401b494 100644
--- a/dlls/mshtml/mshtml.inf
+++ b/dlls/mshtml/mshtml.inf
@@ -111,6 +111,7 @@ HKCR,"giffile\shell\open\ddeexec",,,"""file:%%1"",,-1,,,,,"
 HKCR,"giffile\shell\open\ddeexec\Application",,,"IExplore"
 HKCR,"giffile\shell\open\ddeexec\Topic",,,"WWW_OpenURL"
 ;; HKCR,"giffile\DefaultIcon",,,"%16422%\Internet Explorer\iexplore.exe,9"
+HKCU,Software\Wine\FileOpenNoIntegration\.gif,"iexplore",,"""%16422%\Internet Explorer\iexplore.exe"" -nohome"
 
 ;; GZIP
 HKCR,"MIME\Database\Content Type\application/x-gzip","Extension",,".gz"
@@ -158,6 +159,7 @@ HKCR,"jpegfile\shell\open\ddeexec",,,"""file:%%1"",,-1,,,,,"
 HKCR,"jpegfile\shell\open\ddeexec\Application",,,"IExplore"
 HKCR,"jpegfile\shell\open\ddeexec\Topic",,,"WWW_OpenURL"
 ;; HKCR,"jpegfile\DefaultIcon",,,"%16422%\Internet Explorer\iexplore.exe,8"
+HKCU,Software\Wine\FileOpenNoIntegration\.jpe,"iexplore",,"""%16422%\Internet Explorer\iexplore.exe"" -nohome"
 
 ;; JPEG
 HKCR,"MIME\Database\Content Type\image/jpeg","CLSID",,"%CLSID_HTMLDocument%"
@@ -173,6 +175,7 @@ HKCR,"jpegfile\shell\open\ddeexec",,,"""file:%%1"",,-1,,,,,"
 HKCR,"jpegfile\shell\open\ddeexec\Application",,,"IExplore"
 HKCR,"jpegfile\shell\open\ddeexec\Topic",,,"WWW_OpenURL"
 ;; HKCR,"jpegfile\DefaultIcon",,,"%16422%\Internet Explorer\iexplore.exe,8"
+HKCU,Software\Wine\FileOpenNoIntegration\.jpeg,"iexplore",,"""%16422%\Internet Explorer\iexplore.exe"" -nohome"
 
 ;; JPG
 HKCR,".jpg",,2,"jpegfile"
@@ -184,6 +187,7 @@ HKCR,"jpegfile\shell\open\ddeexec",,,"""file:%%1"",,-1,,,,,"
 HKCR,"jpegfile\shell\open\ddeexec\Application",,,"IExplore"
 HKCR,"jpegfile\shell\open\ddeexec\Topic",,,"WWW_OpenURL"
 ;; HKCR,"jpegfile\DefaultIcon",,,"%16422%\Internet Explorer\iexplore.exe,8"
+HKCU,Software\Wine\FileOpenNoIntegration\.jpg,"iexplore",,"""%16422%\Internet Explorer\iexplore.exe"" -nohome"
 
 ;; MHTML
 HKCR,"MIME\Database\Content Type\message/rfc822","CLSID",,"%CLSID_MHTMLDocument%"
@@ -221,6 +225,7 @@ HKCR,"pjpegfile\shell\open\ddeexec",,,"""file:%%1"",,-1,,,,,"
 HKCR,"pjpegfile\shell\open\ddeexec\Application",,,"IExplore"
 HKCR,"pjpegfile\shell\open\ddeexec\Topic",,,"WWW_OpenURL"
 ;; HKCR,"pjpegfile\DefaultIcon",,,"%16422%\Internet Explorer\iexplore.exe,8"
+HKCU,Software\Wine\FileOpenNoIntegration\.jfif,"iexplore",,"""%16422%\Internet Explorer\iexplore.exe"" -nohome"
 
 ;; PNG
 HKCR,"MIME\Database\Content Type\image/png","Extension",,".png"
@@ -234,6 +239,7 @@ HKCR,"pngfile\shell\open\ddeexec",,,"""file:%%1"",,-1,,,,,"
 HKCR,"pngfile\shell\open\ddeexec\Application",,,"IExplore"
 HKCR,"pngfile\shell\open\ddeexec\Topic",,,"WWW_OpenURL"
 ;; HKCR,"pngfile\DefaultIcon",,,"%16422%\Internet Explorer\iexplore.exe,9"
+HKCU,Software\Wine\FileOpenNoIntegration\.png,"iexplore",,"""%16422%\Internet Explorer\iexplore.exe"" -nohome"
 
 ;; PS
 HKCR,"MIME\Database\Content Type\application/postscript","Extension",,".ps"
diff --git a/loader/wine.inf.in b/loader/wine.inf.in
index d023701c04b..b2747ad9a34 100644
--- a/loader/wine.inf.in
+++ b/loader/wine.inf.in
@@ -507,6 +507,16 @@ HKCR,MIME\Database\Charset\us-ascii,"AliasForCharset",,iso-8859-1
 HKCR,MIME\Database\Charset\visual,"AliasForCharset",,iso-8859-8
 HKCR,MIME\Database\Charset\Windows-1254,"AliasForCharset",,iso-8859-9
 
+HKCU,Software\Wine\FileOpenNoIntegration\.htm,"winebrowser",,"""%11%\winebrowser.exe"" ""%1"""
+HKCU,Software\Wine\FileOpenNoIntegration\.html,"winebrowser",,"""%11%\winebrowser.exe"" ""%1"""
+HKCU,Software\Wine\FileOpenNoIntegration\.ini,"notepad",,"""%11%\notepad.exe"" ""%1"""
+HKCU,Software\Wine\FileOpenNoIntegration\.pdf,"winebrowser",,"""%11%\winebrowser.exe"" ""%1"""
+HKCU,Software\Wine\FileOpenNoIntegration\.rtf,"wordpad",,"""%16422%\Windows NT\Accessories\wordpad.exe"" ""%1"""
+HKCU,Software\Wine\FileOpenNoIntegration\.txt,"notepad",,"""%11%\notepad.exe"" ""%1"""
+HKCU,Software\Wine\FileOpenNoIntegration\.url,"ieframe",,"rundll32.exe ieframe.dll,OpenURL %l"
+HKCU,Software\Wine\FileOpenNoIntegration\.wri,"wordpad",,"""%16422%\Windows NT\Accessories\wordpad.exe"" ""%1"""
+HKCU,Software\Wine\FileOpenNoIntegration\.xml,"winebrowser",,"""%11%\winebrowser.exe"" ""%1"""
+
 [ContentIndex]
 HKLM,System\CurrentControlSet\Control\ContentIndex\Language\Neutral,"WBreakerClass",,"{369647e0-17b0-11ce-9950-00aa004bbb1f}"
 HKLM,System\CurrentControlSet\Control\ContentIndex\Language\Neutral,"StemmerClass",,""
diff --git a/programs/winemenubuilder/winemenubuilder.c b/programs/winemenubuilder/winemenubuilder.c
index f10026a418e..a2790cf203d 100644
--- a/programs/winemenubuilder/winemenubuilder.c
+++ b/programs/winemenubuilder/winemenubuilder.c
@@ -2091,6 +2091,42 @@ static BOOL is_extension_banned(LPCWSTR extension)
     return FALSE;
 }
 
+static BOOL on_exclude_list(const WCHAR *extension, const WCHAR *command)
+{
+    static const WCHAR FileOpenNoIntegrationW[] = L"Software\\Wine\\FileOpenNoIntegration\\";
+    WCHAR key_path[MAX_PATH];
+    HKEY key;
+    WCHAR program_name[MAX_PATH], *command_to_exclude;
+    DWORD len = ARRAY_SIZE(program_name);
+    DWORD i = 0;
+
+    if (ARRAY_SIZE(FileOpenNoIntegrationW) + lstrlenW(extension) > ARRAY_SIZE(key_path))
+        return FALSE;
+
+    lstrcpyW(key_path, FileOpenNoIntegrationW);
+    lstrcatW(key_path, extension);
+
+    if (RegOpenKeyExW(HKEY_CURRENT_USER, key_path, 0, KEY_QUERY_VALUE, &key) != ERROR_SUCCESS)
+        return FALSE;
+
+    while (RegEnumValueW(key, i, program_name, &len, NULL, NULL, NULL, NULL) == ERROR_SUCCESS)
+    {
+        command_to_exclude = reg_get_valW(HKEY_CURRENT_USER, key_path, program_name);
+        if (wcscmp(command, command_to_exclude) == 0)
+        {
+            heap_free(command_to_exclude);
+            RegCloseKey(key);
+            return TRUE;
+        }
+        heap_free(command_to_exclude);
+        len = ARRAY_SIZE(program_name);
+        i++;
+    }
+
+    RegCloseKey(key);
+    return FALSE;
+}
+
 static WCHAR *get_special_mime_type(LPCWSTR extension)
 {
     if (!wcsicmp(extension, L".lnk"))
@@ -2183,6 +2219,15 @@ static BOOL generate_associations(const WCHAR *packages_dir, const WCHAR *applic
         if (extensionW[0] != '.' || is_extension_banned(extensionW))
             goto end;
 
+        commandW = assoc_query(ASSOCSTR_COMMAND, extensionW, L"open");
+        if (commandW == NULL)
+            /* no command => no application is associated */
+            goto end;
+
+        if (on_exclude_list(extensionW, commandW))
+            /* command is on the exclude list => desktop integration is not desirable */
+            goto end;
+
         wcslwr(extensionW);
         friendlyDocNameW = assoc_query(ASSOCSTR_FRIENDLYDOCNAME, extensionW, NULL);
 
@@ -2219,11 +2264,6 @@ static BOOL generate_associations(const WCHAR *packages_dir, const WCHAR *applic
             hasChanged = TRUE;
         }
 
-        commandW = assoc_query(ASSOCSTR_COMMAND, extensionW, L"open");
-        if (commandW == NULL)
-            /* no command => no application is associated */
-            goto end;
-
         executableW = assoc_query(ASSOCSTR_EXECUTABLE, extensionW, L"open");
         if (executableW)
             openWithIcon = compute_native_identifier(0, executableW, NULL);
-- 
2.33.0




More information about the wine-devel mailing list