Alexandre Julliard : ntdll: Update the __wine_ldt_copy pointer directly from the Unix library.

Alexandre Julliard julliard at winehq.org
Mon Jun 29 14:59:20 CDT 2020


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

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Mon Jun 29 12:10:00 2020 +0200

ntdll: Update the __wine_ldt_copy pointer directly from the Unix library.

Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/ntdll/signal_i386.c       | 2 ++
 dlls/ntdll/thread.c            | 4 +---
 dlls/ntdll/unix/loader.c       | 7 +++++++
 dlls/ntdll/unix/server.c       | 3 ---
 dlls/ntdll/unix/thread.c       | 6 +-----
 dlls/ntdll/unix/unix_private.h | 6 ++++--
 dlls/ntdll/unixlib.h           | 5 ++---
 7 files changed, 17 insertions(+), 16 deletions(-)

diff --git a/dlls/ntdll/signal_i386.c b/dlls/ntdll/signal_i386.c
index ac722bef55..7567a5e5d1 100644
--- a/dlls/ntdll/signal_i386.c
+++ b/dlls/ntdll/signal_i386.c
@@ -95,6 +95,8 @@ static inline struct x86_thread_data *x86_thread_data(void)
     return (struct x86_thread_data *)NtCurrentTeb()->SystemReserved2;
 }
 
+struct ldt_copy *__wine_ldt_copy = NULL;
+
 /* Exception record for handling exceptions happening inside exception handlers */
 typedef struct
 {
diff --git a/dlls/ntdll/thread.c b/dlls/ntdll/thread.c
index 7b8a717241..027b72d3be 100644
--- a/dlls/ntdll/thread.c
+++ b/dlls/ntdll/thread.c
@@ -46,8 +46,6 @@ static RTL_BITMAP tls_bitmap;
 static RTL_BITMAP tls_expansion_bitmap;
 static RTL_BITMAP fls_bitmap;
 
-struct ldt_copy *__wine_ldt_copy = NULL;
-
 static RTL_CRITICAL_SECTION peb_lock;
 static RTL_CRITICAL_SECTION_DEBUG critsect_debug =
 {
@@ -104,7 +102,7 @@ int __cdecl __wine_dbg_output( const char *str )
 TEB *thread_init( SIZE_T *info_size )
 {
     ULONG_PTR val;
-    TEB *teb = unix_funcs->init_threading( &__wine_ldt_copy, info_size );
+    TEB *teb = unix_funcs->init_threading( info_size );
 
     peb = teb->Peb;
     peb->FastPebLock        = &peb_lock;
diff --git a/dlls/ntdll/unix/loader.c b/dlls/ntdll/unix/loader.c
index 892ff10c35..600a2b0e39 100644
--- a/dlls/ntdll/unix/loader.c
+++ b/dlls/ntdll/unix/loader.c
@@ -838,6 +838,13 @@ static void fixup_ntdll_imports( const IMAGE_NT_HEADERS *nt )
     GET_FUNC( LdrInitializeThunk );
     GET_FUNC( RtlUserThreadStart );
     GET_FUNC( __wine_set_unix_funcs );
+#ifdef __i386__
+    {
+        struct ldt_copy **p__wine_ldt_copy;
+        GET_FUNC( __wine_ldt_copy );
+        *p__wine_ldt_copy = &__wine_ldt_copy;
+    }
+#endif
 #undef GET_FUNC
 }
 
diff --git a/dlls/ntdll/unix/server.c b/dlls/ntdll/unix/server.c
index f02d1ed8a2..c311665267 100644
--- a/dlls/ntdll/unix/server.c
+++ b/dlls/ntdll/unix/server.c
@@ -1461,9 +1461,6 @@ void server_init_process(void)
  */
 void CDECL server_init_process_done( void *relay )
 {
-#ifdef __i386__
-    extern struct ldt_copy __wine_ldt_copy;
-#endif
     PEB *peb = NtCurrentTeb()->Peb;
     IMAGE_NT_HEADERS *nt = RtlImageNtHeader( peb->ImageBaseAddress );
     void *entry = (char *)peb->ImageBaseAddress + nt->OptionalHeader.AddressOfEntryPoint;
diff --git a/dlls/ntdll/unix/thread.c b/dlls/ntdll/unix/thread.c
index 2be8d2d3e2..129410f8d7 100644
--- a/dlls/ntdll/unix/thread.c
+++ b/dlls/ntdll/unix/thread.c
@@ -86,15 +86,11 @@ static void pthread_exit_wrapper( int status )
 /***********************************************************************
  *           init_threading
  */
-TEB * CDECL init_threading( struct ldt_copy **ldt_copy, SIZE_T *size )
+TEB * CDECL init_threading( SIZE_T *size )
 {
     TEB *teb;
     BOOL suspend;
     SIZE_T info_size;
-#ifdef __i386__
-    extern struct ldt_copy __wine_ldt_copy;
-    *ldt_copy = &__wine_ldt_copy;
-#endif
 
     teb = virtual_alloc_first_teb();
 
diff --git a/dlls/ntdll/unix/unix_private.h b/dlls/ntdll/unix/unix_private.h
index 1f4c2da0c6..54254632e7 100644
--- a/dlls/ntdll/unix/unix_private.h
+++ b/dlls/ntdll/unix/unix_private.h
@@ -73,7 +73,6 @@ extern void     (WINAPI *pDbgUiRemoteBreakin)( void *arg ) DECLSPEC_HIDDEN;
 extern NTSTATUS (WINAPI *pKiUserExceptionDispatcher)(EXCEPTION_RECORD*,CONTEXT*) DECLSPEC_HIDDEN;
 extern void     (WINAPI *pLdrInitializeThunk)(CONTEXT*,void**,ULONG_PTR,ULONG_PTR) DECLSPEC_HIDDEN;
 extern void     (WINAPI *pRtlUserThreadStart)( PRTL_THREAD_START_ROUTINE entry, void *arg ) DECLSPEC_HIDDEN;
-
 extern NTSTATUS CDECL fast_RtlpWaitForCriticalSection( RTL_CRITICAL_SECTION *crit, int timeout ) DECLSPEC_HIDDEN;
 extern NTSTATUS CDECL fast_RtlpUnWaitCriticalSection( RTL_CRITICAL_SECTION *crit ) DECLSPEC_HIDDEN;
 extern NTSTATUS CDECL fast_RtlDeleteCriticalSection( RTL_CRITICAL_SECTION *crit ) DECLSPEC_HIDDEN;
@@ -117,7 +116,7 @@ extern NTSTATUS CDECL server_handle_to_fd( HANDLE handle, unsigned int access, i
                                            unsigned int *options ) DECLSPEC_HIDDEN;
 extern void CDECL server_release_fd( HANDLE handle, int unix_fd ) DECLSPEC_HIDDEN;
 extern void CDECL server_init_process_done( void *relay ) DECLSPEC_HIDDEN;
-extern TEB * CDECL init_threading( struct ldt_copy **ldt_copy, SIZE_T *size ) DECLSPEC_HIDDEN;
+extern TEB * CDECL init_threading( SIZE_T *size ) DECLSPEC_HIDDEN;
 extern void CDECL DECLSPEC_NORETURN exit_thread( int status ) DECLSPEC_HIDDEN;
 extern void CDECL DECLSPEC_NORETURN exit_process( int status ) DECLSPEC_HIDDEN;
 extern NTSTATUS CDECL exec_process( UNICODE_STRING *path, UNICODE_STRING *cmdline, NTSTATUS status ) DECLSPEC_HIDDEN;
@@ -149,6 +148,9 @@ extern sigset_t server_block_set DECLSPEC_HIDDEN;
 extern SIZE_T signal_stack_size DECLSPEC_HIDDEN;
 extern SIZE_T signal_stack_mask DECLSPEC_HIDDEN;
 extern struct _KUSER_SHARED_DATA *user_shared_data DECLSPEC_HIDDEN;
+#ifdef __i386__
+extern struct ldt_copy __wine_ldt_copy DECLSPEC_HIDDEN;
+#endif
 
 extern void init_environment( int argc, char *argv[], char *envp[] ) DECLSPEC_HIDDEN;
 extern DWORD ntdll_umbstowcs( const char *src, DWORD srclen, WCHAR *dst, DWORD dstlen ) DECLSPEC_HIDDEN;
diff --git a/dlls/ntdll/unixlib.h b/dlls/ntdll/unixlib.h
index 19e532da47..c8bcac3836 100644
--- a/dlls/ntdll/unixlib.h
+++ b/dlls/ntdll/unixlib.h
@@ -24,12 +24,11 @@
 #include "wine/server.h"
 #include "wine/debug.h"
 
-struct ldt_copy;
 struct msghdr;
 struct _DISPATCHER_CONTEXT;
 
 /* increment this when you change the function table */
-#define NTDLL_UNIXLIB_VERSION 66
+#define NTDLL_UNIXLIB_VERSION 67
 
 struct unix_funcs
 {
@@ -319,7 +318,7 @@ struct unix_funcs
     void          (CDECL *virtual_set_large_address_space)(void);
 
     /* thread/process functions */
-    TEB *         (CDECL *init_threading)( struct ldt_copy **ldt_copy, SIZE_T *size );
+    TEB *         (CDECL *init_threading)( SIZE_T *size );
     void          (CDECL *exit_thread)( int status );
     void          (CDECL *exit_process)( int status );
     NTSTATUS      (CDECL *exec_process)( UNICODE_STRING *path, UNICODE_STRING *cmdline, NTSTATUS status );




More information about the wine-cvs mailing list