ntdll: Add alloc_type parameter to virtual_map_section and top_down to map_image.
NtMapViewOfSection also accepts the MEM_TOP_DOWN parameter that can be used in combination with zero_bits to map memory on the highest possible address. Signed-off-by: Rémi Bernon <rbernon@codeweavers.com> Signed-off-by: Huw Davies <huw@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
22c5af88ad
commit
1aa963efd7
|
@ -2135,7 +2135,7 @@ static NTSTATUS open_dll_file( UNICODE_STRING *nt_name, WINE_MODREF **pwm,
|
||||||
*module = NULL;
|
*module = NULL;
|
||||||
}
|
}
|
||||||
status = virtual_map_section( mapping, module, 0, 0, NULL, &len,
|
status = virtual_map_section( mapping, module, 0, 0, NULL, &len,
|
||||||
PAGE_EXECUTE_READ, image_info );
|
0, PAGE_EXECUTE_READ, image_info );
|
||||||
if (status == STATUS_IMAGE_NOT_AT_BASE) status = STATUS_SUCCESS;
|
if (status == STATUS_IMAGE_NOT_AT_BASE) status = STATUS_SUCCESS;
|
||||||
NtClose( mapping );
|
NtClose( mapping );
|
||||||
}
|
}
|
||||||
|
|
|
@ -166,8 +166,8 @@ extern NTSTATUS nt_to_unix_file_name_attr( const OBJECT_ATTRIBUTES *attr, ANSI_S
|
||||||
extern NTSTATUS virtual_alloc_aligned( PVOID *ret, ULONG zero_bits, SIZE_T *size_ptr,
|
extern NTSTATUS virtual_alloc_aligned( PVOID *ret, ULONG zero_bits, SIZE_T *size_ptr,
|
||||||
ULONG type, ULONG protect, ULONG alignment ) DECLSPEC_HIDDEN;
|
ULONG type, ULONG protect, ULONG alignment ) DECLSPEC_HIDDEN;
|
||||||
extern NTSTATUS virtual_map_section( HANDLE handle, PVOID *addr_ptr, ULONG zero_bits, SIZE_T commit_size,
|
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,
|
const LARGE_INTEGER *offset_ptr, SIZE_T *size_ptr, ULONG alloc_type,
|
||||||
pe_image_info_t *image_info ) DECLSPEC_HIDDEN;
|
ULONG protect, pe_image_info_t *image_info ) DECLSPEC_HIDDEN;
|
||||||
extern void virtual_get_system_info( SYSTEM_BASIC_INFORMATION *info ) 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_create_builtin_view( void *base ) DECLSPEC_HIDDEN;
|
||||||
extern NTSTATUS virtual_alloc_thread_stack( INITIAL_TEB *stack, SIZE_T reserve_size,
|
extern NTSTATUS virtual_alloc_thread_stack( INITIAL_TEB *stack, SIZE_T reserve_size,
|
||||||
|
|
|
@ -1361,7 +1361,7 @@ static NTSTATUS map_pe_header( void *ptr, size_t size, int fd, BOOL *removable )
|
||||||
*
|
*
|
||||||
* Map an executable (PE format) image into memory.
|
* Map an executable (PE format) image into memory.
|
||||||
*/
|
*/
|
||||||
static NTSTATUS map_image( HANDLE hmapping, ACCESS_MASK access, int fd, SIZE_T zero_bits,
|
static NTSTATUS map_image( HANDLE hmapping, ACCESS_MASK access, int fd, int top_down, SIZE_T zero_bits,
|
||||||
pe_image_info_t *image_info, int shared_fd, BOOL removable, PVOID *addr_ptr )
|
pe_image_info_t *image_info, int shared_fd, BOOL removable, PVOID *addr_ptr )
|
||||||
{
|
{
|
||||||
IMAGE_DOS_HEADER *dos;
|
IMAGE_DOS_HEADER *dos;
|
||||||
|
@ -1391,11 +1391,11 @@ static NTSTATUS map_image( HANDLE hmapping, ACCESS_MASK access, int fd, SIZE_T z
|
||||||
server_enter_uninterrupted_section( &csVirtual, &sigset );
|
server_enter_uninterrupted_section( &csVirtual, &sigset );
|
||||||
|
|
||||||
if (base >= (char *)address_space_start) /* make sure the DOS area remains free */
|
if (base >= (char *)address_space_start) /* make sure the DOS area remains free */
|
||||||
status = map_view( &view, base, total_size, 0, FALSE, SEC_IMAGE | SEC_FILE |
|
status = map_view( &view, base, total_size, 0, top_down, SEC_IMAGE | SEC_FILE |
|
||||||
VPROT_COMMITTED | VPROT_READ | VPROT_EXEC | VPROT_WRITECOPY, zero_bits );
|
VPROT_COMMITTED | VPROT_READ | VPROT_EXEC | VPROT_WRITECOPY, zero_bits );
|
||||||
|
|
||||||
if (status != STATUS_SUCCESS)
|
if (status != STATUS_SUCCESS)
|
||||||
status = map_view( &view, NULL, total_size, 0, FALSE, SEC_IMAGE | SEC_FILE |
|
status = map_view( &view, NULL, total_size, 0, top_down, SEC_IMAGE | SEC_FILE |
|
||||||
VPROT_COMMITTED | VPROT_READ | VPROT_EXEC | VPROT_WRITECOPY, zero_bits );
|
VPROT_COMMITTED | VPROT_READ | VPROT_EXEC | VPROT_WRITECOPY, zero_bits );
|
||||||
|
|
||||||
if (status != STATUS_SUCCESS) goto error;
|
if (status != STATUS_SUCCESS) goto error;
|
||||||
|
@ -1612,8 +1612,8 @@ static NTSTATUS map_image( HANDLE hmapping, ACCESS_MASK access, int fd, SIZE_T z
|
||||||
* Map a file section into memory.
|
* Map a file section into memory.
|
||||||
*/
|
*/
|
||||||
NTSTATUS virtual_map_section( HANDLE handle, PVOID *addr_ptr, ULONG zero_bits, SIZE_T commit_size,
|
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,
|
const LARGE_INTEGER *offset_ptr, SIZE_T *size_ptr, ULONG alloc_type,
|
||||||
pe_image_info_t *image_info )
|
ULONG protect, pe_image_info_t *image_info )
|
||||||
{
|
{
|
||||||
NTSTATUS res;
|
NTSTATUS res;
|
||||||
mem_size_t full_size;
|
mem_size_t full_size;
|
||||||
|
@ -1673,14 +1673,14 @@ NTSTATUS virtual_map_section( HANDLE handle, PVOID *addr_ptr, ULONG zero_bits, S
|
||||||
|
|
||||||
if ((res = server_get_unix_fd( shared_file, FILE_READ_DATA|FILE_WRITE_DATA,
|
if ((res = server_get_unix_fd( shared_file, FILE_READ_DATA|FILE_WRITE_DATA,
|
||||||
&shared_fd, &shared_needs_close, NULL, NULL ))) goto done;
|
&shared_fd, &shared_needs_close, NULL, NULL ))) goto done;
|
||||||
res = map_image( handle, access, unix_handle, zero_bits, image_info,
|
res = map_image( handle, access, unix_handle, alloc_type & MEM_TOP_DOWN, zero_bits, image_info,
|
||||||
shared_fd, needs_close, addr_ptr );
|
shared_fd, needs_close, addr_ptr );
|
||||||
if (shared_needs_close) close( shared_fd );
|
if (shared_needs_close) close( shared_fd );
|
||||||
close_handle( shared_file );
|
close_handle( shared_file );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
res = map_image( handle, access, unix_handle, zero_bits, image_info,
|
res = map_image( handle, access, unix_handle, alloc_type & MEM_TOP_DOWN, zero_bits, image_info,
|
||||||
-1, needs_close, addr_ptr );
|
-1, needs_close, addr_ptr );
|
||||||
}
|
}
|
||||||
if (needs_close) close( unix_handle );
|
if (needs_close) close( unix_handle );
|
||||||
|
@ -1718,7 +1718,7 @@ NTSTATUS virtual_map_section( HANDLE handle, PVOID *addr_ptr, ULONG zero_bits, S
|
||||||
get_vprot_flags( protect, &vprot, sec_flags & SEC_IMAGE );
|
get_vprot_flags( protect, &vprot, sec_flags & SEC_IMAGE );
|
||||||
vprot |= sec_flags;
|
vprot |= sec_flags;
|
||||||
if (!(sec_flags & SEC_RESERVE)) vprot |= VPROT_COMMITTED;
|
if (!(sec_flags & SEC_RESERVE)) vprot |= VPROT_COMMITTED;
|
||||||
res = map_view( &view, *addr_ptr, size, 0, FALSE, vprot, zero_bits );
|
res = map_view( &view, *addr_ptr, size, 0, alloc_type & MEM_TOP_DOWN, vprot, zero_bits );
|
||||||
if (res)
|
if (res)
|
||||||
{
|
{
|
||||||
server_leave_uninterrupted_section( &csVirtual, &sigset );
|
server_leave_uninterrupted_section( &csVirtual, &sigset );
|
||||||
|
@ -3198,7 +3198,8 @@ NTSTATUS WINAPI NtMapViewOfSection( HANDLE handle, HANDLE process, PVOID *addr_p
|
||||||
}
|
}
|
||||||
|
|
||||||
return virtual_map_section( handle, addr_ptr, zero_bits, commit_size,
|
return virtual_map_section( handle, addr_ptr, zero_bits, commit_size,
|
||||||
offset_ptr, size_ptr, protect, &image_info );
|
offset_ptr, size_ptr, alloc_type, protect,
|
||||||
|
&image_info );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue