[PATCH 4/4] shell32: Avoid a deadlock between explorer.exe and winemenubuilder.exe.

Zebediah Figura z.figura12 at gmail.com
Tue Nov 28 23:52:07 CST 2017


Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
---
This is an anticipatory change. Creating shell links from Progman (i.e.
explorer.exe) will cause a deadlock if the icon is missing or (as in the tests)
the link is immediately deleted.

 dlls/shell32/shelllink.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/dlls/shell32/shelllink.c b/dlls/shell32/shelllink.c
index 40fab4d..4d0be82 100644
--- a/dlls/shell32/shelllink.c
+++ b/dlls/shell32/shelllink.c
@@ -340,17 +340,26 @@ BOOL run_winemenubuilder( const WCHAR *args )
 
 static BOOL StartLinkProcessor( LPCOLESTR szLink )
 {
-    static const WCHAR szFormat[] = {' ','-','w',' ','"','%','s','"',0 };
+    static const WCHAR szExplorer[] = {'e','x','p','l','o','r','e','r','.','e','x','e'};
+    static const WCHAR szWait[] = {' ','-','w',0};
+    static const WCHAR szFormat[] = {' ','"','%','s','"',0 };
+    WCHAR module[12];
     LONG len;
     LPWSTR buffer;
     BOOL ret;
 
-    len = sizeof(szFormat) + lstrlenW( szLink ) * sizeof(WCHAR);
+    len = sizeof(szWait) + sizeof(szFormat) + lstrlenW( szLink ) * sizeof(WCHAR);
     buffer = HeapAlloc( GetProcessHeap(), 0, len );
     if( !buffer )
         return FALSE;
 
     wsprintfW( buffer, szFormat, szLink );
+    GetModuleFileNameW(NULL, module, sizeof(module)/sizeof(module[0]));
+
+    /* avoid waiting on explorer.exe as this will cause a deadlock */
+    if (memcmp(module, szExplorer, sizeof(szExplorer)))
+        strcatW(buffer, szWait);
+
     ret = run_winemenubuilder( buffer );
     HeapFree( GetProcessHeap(), 0, buffer );
     return ret;
-- 
2.7.4




More information about the wine-devel mailing list