ntdll: Update the image information when loading a builtin dll.

This commit is contained in:
Alexandre Julliard 2024-02-07 19:04:29 +01:00
parent 4022fb9ba3
commit 0d37cc1d06
3 changed files with 14 additions and 9 deletions

View file

@ -1277,11 +1277,11 @@ done:
* 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,
void **module, SIZE_T *size, ULONG_PTR limit_low, ULONG_PTR limit_high )
SECTION_IMAGE_INFORMATION *info, void **module, SIZE_T *size,
ULONG_PTR limit_low, ULONG_PTR limit_high )
{
NTSTATUS status;
UNICODE_STRING nt_name;
SECTION_IMAGE_INFORMATION info;
enum loadorder loadorder;
init_unicode_string( &nt_name, filename );
@ -1307,10 +1307,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_low, limit_high,
return find_builtin_dll( &nt_name, module, size, info, limit_low, limit_high,
image_info->machine, machine, FALSE );
default:
status = find_builtin_dll( &nt_name, module, size, &info, limit_low, limit_high,
status = find_builtin_dll( &nt_name, module, size, info, limit_low, limit_high,
image_info->machine, machine, (loadorder == LO_DEFAULT) );
if (status == STATUS_DLL_NOT_FOUND || status == STATUS_NOT_SUPPORTED)
return STATUS_IMAGE_ALREADY_LOADED;

View file

@ -185,7 +185,8 @@ extern char **build_envp( const WCHAR *envW );
extern char *get_alternate_wineloader( WORD machine );
extern NTSTATUS exec_wineloader( char **argv, int socketfd, const pe_image_info_t *pe_info );
extern NTSTATUS load_builtin( const pe_image_info_t *image_info, WCHAR *filename, USHORT machine,
void **addr_ptr, SIZE_T *size_ptr, ULONG_PTR limit_low, ULONG_PTR limit_high );
SECTION_IMAGE_INFORMATION *info, void **module, SIZE_T *size,
ULONG_PTR limit_low, ULONG_PTR limit_high );
extern BOOL is_builtin_path( const UNICODE_STRING *path, WORD *machine );
extern NTSTATUS load_main_exe( const WCHAR *name, const char *unix_name, const WCHAR *curdir,
USHORT load_machine, WCHAR **image, void **module );

View file

@ -3161,9 +3161,12 @@ static unsigned int virtual_map_section( HANDLE handle, PVOID *addr_ptr, ULONG_P
if (image_info)
{
SECTION_IMAGE_INFORMATION info;
filename = (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_low, limit_high );
res = load_builtin( image_info, filename, machine, &info,
addr_ptr, size_ptr, limit_low, limit_high );
if (res == STATUS_IMAGE_ALREADY_LOADED)
res = virtual_map_image( handle, addr_ptr, size_ptr, shared_file, limit_low, limit_high,
alloc_type, machine, image_info, filename, FALSE );
@ -3462,12 +3465,13 @@ NTSTATUS virtual_map_module( HANDLE mapping, void **module, SIZE_T *size, SECTIO
filename = (WCHAR *)(image_info + 1);
/* check if we can replace that mapping with the builtin */
status = load_builtin( image_info, filename, machine, module, size, limit_low, limit_high );
status = load_builtin( image_info, filename, machine, info, module, size, limit_low, limit_high );
if (status == STATUS_IMAGE_ALREADY_LOADED)
{
status = virtual_map_image( mapping, module, size, shared_file, limit_low, limit_high, 0,
machine, image_info, filename, FALSE );
virtual_fill_image_information( image_info, info );
virtual_fill_image_information( image_info, info );
}
if (shared_file) NtClose( shared_file );
free( image_info );
return status;