Signed-off-by: Zebediah Figura zfigura@codeweavers.com ---
This series makes it possible to use dynamic libraries from an external path without needing to first copy them into a prefix. As an example, on Debian I am able to install the "libz-minw-w64-dev" package, and then use the following configure command to compile Wine:
configure --enable-win64 ZLIB_PE_CFLAGS="$(x86_64-w64-mingw32-pkg-config --cflags zlib)" ZLIB_PE_LIBS="$(x86_64-w64-mingw32-pkg-config --libs zlib)" SYSTEMDLLDIR=/usr/x86_64-w64-mingw32/lib/
whereafter libraries are linked directly to system zlib1.dll, and no further configuration is needed
I would like to submit patches in the future to allow the use of pkg-config for automatically detecting compile flags and libraries. I would also like to find some way to obviate manual specification of DLL bindirs.
v2: Rebased on top of current git; no other change.
dlls/kernel32/kernel_main.c | 2 +- dlls/krnl386.exe16/ne_module.c | 2 +- dlls/ntdll/loader.c | 10 +++++----- dlls/ntdll/signal_arm64.c | 2 +- dlls/ntdll/signal_x86_64.c | 2 +- include/winternl.h | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/dlls/kernel32/kernel_main.c b/dlls/kernel32/kernel_main.c index 4467af739e0..317ee782d7a 100644 --- a/dlls/kernel32/kernel_main.c +++ b/dlls/kernel32/kernel_main.c @@ -136,7 +136,7 @@ static BOOL process_attach( HMODULE module ) { LDR_DATA_TABLE_ENTRY *ldr;
- if (LdrFindEntryForAddress( GetModuleHandleW( 0 ), &ldr ) || !(ldr->Flags & LDR_WINE_INTERNAL)) + if (LdrFindEntryForAddress( GetModuleHandleW( 0 ), &ldr ) || !(ldr->Flags & LDR_WINE_BUILTIN)) LoadLibraryA( "krnl386.exe16" ); } #endif diff --git a/dlls/krnl386.exe16/ne_module.c b/dlls/krnl386.exe16/ne_module.c index c26fe778253..108e88e5546 100644 --- a/dlls/krnl386.exe16/ne_module.c +++ b/dlls/krnl386.exe16/ne_module.c @@ -982,7 +982,7 @@ static HINSTANCE16 MODULE_LoadModule16( LPCSTR libname, BOOL implicit, BOOL lib_ return ERROR_FILE_NOT_FOUND; } /* check if module was loaded native */ - if (LdrFindEntryForAddress( main_owner, &ldr ) || !(ldr->Flags & LDR_WINE_INTERNAL)) + if (LdrFindEntryForAddress( main_owner, &ldr ) || !(ldr->Flags & LDR_WINE_BUILTIN)) { FreeLibrary( mod32 ); descr = NULL; diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c index 255d5afef79..17c8d7f7485 100644 --- a/dlls/ntdll/loader.c +++ b/dlls/ntdll/loader.c @@ -1081,7 +1081,7 @@ static BOOL is_dll_native_subsystem( LDR_DATA_TABLE_ENTRY *mod, const IMAGE_NT_H
if (nt->OptionalHeader.Subsystem != IMAGE_SUBSYSTEM_NATIVE) return FALSE; if (nt->OptionalHeader.SectionAlignment < page_size) return TRUE; - if (mod->Flags & LDR_WINE_INTERNAL) return TRUE; + if (mod->Flags & LDR_WINE_BUILTIN) return TRUE;
if ((imports = RtlImageDirectoryEntryToData( mod->DllBase, TRUE, IMAGE_DIRECTORY_ENTRY_IMPORT, &size ))) @@ -1310,7 +1310,7 @@ static WINE_MODREF *alloc_module( HMODULE hModule, const UNICODE_STRING *nt_name
wm->ldr.DllBase = hModule; wm->ldr.SizeOfImage = nt->OptionalHeader.SizeOfImage; - wm->ldr.Flags = LDR_DONT_RESOLVE_REFS | (builtin ? LDR_WINE_INTERNAL : 0); + wm->ldr.Flags = LDR_DONT_RESOLVE_REFS | (builtin ? LDR_WINE_BUILTIN : 0); wm->ldr.TlsIndex = -1; wm->ldr.LoadCount = 1; wm->CheckSum = nt->OptionalHeader.CheckSum; @@ -1454,7 +1454,7 @@ static NTSTATUS MODULE_InitDLL( WINE_MODREF *wm, UINT reason, LPVOID lpReserved
if (wm->ldr.Flags & LDR_DONT_RESOLVE_REFS) return STATUS_SUCCESS; if (wm->ldr.TlsIndex != -1) call_tls_callbacks( wm->ldr.DllBase, reason ); - if (wm->ldr.Flags & LDR_WINE_INTERNAL && reason == DLL_PROCESS_ATTACH) + if (wm->ldr.Flags & LDR_WINE_BUILTIN && reason == DLL_PROCESS_ATTACH) unix_funcs->init_builtin_dll( wm->ldr.DllBase ); if (!entry) return STATUS_SUCCESS;
@@ -3643,7 +3643,7 @@ static void free_modref( WINE_MODREF *wm ) if (!TRACE_ON(module)) TRACE_(loaddll)("Unloaded module %s : %s\n", debugstr_w(wm->ldr.FullDllName.Buffer), - (wm->ldr.Flags & LDR_WINE_INTERNAL) ? "builtin" : "native" ); + (wm->ldr.Flags & LDR_WINE_BUILTIN) ? "builtin" : "native" );
free_tls_slot( &wm->ldr ); RtlReleaseActivationContext( wm->ldr.ActivationContext ); @@ -4079,7 +4079,7 @@ void WINAPI LdrInitializeThunk( CONTEXT *context, ULONG_PTR unknown2, ULONG_PTR } release_address_space(); if (wm->ldr.TlsIndex != -1) call_tls_callbacks( wm->ldr.DllBase, DLL_PROCESS_ATTACH ); - if (wm->ldr.Flags & LDR_WINE_INTERNAL) unix_funcs->init_builtin_dll( wm->ldr.DllBase ); + if (wm->ldr.Flags & LDR_WINE_BUILTIN) unix_funcs->init_builtin_dll( wm->ldr.DllBase ); if (wm->ldr.ActivationContext) RtlDeactivateActivationContext( 0, cookie ); process_breakpoint(); } diff --git a/dlls/ntdll/signal_arm64.c b/dlls/ntdll/signal_arm64.c index 290639b676b..bfbaeab47c9 100644 --- a/dlls/ntdll/signal_arm64.c +++ b/dlls/ntdll/signal_arm64.c @@ -191,7 +191,7 @@ static NTSTATUS virtual_unwind( ULONG type, DISPATCHER_CONTEXT *dispatch, CONTEX
/* then look for host system exception information */
- if (!module || (module->Flags & LDR_WINE_INTERNAL)) + if (!module || (module->Flags & LDR_WINE_BUILTIN)) { status = unix_funcs->unwind_builtin_dll( type, dispatch, context ); if (status != STATUS_SUCCESS) return status; diff --git a/dlls/ntdll/signal_x86_64.c b/dlls/ntdll/signal_x86_64.c index ef32eba68b7..8515b176e5d 100644 --- a/dlls/ntdll/signal_x86_64.c +++ b/dlls/ntdll/signal_x86_64.c @@ -275,7 +275,7 @@ static NTSTATUS virtual_unwind( ULONG type, DISPATCHER_CONTEXT *dispatch, CONTEX
/* then look for host system exception information */
- if (!module || (module->Flags & LDR_WINE_INTERNAL)) + if (!module || (module->Flags & LDR_WINE_BUILTIN)) { status = unix_funcs->unwind_builtin_dll( type, dispatch, context );
diff --git a/include/winternl.h b/include/winternl.h index eea97f1238b..216a3b3fdaa 100644 --- a/include/winternl.h +++ b/include/winternl.h @@ -3394,7 +3394,7 @@ typedef void (CALLBACK *PLDR_DLL_NOTIFICATION_FUNCTION)(ULONG, LDR_DLL_NOTIFICAT
/* these ones is Wine specific */ #define LDR_DONT_RESOLVE_REFS 0x40000000 -#define LDR_WINE_INTERNAL 0x80000000 +#define LDR_WINE_BUILTIN 0x80000000
/* flag for LdrAddRefDll */ #define LDR_ADDREF_DLL_PIN 0x00000001
Many distributions provide MinGW-compiled system DLLs which are currently bundled with Wine. Unfortunately, while MinGW pkg-config can be used to detect the linking path, there is no standardized runtime path, and many distributions in fact use different paths.
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- To be clear I don't necessarily think this is *clearly* the best option. Obviously it'd be nice to establish some sort of standard along the lines of ld.so's standardized search location, but this may be a length process.
An environment variable configurable at runtime would also be useful, as LD_LIBRARY_PATH often is. I could see arguments for specifying it in addition to, or in lieu of, a path supplied at configure time.
It's also possible that we should allow specifying multiple paths here.
Nevertheless, I believe we should allow some way to load DLLs from an external path, rather than forcing the user to manually copy them into the prefix (or forcing Wine to be built with bundled dependencies.) I readily welcome consensus on any of the above questions, but in lieu thereof, since it is relatively easy to effect incremental improvement here, I propose this solution for now.
configure.ac | 4 ++++ dlls/ntdll/loader.c | 10 ++++++++-- dlls/ntdll/unix/env.c | 1 + dlls/ntdll/unix/loader.c | 5 +++++ dlls/ntdll/unix/unix_private.h | 1 + 5 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/configure.ac b/configure.ac index 57383fb2e31..a00f2ebc11f 100644 --- a/configure.ac +++ b/configure.ac @@ -36,6 +36,8 @@ AC_ARG_ENABLE(maintainer-mode, AS_HELP_STRING([--enable-maintainer-mode],[enable AC_ARG_ENABLE(silent-rules, AS_HELP_STRING([--enable-silent-rules],[use silent build rules (override: "make V=1")])) AC_ARG_ENABLE(werror, AS_HELP_STRING([--enable-werror],[treat compilation warnings as errors]))
+AC_ARG_VAR([SYSTEMDLLDIR], [path containing system dependency shared libraries]) + AC_ARG_WITH(alsa, AS_HELP_STRING([--without-alsa],[do not use the Alsa sound support])) AC_ARG_WITH(capi, AS_HELP_STRING([--without-capi],[do not use CAPI (ISDN support)])) AC_ARG_WITH(coreaudio, AS_HELP_STRING([--without-coreaudio],[do not use the CoreAudio sound support]), @@ -108,6 +110,8 @@ AC_ARG_WITH(wine64, AS_HELP_STRING([--with-wine64=DIR],[use the 64-bit Wine i
AC_CANONICAL_HOST
+AS_VAR_IF([SYSTEMDLLDIR],[],[],[AC_DEFINE_UNQUOTED([SYSTEMDLLDIR],["$SYSTEMDLLDIR"],[Define to the path containing system dependency shared libraries.])]) + dnl **** Check for some programs ****
AC_PROG_MAKE_SET diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c index 17c8d7f7485..c83f7980572 100644 --- a/dlls/ntdll/loader.c +++ b/dlls/ntdll/loader.c @@ -95,6 +95,7 @@ static int free_lib_count; /* recursion depth of LdrUnloadDll calls */ static ULONG path_safe_mode; /* path mode set by RtlSetSearchPathMode */ static ULONG dll_safe_mode = 1; /* dll search mode */ static UNICODE_STRING dll_directory; /* extra path for LdrSetDllDirectory */ +static UNICODE_STRING system_dll_path; /* path to search for system dependency dlls */ static DWORD default_search_flags; /* default flags set by LdrSetDefaultDllDirectories */ static WCHAR *default_load_path; /* default dll search path */
@@ -2981,12 +2982,15 @@ static NTSTATUS load_dll( const WCHAR *load_path, const WCHAR *libname, const WC struct file_id id; HANDLE mapping = 0; SECTION_IMAGE_INFORMATION image_info; - NTSTATUS nts; + NTSTATUS nts = STATUS_DLL_NOT_FOUND; ULONG64 prev;
TRACE( "looking for %s in %s\n", debugstr_w(libname), debugstr_w(load_path) );
- nts = find_dll_file( load_path, libname, default_ext, &nt_name, pwm, &mapping, &image_info, &id ); + if (system_dll_path.Buffer) + nts = find_dll_file( system_dll_path.Buffer, libname, default_ext, &nt_name, pwm, &mapping, &image_info, &id ); + if (nts) + nts = find_dll_file( load_path, libname, default_ext, &nt_name, pwm, &mapping, &image_info, &id );
if (*pwm) /* found already loaded module */ { @@ -3997,6 +4001,8 @@ void WINAPI LdrInitializeThunk( CONTEXT *context, ULONG_PTR unknown2, ULONG_PTR load_global_options(); version_init();
+ get_env_var( L"WINESYSTEMDLLDIR", 0, &system_dll_path ); + wm = build_main_module(); wm->ldr.LoadCount = -1;
diff --git a/dlls/ntdll/unix/env.c b/dlls/ntdll/unix/env.c index 43a34bf831b..1647603efa5 100644 --- a/dlls/ntdll/unix/env.c +++ b/dlls/ntdll/unix/env.c @@ -1296,6 +1296,7 @@ static void add_dynamic_environment( WCHAR **env, SIZE_T *pos, SIZE_T *size ) add_path_var( env, pos, size, "WINEHOMEDIR", home_dir ); add_path_var( env, pos, size, "WINEBUILDDIR", build_dir ); add_path_var( env, pos, size, "WINECONFIGDIR", config_dir ); + add_path_var( env, pos, size, "WINESYSTEMDLLDIR", system_dll_path ); for (i = 0; dll_paths[i]; i++) { sprintf( str, "WINEDLLDIR%u", i ); diff --git a/dlls/ntdll/unix/loader.c b/dlls/ntdll/unix/loader.c index 0ca4b1ea6dd..5dfe7191dbe 100644 --- a/dlls/ntdll/unix/loader.c +++ b/dlls/ntdll/unix/loader.c @@ -388,6 +388,7 @@ const char *data_dir = NULL; const char *build_dir = NULL; const char *config_dir = NULL; const char **dll_paths = NULL; +const char *system_dll_path = NULL; const char *user_name = NULL; SECTION_IMAGE_INFORMATION main_image_info = { NULL }; static HMODULE ntdll_module; @@ -619,6 +620,10 @@ static void init_paths( char *argv[] ) data_dir = build_path( bin_dir, BIN_TO_DATADIR ); }
+#ifdef SYSTEMDLLDIR + system_dll_path = SYSTEMDLLDIR; +#endif + set_dll_path(); set_home_dir(); set_config_dir(); diff --git a/dlls/ntdll/unix/unix_private.h b/dlls/ntdll/unix/unix_private.h index 792cb33710d..01c7cc1c103 100644 --- a/dlls/ntdll/unix/unix_private.h +++ b/dlls/ntdll/unix/unix_private.h @@ -125,6 +125,7 @@ extern const char *build_dir DECLSPEC_HIDDEN; extern const char *config_dir DECLSPEC_HIDDEN; extern const char *user_name DECLSPEC_HIDDEN; extern const char **dll_paths DECLSPEC_HIDDEN; +extern const char *system_dll_path DECLSPEC_HIDDEN; extern PEB *peb DECLSPEC_HIDDEN; extern USHORT *uctable DECLSPEC_HIDDEN; extern USHORT *lctable DECLSPEC_HIDDEN;
Zebediah Figura zfigura@codeweavers.com writes:
@@ -36,6 +36,8 @@ AC_ARG_ENABLE(maintainer-mode, AS_HELP_STRING([--enable-maintainer-mode],[enable AC_ARG_ENABLE(silent-rules, AS_HELP_STRING([--enable-silent-rules],[use silent build rules (override: "make V=1")])) AC_ARG_ENABLE(werror, AS_HELP_STRING([--enable-werror],[treat compilation warnings as errors]))
+AC_ARG_VAR([SYSTEMDLLDIR], [path containing system dependency shared libraries])
I'd suggest to make this a --with option, along the lines of --with-wine-tools.
Also the resulting variable should probably be set through the makefile, similarly to BINDIR etc.
That is, load Wine system dependencies only when they are imported from Wine builtins or other system dependencies, and do not match a Wine system dependency by its base name when looking for already-loaded modules.
The reasoning is that it is possible for an application to ship, and expect to use, a newer version of a MinGW-compiled library, or one with custom patches, or possibly an unrelated library with the same name. We don't want to offer Wine's system dependencies in place of the application's, or vice versa.
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/ntdll/loader.c | 45 ++++++++++++++++++++++++++------------------- include/winternl.h | 1 + 2 files changed, 27 insertions(+), 19 deletions(-)
diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c index c83f7980572..a8ecf58ab37 100644 --- a/dlls/ntdll/loader.c +++ b/dlls/ntdll/loader.c @@ -186,7 +186,7 @@ static WINE_MODREF *last_failed_modref; static LDR_DDAG_NODE *node_ntdll, *node_kernel32;
static NTSTATUS load_dll( const WCHAR *load_path, const WCHAR *libname, const WCHAR *default_ext, - DWORD flags, WINE_MODREF** pwm ); + DWORD flags, WINE_MODREF **pwm, BOOL system ); static NTSTATUS process_attach( LDR_DDAG_NODE *node, LPVOID lpReserved ); static FARPROC find_ordinal_export( HMODULE module, const IMAGE_EXPORT_DIRECTORY *exports, DWORD exp_size, DWORD ordinal, LPCWSTR load_path ); @@ -505,21 +505,23 @@ static WINE_MODREF *get_modref( HMODULE hmod ) * Find a module from its base name. * The loader_section must be locked while calling this function */ -static WINE_MODREF *find_basename_module( LPCWSTR name ) +static WINE_MODREF *find_basename_module( const WCHAR *name, BOOL system ) { PLIST_ENTRY mark, entry; UNICODE_STRING name_str;
RtlInitUnicodeString( &name_str, name );
- if (cached_modref && RtlEqualUnicodeString( &name_str, &cached_modref->ldr.BaseDllName, TRUE )) + if (cached_modref && RtlEqualUnicodeString( &name_str, &cached_modref->ldr.BaseDllName, TRUE ) + && system == !!(cached_modref->ldr.Flags & LDR_WINE_SYSTEM)) return cached_modref;
mark = &NtCurrentTeb()->Peb->LdrData->InLoadOrderModuleList; for (entry = mark->Flink; entry != mark; entry = entry->Flink) { LDR_DATA_TABLE_ENTRY *mod = CONTAINING_RECORD(entry, LDR_DATA_TABLE_ENTRY, InLoadOrderLinks); - if (RtlEqualUnicodeString( &name_str, &mod->BaseDllName, TRUE )) + if (RtlEqualUnicodeString( &name_str, &mod->BaseDllName, TRUE ) + && system == !!(mod->Flags & LDR_WINE_SYSTEM)) { cached_modref = CONTAINING_RECORD(mod, WINE_MODREF, ldr); return cached_modref; @@ -714,6 +716,7 @@ static NTSTATUS walk_node_dependencies( LDR_DDAG_NODE *node, void *context, */ static FARPROC find_forwarded_export( HMODULE module, const char *forward, LPCWSTR load_path ) { + BOOL system = !!(get_modref( module )->ldr.Flags & (LDR_WINE_SYSTEM | LDR_WINE_BUILTIN)); const IMAGE_EXPORT_DIRECTORY *exports; DWORD exp_size; WINE_MODREF *wm; @@ -733,10 +736,10 @@ static FARPROC find_forwarded_export( HMODULE module, const char *forward, LPCWS if (!wcschr( mod_name, '.' )) memcpy( mod_name + (end - forward), L".dll", sizeof(L".dll") );
- if (!(wm = find_basename_module( mod_name ))) + if (!(wm = find_basename_module( mod_name, system ))) { TRACE( "delay loading %s for '%s'\n", debugstr_w(mod_name), forward ); - if (load_dll( load_path, mod_name, L".dll", 0, &wm ) == STATUS_SUCCESS && + if (load_dll( load_path, mod_name, L".dll", 0, &wm, system ) == STATUS_SUCCESS && !(wm->ldr.Flags & LDR_DONT_RESOLVE_REFS)) { if (!imports_fixup_done && current_modref) @@ -903,6 +906,7 @@ void * WINAPI RtlFindExportedRoutineByName( HMODULE module, const char *name ) */ static BOOL import_dll( HMODULE module, const IMAGE_IMPORT_DESCRIPTOR *descr, LPCWSTR load_path, WINE_MODREF **pwm ) { + BOOL system = !!(current_modref->ldr.Flags & (LDR_WINE_SYSTEM | LDR_WINE_BUILTIN)); NTSTATUS status; WINE_MODREF *wmImp; HMODULE imp_mod; @@ -936,7 +940,7 @@ static BOOL import_dll( HMODULE module, const IMAGE_IMPORT_DESCRIPTOR *descr, LP { ascii_to_unicode( buffer, name, len ); buffer[len] = 0; - status = load_dll( load_path, buffer, L".dll", 0, &wmImp ); + status = load_dll( load_path, buffer, L".dll", 0, &wmImp, system ); } else /* need to allocate a larger buffer */ { @@ -944,7 +948,7 @@ static BOOL import_dll( HMODULE module, const IMAGE_IMPORT_DESCRIPTOR *descr, LP if (!ptr) return FALSE; ascii_to_unicode( ptr, name, len ); ptr[len] = 0; - status = load_dll( load_path, ptr, L".dll", 0, &wmImp ); + status = load_dll( load_path, ptr, L".dll", 0, &wmImp, system ); RtlFreeHeap( GetProcessHeap(), 0, ptr ); }
@@ -1216,7 +1220,7 @@ static NTSTATUS fixup_imports_ilonly( WINE_MODREF *wm, LPCWSTR load_path, void * prev = current_modref; current_modref = wm; assert( !wm->ldr.DdagNode->Dependencies.Tail ); - if (!(status = load_dll( load_path, L"mscoree.dll", NULL, 0, &imp )) + if (!(status = load_dll( load_path, L"mscoree.dll", NULL, 0, &imp, FALSE )) && !add_module_dependency_after( wm->ldr.DdagNode, imp->ldr.DdagNode, NULL )) status = STATUS_NO_MEMORY; current_modref = prev; @@ -2902,7 +2906,7 @@ done: */ static NTSTATUS find_dll_file( const WCHAR *load_path, const WCHAR *libname, const WCHAR *default_ext, UNICODE_STRING *nt_name, WINE_MODREF **pwm, HANDLE *mapping, - SECTION_IMAGE_INFORMATION *image_info, struct file_id *id ) + SECTION_IMAGE_INFORMATION *image_info, struct file_id *id, BOOL system ) { WCHAR *ext, *dllname; NTSTATUS status; @@ -2943,7 +2947,7 @@ static NTSTATUS find_dll_file( const WCHAR *load_path, const WCHAR *libname, con else { if (status != STATUS_SXS_KEY_NOT_FOUND) goto done; - if ((*pwm = find_basename_module( libname )) != NULL) + if ((*pwm = find_basename_module( libname, system )) != NULL) { status = STATUS_SUCCESS; goto done; @@ -2976,7 +2980,7 @@ done: * The loader_section must be locked while calling this function. */ static NTSTATUS load_dll( const WCHAR *load_path, const WCHAR *libname, const WCHAR *default_ext, - DWORD flags, WINE_MODREF** pwm ) + DWORD flags, WINE_MODREF **pwm, BOOL system ) { UNICODE_STRING nt_name; struct file_id id; @@ -2987,10 +2991,10 @@ static NTSTATUS load_dll( const WCHAR *load_path, const WCHAR *libname, const WC
TRACE( "looking for %s in %s\n", debugstr_w(libname), debugstr_w(load_path) );
- if (system_dll_path.Buffer) - nts = find_dll_file( system_dll_path.Buffer, libname, default_ext, &nt_name, pwm, &mapping, &image_info, &id ); + if (system && system_dll_path.Buffer) + nts = find_dll_file( system_dll_path.Buffer, libname, default_ext, &nt_name, pwm, &mapping, &image_info, &id, TRUE ); if (nts) - nts = find_dll_file( load_path, libname, default_ext, &nt_name, pwm, &mapping, &image_info, &id ); + nts = find_dll_file( load_path, libname, default_ext, &nt_name, pwm, &mapping, &image_info, &id, FALSE );
if (*pwm) /* found already loaded module */ { @@ -3027,6 +3031,9 @@ static NTSTATUS load_dll( const WCHAR *load_path, const WCHAR *libname, const WC break; }
+ if (system) + (*pwm)->ldr.Flags |= LDR_WINE_SYSTEM; + if (NtCurrentTeb64()) NtCurrentTeb64()->Tib.ArbitraryUserPointer = prev; else @@ -3084,7 +3091,7 @@ NTSTATUS WINAPI DECLSPEC_HOTPATCH LdrLoadDll(LPCWSTR path_name, DWORD flags,
RtlEnterCriticalSection( &loader_section );
- nts = load_dll( path_name, libname->Buffer, L".dll", flags, &wm ); + nts = load_dll( path_name, libname->Buffer, L".dll", flags, &wm, FALSE );
if (nts == STATUS_SUCCESS && !(wm->ldr.Flags & LDR_DONT_RESOLVE_REFS)) { @@ -3159,7 +3166,7 @@ NTSTATUS WINAPI LdrGetDllHandleEx( ULONG flags, LPCWSTR load_path, ULONG *dll_ch
RtlEnterCriticalSection( &loader_section );
- status = find_dll_file( load_path, name->Buffer, L".dll", &nt_name, &wm, &mapping, &image_info, &id ); + status = find_dll_file( load_path, name->Buffer, L".dll", &nt_name, &wm, &mapping, &image_info, &id, FALSE );
if (wm) *base = wm->ldr.DllBase; else @@ -3860,7 +3867,7 @@ static void init_wow64( CONTEXT *context ) NTSTATUS status; static const WCHAR wow64_path[] = L"C:\windows\system32\wow64.dll";
- if ((status = load_dll( NULL, wow64_path, NULL, 0, &wm ))) + if ((status = load_dll( NULL, wow64_path, NULL, 0, &wm, FALSE ))) { ERR( "could not load %s, status %x\n", debugstr_w(wow64_path), status ); NtTerminateProcess( GetCurrentProcess(), status ); @@ -4010,7 +4017,7 @@ void WINAPI LdrInitializeThunk( CONTEXT *context, ULONG_PTR unknown2, ULONG_PTR
if (NtCurrentTeb()->WowTebOffset) init_wow64( context );
- if ((status = load_dll( NULL, L"kernel32.dll", NULL, 0, &kernel32 )) != STATUS_SUCCESS) + if ((status = load_dll( NULL, L"kernel32.dll", NULL, 0, &kernel32, FALSE )) != STATUS_SUCCESS) { MESSAGE( "wine: could not load kernel32.dll, status %x\n", status ); NtTerminateProcess( GetCurrentProcess(), status ); diff --git a/include/winternl.h b/include/winternl.h index 216a3b3fdaa..4bf9f0a8b11 100644 --- a/include/winternl.h +++ b/include/winternl.h @@ -3393,6 +3393,7 @@ typedef void (CALLBACK *PLDR_DLL_NOTIFICATION_FUNCTION)(ULONG, LDR_DLL_NOTIFICAT #define LDR_COR_ILONLY 0x01000000
/* these ones is Wine specific */ +#define LDR_WINE_SYSTEM 0x20000000 #define LDR_DONT_RESOLVE_REFS 0x40000000 #define LDR_WINE_BUILTIN 0x80000000