Revert "ntdll: Get rid of the server_init_process_done() Unix library callback."

This partially reverts commit 1581fb619b.
Steam wants Eip to be valid even before LdrInitializeThunk.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alexandre Julliard 2020-08-28 21:05:37 +02:00
parent 7bae2aaf95
commit 2b9a0550bc
5 changed files with 10 additions and 9 deletions

View File

@ -3426,16 +3426,12 @@ void WINAPI LdrInitializeThunk( CONTEXT *context, ULONG_PTR unknown2, ULONG_PTR
#ifdef __i386__
entry = (void **)&context->Eax;
if (!context->Eip) context->Eip = (DWORD_PTR)kernel32_start_process;
#elif defined(__x86_64__)
entry = (void **)&context->Rcx;
if (!context->Rip) context->Rip = (DWORD_PTR)kernel32_start_process;
#elif defined(__arm__)
entry = (void **)&context->R0;
if (!context->Pc) context->Pc = (DWORD_PTR)kernel32_start_process;
#elif defined(__aarch64__)
entry = (void **)&context->u.s.X0;
if (!context->Pc) context->Pc = (DWORD_PTR)kernel32_start_process;
#endif
if (process_detaching) NtTerminateThread( GetCurrentThread(), 0 );
@ -4053,6 +4049,8 @@ static void process_init(void)
teb->Tib.StackBase = stack.StackBase;
teb->Tib.StackLimit = stack.StackLimit;
teb->DeallocationStack = stack.DeallocationStack;
unix_funcs->server_init_process_done( kernel32_start_process );
}
/***********************************************************************

View File

@ -1368,6 +1368,7 @@ static struct unix_funcs unix_funcs =
get_locales,
virtual_release_address_space,
exec_process,
server_init_process_done,
set_show_dot_files,
load_so_dll,
load_builtin_dll,
@ -1400,7 +1401,6 @@ static void start_main_thread(void)
init_files();
NtCreateKeyedEvent( &keyed_event, GENERIC_READ | GENERIC_WRITE, NULL, 0 );
p__wine_set_unix_funcs( NTDLL_UNIXLIB_VERSION, &unix_funcs );
server_init_process_done();
}

View File

@ -1453,7 +1453,7 @@ void server_init_process(void)
/***********************************************************************
* server_init_process_done
*/
void server_init_process_done(void)
void CDECL server_init_process_done( void *relay )
{
PEB *peb = NtCurrentTeb()->Peb;
IMAGE_NT_HEADERS *nt = get_exe_nt_header();
@ -1486,7 +1486,7 @@ void server_init_process_done(void)
SERVER_END_REQ;
assert( !status );
signal_start_thread( entry, peb, suspend, NULL, pLdrInitializeThunk, NtCurrentTeb() );
signal_start_thread( entry, peb, suspend, relay, pLdrInitializeThunk, NtCurrentTeb() );
}

View File

@ -117,6 +117,7 @@ extern USHORT * CDECL get_unix_codepage_data(void) DECLSPEC_HIDDEN;
extern void CDECL get_locales( WCHAR *sys, WCHAR *user ) DECLSPEC_HIDDEN;
extern void CDECL virtual_release_address_space(void) DECLSPEC_HIDDEN;
extern void CDECL server_init_process_done( void *relay ) DECLSPEC_HIDDEN;
extern NTSTATUS CDECL exec_process( UNICODE_STRING *path, UNICODE_STRING *cmdline, NTSTATUS status ) DECLSPEC_HIDDEN;
extern NTSTATUS CDECL unwind_builtin_dll( ULONG type, struct _DISPATCHER_CONTEXT *dispatch,
CONTEXT *context ) DECLSPEC_HIDDEN;
@ -166,7 +167,6 @@ extern unsigned int server_queue_process_apc( HANDLE process, const apc_call_t *
extern int server_get_unix_fd( HANDLE handle, unsigned int wanted_access, int *unix_fd,
int *needs_close, enum server_fd_type *type, unsigned int *options ) DECLSPEC_HIDDEN;
extern void server_init_process(void) DECLSPEC_HIDDEN;
extern void server_init_process_done(void) DECLSPEC_HIDDEN;
extern size_t server_init_thread( void *entry_point, BOOL *suspend ) DECLSPEC_HIDDEN;
extern int server_pipe( int fd[2] ) DECLSPEC_HIDDEN;

View File

@ -27,7 +27,7 @@
struct _DISPATCHER_CONTEXT;
/* increment this when you change the function table */
#define NTDLL_UNIXLIB_VERSION 100
#define NTDLL_UNIXLIB_VERSION 101
struct unix_funcs
{
@ -84,6 +84,9 @@ struct unix_funcs
/* thread/process functions */
NTSTATUS (CDECL *exec_process)( UNICODE_STRING *path, UNICODE_STRING *cmdline, NTSTATUS status );
/* server functions */
void (CDECL *server_init_process_done)( void *relay );
/* file functions */
void (CDECL *set_show_dot_files)( BOOL enable );