Alexandre Julliard : ntdll: Move suspending a thread on startup into attach_dlls().

Alexandre Julliard julliard at winehq.org
Fri Dec 1 14:08:20 CST 2017


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

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Fri Dec  1 20:31:21 2017 +0100

ntdll: Move suspending a thread on startup into attach_dlls().

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

---

 dlls/ntdll/loader.c         | 8 +++++---
 dlls/ntdll/ntdll_misc.h     | 2 +-
 dlls/ntdll/signal_arm.c     | 3 +--
 dlls/ntdll/signal_arm64.c   | 3 +--
 dlls/ntdll/signal_i386.c    | 3 +--
 dlls/ntdll/signal_powerpc.c | 3 +--
 dlls/ntdll/signal_x86_64.c  | 3 +--
 7 files changed, 11 insertions(+), 14 deletions(-)

diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c
index c8c7f6a..170eefe 100644
--- a/dlls/ntdll/loader.c
+++ b/dlls/ntdll/loader.c
@@ -2990,12 +2990,14 @@ PIMAGE_NT_HEADERS WINAPI RtlImageNtHeader(HMODULE hModule)
  * Attach to all the loaded dlls.
  * If this is the first time, perform the full process initialization.
  */
-NTSTATUS attach_dlls( void *reserved )
+NTSTATUS attach_dlls( CONTEXT *context, BOOL suspend )
 {
     NTSTATUS status;
     WINE_MODREF *wm;
     LPCWSTR load_path = NtCurrentTeb()->Peb->ProcessParameters->DllPath.Buffer;
 
+    if (suspend) wait_suspend( context );
+
     pthread_sigmask( SIG_UNBLOCK, &server_block_set, NULL );
 
     if (process_detaching) return STATUS_SUCCESS;
@@ -3029,7 +3031,7 @@ NTSTATUS attach_dlls( void *reserved )
                  debugstr_w(NtCurrentTeb()->Peb->ProcessParameters->ImagePathName.Buffer), status );
             NtTerminateProcess( GetCurrentProcess(), status );
         }
-        if ((status = process_attach( wm, reserved )) != STATUS_SUCCESS)
+        if ((status = process_attach( wm, context )) != STATUS_SUCCESS)
         {
             if (last_failed_modref)
                 ERR( "%s failed to initialize, aborting\n",
@@ -3038,7 +3040,7 @@ NTSTATUS attach_dlls( void *reserved )
                  debugstr_w(NtCurrentTeb()->Peb->ProcessParameters->ImagePathName.Buffer), status );
             NtTerminateProcess( GetCurrentProcess(), status );
         }
-        attach_implicitly_loaded_dlls( reserved );
+        attach_implicitly_loaded_dlls( context );
         virtual_release_address_space();
     }
     else
diff --git a/dlls/ntdll/ntdll_misc.h b/dlls/ntdll/ntdll_misc.h
index 1393bbf..149462d 100644
--- a/dlls/ntdll/ntdll_misc.h
+++ b/dlls/ntdll/ntdll_misc.h
@@ -105,7 +105,7 @@ extern NTSTATUS validate_open_object_attributes( const OBJECT_ATTRIBUTES *attr )
 
 /* module handling */
 extern LIST_ENTRY tls_links DECLSPEC_HIDDEN;
-extern NTSTATUS attach_dlls( void *unused ) DECLSPEC_HIDDEN;
+extern NTSTATUS attach_dlls( CONTEXT *context, BOOL suspend ) DECLSPEC_HIDDEN;
 extern FARPROC RELAY_GetProcAddress( HMODULE module, const IMAGE_EXPORT_DIRECTORY *exports,
                                      DWORD exp_size, FARPROC proc, DWORD ordinal, const WCHAR *user ) DECLSPEC_HIDDEN;
 extern FARPROC SNOOP_GetProcAddress( HMODULE hmod, const IMAGE_EXPORT_DIRECTORY *exports, DWORD exp_size,
diff --git a/dlls/ntdll/signal_arm.c b/dlls/ntdll/signal_arm.c
index e1aa94f..59ae765 100644
--- a/dlls/ntdll/signal_arm.c
+++ b/dlls/ntdll/signal_arm.c
@@ -1230,8 +1230,7 @@ static void thread_startup( void *param )
     context.Sp = (DWORD)NtCurrentTeb()->Tib.StackBase;
     context.Pc = (DWORD)call_thread_entry_point;
 
-    if (info->suspend) wait_suspend( &context );
-    attach_dlls( &context );
+    attach_dlls( &context, info->suspend );
 
     set_cpu_context( &context );
 }
diff --git a/dlls/ntdll/signal_arm64.c b/dlls/ntdll/signal_arm64.c
index 3dc92ad..36c7f2f 100644
--- a/dlls/ntdll/signal_arm64.c
+++ b/dlls/ntdll/signal_arm64.c
@@ -973,8 +973,7 @@ static void thread_startup( void *param )
     context.Sp = (DWORD_PTR)NtCurrentTeb()->Tib.StackBase;
     context.Pc = (DWORD_PTR)call_thread_entry_point;
 
-    if (info->suspend) wait_suspend( &context );
-    attach_dlls( &context );
+    attach_dlls( &context, info->suspend );
 
     call_thread_entry_point( (LPTHREAD_START_ROUTINE)context.X0, (void *)context.X1 );
 }
diff --git a/dlls/ntdll/signal_i386.c b/dlls/ntdll/signal_i386.c
index f894816..1c04c82 100644
--- a/dlls/ntdll/signal_i386.c
+++ b/dlls/ntdll/signal_i386.c
@@ -2984,8 +2984,7 @@ void DECLSPEC_HIDDEN call_process_func( LPTHREAD_START_ROUTINE entry, void *arg
  */
 void DECLSPEC_HIDDEN thread_startup( CONTEXT *context, BOOL suspend )
 {
-    if (suspend) wait_suspend( context );
-    attach_dlls( context );
+    attach_dlls( context, suspend );
     virtual_clear_thread_stack();
     set_cpu_context( context );
 }
diff --git a/dlls/ntdll/signal_powerpc.c b/dlls/ntdll/signal_powerpc.c
index b012497..5122c54 100644
--- a/dlls/ntdll/signal_powerpc.c
+++ b/dlls/ntdll/signal_powerpc.c
@@ -1175,8 +1175,7 @@ static void thread_startup( void *param )
     context.Gpr4 = (DWORD)info->arg;
     context.Iar  = (DWORD)call_thread_entry_point;
 
-    if (info->suspend) wait_suspend( &context );
-    attach_dlls( &context );
+    attach_dlls( &context, info->suspend );
 
     call_thread_entry_point( (LPTHREAD_START_ROUTINE)context.Gpr3, (void *)context.Gpr4 );
 }
diff --git a/dlls/ntdll/signal_x86_64.c b/dlls/ntdll/signal_x86_64.c
index 3994569..af2682e 100644
--- a/dlls/ntdll/signal_x86_64.c
+++ b/dlls/ntdll/signal_x86_64.c
@@ -4145,8 +4145,7 @@ __ASM_GLOBAL_FUNC( call_thread_exit_func,
  */
 void DECLSPEC_HIDDEN thread_startup( CONTEXT *context, BOOL suspend )
 {
-    if (suspend) wait_suspend( context );
-    attach_dlls( context );
+    attach_dlls( context, suspend );
     virtual_clear_thread_stack();
     set_cpu_context( context );
 }




More information about the wine-cvs mailing list