Commit 2a8a4cbb authored by Alexandre Julliard's avatar Alexandre Julliard

ntdll: Move kernel32 loading into LdrInitializeThunk().

parent 0bbbf016
......@@ -68,6 +68,7 @@ const WCHAR windows_dir[] = L"C:\\windows";
const WCHAR system_dir[] = L"C:\\windows\\system32\\";
const WCHAR syswow64_dir[] = L"C:\\windows\\syswow64\\";
HMODULE kernel32_handle = 0;
BOOL is_wow64 = FALSE;
/* system search path */
......@@ -3517,6 +3518,23 @@ void WINAPI LdrInitializeThunk( CONTEXT *context, ULONG_PTR unknown2, ULONG_PTR
if (!imports_fixup_done)
{
ANSI_STRING func_name;
WINE_MODREF *kernel32;
if ((status = load_dll( NULL, L"kernel32.dll", NULL, 0, &kernel32 )) != STATUS_SUCCESS)
{
MESSAGE( "wine: could not load kernel32.dll, status %x\n", status );
NtTerminateProcess( GetCurrentProcess(), status );
}
kernel32_handle = kernel32->ldr.DllBase;
RtlInitAnsiString( &func_name, "BaseThreadInitThunk" );
if ((status = LdrGetProcedureAddress( kernel32_handle, &func_name,
0, (void **)&pBaseThreadInitThunk )) != STATUS_SUCCESS)
{
MESSAGE( "wine: could not find BaseThreadInitThunk in kernel32.dll, status %x\n", status );
NtTerminateProcess( GetCurrentProcess(), status );
}
actctx_init();
if (wm->ldr.Flags & LDR_COR_ILONLY)
status = fixup_imports_ilonly( wm, NULL, entry );
......@@ -4002,9 +4020,6 @@ static void map_wow64cpu(void)
*/
static NTSTATUS process_init(void)
{
WINE_MODREF *wm;
NTSTATUS status;
ANSI_STRING func_name;
INITIAL_TEB stack;
TEB *teb = NtCurrentTeb();
PEB *peb = teb->Peb;
......@@ -4039,6 +4054,7 @@ static NTSTATUS process_init(void)
load_global_options();
version_init();
build_main_module();
build_ntdll_module();
#ifndef _WIN64
if (NtCurrentTeb64())
......@@ -4050,30 +4066,9 @@ static NTSTATUS process_init(void)
peb64->OSBuildNumber = peb->OSBuildNumber;
peb64->OSPlatformId = peb->OSPlatformId;
peb64->SessionId = peb->SessionId;
}
#endif
build_ntdll_module();
#ifndef _WIN64
if (is_wow64)
map_wow64cpu();
#endif
if ((status = load_dll( NULL, L"C:\\windows\\system32\\kernel32.dll", NULL, 0, &wm )) != STATUS_SUCCESS)
{
MESSAGE( "wine: could not load kernel32.dll, status %x\n", status );
NtTerminateProcess( GetCurrentProcess(), status );
}
RtlInitAnsiString( &func_name, "BaseThreadInitThunk" );
if ((status = LdrGetProcedureAddress( wm->ldr.DllBase, &func_name,
0, (void **)&pBaseThreadInitThunk )) != STATUS_SUCCESS)
{
MESSAGE( "wine: could not find BaseThreadInitThunk in kernel32.dll, status %x\n", status );
NtTerminateProcess( GetCurrentProcess(), status );
}
init_locale( wm->ldr.DllBase );
#endif
RtlCreateUserStack( 0, 0, 0, 0x10000, 0x10000, &stack );
teb->Tib.StackBase = stack.StackBase;
......
......@@ -101,7 +101,6 @@ struct norm_table
};
static NLSTABLEINFO nls_info;
static HMODULE kernel32_handle;
static struct norm_table *norm_tables[16];
......@@ -531,15 +530,6 @@ static unsigned int compose_string( const struct norm_table *info, WCHAR *str, u
}
/******************************************************************
* init_locale
*/
void init_locale( HMODULE module )
{
kernel32_handle = module;
}
static NTSTATUS get_dummy_preferred_ui_language( DWORD flags, LANGID lang, ULONG *count,
WCHAR *buffer, ULONG *size )
{
......
......@@ -61,7 +61,6 @@ extern void version_init(void) DECLSPEC_HIDDEN;
extern void debug_init(void) DECLSPEC_HIDDEN;
extern void actctx_init(void) DECLSPEC_HIDDEN;
extern void heap_set_debug_flags( HANDLE handle ) DECLSPEC_HIDDEN;
extern void init_locale( HMODULE module ) DECLSPEC_HIDDEN;
extern void init_user_process_params(void) DECLSPEC_HIDDEN;
extern void CDECL DECLSPEC_NORETURN signal_start_thread( CONTEXT *ctx ) DECLSPEC_HIDDEN;
......@@ -79,6 +78,7 @@ extern void SNOOP_SetupDLL( HMODULE hmod ) DECLSPEC_HIDDEN;
extern const WCHAR windows_dir[] DECLSPEC_HIDDEN;
extern const WCHAR system_dir[] DECLSPEC_HIDDEN;
extern const WCHAR syswow64_dir[] DECLSPEC_HIDDEN;
extern HMODULE kernel32_handle DECLSPEC_HIDDEN;
extern void (FASTCALL *pBaseThreadInitThunk)(DWORD,LPTHREAD_START_ROUTINE,void *) DECLSPEC_HIDDEN;
extern const struct unix_funcs *unix_funcs DECLSPEC_HIDDEN;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment