Commit 2d91f7de authored by Alexandre Julliard's avatar Alexandre Julliard

ntdll: Load libwine dynamically.

parent 4e80f2ea
......@@ -3,7 +3,7 @@ MODULE = ntdll.dll
IMPORTLIB = ntdll
IMPORTS = winecrt0
EXTRAINCL = $(UNWIND_CFLAGS)
EXTRALIBS = -lwine $(IOKIT_LIBS) $(COREFOUNDATION_LIBS) $(CORESERVICES_LIBS) $(RT_LIBS) $(PTHREAD_LIBS) $(UNWIND_LIBS) $(I386_LIBS)
EXTRALIBS = $(IOKIT_LIBS) $(COREFOUNDATION_LIBS) $(CORESERVICES_LIBS) $(RT_LIBS) $(PTHREAD_LIBS) $(UNWIND_LIBS) $(I386_LIBS)
EXTRADLLFLAGS = -mno-cygwin -nodefaultlibs -Wl,--image-base,0x7bc00000
C_SRCS = \
......
......@@ -60,18 +60,13 @@
WINE_DEFAULT_DEBUG_CHANNEL(environ);
extern int __wine_main_argc;
extern char **__wine_main_argv;
extern char **__wine_main_environ;
extern WCHAR **__wine_main_wargv;
USHORT *uctable = NULL, *lctable = NULL;
SIZE_T startup_info_size = 0;
int main_argc = 0;
char **main_argv = NULL;
char **main_envp = NULL;
static WCHAR **main_wargv;
WCHAR **main_wargv = NULL;
static LCID user_lcid, system_lcid;
static LANGID user_ui_language, system_ui_language;
......@@ -966,10 +961,10 @@ void init_environment( int argc, char *argv[], char *envp[] )
uctable = case_table + 2;
lctable = case_table + case_table[1] + 2;
}
__wine_main_argc = main_argc = argc;
__wine_main_argv = main_argv = argv;
__wine_main_wargv = main_wargv = build_wargv( argv );
__wine_main_environ = main_envp = envp;
main_argc = argc;
main_argv = argv;
main_wargv = build_wargv( argv );
main_envp = envp;
}
......
......@@ -87,7 +87,6 @@
#include "winternl.h"
#include "unix_private.h"
#include "wine/list.h"
#include "wine/library.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(module);
......@@ -815,6 +814,48 @@ static void load_builtin_callback( void *module, const char *filename )
callback_module = module;
}
/***********************************************************************
* load_libwine
*/
static void load_libwine(void)
{
#ifdef __APPLE__
#define LIBWINE "libwine.1.dylib"
#elif defined(__ANDROID__)
#define LIBWINE "libwine.so"
#else
#define LIBWINE "libwine.so.1"
#endif
typedef void (*load_dll_callback_t)( void *, const char * );
static void (*p_wine_dll_set_callback)( load_dll_callback_t load );
static int *p___wine_main_argc;
static char ***p___wine_main_argv;
static char ***p___wine_main_environ;
static WCHAR ***p___wine_main_wargv;
char *path;
void *handle;
if (build_dir) path = build_path( build_dir, "libs/wine/" LIBWINE );
else path = build_path( dll_dir, "../" LIBWINE );
if (!(handle = dlopen( path, RTLD_NOW )) && !(handle = dlopen( LIBWINE, RTLD_NOW ))) return;
p_wine_dll_set_callback = dlsym( handle, "wine_dll_set_callback" );
p___wine_main_argc = dlsym( handle, "__wine_main_argc" );
p___wine_main_argv = dlsym( handle, "__wine_main_argv" );
p___wine_main_wargv = dlsym( handle, "__wine_main_wargv" );
p___wine_main_environ = dlsym( handle, "__wine_main_environ" );
if (p_wine_dll_set_callback) p_wine_dll_set_callback( load_builtin_callback );
if (p___wine_main_argc) *p___wine_main_argc = main_argc;
if (p___wine_main_argv) *p___wine_main_argv = main_argv;
if (p___wine_main_wargv) *p___wine_main_wargv = main_wargv;
if (p___wine_main_environ) *p___wine_main_environ = main_envp;
}
/***********************************************************************
* dlopen_dll
*/
......@@ -1610,7 +1651,7 @@ void __wine_main( int argc, char *argv[], char *envp[] )
load_ntdll();
init_environment( argc, argv, envp );
wine_dll_set_callback( load_builtin_callback );
load_libwine();
#ifdef __APPLE__
apple_main_thread();
......
......@@ -129,6 +129,7 @@ extern SIZE_T startup_info_size DECLSPEC_HIDDEN;
extern int main_argc DECLSPEC_HIDDEN;
extern char **main_argv DECLSPEC_HIDDEN;
extern char **main_envp DECLSPEC_HIDDEN;
extern WCHAR **main_wargv DECLSPEC_HIDDEN;
extern unsigned int server_cpus DECLSPEC_HIDDEN;
extern BOOL is_wow64 DECLSPEC_HIDDEN;
extern HANDLE keyed_event DECLSPEC_HIDDEN;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment