Robert Shearman : user: Make ExitWindowsEx asynchronous by deferring the real work to the explorer process .

Alexandre Julliard julliard at wine.codeweavers.com
Tue Aug 8 13:21:29 CDT 2006


Module: wine
Branch: refs/heads/master
Commit: b550f34f2e1ef3e73d21dfe87fbb2d7b3d49fb14
URL:    http://source.winehq.org/git/?p=wine.git;a=commit;h=b550f34f2e1ef3e73d21dfe87fbb2d7b3d49fb14

Author: Robert Shearman <rob at codeweavers.com>
Date:   Fri Aug  4 17:28:04 2006 +0100

user: Make ExitWindowsEx asynchronous by deferring the real work to the explorer process.

---

 dlls/user/user_main.c       |   13 ++++++++++++-
 programs/explorer/desktop.c |    7 +++++++
 2 files changed, 19 insertions(+), 1 deletions(-)

diff --git a/dlls/user/user_main.c b/dlls/user/user_main.c
index 70ec9fc..743bded 100644
--- a/dlls/user/user_main.c
+++ b/dlls/user/user_main.c
@@ -411,6 +411,18 @@ BOOL WINAPI ExitWindowsEx( UINT flags, D
 {
     TRACE("(%x,%lx)\n", flags, reason);
 
+    if (!WIN_IsCurrentThread( GetDesktopWindow() ))
+    {
+        BOOL ret = PostMessageW( GetDesktopWindow(), WM_USER + 666,
+                                 MAKEWPARAM( flags, 0xbabe ), reason);
+        if (ret)
+            return TRUE;
+        /* this can happen if explorer hasn't been started or created the
+         * desktop window yet */
+        WARN("PostMessage failed with error %ld\n", GetLastError());
+        /* fall through to doing it in the same process */
+    }
+
     if ((flags & EWX_FORCE) == 0)
     {
         HWND *list;
@@ -468,6 +480,5 @@ BOOL WINAPI ExitWindowsEx( UINT flags, D
             MESSAGE("wine: Failed to start wineboot\n");
     }
 
-    ExitProcess(0);
     return TRUE;
 }
diff --git a/programs/explorer/desktop.c b/programs/explorer/desktop.c
index 67025b8..d4db46d 100644
--- a/programs/explorer/desktop.c
+++ b/programs/explorer/desktop.c
@@ -62,6 +62,13 @@ static LRESULT WINAPI desktop_wnd_proc( 
         }
         return 0;
 
+    /* simple check to prevent applications accidentally triggering the
+     * ExitWindowsEx code if they send random messages to the desktop window */
+    case WM_USER + 666:
+        if (HIWORD(wp) == 0xbabe)
+            return ExitWindowsEx( LOWORD(wp), lp );
+        return DefWindowProcW( hwnd, message, wp, lp );
+
     default:
         return DefWindowProcW( hwnd, message, wp, lp );
     }




More information about the wine-cvs mailing list