ntdll: Skip dlls of the wrong machine type when searching through the load path.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
2062df7e6c
commit
9839bb7691
|
@ -685,7 +685,7 @@ static NTSTATUS map_image_section( const IMAGE_NT_HEADERS *nt_header, const IMAG
|
||||||
/* some dlls with invalid entry point will crash, but this means we loaded the test dll */
|
/* some dlls with invalid entry point will crash, but this means we loaded the test dll */
|
||||||
ok( !expect_fallback, "%u: got test dll but expected fallback\n", line );
|
ok( !expect_fallback, "%u: got test dll but expected fallback\n", line );
|
||||||
}
|
}
|
||||||
else todo_wine_if( !expect_status )
|
else
|
||||||
{
|
{
|
||||||
ok( ldr_status == expect_status ||
|
ok( ldr_status == expect_status ||
|
||||||
broken(il_only && !expect_status && ldr_status == STATUS_INVALID_IMAGE_FORMAT),
|
broken(il_only && !expect_status && ldr_status == STATUS_INVALID_IMAGE_FORMAT),
|
||||||
|
|
|
@ -1999,12 +1999,6 @@ static NTSTATUS load_native_dll( LPCWSTR load_path, const UNICODE_STRING *nt_nam
|
||||||
|
|
||||||
TRACE("Trying native dll %s\n", debugstr_us(nt_name));
|
TRACE("Trying native dll %s\n", debugstr_us(nt_name));
|
||||||
|
|
||||||
if (!is_valid_binary( module, image_info ))
|
|
||||||
{
|
|
||||||
NtUnmapViewOfSection( NtCurrentProcess(), module );
|
|
||||||
return STATUS_INVALID_IMAGE_FORMAT;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* perform base relocation, if necessary */
|
/* perform base relocation, if necessary */
|
||||||
|
|
||||||
if ((status = perform_relocations( module, nt, image_info->map_size )))
|
if ((status = perform_relocations( module, nt, image_info->map_size )))
|
||||||
|
@ -2363,6 +2357,12 @@ static NTSTATUS open_dll_file( const WCHAR *name, UNICODE_STRING *nt_name, WINE_
|
||||||
if (status == STATUS_IMAGE_NOT_AT_BASE) status = STATUS_SUCCESS;
|
if (status == STATUS_IMAGE_NOT_AT_BASE) status = STATUS_SUCCESS;
|
||||||
NtClose( mapping );
|
NtClose( mapping );
|
||||||
}
|
}
|
||||||
|
if (!status && !is_valid_binary( *module, image_info ))
|
||||||
|
{
|
||||||
|
TRACE( "%s is for arch %x, continuing search\n", debugstr_us(nt_name), image_info->machine );
|
||||||
|
NtUnmapViewOfSection( NtCurrentProcess(), *module );
|
||||||
|
status = STATUS_IMAGE_MACHINE_TYPE_MISMATCH;
|
||||||
|
}
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2377,6 +2377,7 @@ static NTSTATUS search_dll_file( LPCWSTR paths, LPCWSTR search, UNICODE_STRING *
|
||||||
struct stat *st )
|
struct stat *st )
|
||||||
{
|
{
|
||||||
WCHAR *name;
|
WCHAR *name;
|
||||||
|
BOOL found_image = FALSE;
|
||||||
NTSTATUS status = STATUS_DLL_NOT_FOUND;
|
NTSTATUS status = STATUS_DLL_NOT_FOUND;
|
||||||
ULONG len = strlenW( paths );
|
ULONG len = strlenW( paths );
|
||||||
|
|
||||||
|
@ -2397,15 +2398,20 @@ static NTSTATUS search_dll_file( LPCWSTR paths, LPCWSTR search, UNICODE_STRING *
|
||||||
if (len && name[len - 1] != '\\') name[len++] = '\\';
|
if (len && name[len - 1] != '\\') name[len++] = '\\';
|
||||||
strcpyW( name + len, search );
|
strcpyW( name + len, search );
|
||||||
status = open_dll_file( name, nt_name, pwm, module, image_info, st );
|
status = open_dll_file( name, nt_name, pwm, module, image_info, st );
|
||||||
if (status != STATUS_DLL_NOT_FOUND) goto done;
|
if (status == STATUS_IMAGE_MACHINE_TYPE_MISMATCH) found_image = TRUE;
|
||||||
|
else if (status != STATUS_DLL_NOT_FOUND) goto done;
|
||||||
RtlFreeUnicodeString( nt_name );
|
RtlFreeUnicodeString( nt_name );
|
||||||
paths = ptr;
|
paths = ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!found_image)
|
||||||
|
{
|
||||||
/* not found, return file in the system dir to be loaded as builtin */
|
/* not found, return file in the system dir to be loaded as builtin */
|
||||||
strcpyW( name, system_dir );
|
strcpyW( name, system_dir );
|
||||||
strcatW( name, search );
|
strcatW( name, search );
|
||||||
if (!RtlDosPathNameToNtPathName_U( name, nt_name, NULL, NULL )) status = STATUS_NO_MEMORY;
|
if (!RtlDosPathNameToNtPathName_U( name, nt_name, NULL, NULL )) status = STATUS_NO_MEMORY;
|
||||||
|
}
|
||||||
|
else status = STATUS_IMAGE_MACHINE_TYPE_MISMATCH;
|
||||||
|
|
||||||
done:
|
done:
|
||||||
RtlFreeHeap( GetProcessHeap(), 0, name );
|
RtlFreeHeap( GetProcessHeap(), 0, name );
|
||||||
|
@ -2463,6 +2469,8 @@ static NTSTATUS find_dll_file( const WCHAR *load_path, const WCHAR *libname,
|
||||||
else
|
else
|
||||||
status = open_dll_file( libname, nt_name, pwm, module, image_info, st );
|
status = open_dll_file( libname, nt_name, pwm, module, image_info, st );
|
||||||
|
|
||||||
|
if (status == STATUS_IMAGE_MACHINE_TYPE_MISMATCH) status = STATUS_INVALID_IMAGE_FORMAT;
|
||||||
|
|
||||||
done:
|
done:
|
||||||
RtlFreeHeap( GetProcessHeap(), 0, dllname );
|
RtlFreeHeap( GetProcessHeap(), 0, dllname );
|
||||||
return status;
|
return status;
|
||||||
|
|
Loading…
Reference in New Issue