Alexandre Julliard : ntdll: Move some initializations out of thread_init().
Alexandre Julliard
julliard at winehq.org
Thu Nov 7 16:16:04 CST 2019
Module: wine
Branch: master
Commit: 608d086f1b1bb7168e9322c65224c23f34e75f29
URL: https://source.winehq.org/git/wine.git/?a=commit;h=608d086f1b1bb7168e9322c65224c23f34e75f29
Author: Alexandre Julliard <julliard at winehq.org>
Date: Thu Nov 7 17:00:39 2019 +0100
ntdll: Move some initializations out of thread_init().
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/ntdll/loader.c | 36 ++++++++++++++++++++++--------------
dlls/ntdll/ntdll_misc.h | 2 +-
dlls/ntdll/thread.c | 22 +++-------------------
3 files changed, 26 insertions(+), 34 deletions(-)
diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c
index b16d646bdd..98c3f2d950 100644
--- a/dlls/ntdll/loader.c
+++ b/dlls/ntdll/loader.c
@@ -4234,8 +4234,22 @@ void __wine_process_init(void)
UNICODE_STRING nt_name;
void * (CDECL *init_func)(void);
INITIAL_TEB stack;
+ BOOL suspend;
+ SIZE_T info_size;
+ TEB *teb = thread_init();
+ PEB *peb = teb->Peb;
- thread_init();
+ /* setup the server connection */
+ server_init_process();
+ info_size = server_init_thread( peb, &suspend );
+
+ peb->ProcessHeap = RtlCreateHeap( HEAP_GROWABLE, NULL, 0, 0, NULL, NULL );
+ peb->LoaderLock = &loader_section;
+
+ init_directories();
+ init_user_process_params( info_size );
+
+ NtCreateKeyedEvent( &keyed_event, GENERIC_READ | GENERIC_WRITE, NULL, 0 );
/* retrieve current umask */
FILE_umask = umask(0777);
@@ -4263,7 +4277,7 @@ void __wine_process_init(void)
kernel32_start_process = init_func();
- wm = get_modref( NtCurrentTeb()->Peb->ImageBaseAddress );
+ wm = get_modref( peb->ImageBaseAddress );
assert( wm );
if (wm->ldr.Flags & LDR_IMAGE_IS_DLL)
{
@@ -4271,24 +4285,18 @@ void __wine_process_init(void)
exit(1);
}
- NtCurrentTeb()->Peb->LoaderLock = &loader_section;
virtual_set_large_address_space();
/* the main exe needs to be the first in the load order list */
RemoveEntryList( &wm->ldr.InLoadOrderModuleList );
- InsertHeadList( &NtCurrentTeb()->Peb->LdrData->InLoadOrderModuleList, &wm->ldr.InLoadOrderModuleList );
+ InsertHeadList( &peb->LdrData->InLoadOrderModuleList, &wm->ldr.InLoadOrderModuleList );
RemoveEntryList( &wm->ldr.InMemoryOrderModuleList );
- InsertHeadList( &NtCurrentTeb()->Peb->LdrData->InMemoryOrderModuleList, &wm->ldr.InMemoryOrderModuleList );
+ InsertHeadList( &peb->LdrData->InMemoryOrderModuleList, &wm->ldr.InMemoryOrderModuleList );
- if ((status = virtual_alloc_thread_stack( &stack, 0, 0, NULL )) != STATUS_SUCCESS)
- {
- ERR( "Main exe initialization for %s failed, status %x\n",
- debugstr_w(wm->ldr.FullDllName.Buffer), status );
- NtTerminateProcess( GetCurrentProcess(), status );
- }
- NtCurrentTeb()->Tib.StackBase = stack.StackBase;
- NtCurrentTeb()->Tib.StackLimit = stack.StackLimit;
- NtCurrentTeb()->DeallocationStack = stack.DeallocationStack;
+ virtual_alloc_thread_stack( &stack, 0, 0, NULL );
+ teb->Tib.StackBase = stack.StackBase;
+ teb->Tib.StackLimit = stack.StackLimit;
+ teb->DeallocationStack = stack.DeallocationStack;
server_init_process_done();
}
diff --git a/dlls/ntdll/ntdll_misc.h b/dlls/ntdll/ntdll_misc.h
index 074792ff2a..eb31bb5bce 100644
--- a/dlls/ntdll/ntdll_misc.h
+++ b/dlls/ntdll/ntdll_misc.h
@@ -79,7 +79,7 @@ extern void DECLSPEC_NORETURN signal_exit_thread( int status ) DECLSPEC_HIDDEN;
extern void DECLSPEC_NORETURN signal_exit_process( int status ) DECLSPEC_HIDDEN;
extern void version_init(void) DECLSPEC_HIDDEN;
extern void debug_init(void) DECLSPEC_HIDDEN;
-extern void thread_init(void) DECLSPEC_HIDDEN;
+extern TEB *thread_init(void) DECLSPEC_HIDDEN;
extern void actctx_init(void) DECLSPEC_HIDDEN;
extern void virtual_init(void) DECLSPEC_HIDDEN;
extern void virtual_init_threading(void) DECLSPEC_HIDDEN;
diff --git a/dlls/ntdll/thread.c b/dlls/ntdll/thread.c
index be54f89082..621aaddfe3 100644
--- a/dlls/ntdll/thread.c
+++ b/dlls/ntdll/thread.c
@@ -220,12 +220,11 @@ static void set_process_name( int argc, char *argv[] )
*
* NOTES: The first allocated TEB on NT is at 0x7ffde000.
*/
-void thread_init(void)
+TEB *thread_init(void)
{
TEB *teb;
void *addr;
- BOOL suspend;
- SIZE_T size, info_size;
+ SIZE_T size;
LARGE_INTEGER now;
NTSTATUS status;
struct ntdll_thread_data *thread_data;
@@ -299,21 +298,7 @@ void thread_init(void)
signal_init_thread( teb );
virtual_init_threading();
debug_init();
-
- /* setup the server connection */
- server_init_process();
- info_size = server_init_thread( peb, &suspend );
-
- /* create the process heap */
- if (!(peb->ProcessHeap = RtlCreateHeap( HEAP_GROWABLE, NULL, 0, 0, NULL, NULL )))
- {
- MESSAGE( "wine: failed to create the process heap\n" );
- exit(1);
- }
-
set_process_name( __wine_main_argc, __wine_main_argv );
- init_directories();
- init_user_process_params( info_size );
/* initialize time values in user_shared_data */
NtQuerySystemTime( &now );
@@ -323,10 +308,9 @@ void thread_init(void)
user_shared_data->u.TickCount.High2Time = user_shared_data->u.TickCount.High1Time;
user_shared_data->TickCountLowDeprecated = user_shared_data->u.TickCount.LowPart;
user_shared_data->TickCountMultiplier = 1 << 24;
-
fill_cpu_info();
- NtCreateKeyedEvent( &keyed_event, GENERIC_READ | GENERIC_WRITE, NULL, 0 );
+ return teb;
}
More information about the wine-cvs
mailing list