ntdll: Use the actual zero_bits parameter in the server requests.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
feature/deterministic
Alexandre Julliard 2020-06-01 13:27:40 +02:00
parent 3e9f8c87e5
commit b925dd78b8
8 changed files with 38 additions and 55 deletions

View File

@ -177,8 +177,6 @@ extern NTSTATUS nt_to_unix_file_name_attr( const OBJECT_ATTRIBUTES *attr, ANSI_S
UINT disposition ) DECLSPEC_HIDDEN;
/* virtual memory */
extern NTSTATUS virtual_alloc( PVOID *ret, unsigned short zero_bits_64, SIZE_T *size_ptr,
ULONG type, ULONG protect ) DECLSPEC_HIDDEN;
extern NTSTATUS virtual_map_section( HANDLE handle, PVOID *addr_ptr, unsigned short zero_bits_64, SIZE_T commit_size,
const LARGE_INTEGER *offset_ptr, SIZE_T *size_ptr, ULONG alloc_type,
ULONG protect, pe_image_info_t *image_info ) DECLSPEC_HIDDEN;

View File

@ -258,9 +258,8 @@ static void invoke_apc( const user_apc_t *apc )
*/
static void invoke_system_apc( const apc_call_t *call, apc_result_t *result )
{
SIZE_T size;
SIZE_T size, bits;
void *addr;
pe_image_info_t image_info;
memset( result, 0, sizeof(*result) );
@ -282,11 +281,13 @@ static void invoke_system_apc( const apc_call_t *call, apc_result_t *result )
result->type = call->type;
addr = wine_server_get_ptr( call->virtual_alloc.addr );
size = call->virtual_alloc.size;
if ((ULONG_PTR)addr == call->virtual_alloc.addr && size == call->virtual_alloc.size)
bits = call->virtual_alloc.zero_bits;
if ((ULONG_PTR)addr == call->virtual_alloc.addr && size == call->virtual_alloc.size &&
bits == call->virtual_alloc.zero_bits)
{
result->virtual_alloc.status = virtual_alloc( &addr, call->virtual_alloc.zero_bits_64, &size,
call->virtual_alloc.op_type,
call->virtual_alloc.prot );
result->virtual_alloc.status = NtAllocateVirtualMemory( NtCurrentProcess(), &addr, bits, &size,
call->virtual_alloc.op_type,
call->virtual_alloc.prot );
result->virtual_alloc.addr = wine_server_client_ptr( addr );
result->virtual_alloc.size = size;
}
@ -384,16 +385,16 @@ static void invoke_system_apc( const apc_call_t *call, apc_result_t *result )
result->type = call->type;
addr = wine_server_get_ptr( call->map_view.addr );
size = call->map_view.size;
if ((ULONG_PTR)addr == call->map_view.addr && size == call->map_view.size)
bits = call->map_view.zero_bits;
if ((ULONG_PTR)addr == call->map_view.addr && size == call->map_view.size &&
bits == call->map_view.zero_bits)
{
LARGE_INTEGER offset;
offset.QuadPart = call->map_view.offset;
result->map_view.status = virtual_map_section( wine_server_ptr_handle(call->map_view.handle),
&addr,
call->map_view.zero_bits_64, 0,
&offset, &size,
call->map_view.alloc_type, call->map_view.prot,
&image_info );
result->map_view.status = NtMapViewOfSection( wine_server_ptr_handle(call->map_view.handle),
NtCurrentProcess(),
&addr, bits, 0, &offset, &size, 0,
call->map_view.alloc_type, call->map_view.prot );
result->map_view.addr = wine_server_client_ptr( addr );
result->map_view.size = size;
}

View File

@ -2959,6 +2959,11 @@ void virtual_set_large_address_space(void)
NTSTATUS WINAPI NtAllocateVirtualMemory( HANDLE process, PVOID *ret, ULONG_PTR zero_bits,
SIZE_T *size_ptr, ULONG type, ULONG protect )
{
void *base;
unsigned int vprot;
BOOL is_dos_memory = FALSE;
struct file_view *view;
sigset_t sigset;
SIZE_T size = *size_ptr;
NTSTATUS status = STATUS_SUCCESS;
unsigned short zero_bits_64 = zero_bits_win_to_64( zero_bits );
@ -2979,7 +2984,7 @@ NTSTATUS WINAPI NtAllocateVirtualMemory( HANDLE process, PVOID *ret, ULONG_PTR z
call.virtual_alloc.type = APC_VIRTUAL_ALLOC;
call.virtual_alloc.addr = wine_server_client_ptr( *ret );
call.virtual_alloc.size = *size_ptr;
call.virtual_alloc.zero_bits_64 = zero_bits_64;
call.virtual_alloc.zero_bits = zero_bits;
call.virtual_alloc.op_type = type;
call.virtual_alloc.prot = protect;
status = server_queue_process_apc( process, &call, &result );
@ -2993,26 +2998,6 @@ NTSTATUS WINAPI NtAllocateVirtualMemory( HANDLE process, PVOID *ret, ULONG_PTR z
return result.virtual_alloc.status;
}
return virtual_alloc( ret, zero_bits_64, size_ptr, type, protect );
}
/***********************************************************************
* virtual_alloc (NTDLL.@)
*
* Same as NtAllocateVirtualMemory for the current process.
*/
NTSTATUS virtual_alloc( PVOID *ret, unsigned short zero_bits_64, SIZE_T *size_ptr,
ULONG type, ULONG protect )
{
void *base;
unsigned int vprot;
SIZE_T size = *size_ptr;
NTSTATUS status = STATUS_SUCCESS;
BOOL is_dos_memory = FALSE;
struct file_view *view;
sigset_t sigset;
/* Round parameters to a page boundary */
if (is_beyond_limit( 0, size, working_set_limit )) return STATUS_WORKING_SET_LIMIT_RANGE;
@ -3709,7 +3694,7 @@ NTSTATUS WINAPI NtMapViewOfSection( HANDLE handle, HANDLE process, PVOID *addr_p
call.map_view.addr = wine_server_client_ptr( *addr_ptr );
call.map_view.size = *size_ptr;
call.map_view.offset = offset.QuadPart;
call.map_view.zero_bits_64 = zero_bits_64;
call.map_view.zero_bits = zero_bits;
call.map_view.alloc_type = alloc_type;
call.map_view.prot = protect;
res = server_queue_process_apc( process, &call, &result );

View File

@ -493,7 +493,7 @@ typedef union
unsigned int op_type;
client_ptr_t addr;
mem_size_t size;
unsigned int zero_bits_64;
mem_size_t zero_bits;
unsigned int prot;
} virtual_alloc;
struct
@ -544,9 +544,9 @@ typedef union
client_ptr_t addr;
mem_size_t size;
file_pos_t offset;
mem_size_t zero_bits;
unsigned int alloc_type;
unsigned short zero_bits_64;
unsigned short prot;
unsigned int prot;
} map_view;
struct
{
@ -1270,7 +1270,7 @@ struct select_reply
apc_call_t call;
obj_handle_t apc_handle;
/* VARARG(context,context); */
char __pad_52[4];
char __pad_60[4];
};
#define SELECT_ALERTABLE 1
#define SELECT_INTERRUPTIBLE 2
@ -6683,7 +6683,7 @@ union generic_reply
/* ### protocol_version begin ### */
#define SERVER_PROTOCOL_VERSION 606
#define SERVER_PROTOCOL_VERSION 607
/* ### protocol_version end ### */

View File

@ -509,7 +509,7 @@ typedef union
unsigned int op_type; /* type of operation */
client_ptr_t addr; /* requested address */
mem_size_t size; /* allocation size */
unsigned int zero_bits_64; /* number of zero high bits */
mem_size_t zero_bits; /* number of zero high bits */
unsigned int prot; /* memory protection flags */
} virtual_alloc;
struct
@ -560,9 +560,9 @@ typedef union
client_ptr_t addr; /* requested address */
mem_size_t size; /* allocation size */
file_pos_t offset; /* file offset */
mem_size_t zero_bits; /* number of zero high bits */
unsigned int alloc_type; /* allocation type */
unsigned short zero_bits_64; /* number of zero high bits */
unsigned short prot; /* memory protection flags */
unsigned int prot; /* memory protection flags */
} map_view;
struct
{

View File

@ -719,7 +719,7 @@ static const req_handler req_handlers[REQ_NB_REQUESTS] =
C_ASSERT( sizeof(abstime_t) == 8 );
C_ASSERT( sizeof(affinity_t) == 8 );
C_ASSERT( sizeof(apc_call_t) == 40 );
C_ASSERT( sizeof(apc_call_t) == 48 );
C_ASSERT( sizeof(apc_param_t) == 8 );
C_ASSERT( sizeof(apc_result_t) == 40 );
C_ASSERT( sizeof(async_data_t) == 40 );
@ -891,7 +891,7 @@ C_ASSERT( FIELD_OFFSET(struct unload_dll_request, base) == 16 );
C_ASSERT( sizeof(struct unload_dll_request) == 24 );
C_ASSERT( FIELD_OFFSET(struct queue_apc_request, handle) == 12 );
C_ASSERT( FIELD_OFFSET(struct queue_apc_request, call) == 16 );
C_ASSERT( sizeof(struct queue_apc_request) == 56 );
C_ASSERT( sizeof(struct queue_apc_request) == 64 );
C_ASSERT( FIELD_OFFSET(struct queue_apc_reply, handle) == 8 );
C_ASSERT( FIELD_OFFSET(struct queue_apc_reply, self) == 12 );
C_ASSERT( sizeof(struct queue_apc_reply) == 16 );
@ -937,8 +937,8 @@ C_ASSERT( FIELD_OFFSET(struct select_request, size) == 32 );
C_ASSERT( FIELD_OFFSET(struct select_request, prev_apc) == 36 );
C_ASSERT( sizeof(struct select_request) == 40 );
C_ASSERT( FIELD_OFFSET(struct select_reply, call) == 8 );
C_ASSERT( FIELD_OFFSET(struct select_reply, apc_handle) == 48 );
C_ASSERT( sizeof(struct select_reply) == 56 );
C_ASSERT( FIELD_OFFSET(struct select_reply, apc_handle) == 56 );
C_ASSERT( sizeof(struct select_reply) == 64 );
C_ASSERT( FIELD_OFFSET(struct create_event_request, access) == 12 );
C_ASSERT( FIELD_OFFSET(struct create_event_request, manual_reset) == 16 );
C_ASSERT( FIELD_OFFSET(struct create_event_request, initial_state) == 20 );

View File

@ -177,9 +177,8 @@ static void dump_apc_call( const char *prefix, const apc_call_t *call )
case APC_VIRTUAL_ALLOC:
dump_uint64( "APC_VIRTUAL_ALLOC,addr==", &call->virtual_alloc.addr );
dump_uint64( ",size=", &call->virtual_alloc.size );
fprintf( stderr, ",zero_bits_64=%u,op_type=%x,prot=%x",
call->virtual_alloc.zero_bits_64, call->virtual_alloc.op_type,
call->virtual_alloc.prot );
dump_uint64( ",zero_bits=", &call->virtual_alloc.zero_bits );
fprintf( stderr, ",op_type=%x,prot=%x", call->virtual_alloc.op_type, call->virtual_alloc.prot );
break;
case APC_VIRTUAL_FREE:
dump_uint64( "APC_VIRTUAL_FREE,addr=", &call->virtual_free.addr );
@ -211,8 +210,8 @@ static void dump_apc_call( const char *prefix, const apc_call_t *call )
dump_uint64( ",addr=", &call->map_view.addr );
dump_uint64( ",size=", &call->map_view.size );
dump_uint64( ",offset=", &call->map_view.offset );
fprintf( stderr, ",zero_bits_64=%u,alloc_type=%x,prot=%x",
call->map_view.zero_bits_64, call->map_view.alloc_type, call->map_view.prot );
dump_uint64( ",zero_bits=", &call->map_view.zero_bits );
fprintf( stderr, ",alloc_type=%x,prot=%x", call->map_view.alloc_type, call->map_view.prot );
break;
case APC_UNMAP_VIEW:
dump_uint64( "APC_UNMAP_VIEW,addr=", &call->unmap_view.addr );

View File

@ -46,7 +46,7 @@ my %formats =
"abstime_t" => [ 8, 8, "&dump_abstime" ],
"rectangle_t" => [ 16, 4, "&dump_rectangle" ],
"char_info_t" => [ 4, 2, "&dump_char_info" ],
"apc_call_t" => [ 40, 8, "&dump_apc_call" ],
"apc_call_t" => [ 48, 8, "&dump_apc_call" ],
"apc_result_t" => [ 40, 8, "&dump_apc_result" ],
"async_data_t" => [ 40, 8, "&dump_async_data" ],
"irp_params_t" => [ 32, 8, "&dump_irp_params" ],