ntdll: Check the loadorder for .so dlls on the Unix side.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alexandre Julliard 2021-03-26 16:15:01 +01:00
parent e8ec7a8cec
commit f17483b936
2 changed files with 6 additions and 19 deletions

View File

@ -2349,10 +2349,11 @@ static NTSTATUS load_so_dll( LPCWSTR load_path, const UNICODE_STRING *nt_name,
UNICODE_STRING win_name = *nt_name; UNICODE_STRING win_name = *nt_name;
TRACE( "trying %s as so lib\n", debugstr_us(&win_name) ); TRACE( "trying %s as so lib\n", debugstr_us(&win_name) );
if (unix_funcs->load_so_dll( &win_name, &module )) if ((status = unix_funcs->load_so_dll( &win_name, &module )))
{ {
WARN( "failed to load .so lib %s\n", debugstr_us(nt_name) ); WARN( "failed to load .so lib %s\n", debugstr_us(nt_name) );
return STATUS_INVALID_IMAGE_FORMAT; if (status == STATUS_INVALID_IMAGE_FORMAT) status = STATUS_INVALID_IMAGE_NOT_MZ;
return status;
} }
if ((wm = get_modref( module ))) /* already loaded */ if ((wm = get_modref( module ))) /* already loaded */
@ -2690,7 +2691,6 @@ done:
static NTSTATUS load_dll( const WCHAR *load_path, const WCHAR *libname, const WCHAR *default_ext, 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 )
{ {
enum loadorder loadorder;
UNICODE_STRING nt_name; UNICODE_STRING nt_name;
struct file_id id; struct file_id id;
HANDLE mapping = 0; HANDLE mapping = 0;
@ -2715,27 +2715,13 @@ static NTSTATUS load_dll( const WCHAR *load_path, const WCHAR *libname, const WC
if (nts && nts != STATUS_DLL_NOT_FOUND && nts != STATUS_INVALID_IMAGE_NOT_MZ) goto done; if (nts && nts != STATUS_DLL_NOT_FOUND && nts != STATUS_INVALID_IMAGE_NOT_MZ) goto done;
loadorder = unix_funcs->get_load_order( &nt_name );
prev = NtCurrentTeb()->Tib.ArbitraryUserPointer; prev = NtCurrentTeb()->Tib.ArbitraryUserPointer;
NtCurrentTeb()->Tib.ArbitraryUserPointer = nt_name.Buffer + 4; NtCurrentTeb()->Tib.ArbitraryUserPointer = nt_name.Buffer + 4;
switch (nts) switch (nts)
{ {
case STATUS_INVALID_IMAGE_NOT_MZ: /* not in PE format, maybe it's a .so file */ case STATUS_INVALID_IMAGE_NOT_MZ: /* not in PE format, maybe it's a .so file */
switch (loadorder) nts = load_so_dll( load_path, &nt_name, flags, pwm );
{
case LO_NATIVE:
case LO_NATIVE_BUILTIN:
case LO_BUILTIN:
case LO_BUILTIN_NATIVE:
case LO_DEFAULT:
if (!load_so_dll( load_path, &nt_name, flags, pwm )) nts = STATUS_SUCCESS;
break;
default:
nts = STATUS_DLL_NOT_FOUND;
break;
}
break; break;
case STATUS_SUCCESS: /* valid PE file */ case STATUS_SUCCESS: /* valid PE file */
@ -2743,7 +2729,7 @@ static NTSTATUS load_dll( const WCHAR *load_path, const WCHAR *libname, const WC
break; break;
case STATUS_DLL_NOT_FOUND: /* no file found, try builtin */ case STATUS_DLL_NOT_FOUND: /* no file found, try builtin */
switch (loadorder) switch (unix_funcs->get_load_order( &nt_name ))
{ {
case LO_NATIVE_BUILTIN: case LO_NATIVE_BUILTIN:
case LO_BUILTIN: case LO_BUILTIN:

View File

@ -1153,6 +1153,7 @@ static NTSTATUS CDECL load_so_dll( UNICODE_STRING *nt_name, void **module )
NTSTATUS status; NTSTATUS status;
DWORD len; DWORD len;
if (get_load_order( nt_name ) == LO_DISABLED) return STATUS_DLL_NOT_FOUND;
if (nt_to_unix_file_name( nt_name, &unix_name, NULL, FILE_OPEN )) return STATUS_DLL_NOT_FOUND; if (nt_to_unix_file_name( nt_name, &unix_name, NULL, FILE_OPEN )) return STATUS_DLL_NOT_FOUND;
/* remove .so extension from Windows name */ /* remove .so extension from Windows name */