Alexandre Julliard : ntdll: Move creation of the initial modules to LdrInitializeThunk().
Alexandre Julliard
julliard at winehq.org
Thu Apr 1 16:09:27 CDT 2021
Module: wine
Branch: master
Commit: e6ed943028d8d5d63ae0d40c898fbf0fbfc38c54
URL: https://source.winehq.org/git/wine.git/?a=commit;h=e6ed943028d8d5d63ae0d40c898fbf0fbfc38c54
Author: Alexandre Julliard <julliard at winehq.org>
Date: Thu Apr 1 12:01:43 2021 +0200
ntdll: Move creation of the initial modules to LdrInitializeThunk().
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/ntdll/loader.c | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c
index e418eef6acb..39e87e5d752 100644
--- a/dlls/ntdll/loader.c
+++ b/dlls/ntdll/loader.c
@@ -2389,7 +2389,7 @@ static NTSTATUS load_so_dll( LPCWSTR load_path, const UNICODE_STRING *nt_name,
*
* Build the module data for the main image.
*/
-static void build_main_module(void)
+static WINE_MODREF *build_main_module(void)
{
SECTION_IMAGE_INFORMATION info;
UNICODE_STRING nt_name;
@@ -2419,11 +2419,12 @@ static void build_main_module(void)
if (status) goto failed;
status = build_module( NULL, &nt_name, &module, &info, NULL, DONT_RESOLVE_DLL_REFERENCES, &wm );
RtlFreeUnicodeString( &nt_name );
- if (!status) return;
+ if (!status) return wm;
failed:
MESSAGE( "wine: failed to create main module for %s, status %x\n",
debugstr_us(¶ms->ImagePathName), status );
NtTerminateProcess( GetCurrentProcess(), status );
+ return NULL; /* unreached */
}
@@ -3513,14 +3514,16 @@ void WINAPI LdrInitializeThunk( CONTEXT *context, ULONG_PTR unknown2, ULONG_PTR
RtlEnterCriticalSection( &loader_section );
- wm = get_modref( NtCurrentTeb()->Peb->ImageBaseAddress );
- assert( wm );
-
if (!imports_fixup_done)
{
ANSI_STRING func_name;
WINE_MODREF *kernel32;
+ wm = build_main_module();
+ wm->ldr.LoadCount = -1;
+
+ build_ntdll_module();
+
if ((status = load_dll( NULL, L"kernel32.dll", NULL, 0, &kernel32 )) != STATUS_SUCCESS)
{
MESSAGE( "wine: could not load kernel32.dll, status %x\n", status );
@@ -3549,6 +3552,7 @@ void WINAPI LdrInitializeThunk( CONTEXT *context, ULONG_PTR unknown2, ULONG_PTR
}
imports_fixup_done = TRUE;
}
+ else wm = get_modref( NtCurrentTeb()->Peb->ImageBaseAddress );
RtlAcquirePebLock();
InsertHeadList( &tls_links, &NtCurrentTeb()->TlsLinks );
@@ -3565,7 +3569,6 @@ void WINAPI LdrInitializeThunk( CONTEXT *context, ULONG_PTR unknown2, ULONG_PTR
debugstr_w(NtCurrentTeb()->Peb->ProcessParameters->ImagePathName.Buffer), status );
NtTerminateProcess( GetCurrentProcess(), status );
}
- wm->ldr.LoadCount = -1;
wm->ldr.Flags |= LDR_PROCESS_ATTACHED; /* don't try to attach again */
if (wm->ldr.ActivationContext)
RtlActivateActivationContext( 0, wm->ldr.ActivationContext, &cookie );
@@ -4052,8 +4055,6 @@ static NTSTATUS process_init(void)
init_user_process_params();
load_global_options();
version_init();
- build_main_module();
- build_ntdll_module();
#ifndef _WIN64
if (NtCurrentTeb64())
More information about the wine-cvs
mailing list