server: Access the list of committed ranges directly from the mapped view.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
7e6cf601f4
commit
26314a56d3
|
@ -1208,7 +1208,7 @@ static SIZE_T get_committed_size( struct file_view *view, void *base, BYTE *vpro
|
|||
SIZE_T ret = 0;
|
||||
SERVER_START_REQ( get_mapping_committed_range )
|
||||
{
|
||||
req->handle = wine_server_obj_handle( view->mapping );
|
||||
req->base = wine_server_client_ptr( view->base );
|
||||
req->offset = start << page_shift;
|
||||
if (!wine_server_call( req ))
|
||||
{
|
||||
|
@ -2320,7 +2320,7 @@ NTSTATUS WINAPI NtAllocateVirtualMemory( HANDLE process, PVOID *ret, ULONG zero_
|
|||
{
|
||||
SERVER_START_REQ( add_mapping_committed_range )
|
||||
{
|
||||
req->handle = wine_server_obj_handle( view->mapping );
|
||||
req->base = wine_server_client_ptr( view->base );
|
||||
req->offset = (char *)base - (char *)view->base;
|
||||
req->size = size;
|
||||
wine_server_call( req );
|
||||
|
|
|
@ -2261,7 +2261,8 @@ struct unmap_view_reply
|
|||
struct get_mapping_committed_range_request
|
||||
{
|
||||
struct request_header __header;
|
||||
obj_handle_t handle;
|
||||
char __pad_12[4];
|
||||
client_ptr_t base;
|
||||
file_pos_t offset;
|
||||
};
|
||||
struct get_mapping_committed_range_reply
|
||||
|
@ -2277,7 +2278,8 @@ struct get_mapping_committed_range_reply
|
|||
struct add_mapping_committed_range_request
|
||||
{
|
||||
struct request_header __header;
|
||||
obj_handle_t handle;
|
||||
char __pad_12[4];
|
||||
client_ptr_t base;
|
||||
file_pos_t offset;
|
||||
mem_size_t size;
|
||||
};
|
||||
|
@ -6444,6 +6446,6 @@ union generic_reply
|
|||
struct terminate_job_reply terminate_job_reply;
|
||||
};
|
||||
|
||||
#define SERVER_PROTOCOL_VERSION 538
|
||||
#define SERVER_PROTOCOL_VERSION 539
|
||||
|
||||
#endif /* __WINE_WINE_SERVER_PROTOCOL_H */
|
||||
|
|
|
@ -85,6 +85,7 @@ static const struct object_ops ranges_ops =
|
|||
struct memory_view
|
||||
{
|
||||
struct list entry; /* entry in per-process view list */
|
||||
struct ranges *committed; /* list of committed ranges in this mapping */
|
||||
unsigned int flags; /* SEC_* flags */
|
||||
client_ptr_t base; /* view base address (in process addr space) */
|
||||
mem_size_t size; /* view size */
|
||||
|
@ -258,6 +259,7 @@ static struct memory_view *find_mapped_view( struct process *process, client_ptr
|
|||
|
||||
static void free_memory_view( struct memory_view *view )
|
||||
{
|
||||
if (view->committed) release_object( view->committed );
|
||||
list_remove( &view->entry );
|
||||
free( view );
|
||||
}
|
||||
|
@ -297,14 +299,25 @@ static inline void get_section_sizes( const IMAGE_SECTION_HEADER *sec, size_t *m
|
|||
}
|
||||
|
||||
/* add a range to the committed list */
|
||||
static void add_committed_range( struct mapping *mapping, file_pos_t start, file_pos_t end )
|
||||
static void add_committed_range( struct memory_view *view, file_pos_t start, file_pos_t end )
|
||||
{
|
||||
unsigned int i, j;
|
||||
struct ranges *committed = mapping->committed;
|
||||
struct ranges *committed = view->committed;
|
||||
struct range *ranges;
|
||||
|
||||
if ((start & page_mask) || (end & page_mask) ||
|
||||
start >= view->size || end >= view->size ||
|
||||
start >= end)
|
||||
{
|
||||
set_error( STATUS_INVALID_PARAMETER );
|
||||
return;
|
||||
}
|
||||
|
||||
if (!committed) return; /* everything committed already */
|
||||
|
||||
start += view->start;
|
||||
end += view->start;
|
||||
|
||||
for (i = 0, ranges = committed->ranges; i < committed->count; i++)
|
||||
{
|
||||
if (ranges[i].start > end) break;
|
||||
|
@ -344,31 +357,36 @@ static void add_committed_range( struct mapping *mapping, file_pos_t start, file
|
|||
}
|
||||
|
||||
/* find the range containing start and return whether it's committed */
|
||||
static int find_committed_range( struct mapping *mapping, file_pos_t start, mem_size_t *size )
|
||||
static int find_committed_range( struct memory_view *view, file_pos_t start, mem_size_t *size )
|
||||
{
|
||||
unsigned int i;
|
||||
struct ranges *committed = mapping->committed;
|
||||
struct ranges *committed = view->committed;
|
||||
struct range *ranges;
|
||||
|
||||
if ((start & page_mask) || start >= view->size)
|
||||
{
|
||||
set_error( STATUS_INVALID_PARAMETER );
|
||||
return 0;
|
||||
}
|
||||
if (!committed) /* everything is committed */
|
||||
{
|
||||
*size = mapping->size - start;
|
||||
*size = view->size - start;
|
||||
return 1;
|
||||
}
|
||||
for (i = 0, ranges = committed->ranges; i < committed->count; i++)
|
||||
{
|
||||
if (ranges[i].start > start)
|
||||
if (ranges[i].start > view->start + start)
|
||||
{
|
||||
*size = ranges[i].start - start;
|
||||
*size = min( ranges[i].start, view->start + view->size ) - (view->start + start);
|
||||
return 0;
|
||||
}
|
||||
if (ranges[i].end > start)
|
||||
if (ranges[i].end > view->start + start)
|
||||
{
|
||||
*size = ranges[i].end - start;
|
||||
*size = min( ranges[i].end, view->start + view->size ) - (view->start + start);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
*size = mapping->size - start;
|
||||
*size = view->size - start;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -907,6 +925,7 @@ DECL_HANDLER(map_view)
|
|||
view->size = req->size;
|
||||
view->start = req->start;
|
||||
view->flags = mapping->flags;
|
||||
view->committed = mapping->committed ? (struct ranges *)grab_object( mapping->committed ) : NULL;
|
||||
list_add_tail( ¤t->process->views, &view->entry );
|
||||
}
|
||||
|
||||
|
@ -925,35 +944,15 @@ DECL_HANDLER(unmap_view)
|
|||
/* get a range of committed pages in a file mapping */
|
||||
DECL_HANDLER(get_mapping_committed_range)
|
||||
{
|
||||
struct mapping *mapping;
|
||||
struct memory_view *view = find_mapped_view( current->process, req->base );
|
||||
|
||||
if ((mapping = get_mapping_obj( current->process, req->handle, 0 )))
|
||||
{
|
||||
if (!(req->offset & page_mask) && req->offset < mapping->size)
|
||||
reply->committed = find_committed_range( mapping, req->offset, &reply->size );
|
||||
else
|
||||
set_error( STATUS_INVALID_PARAMETER );
|
||||
|
||||
release_object( mapping );
|
||||
}
|
||||
if (view) reply->committed = find_committed_range( view, req->offset, &reply->size );
|
||||
}
|
||||
|
||||
/* add a range to the committed pages in a file mapping */
|
||||
DECL_HANDLER(add_mapping_committed_range)
|
||||
{
|
||||
struct mapping *mapping;
|
||||
struct memory_view *view = find_mapped_view( current->process, req->base );
|
||||
|
||||
if ((mapping = get_mapping_obj( current->process, req->handle, 0 )))
|
||||
{
|
||||
if (!(req->size & page_mask) &&
|
||||
!(req->offset & page_mask) &&
|
||||
req->offset < mapping->size &&
|
||||
req->size > 0 &&
|
||||
req->size <= mapping->size - req->offset)
|
||||
add_committed_range( mapping, req->offset, req->offset + req->size );
|
||||
else
|
||||
set_error( STATUS_INVALID_PARAMETER );
|
||||
|
||||
release_object( mapping );
|
||||
}
|
||||
if (view) add_committed_range( view, req->offset, req->offset + req->size );
|
||||
}
|
||||
|
|
|
@ -1744,7 +1744,7 @@ enum char_info_mode
|
|||
|
||||
/* Get a range of committed pages in a file mapping */
|
||||
@REQ(get_mapping_committed_range)
|
||||
obj_handle_t handle; /* handle to the mapping */
|
||||
client_ptr_t base; /* view base address */
|
||||
file_pos_t offset; /* starting offset (page-aligned, in bytes) */
|
||||
@REPLY
|
||||
mem_size_t size; /* size of range starting at offset (page-aligned, in bytes) */
|
||||
|
@ -1754,7 +1754,7 @@ enum char_info_mode
|
|||
|
||||
/* Add a range to the committed pages in a file mapping */
|
||||
@REQ(add_mapping_committed_range)
|
||||
obj_handle_t handle; /* handle to the mapping */
|
||||
client_ptr_t base; /* view base address */
|
||||
file_pos_t offset; /* starting offset (page-aligned, in bytes) */
|
||||
mem_size_t size; /* size to set (page-aligned, in bytes) or 0 if only retrieving */
|
||||
@END
|
||||
|
|
|
@ -1278,16 +1278,16 @@ C_ASSERT( FIELD_OFFSET(struct map_view_request, start) == 40 );
|
|||
C_ASSERT( sizeof(struct map_view_request) == 48 );
|
||||
C_ASSERT( FIELD_OFFSET(struct unmap_view_request, base) == 16 );
|
||||
C_ASSERT( sizeof(struct unmap_view_request) == 24 );
|
||||
C_ASSERT( FIELD_OFFSET(struct get_mapping_committed_range_request, handle) == 12 );
|
||||
C_ASSERT( FIELD_OFFSET(struct get_mapping_committed_range_request, offset) == 16 );
|
||||
C_ASSERT( sizeof(struct get_mapping_committed_range_request) == 24 );
|
||||
C_ASSERT( FIELD_OFFSET(struct get_mapping_committed_range_request, base) == 16 );
|
||||
C_ASSERT( FIELD_OFFSET(struct get_mapping_committed_range_request, offset) == 24 );
|
||||
C_ASSERT( sizeof(struct get_mapping_committed_range_request) == 32 );
|
||||
C_ASSERT( FIELD_OFFSET(struct get_mapping_committed_range_reply, size) == 8 );
|
||||
C_ASSERT( FIELD_OFFSET(struct get_mapping_committed_range_reply, committed) == 16 );
|
||||
C_ASSERT( sizeof(struct get_mapping_committed_range_reply) == 24 );
|
||||
C_ASSERT( FIELD_OFFSET(struct add_mapping_committed_range_request, handle) == 12 );
|
||||
C_ASSERT( FIELD_OFFSET(struct add_mapping_committed_range_request, offset) == 16 );
|
||||
C_ASSERT( FIELD_OFFSET(struct add_mapping_committed_range_request, size) == 24 );
|
||||
C_ASSERT( sizeof(struct add_mapping_committed_range_request) == 32 );
|
||||
C_ASSERT( FIELD_OFFSET(struct add_mapping_committed_range_request, base) == 16 );
|
||||
C_ASSERT( FIELD_OFFSET(struct add_mapping_committed_range_request, offset) == 24 );
|
||||
C_ASSERT( FIELD_OFFSET(struct add_mapping_committed_range_request, size) == 32 );
|
||||
C_ASSERT( sizeof(struct add_mapping_committed_range_request) == 40 );
|
||||
C_ASSERT( FIELD_OFFSET(struct create_snapshot_request, attributes) == 12 );
|
||||
C_ASSERT( FIELD_OFFSET(struct create_snapshot_request, flags) == 16 );
|
||||
C_ASSERT( sizeof(struct create_snapshot_request) == 24 );
|
||||
|
|
|
@ -2259,7 +2259,7 @@ static void dump_unmap_view_request( const struct unmap_view_request *req )
|
|||
|
||||
static void dump_get_mapping_committed_range_request( const struct get_mapping_committed_range_request *req )
|
||||
{
|
||||
fprintf( stderr, " handle=%04x", req->handle );
|
||||
dump_uint64( " base=", &req->base );
|
||||
dump_uint64( ", offset=", &req->offset );
|
||||
}
|
||||
|
||||
|
@ -2271,7 +2271,7 @@ static void dump_get_mapping_committed_range_reply( const struct get_mapping_com
|
|||
|
||||
static void dump_add_mapping_committed_range_request( const struct add_mapping_committed_range_request *req )
|
||||
{
|
||||
fprintf( stderr, " handle=%04x", req->handle );
|
||||
dump_uint64( " base=", &req->base );
|
||||
dump_uint64( ", offset=", &req->offset );
|
||||
dump_uint64( ", size=", &req->size );
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue