[PATCH v2 4/4] ntdll: Clarify NtMapViewOfSection zero_bits parameter semantics
Rémi Bernon
rbernon at codeweavers.com
Mon May 27 08:07:36 CDT 2019
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 at 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 a629ea8751c..b4e7ae6aedb 100644
--- a/dlls/ntdll/ntdll_misc.h
+++ b/dlls/ntdll/ntdll_misc.h
@@ -173,7 +173,7 @@ extern NTSTATUS CDECL __wine_allocate_virtual_memory( HANDLE process, PVOID *ret
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 bac1ea47f0d..dfead5b2eea 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;
@@ -3097,7 +3097,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;
@@ -3108,8 +3108,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))
@@ -3149,7 +3152,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 );
}
--
2.20.1
More information about the wine-devel
mailing list