This is called if no preloader is available and the loader doesn't find ntdll.so right away.
The codepath used normally has seen a fair bit of restructurings in the past few months, while this codepath seems to have been left as things were before.
Signed-off-by: Martin Storsjo martin@martin.st --- libs/wine/loader.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-)
diff --git a/libs/wine/loader.c b/libs/wine/loader.c index c3b59d9022..e54cbd4cc1 100644 --- a/libs/wine/loader.c +++ b/libs/wine/loader.c @@ -857,6 +857,14 @@ static int apple_alloc_thread_stack( void *base, size_t size, void *arg ) } #endif
+static void *init_func_wrap( void *arg ) +{ + void (*init_func)(int, char **, char **) = + (void(*)(int, char **, char **)) arg; + init_func( __wine_main_argc, __wine_main_argv, __wine_main_environ ); + return NULL; +} + /*********************************************************************** * apple_create_wine_thread * @@ -888,7 +896,7 @@ static void apple_create_wine_thread( void *init_func ) #endif
if (!pthread_attr_setdetachstate( &attr, PTHREAD_CREATE_JOINABLE ) && - !pthread_create( &thread, &attr, init_func, NULL )) + !pthread_create( &thread, &attr, init_func_wrap, init_func )) success = 1;
pthread_attr_destroy( &attr ); @@ -1090,7 +1098,7 @@ void wine_init( int argc, char *argv[], char *error, int error_size ) struct dll_path_context context; char *path; void *ntdll = NULL; - void (*init_func)(void); + void (*init_func)(int, char **, char **);
/* force a few limits that are set too low on some platforms */ #ifdef RLIMIT_NOFILE @@ -1105,9 +1113,8 @@ void wine_init( int argc, char *argv[], char *error, int error_size ) __wine_main_argc = argc; __wine_main_argv = argv; __wine_main_environ = __wine_get_main_environment(); - mmap_init();
- for (path = first_dll_path( "ntdll.dll", 0, &context ); path; path = next_dll_path( &context )) + for (path = first_dll_path( "ntdll", 0, &context ); path; path = next_dll_path( &context )) { if ((ntdll = dlopen( path, RTLD_NOW ))) { @@ -1118,7 +1125,7 @@ void wine_init( int argc, char *argv[], char *error, int error_size ) } free_dll_path( &context );
- if (!ntdll || !(init_func = dlsym( ntdll, "__wine_process_init" ))) + if (!ntdll || !(init_func = dlsym( ntdll, "__wine_main" ))) { if (error && error_size) { @@ -1136,6 +1143,6 @@ void wine_init( int argc, char *argv[], char *error, int error_size ) #ifdef __APPLE__ apple_main_thread( init_func ); #else - init_func(); + init_func( __wine_main_argc, __wine_main_argv, __wine_main_environ ); #endif }
Martin Storsjo martin@martin.st writes:
This is called if no preloader is available and the loader doesn't find ntdll.so right away.
The codepath used normally has seen a fair bit of restructurings in the past few months, while this codepath seems to have been left as things were before.
If the loader doesn't find ntdll.so, then it's assumed that it's an older Wine version, that's why it's using the old-style init.
If there's an ntdll.so and libwine finds it but not the loader, that's a bug that should be fixed.
On Wed, 19 Aug 2020, Alexandre Julliard wrote:
Martin Storsjo martin@martin.st writes:
This is called if no preloader is available and the loader doesn't find ntdll.so right away.
The codepath used normally has seen a fair bit of restructurings in the past few months, while this codepath seems to have been left as things were before.
If the loader doesn't find ntdll.so, then it's assumed that it's an older Wine version, that's why it's using the old-style init.
Ah, thanks, that explains it.
If there's an ntdll.so and libwine finds it but not the loader, that's a bug that should be fixed.
Ok, will do.
// Martin