[PATCH rebase 1/2] winemenubuilder: Skip desktop integration for certain associations

Alex Henrie alexhenrie24 at gmail.com
Mon Apr 4 00:31:46 CDT 2022


Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=41275
Signed-off-by: Alex Henrie <alexhenrie24 at gmail.com>
---
 loader/wine.inf.in                         |  6 +++
 programs/winemenubuilder/winemenubuilder.c | 43 +++++++++++++++++++---
 2 files changed, 44 insertions(+), 5 deletions(-)

diff --git a/loader/wine.inf.in b/loader/wine.inf.in
index 46b2caf3647..ad9e1ac8c43 100644
--- a/loader/wine.inf.in
+++ b/loader/wine.inf.in
@@ -320,6 +320,12 @@ HKCR,http\shell\open\command,,2,"""%11%\winebrowser.exe"" ""%1"""
 HKCR,https\shell\open\command,,2,"""%11%\winebrowser.exe"" ""%1"""
 HKCR,mailto\shell\open\command,,2,"""%11%\winebrowser.exe"" ""%1"""
 
+HKCU,Software\Wine\FileOpenNoIntegration,"ieframe",,"ieframe.dll"
+HKCU,Software\Wine\FileOpenNoIntegration,"iexplore",,"iexplore.exe"
+HKCU,Software\Wine\FileOpenNoIntegration,"notepad",,"notepad.exe"
+HKCU,Software\Wine\FileOpenNoIntegration,"winebrowser",,"winebrowser.exe"
+HKCU,Software\Wine\FileOpenNoIntegration,"wordpad",,"wordpad.exe"
+
 [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 1579ca8dafa..ef280954b67 100644
--- a/programs/winemenubuilder/winemenubuilder.c
+++ b/programs/winemenubuilder/winemenubuilder.c
@@ -1974,6 +1974,35 @@ static BOOL is_extension_banned(LPCWSTR extension)
     return FALSE;
 }
 
+static BOOL on_exclude_list(const WCHAR *command)
+{
+    static const WCHAR FileOpenNoIntegrationW[] = L"Software\\Wine\\FileOpenNoIntegration";
+    HKEY key;
+    WCHAR program_name[MAX_PATH], *pattern_to_exclude;
+    DWORD len = ARRAY_SIZE(program_name);
+    DWORD i = 0;
+
+    if (RegOpenKeyExW(HKEY_CURRENT_USER, FileOpenNoIntegrationW, 0, KEY_QUERY_VALUE, &key) != ERROR_SUCCESS)
+        return FALSE;
+
+    while (RegEnumValueW(key, i, program_name, &len, NULL, NULL, NULL, NULL) == ERROR_SUCCESS)
+    {
+        pattern_to_exclude = reg_get_valW(HKEY_CURRENT_USER, FileOpenNoIntegrationW, program_name);
+        if (wcsstr(command, pattern_to_exclude))
+        {
+            heap_free(pattern_to_exclude);
+            RegCloseKey(key);
+            return TRUE;
+        }
+        heap_free(pattern_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"))
@@ -2054,6 +2083,15 @@ static BOOL generate_associations(const WCHAR *packages_dir, const WCHAR *applic
             WCHAR *mimeProgId = NULL;
             struct rb_string_entry *entry;
 
+            commandW = assoc_query(ASSOCSTR_COMMAND, extensionW, L"open");
+            if (commandW == NULL)
+                /* no command => no application is associated */
+                goto end;
+
+            if (on_exclude_list(commandW))
+                /* command is on the exclude list => desktop integration is not desirable */
+                goto end;
+
             wcslwr(extensionW);
             friendlyDocNameW = assoc_query(ASSOCSTR_FRIENDLYDOCNAME, extensionW, NULL);
 
@@ -2093,11 +2131,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.35.1




More information about the wine-devel mailing list