From 23ce18d5e5a31bf2712c2951a45cfda4747e0c54 Mon Sep 17 00:00:00 2001 From: Zhiyi Zhang Date: Tue, 1 Sep 2020 15:03:26 +0800 Subject: [PATCH] user32: Always wait for the desktop process to be ready in load_desktop_driver(). 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 Signed-off-by: Alexandre Julliard --- 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 );