ntdll: Store the kernel32 process entry point in a global variable.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alexandre Julliard 2017-09-19 11:59:58 +02:00
parent 302153117e
commit a003f0aed8
3 changed files with 5 additions and 14 deletions

View File

@ -100,12 +100,6 @@ struct builtin_load_info
static struct builtin_load_info default_load_info; static struct builtin_load_info default_load_info;
static struct builtin_load_info *builtin_load_info = &default_load_info; static struct builtin_load_info *builtin_load_info = &default_load_info;
struct start_params
{
void *kernel_start;
LPTHREAD_START_ROUTINE entry;
};
static HANDLE main_exe_file; static HANDLE main_exe_file;
static UINT tls_module_count; /* number of modules with TLS directory */ static UINT tls_module_count; /* number of modules with TLS directory */
static IMAGE_TLS_DIRECTORY *tls_dirs; /* array of TLS directories */ static IMAGE_TLS_DIRECTORY *tls_dirs; /* array of TLS directories */
@ -3106,8 +3100,7 @@ static void load_global_options(void)
*/ */
static void start_process( void *arg ) static void start_process( void *arg )
{ {
struct start_params *start_params = (struct start_params *)arg; call_thread_entry_point( kernel32_start_process, arg );
call_thread_entry_point( start_params->kernel_start, start_params->entry );
} }
/****************************************************************** /******************************************************************
@ -3122,8 +3115,8 @@ void WINAPI LdrInitializeThunk( void *kernel_start, ULONG_PTR unknown2,
WINE_MODREF *wm; WINE_MODREF *wm;
LPCWSTR load_path; LPCWSTR load_path;
PEB *peb = NtCurrentTeb()->Peb; PEB *peb = NtCurrentTeb()->Peb;
struct start_params start_params;
kernel32_start_process = kernel_start;
if (main_exe_file) NtClose( main_exe_file ); /* at this point the main module is created */ if (main_exe_file) NtClose( main_exe_file ); /* at this point the main module is created */
/* allocate the modref for the main exe (if not already done) */ /* allocate the modref for the main exe (if not already done) */
@ -3159,16 +3152,12 @@ void WINAPI LdrInitializeThunk( void *kernel_start, ULONG_PTR unknown2,
if ((status = fixup_imports( wm, load_path )) != STATUS_SUCCESS) goto error; if ((status = fixup_imports( wm, load_path )) != STATUS_SUCCESS) goto error;
heap_set_debug_flags( GetProcessHeap() ); heap_set_debug_flags( GetProcessHeap() );
/* Store original entrypoint (in case it gets corrupted) */
start_params.kernel_start = kernel_start;
start_params.entry = wm->ldr.EntryPoint;
status = wine_call_on_stack( attach_process_dlls, wm, NtCurrentTeb()->Tib.StackBase ); status = wine_call_on_stack( attach_process_dlls, wm, NtCurrentTeb()->Tib.StackBase );
if (status != STATUS_SUCCESS) goto error; if (status != STATUS_SUCCESS) goto error;
virtual_release_address_space(); virtual_release_address_space();
virtual_clear_thread_stack(); virtual_clear_thread_stack();
wine_switch_to_stack( start_process, &start_params, NtCurrentTeb()->Tib.StackBase ); wine_switch_to_stack( start_process, wm->ldr.EntryPoint, NtCurrentTeb()->Tib.StackBase );
error: error:
ERR( "Main exe initialization for %s failed, status %x\n", ERR( "Main exe initialization for %s failed, status %x\n",

View File

@ -114,6 +114,7 @@ extern UNICODE_STRING system_dir DECLSPEC_HIDDEN;
typedef LONG (WINAPI *PUNHANDLED_EXCEPTION_FILTER)(PEXCEPTION_POINTERS); typedef LONG (WINAPI *PUNHANDLED_EXCEPTION_FILTER)(PEXCEPTION_POINTERS);
extern PUNHANDLED_EXCEPTION_FILTER unhandled_exception_filter DECLSPEC_HIDDEN; extern PUNHANDLED_EXCEPTION_FILTER unhandled_exception_filter DECLSPEC_HIDDEN;
extern LPTHREAD_START_ROUTINE kernel32_start_process DECLSPEC_HIDDEN;
/* redefine these to make sure we don't reference kernel symbols */ /* redefine these to make sure we don't reference kernel symbols */
#define GetProcessHeap() (NtCurrentTeb()->Peb->ProcessHeap) #define GetProcessHeap() (NtCurrentTeb()->Peb->ProcessHeap)

View File

@ -51,6 +51,7 @@ WINE_DECLARE_DEBUG_CHANNEL(relay);
struct _KUSER_SHARED_DATA *user_shared_data = NULL; struct _KUSER_SHARED_DATA *user_shared_data = NULL;
PUNHANDLED_EXCEPTION_FILTER unhandled_exception_filter = NULL; PUNHANDLED_EXCEPTION_FILTER unhandled_exception_filter = NULL;
LPTHREAD_START_ROUTINE kernel32_start_process = NULL;
/* info passed to a starting thread */ /* info passed to a starting thread */
struct startup_info struct startup_info