Alexandre Julliard : ntdll: Get rid of the exec_process() Unix library callback.
Alexandre Julliard
julliard at winehq.org
Wed Sep 2 15:24:32 CDT 2020
Module: wine
Branch: master
Commit: 4c45348f7808c3a1ea635e196402951f0008ab90
URL: https://source.winehq.org/git/wine.git/?a=commit;h=4c45348f7808c3a1ea635e196402951f0008ab90
Author: Alexandre Julliard <julliard at winehq.org>
Date: Wed Sep 2 15:06:05 2020 +0200
ntdll: Get rid of the exec_process() Unix library callback.
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/ntdll/loader.c | 16 +++++++---------
dlls/ntdll/unix/loader.c | 7 ++++---
dlls/ntdll/unix/process.c | 36 ++++++++++++++++++++++++++++--------
dlls/ntdll/unix/unix_private.h | 2 +-
dlls/ntdll/unixlib.h | 5 +----
5 files changed, 41 insertions(+), 25 deletions(-)
diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c
index e87f092784..ccaae0a5a2 100644
--- a/dlls/ntdll/loader.c
+++ b/dlls/ntdll/loader.c
@@ -3957,7 +3957,7 @@ static void restart_winevdm( RTL_USER_PROCESS_PARAMETERS *params )
/***********************************************************************
* process_init
*/
-static void process_init(void)
+static NTSTATUS process_init(void)
{
static const WCHAR ntdllW[] = {'\\','?','?','\\','C',':','\\','w','i','n','d','o','w','s','\\',
's','y','s','t','e','m','3','2','\\',
@@ -4058,20 +4058,17 @@ static void process_init(void)
restart_winevdm( params );
status = STATUS_INVALID_IMAGE_WIN_16;
}
- status = unix_funcs->exec_process( status );
- break;
+ return status;
}
case STATUS_INVALID_IMAGE_WIN_16:
case STATUS_INVALID_IMAGE_NE_FORMAT:
case STATUS_INVALID_IMAGE_PROTECT:
restart_winevdm( params );
- status = unix_funcs->exec_process( status );
- break;
+ return status;
case STATUS_CONFLICTING_ADDRESSES:
case STATUS_NO_MEMORY:
case STATUS_INVALID_IMAGE_FORMAT:
- status = unix_funcs->exec_process( status );
- break;
+ return status;
case STATUS_INVALID_IMAGE_WIN_64:
ERR( "%s 64-bit application not supported in 32-bit prefix\n",
debugstr_us(¶ms->ImagePathName) );
@@ -4109,14 +4106,15 @@ static void process_init(void)
teb->Tib.StackBase = stack.StackBase;
teb->Tib.StackLimit = stack.StackLimit;
teb->DeallocationStack = stack.DeallocationStack;
+ return STATUS_SUCCESS;
}
/***********************************************************************
* __wine_set_unix_funcs
*/
-void CDECL __wine_set_unix_funcs( int version, const struct unix_funcs *funcs )
+NTSTATUS CDECL __wine_set_unix_funcs( int version, const struct unix_funcs *funcs )
{
assert( version == NTDLL_UNIXLIB_VERSION );
unix_funcs = funcs;
- process_init();
+ return process_init();
}
diff --git a/dlls/ntdll/unix/loader.c b/dlls/ntdll/unix/loader.c
index 6f25f4ae87..73d4ceee14 100644
--- a/dlls/ntdll/unix/loader.c
+++ b/dlls/ntdll/unix/loader.c
@@ -99,7 +99,7 @@ NTSTATUS (WINAPI *pKiUserExceptionDispatcher)(EXCEPTION_RECORD*,CONTEXT*) = NULL
void (WINAPI *pLdrInitializeThunk)(CONTEXT*,void**,ULONG_PTR,ULONG_PTR) = NULL;
void (WINAPI *pRtlUserThreadStart)( PRTL_THREAD_START_ROUTINE entry, void *arg ) = NULL;
-static void (CDECL *p__wine_set_unix_funcs)( int version, const struct unix_funcs *funcs );
+static NTSTATUS (CDECL *p__wine_set_unix_funcs)( int version, const struct unix_funcs *funcs );
#ifdef __GNUC__
static void fatal_error( const char *err, ... ) __attribute__((noreturn, format(printf,1,2)));
@@ -1367,7 +1367,6 @@ static struct unix_funcs unix_funcs =
get_unix_codepage_data,
get_locales,
virtual_release_address_space,
- exec_process,
set_show_dot_files,
load_so_dll,
load_builtin_dll,
@@ -1387,6 +1386,7 @@ static struct unix_funcs unix_funcs =
static void start_main_thread(void)
{
BOOL suspend;
+ NTSTATUS status;
TEB *teb = virtual_alloc_first_teb();
signal_init_threading();
@@ -1399,7 +1399,8 @@ static void start_main_thread(void)
init_cpu_info();
init_files();
NtCreateKeyedEvent( &keyed_event, GENERIC_READ | GENERIC_WRITE, NULL, 0 );
- p__wine_set_unix_funcs( NTDLL_UNIXLIB_VERSION, &unix_funcs );
+ status = p__wine_set_unix_funcs( NTDLL_UNIXLIB_VERSION, &unix_funcs );
+ if (status) exec_process( status );
server_init_process_done();
}
diff --git a/dlls/ntdll/unix/process.c b/dlls/ntdll/unix/process.c
index e16410d0ec..64380aba03 100644
--- a/dlls/ntdll/unix/process.c
+++ b/dlls/ntdll/unix/process.c
@@ -613,7 +613,7 @@ static NTSTATUS spawn_process( const RTL_USER_PROCESS_PARAMETERS *params, int so
/***********************************************************************
* exec_process
*/
-NTSTATUS CDECL exec_process( NTSTATUS status )
+void DECLSPEC_NORETURN exec_process( NTSTATUS status )
{
RTL_USER_PROCESS_PARAMETERS *params = NtCurrentTeb()->Peb->ProcessParameters;
pe_image_info_t pe_info;
@@ -621,7 +621,7 @@ NTSTATUS CDECL exec_process( NTSTATUS status )
char **argv;
HANDLE handle;
- if (startup_info_size) return status; /* started from another Win32 process */
+ if (startup_info_size) goto done; /* started from another Win32 process */
switch (status)
{
@@ -631,10 +631,10 @@ NTSTATUS CDECL exec_process( NTSTATUS status )
case STATUS_INVALID_IMAGE_NOT_MZ:
{
UNICODE_STRING image;
- if (getenv( "WINEPRELOADRESERVE" )) return status;
+ if (getenv( "WINEPRELOADRESERVE" )) goto done;
image.Buffer = get_nt_pathname( ¶ms->ImagePathName );
image.Length = wcslen( image.Buffer ) * sizeof(WCHAR);
- if ((status = get_pe_file_info( &image, &handle, &pe_info ))) return status;
+ if ((status = get_pe_file_info( &image, &handle, &pe_info ))) goto done;
break;
}
case STATUS_INVALID_IMAGE_WIN_16:
@@ -645,12 +645,16 @@ NTSTATUS CDECL exec_process( NTSTATUS status )
pe_info.cpu = CPU_x86;
break;
default:
- return status;
+ goto done;
}
unixdir = get_unix_curdir( params );
- if (socketpair( PF_UNIX, SOCK_STREAM, 0, socketfd ) == -1) return STATUS_TOO_MANY_OPENED_FILES;
+ if (socketpair( PF_UNIX, SOCK_STREAM, 0, socketfd ) == -1)
+ {
+ status = STATUS_TOO_MANY_OPENED_FILES;
+ goto done;
+ }
#ifdef SO_PASSCRED
else
{
@@ -671,7 +675,11 @@ NTSTATUS CDECL exec_process( NTSTATUS status )
if (!status)
{
- if (!(argv = build_argv( ¶ms->CommandLine, 2 ))) return STATUS_NO_MEMORY;
+ if (!(argv = build_argv( ¶ms->CommandLine, 2 )))
+ {
+ status = STATUS_NO_MEMORY;
+ goto done;
+ }
fchdir( unixdir );
do
{
@@ -685,7 +693,19 @@ NTSTATUS CDECL exec_process( NTSTATUS status )
free( argv );
}
close( socketfd[0] );
- return status;
+
+done:
+ switch (status)
+ {
+ case STATUS_INVALID_IMAGE_FORMAT:
+ case STATUS_INVALID_IMAGE_NOT_MZ:
+ ERR( "%s not supported on this system\n", debugstr_us(¶ms->ImagePathName) );
+ break;
+ default:
+ ERR( "failed to load %s error %x\n", debugstr_us(¶ms->ImagePathName), status );
+ break;
+ }
+ for (;;) NtTerminateProcess( GetCurrentProcess(), status );
}
diff --git a/dlls/ntdll/unix/unix_private.h b/dlls/ntdll/unix/unix_private.h
index 54bd53c482..0a21a059b4 100644
--- a/dlls/ntdll/unix/unix_private.h
+++ b/dlls/ntdll/unix/unix_private.h
@@ -117,7 +117,6 @@ 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 NTSTATUS CDECL exec_process( NTSTATUS status ) DECLSPEC_HIDDEN;
extern NTSTATUS CDECL unwind_builtin_dll( ULONG type, struct _DISPATCHER_CONTEXT *dispatch,
CONTEXT *context ) DECLSPEC_HIDDEN;
@@ -220,6 +219,7 @@ extern void signal_init_process(void) DECLSPEC_HIDDEN;
extern void DECLSPEC_NORETURN signal_start_thread( PRTL_THREAD_START_ROUTINE entry, void *arg,
BOOL suspend, void *thunk, TEB *teb ) DECLSPEC_HIDDEN;
extern void DECLSPEC_NORETURN signal_exit_thread( int status, void (*func)(int) ) DECLSPEC_HIDDEN;
+extern void DECLSPEC_NORETURN exec_process( NTSTATUS status ) DECLSPEC_HIDDEN;
extern void __wine_syscall_dispatcher(void) DECLSPEC_HIDDEN;
extern void fill_vm_counters( VM_COUNTERS_EX *pvmi, int unix_pid ) DECLSPEC_HIDDEN;
diff --git a/dlls/ntdll/unixlib.h b/dlls/ntdll/unixlib.h
index d4aa010ee0..d6cd4ed403 100644
--- a/dlls/ntdll/unixlib.h
+++ b/dlls/ntdll/unixlib.h
@@ -27,7 +27,7 @@
struct _DISPATCHER_CONTEXT;
/* increment this when you change the function table */
-#define NTDLL_UNIXLIB_VERSION 103
+#define NTDLL_UNIXLIB_VERSION 104
struct unix_funcs
{
@@ -81,9 +81,6 @@ struct unix_funcs
/* virtual memory functions */
void (CDECL *virtual_release_address_space)(void);
- /* thread/process functions */
- NTSTATUS (CDECL *exec_process)( NTSTATUS status );
-
/* file functions */
void (CDECL *set_show_dot_files)( BOOL enable );
More information about the wine-cvs
mailing list