server: Get the process entry point from the exe image info.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alexandre Julliard 2021-02-08 12:10:49 +01:00
parent 52d733b5c4
commit a3c92a02cc
6 changed files with 28 additions and 28 deletions

View File

@ -1587,7 +1587,7 @@ void server_init_process_done(void)
{ {
PEB *peb = NtCurrentTeb()->Peb; PEB *peb = NtCurrentTeb()->Peb;
IMAGE_NT_HEADERS *nt = get_exe_nt_header(); IMAGE_NT_HEADERS *nt = get_exe_nt_header();
void *entry = (char *)peb->ImageBaseAddress + nt->OptionalHeader.AddressOfEntryPoint; void *entry;
NTSTATUS status; NTSTATUS status;
int suspend, needs_close, unixdir; int suspend, needs_close, unixdir;
@ -1613,11 +1613,9 @@ void server_init_process_done(void)
/* Signal the parent process to continue */ /* Signal the parent process to continue */
SERVER_START_REQ( init_process_done ) SERVER_START_REQ( init_process_done )
{ {
req->module = wine_server_client_ptr( peb->ImageBaseAddress );
req->entry = wine_server_client_ptr( entry );
req->gui = (nt->OptionalHeader.Subsystem != IMAGE_SUBSYSTEM_WINDOWS_CUI);
status = wine_server_call( req ); status = wine_server_call( req );
suspend = reply->suspend; suspend = reply->suspend;
entry = wine_server_get_ptr( reply->entry );
} }
SERVER_END_REQ; SERVER_END_REQ;

View File

@ -900,15 +900,14 @@ struct get_startup_info_reply
struct init_process_done_request struct init_process_done_request
{ {
struct request_header __header; struct request_header __header;
int gui; char __pad_12[4];
mod_handle_t module;
client_ptr_t entry;
}; };
struct init_process_done_reply struct init_process_done_reply
{ {
struct reply_header __header; struct reply_header __header;
client_ptr_t entry;
int suspend; int suspend;
char __pad_12[4]; char __pad_20[4];
}; };
@ -6280,7 +6279,7 @@ union generic_reply
/* ### protocol_version begin ### */ /* ### protocol_version begin ### */
#define SERVER_PROTOCOL_VERSION 669 #define SERVER_PROTOCOL_VERSION 670
/* ### protocol_version end ### */ /* ### protocol_version end ### */

View File

@ -1349,31 +1349,40 @@ DECL_HANDLER(init_process_done)
{ {
struct process_dll *dll; struct process_dll *dll;
struct process *process = current->process; struct process *process = current->process;
struct memory_view *view;
client_ptr_t base;
const pe_image_info_t *image_info;
if (is_process_init_done(process)) if (is_process_init_done(process))
{ {
set_error( STATUS_INVALID_PARAMETER ); set_error( STATUS_INVALID_PARAMETER );
return; return;
} }
if (!(dll = find_process_dll( process, req->module ))) if (!(view = get_exe_view( process )))
{ {
set_error( STATUS_DLL_NOT_FOUND ); set_error( STATUS_DLL_NOT_FOUND );
return; return;
} }
if (!(image_info = get_view_image_info( view, &base ))) return;
/* main exe is the first in the dll list */ if ((dll = find_process_dll( process, base )))
list_remove( &dll->entry ); {
list_add_head( &process->dlls, &dll->entry ); /* main exe is the first in the dll list */
list_remove( &dll->entry );
list_add_head( &process->dlls, &dll->entry );
}
process->start_time = current_time; process->start_time = current_time;
current->entry_point = req->entry; current->entry_point = image_info->entry_point;
init_process_tracing( process ); init_process_tracing( process );
generate_startup_debug_events( process ); generate_startup_debug_events( process );
set_process_startup_state( process, STARTUP_DONE ); set_process_startup_state( process, STARTUP_DONE );
if (req->gui) process->idle_event = create_event( NULL, NULL, 0, 1, 0, NULL ); if (image_info->subsystem != IMAGE_SUBSYSTEM_WINDOWS_CUI)
process->idle_event = create_event( NULL, NULL, 0, 1, 0, NULL );
if (process->debug_obj) set_process_debug_flag( process, 1 ); if (process->debug_obj) set_process_debug_flag( process, 1 );
reply->entry = image_info->entry_point;
reply->suspend = (current->suspend || process->suspend); reply->suspend = (current->suspend || process->suspend);
} }

View File

@ -882,10 +882,8 @@ typedef struct
/* Signal the end of the process initialization */ /* Signal the end of the process initialization */
@REQ(init_process_done) @REQ(init_process_done)
int gui; /* is it a GUI process? */
mod_handle_t module; /* main module base address */
client_ptr_t entry; /* process entry point */
@REPLY @REPLY
client_ptr_t entry; /* process entry point */
int suspend; /* is process suspended? */ int suspend; /* is process suspended? */
@END @END

View File

@ -748,12 +748,10 @@ C_ASSERT( sizeof(struct new_thread_reply) == 16 );
C_ASSERT( sizeof(struct get_startup_info_request) == 16 ); C_ASSERT( sizeof(struct get_startup_info_request) == 16 );
C_ASSERT( FIELD_OFFSET(struct get_startup_info_reply, info_size) == 8 ); C_ASSERT( FIELD_OFFSET(struct get_startup_info_reply, info_size) == 8 );
C_ASSERT( sizeof(struct get_startup_info_reply) == 16 ); C_ASSERT( sizeof(struct get_startup_info_reply) == 16 );
C_ASSERT( FIELD_OFFSET(struct init_process_done_request, gui) == 12 ); C_ASSERT( sizeof(struct init_process_done_request) == 16 );
C_ASSERT( FIELD_OFFSET(struct init_process_done_request, module) == 16 ); C_ASSERT( FIELD_OFFSET(struct init_process_done_reply, entry) == 8 );
C_ASSERT( FIELD_OFFSET(struct init_process_done_request, entry) == 24 ); C_ASSERT( FIELD_OFFSET(struct init_process_done_reply, suspend) == 16 );
C_ASSERT( sizeof(struct init_process_done_request) == 32 ); C_ASSERT( sizeof(struct init_process_done_reply) == 24 );
C_ASSERT( FIELD_OFFSET(struct init_process_done_reply, suspend) == 8 );
C_ASSERT( sizeof(struct init_process_done_reply) == 16 );
C_ASSERT( FIELD_OFFSET(struct init_first_thread_request, unix_pid) == 12 ); C_ASSERT( FIELD_OFFSET(struct init_first_thread_request, unix_pid) == 12 );
C_ASSERT( FIELD_OFFSET(struct init_first_thread_request, unix_tid) == 16 ); C_ASSERT( FIELD_OFFSET(struct init_first_thread_request, unix_tid) == 16 );
C_ASSERT( FIELD_OFFSET(struct init_first_thread_request, debug_level) == 20 ); C_ASSERT( FIELD_OFFSET(struct init_first_thread_request, debug_level) == 20 );

View File

@ -1420,14 +1420,12 @@ static void dump_get_startup_info_reply( const struct get_startup_info_reply *re
static void dump_init_process_done_request( const struct init_process_done_request *req ) static void dump_init_process_done_request( const struct init_process_done_request *req )
{ {
fprintf( stderr, " gui=%d", req->gui );
dump_uint64( ", module=", &req->module );
dump_uint64( ", entry=", &req->entry );
} }
static void dump_init_process_done_reply( const struct init_process_done_reply *req ) static void dump_init_process_done_reply( const struct init_process_done_reply *req )
{ {
fprintf( stderr, " suspend=%d", req->suspend ); dump_uint64( " entry=", &req->entry );
fprintf( stderr, ", suspend=%d", req->suspend );
} }
static void dump_init_first_thread_request( const struct init_first_thread_request *req ) static void dump_init_first_thread_request( const struct init_first_thread_request *req )