[PATCH] user32: Always wait for the desktop process to be ready in load_desktop_driver().

Zhiyi Zhang zzhang at codeweavers.com
Tue Sep 1 02:03:26 CDT 2020


Having a __wine_display_device_guid property in the desktop window only guarantees that the window
is created. Explorer.exe still has to finish setting up virtual desktop, display settings etc.
load_desktop_driver() needs to make sure that the desktop initialization is done before allowing
applications to call user32 driver functions. Otherwise, they might get incorrect data. This race
condition became apparent after aadae4d1ea173dfa30e09d6cc816bb174e35f90d, which adds ~100ms to the
initialization process.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=49762
Signed-off-by: Zhiyi Zhang <zzhang at codeweavers.com>
---
 dlls/user32/driver.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/dlls/user32/driver.c b/dlls/user32/driver.c
index 6d916c7d65d..abd8a34cceb 100644
--- a/dlls/user32/driver.c
+++ b/dlls/user32/driver.c
@@ -59,17 +59,14 @@ static BOOL load_desktop_driver( HWND hwnd, HMODULE *module )
     DWORD size;
     WCHAR path[MAX_PATH];
     WCHAR key[ARRAY_SIZE(key_pathW) + ARRAY_SIZE(displayW) + 40];
-    UINT guid_atom = HandleToULong( GetPropW( hwnd, display_device_guid_propW ));
+    UINT guid_atom;
 
     USER_CheckNotLock();
 
     strcpy( driver_load_error, "The explorer process failed to start." );  /* default error */
+    SendMessageW( hwnd, WM_NULL, 0, 0 );  /* wait for the desktop process to be ready */
 
-    if (!guid_atom)
-    {
-        SendMessageW( hwnd, WM_NULL, 0, 0 );  /* wait for the desktop process to be ready */
-        guid_atom = HandleToULong( GetPropW( hwnd, display_device_guid_propW ));
-    }
+    guid_atom = HandleToULong( GetPropW( hwnd, display_device_guid_propW ));
     memcpy( key, key_pathW, sizeof(key_pathW) );
     if (!GlobalGetAtomNameW( guid_atom, key + strlenW(key), 40 )) return 0;
     strcatW( key, displayW );
-- 
2.25.1



More information about the wine-devel mailing list