From: Rémi Bernon rbernon@codeweavers.com
--- dlls/ntdll/unix/loader.c | 12 ++++----- dlls/ntdll/unix/unix_private.h | 2 +- dlls/ntdll/unix/virtual.c | 46 +++++++++++++++++----------------- 3 files changed, 29 insertions(+), 31 deletions(-)
diff --git a/dlls/ntdll/unix/loader.c b/dlls/ntdll/unix/loader.c index 4d855a18cff..55abbcbb6ea 100644 --- a/dlls/ntdll/unix/loader.c +++ b/dlls/ntdll/unix/loader.c @@ -1567,16 +1567,14 @@ done: * Load the builtin dll if specified by load order configuration. * Return STATUS_IMAGE_ALREADY_LOADED if we should keep the native one that we have found. */ -NTSTATUS load_builtin( const pe_image_info_t *image_info, WCHAR *filename, USHORT machine, +NTSTATUS load_builtin( const pe_image_info_t *image_info, UNICODE_STRING *nt_name, USHORT machine, void **module, SIZE_T *size, ULONG_PTR limit ) { NTSTATUS status; - UNICODE_STRING nt_name; SECTION_IMAGE_INFORMATION info; enum loadorder loadorder;
- init_unicode_string( &nt_name, filename ); - loadorder = get_load_order( &nt_name ); + loadorder = get_load_order( nt_name );
if (loadorder == LO_DISABLED) return STATUS_DLL_NOT_FOUND;
@@ -1587,7 +1585,7 @@ NTSTATUS load_builtin( const pe_image_info_t *image_info, WCHAR *filename, USHOR } else if (image_info->wine_fakedll) { - TRACE( "%s is a fake Wine dll\n", debugstr_w(filename) ); + TRACE( "%s is a fake Wine dll\n", debugstr_us(nt_name) ); if (loadorder == LO_NATIVE) return STATUS_DLL_NOT_FOUND; loadorder = LO_BUILTIN; /* builtin with no fallback since mapping a fake dll is not useful */ } @@ -1598,10 +1596,10 @@ NTSTATUS load_builtin( const pe_image_info_t *image_info, WCHAR *filename, USHOR case LO_NATIVE_BUILTIN: return STATUS_IMAGE_ALREADY_LOADED; case LO_BUILTIN: - return find_builtin_dll( &nt_name, module, size, &info, limit, + return find_builtin_dll( nt_name, module, size, &info, limit, image_info->machine, machine, FALSE ); default: - status = find_builtin_dll( &nt_name, module, size, &info, limit, + status = find_builtin_dll( nt_name, module, size, &info, limit, image_info->machine, machine, (loadorder == LO_DEFAULT) ); if (status == STATUS_DLL_NOT_FOUND || status == STATUS_NOT_SUPPORTED) return STATUS_IMAGE_ALREADY_LOADED; diff --git a/dlls/ntdll/unix/unix_private.h b/dlls/ntdll/unix/unix_private.h index 4d62c4f6570..0afc53f3696 100644 --- a/dlls/ntdll/unix/unix_private.h +++ b/dlls/ntdll/unix/unix_private.h @@ -173,7 +173,7 @@ extern void *create_startup_info( const UNICODE_STRING *nt_image, const RTL_USER extern char **build_envp( const WCHAR *envW ) DECLSPEC_HIDDEN; extern char *get_alternate_wineloader( WORD machine ) DECLSPEC_HIDDEN; extern NTSTATUS exec_wineloader( char **argv, int socketfd, const pe_image_info_t *pe_info ) DECLSPEC_HIDDEN; -extern NTSTATUS load_builtin( const pe_image_info_t *image_info, WCHAR *filename, USHORT machine, +extern NTSTATUS load_builtin( const pe_image_info_t *image_info, UNICODE_STRING *nt_name, USHORT machine, void **addr_ptr, SIZE_T *size_ptr, ULONG_PTR limit ) DECLSPEC_HIDDEN; extern BOOL is_builtin_path( const UNICODE_STRING *path, WORD *machine ) DECLSPEC_HIDDEN; extern NTSTATUS load_main_exe( const WCHAR *name, const char *unix_name, const WCHAR *curdir, diff --git a/dlls/ntdll/unix/virtual.c b/dlls/ntdll/unix/virtual.c index 19b595560f1..04dc0dda984 100644 --- a/dlls/ntdll/unix/virtual.c +++ b/dlls/ntdll/unix/virtual.c @@ -2539,7 +2539,7 @@ static void update_arm64x_mapping( char *base, IMAGE_NT_HEADERS *nt, IMAGE_SECTI * Map an executable (PE format) image into an existing view. * virtual_mutex must be held by caller. */ -static NTSTATUS map_image_into_view( struct file_view *view, const WCHAR *filename, int fd, void *orig_base, +static NTSTATUS map_image_into_view( struct file_view *view, UNICODE_STRING *nt_name, int fd, void *orig_base, pe_image_info_t *image_info, USHORT machine, int shared_fd, BOOL removable ) { @@ -2556,7 +2556,7 @@ static NTSTATUS map_image_into_view( struct file_view *view, const WCHAR *filena char *ptr = view->base; SIZE_T header_size, total_size = view->size;
- TRACE_(module)( "mapping PE file %s at %p-%p\n", debugstr_w(filename), ptr, ptr + total_size ); + TRACE_(module)( "mapping PE file %s at %p-%p\n", debugstr_us(nt_name), ptr, ptr + total_size );
/* map the header */
@@ -2630,7 +2630,7 @@ static NTSTATUS map_image_into_view( struct file_view *view, const WCHAR *filena if (sec->VirtualAddress > total_size || end > total_size || end < sec->VirtualAddress) { WARN_(module)( "%s section %.8s too large (%x+%lx/%lx)\n", - debugstr_w(filename), sec->Name, (int)sec->VirtualAddress, map_size, total_size ); + debugstr_us(nt_name), sec->Name, (int)sec->VirtualAddress, map_size, total_size ); return status; }
@@ -2638,13 +2638,13 @@ static NTSTATUS map_image_into_view( struct file_view *view, const WCHAR *filena (sec->Characteristics & IMAGE_SCN_MEM_WRITE)) { TRACE_(module)( "%s mapping shared section %.8s at %p off %x (%x) size %lx (%lx) flags %x\n", - debugstr_w(filename), sec->Name, ptr + sec->VirtualAddress, + debugstr_us(nt_name), sec->Name, ptr + sec->VirtualAddress, (int)sec->PointerToRawData, (int)pos, file_size, map_size, (int)sec->Characteristics ); if (map_file_into_view( view, shared_fd, sec->VirtualAddress, map_size, pos, VPROT_COMMITTED | VPROT_READ | VPROT_WRITE, FALSE ) != STATUS_SUCCESS) { - ERR_(module)( "Could not map %s shared section %.8s\n", debugstr_w(filename), sec->Name ); + ERR_(module)( "Could not map %s shared section %.8s\n", debugstr_us(nt_name), sec->Name ); return status; }
@@ -2665,7 +2665,7 @@ static NTSTATUS map_image_into_view( struct file_view *view, const WCHAR *filena }
TRACE_(module)( "mapping %s section %.8s at %p off %x size %x virt %x flags %x\n", - debugstr_w(filename), sec->Name, ptr + sec->VirtualAddress, + debugstr_us(nt_name), sec->Name, ptr + sec->VirtualAddress, (int)sec->PointerToRawData, (int)sec->SizeOfRawData, (int)sec->Misc.VirtualSize, (int)sec->Characteristics );
@@ -2683,7 +2683,7 @@ static NTSTATUS map_image_into_view( struct file_view *view, const WCHAR *filena removable ) != STATUS_SUCCESS) { ERR_(module)( "Could not map %s section %.8s, file probably truncated\n", - debugstr_w(filename), sec->Name ); + debugstr_us(nt_name), sec->Name ); return status; }
@@ -2731,7 +2731,7 @@ static NTSTATUS map_image_into_view( struct file_view *view, const WCHAR *filena
if (!set_vprot( view, ptr + sec->VirtualAddress, size, vprot ) && (vprot & VPROT_EXEC)) ERR( "failed to set %08x protection on %s section %.8s, noexec filesystem?\n", - (int)sec->Characteristics, debugstr_w(filename), sec->Name ); + (int)sec->Characteristics, debugstr_us(nt_name), sec->Name ); }
#ifdef VALGRIND_LOAD_PDB_DEBUGINFO @@ -2796,7 +2796,7 @@ static unsigned int get_mapping_info( HANDLE handle, ACCESS_MASK access, unsigne */ static NTSTATUS virtual_map_image( HANDLE mapping, void **addr_ptr, SIZE_T *size_ptr, HANDLE shared_file, ULONG_PTR limit, ULONG alloc_type, USHORT machine, - pe_image_info_t *image_info, WCHAR *filename, BOOL is_builtin ) + pe_image_info_t *image_info, UNICODE_STRING *nt_name, BOOL is_builtin ) { unsigned int vprot = SEC_IMAGE | SEC_FILE | VPROT_COMMITTED | VPROT_READ | VPROT_EXEC | VPROT_WRITECOPY; int unix_fd = -1, needs_close; @@ -2829,7 +2829,7 @@ static NTSTATUS virtual_map_image( HANDLE mapping, void **addr_ptr, SIZE_T *size if (status) status = map_view( &view, NULL, size, alloc_type, vprot, limit, 0 ); if (status) goto done;
- status = map_image_into_view( view, filename, unix_fd, base, image_info, + status = map_image_into_view( view, nt_name, unix_fd, base, image_info, machine, shared_fd, needs_close ); if (status == STATUS_SUCCESS) { @@ -2876,7 +2876,6 @@ static unsigned int virtual_map_section( HANDLE handle, PVOID *addr_ptr, ULONG_P ACCESS_MASK access; SIZE_T size; pe_image_info_t *image_info = NULL; - WCHAR *filename; void *base; int unix_handle = -1, needs_close; unsigned int vprot, sec_flags; @@ -2912,12 +2911,13 @@ static unsigned int virtual_map_section( HANDLE handle, PVOID *addr_ptr, ULONG_P
if (image_info) { - filename = (WCHAR *)(image_info + 1); + UNICODE_STRING nt_name; + init_unicode_string( &nt_name, (WCHAR *)(image_info + 1) ); /* check if we can replace that mapping with the builtin */ - res = load_builtin( image_info, filename, machine, addr_ptr, size_ptr, limit ); + res = load_builtin( image_info, &nt_name, machine, addr_ptr, size_ptr, limit ); if (res == STATUS_IMAGE_ALREADY_LOADED) res = virtual_map_image( handle, addr_ptr, size_ptr, shared_file, limit, - alloc_type, machine, image_info, filename, FALSE ); + alloc_type, machine, image_info, &nt_name, FALSE ); if (shared_file) NtClose( shared_file ); free( image_info ); return res; @@ -3135,8 +3135,8 @@ NTSTATUS virtual_map_builtin_module( HANDLE mapping, void **module, SIZE_T *size unsigned int sec_flags; HANDLE shared_file; pe_image_info_t *image_info = NULL; + UNICODE_STRING nt_name; NTSTATUS status; - WCHAR *filename;
if ((status = get_mapping_info( mapping, SECTION_MAP_READ, &sec_flags, &full_size, &shared_file, &image_info ))) @@ -3146,22 +3146,22 @@ NTSTATUS virtual_map_builtin_module( HANDLE mapping, void **module, SIZE_T *size
*module = NULL; *size = 0; - filename = (WCHAR *)(image_info + 1); + init_unicode_string( &nt_name, (WCHAR *)(image_info + 1) );
if (!image_info->wine_builtin) /* ignore non-builtins */ { - WARN( "%s found in WINEDLLPATH but not a builtin, ignoring\n", debugstr_w(filename) ); + WARN( "%s found in WINEDLLPATH but not a builtin, ignoring\n", debugstr_us(&nt_name) ); status = STATUS_DLL_NOT_FOUND; } else if (prefer_native && (image_info->dll_charact & IMAGE_DLLCHARACTERISTICS_PREFER_NATIVE)) { - TRACE( "%s has prefer-native flag, ignoring builtin\n", debugstr_w(filename) ); + TRACE( "%s has prefer-native flag, ignoring builtin\n", debugstr_us(&nt_name) ); status = STATUS_IMAGE_ALREADY_LOADED; } else { status = virtual_map_image( mapping, module, size, shared_file, limit, 0, - machine, image_info, filename, TRUE ); + machine, image_info, &nt_name, TRUE ); virtual_fill_image_information( image_info, info ); }
@@ -3182,7 +3182,7 @@ NTSTATUS virtual_map_module( HANDLE mapping, void **module, SIZE_T *size, SECTIO unsigned int sec_flags; HANDLE shared_file; pe_image_info_t *image_info = NULL; - WCHAR *filename; + UNICODE_STRING nt_name;
if ((status = get_mapping_info( mapping, SECTION_MAP_READ, &sec_flags, &full_size, &shared_file, &image_info ))) @@ -3192,13 +3192,13 @@ NTSTATUS virtual_map_module( HANDLE mapping, void **module, SIZE_T *size, SECTIO
*module = NULL; *size = 0; - filename = (WCHAR *)(image_info + 1); + init_unicode_string( &nt_name, (WCHAR *)(image_info + 1) );
/* check if we can replace that mapping with the builtin */ - status = load_builtin( image_info, filename, machine, module, size, limit ); + status = load_builtin( image_info, &nt_name, machine, module, size, limit ); if (status == STATUS_IMAGE_ALREADY_LOADED) status = virtual_map_image( mapping, module, size, shared_file, limit, 0, - machine, image_info, filename, FALSE ); + machine, image_info, &nt_name, FALSE );
virtual_fill_image_information( image_info, info ); if (shared_file) NtClose( shared_file );