As for NtAllocateVirtualMemory, the parameter was misinterpreted as an alignment value. This wasn't used anywhere, so just add an explicit alignment parameter to internal virtual_map_section function and return an error when zero_bits is used.
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/ntdll/loader.c | 2 +- dlls/ntdll/ntdll_misc.h | 2 +- dlls/ntdll/virtual.c | 14 +++++++++----- 3 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c index 166066783ff..4807490be0c 100644 --- a/dlls/ntdll/loader.c +++ b/dlls/ntdll/loader.c @@ -2101,7 +2101,7 @@ static NTSTATUS open_dll_file( UNICODE_STRING *nt_name, WINE_MODREF **pwm, if (!status) { status = virtual_map_section( mapping, module, 0, 0, NULL, &len, - PAGE_EXECUTE_READ, image_info ); + PAGE_EXECUTE_READ, image_info, 0 ); if (status == STATUS_IMAGE_NOT_AT_BASE) status = STATUS_SUCCESS; NtClose( mapping ); } diff --git a/dlls/ntdll/ntdll_misc.h b/dlls/ntdll/ntdll_misc.h index 24af706399b..944ff04aa96 100644 --- a/dlls/ntdll/ntdll_misc.h +++ b/dlls/ntdll/ntdll_misc.h @@ -172,7 +172,7 @@ extern NTSTATUS virtual_alloc( PVOID *ret, ULONG zero_bits, SIZE_T *size_ptr, ULONG type, ULONG protect, ULONG alignment ); extern NTSTATUS virtual_map_section( HANDLE handle, PVOID *addr_ptr, ULONG zero_bits, SIZE_T commit_size, const LARGE_INTEGER *offset_ptr, SIZE_T *size_ptr, ULONG protect, - pe_image_info_t *image_info ) DECLSPEC_HIDDEN; + pe_image_info_t *image_info, ULONG alignment ) DECLSPEC_HIDDEN; extern void virtual_get_system_info( SYSTEM_BASIC_INFORMATION *info ) DECLSPEC_HIDDEN; extern NTSTATUS virtual_create_builtin_view( void *base ) DECLSPEC_HIDDEN; extern NTSTATUS virtual_alloc_thread_stack( TEB *teb, SIZE_T reserve_size, diff --git a/dlls/ntdll/virtual.c b/dlls/ntdll/virtual.c index 90475a01f21..175d73cbe7c 100644 --- a/dlls/ntdll/virtual.c +++ b/dlls/ntdll/virtual.c @@ -1609,12 +1609,12 @@ static NTSTATUS map_image( HANDLE hmapping, ACCESS_MASK access, int fd, SIZE_T m */ NTSTATUS virtual_map_section( HANDLE handle, PVOID *addr_ptr, ULONG zero_bits, SIZE_T commit_size, const LARGE_INTEGER *offset_ptr, SIZE_T *size_ptr, ULONG protect, - pe_image_info_t *image_info ) + pe_image_info_t *image_info, ULONG alignment ) { NTSTATUS res; mem_size_t full_size; ACCESS_MASK access; - SIZE_T size, mask = get_mask( zero_bits ); + SIZE_T size, mask = get_mask( alignment ); int unix_handle = -1, needs_close; unsigned int vprot, sec_flags; struct file_view *view; @@ -3099,7 +3099,7 @@ NTSTATUS WINAPI NtMapViewOfSection( HANDLE handle, HANDLE process, PVOID *addr_p SECTION_INHERIT inherit, ULONG alloc_type, ULONG protect ) { NTSTATUS res; - SIZE_T mask = get_mask( zero_bits ); + SIZE_T mask = get_mask( 0 ); pe_image_info_t image_info; LARGE_INTEGER offset;
@@ -3110,8 +3110,11 @@ NTSTATUS WINAPI NtMapViewOfSection( HANDLE handle, HANDLE process, PVOID *addr_p
/* Check parameters */
- if ((*addr_ptr && zero_bits) || !mask) + if (zero_bits) + { + FIXME("Unimplemented zero_bits handling\n"); return STATUS_INVALID_PARAMETER_4; + }
#ifndef _WIN64 if (!is_wow64 && (alloc_type & AT_ROUND_TO_PAGE)) @@ -3151,7 +3154,8 @@ NTSTATUS WINAPI NtMapViewOfSection( HANDLE handle, HANDLE process, PVOID *addr_p }
return virtual_map_section( handle, addr_ptr, zero_bits, commit_size, - offset_ptr, size_ptr, protect, &image_info ); + offset_ptr, size_ptr, protect, &image_info, + 0 ); }