Jacek Caban : user32: Introduced ThreadDetach driver entry point.

Alexandre Julliard julliard at winehq.org
Mon Aug 29 11:07:22 CDT 2016


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

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Thu Aug 25 14:33:45 2016 +0200

user32: Introduced ThreadDetach driver entry point.

The problem was diagnosed by Ken Thomases.

Currently drivers use DllMain(DLL_THREAD_DETACH) to release thread data.
The problem is that DLLs (like native urlmon.dll, esp. reproducible in
IE8) may still do user32 calls after driver detaches thread. Loader
ensures that since user32.dll was loaded before dependent DLLs, user32's
DllMain will be called in the right moment. Due to lazy loading of
drivers, we have no control over them. We may use a new entry point to
make sure that we detach user32 and driver at the same time.

Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/user32/driver.c       | 13 +++++++++++--
 dlls/user32/user_main.c    |  1 +
 dlls/user32/user_private.h |  2 ++
 3 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/dlls/user32/driver.c b/dlls/user32/driver.c
index 201988c..32acf28 100644
--- a/dlls/user32/driver.c
+++ b/dlls/user32/driver.c
@@ -155,6 +155,7 @@ static const USER_DRIVER *load_driver(void)
         GET_USER_FUNC(WindowPosChanging);
         GET_USER_FUNC(WindowPosChanged);
         GET_USER_FUNC(SystemParametersInfo);
+        GET_USER_FUNC(ThreadDetach);
 #undef GET_USER_FUNC
     }
 
@@ -512,6 +513,10 @@ static BOOL CDECL nulldrv_SystemParametersInfo( UINT action, UINT int_param, voi
     return FALSE;
 }
 
+static void CDECL nulldrv_ThreadDetach( void )
+{
+}
+
 static USER_DRIVER null_driver =
 {
     /* keyboard functions */
@@ -572,7 +577,9 @@ static USER_DRIVER null_driver =
     nulldrv_WindowPosChanging,
     nulldrv_WindowPosChanged,
     /* system parameters */
-    nulldrv_SystemParametersInfo
+    nulldrv_SystemParametersInfo,
+    /* thread management */
+    nulldrv_ThreadDetach
 };
 
 
@@ -827,5 +834,7 @@ static USER_DRIVER lazy_load_driver =
     nulldrv_WindowPosChanging,
     nulldrv_WindowPosChanged,
     /* system parameters */
-    nulldrv_SystemParametersInfo
+    nulldrv_SystemParametersInfo,
+    /* thread management */
+    nulldrv_ThreadDetach
 };
diff --git a/dlls/user32/user_main.c b/dlls/user32/user_main.c
index 45aea81..74a7617 100644
--- a/dlls/user32/user_main.c
+++ b/dlls/user32/user_main.c
@@ -303,6 +303,7 @@ static void thread_detach(void)
     exiting_thread_id = GetCurrentThreadId();
 
     WDML_NotifyThreadDetach();
+    USER_Driver->pThreadDetach();
 
     if (thread_info->top_window) WIN_DestroyThreadWindows( thread_info->top_window );
     if (thread_info->msg_window) WIN_DestroyThreadWindows( thread_info->msg_window );
diff --git a/dlls/user32/user_private.h b/dlls/user32/user_private.h
index e4a2ed1..efad519 100644
--- a/dlls/user32/user_private.h
+++ b/dlls/user32/user_private.h
@@ -117,6 +117,8 @@ typedef struct tagUSER_DRIVER {
     void   (CDECL *pWindowPosChanged)(HWND,HWND,UINT,const RECT *,const RECT *,const RECT *,const RECT *,struct window_surface*);
     /* system parameters */
     BOOL   (CDECL *pSystemParametersInfo)(UINT,UINT,void*,UINT);
+    /* thread management */
+    void   (CDECL *pThreadDetach)(void);
 } USER_DRIVER;
 
 extern const USER_DRIVER *USER_Driver DECLSPEC_HIDDEN;




More information about the wine-cvs mailing list