Commit b1b4f5d4 authored by Alexandre Julliard's avatar Alexandre Julliard

server: Store the mapped file descriptor in the memory view.

parent 26314a56
...@@ -169,8 +169,8 @@ static int fill_create_process_event( struct debug_event *event, const void *arg ...@@ -169,8 +169,8 @@ static int fill_create_process_event( struct debug_event *event, const void *arg
event->data.create_process.name = exe_module->name; event->data.create_process.name = exe_module->name;
event->data.create_process.unicode = 1; event->data.create_process.unicode = 1;
if (exe_module->mapping) /* the doc says write access too, but this doesn't seem a good idea */ /* the doc says write access too, but this doesn't seem a good idea */
event->data.create_process.file = open_mapping_file( debugger, exe_module->mapping, GENERIC_READ, event->data.create_process.file = open_mapping_file( debugger, exe_module->base, GENERIC_READ,
FILE_SHARE_READ | FILE_SHARE_WRITE ); FILE_SHARE_READ | FILE_SHARE_WRITE );
return 1; return 1;
} }
...@@ -200,8 +200,7 @@ static int fill_load_dll_event( struct debug_event *event, const void *arg ) ...@@ -200,8 +200,7 @@ static int fill_load_dll_event( struct debug_event *event, const void *arg )
event->data.load_dll.dbg_size = dll->dbg_size; event->data.load_dll.dbg_size = dll->dbg_size;
event->data.load_dll.name = dll->name; event->data.load_dll.name = dll->name;
event->data.load_dll.unicode = 1; event->data.load_dll.unicode = 1;
if (dll->mapping) event->data.load_dll.handle = open_mapping_file( debugger, dll->base, GENERIC_READ,
event->data.load_dll.handle = open_mapping_file( debugger, dll->mapping, GENERIC_READ,
FILE_SHARE_READ | FILE_SHARE_WRITE ); FILE_SHARE_READ | FILE_SHARE_WRITE );
return 1; return 1;
} }
......
...@@ -147,7 +147,7 @@ extern mode_t sd_to_mode( const struct security_descriptor *sd, const SID *owner ...@@ -147,7 +147,7 @@ extern mode_t sd_to_mode( const struct security_descriptor *sd, const SID *owner
extern struct mapping *get_mapping_obj( struct process *process, obj_handle_t handle, extern struct mapping *get_mapping_obj( struct process *process, obj_handle_t handle,
unsigned int access ); unsigned int access );
extern obj_handle_t open_mapping_file( struct process *process, struct mapping *mapping, extern obj_handle_t open_mapping_file( struct process *process, client_ptr_t base,
unsigned int access, unsigned int sharing ); unsigned int access, unsigned int sharing );
extern struct mapping *grab_mapping_unless_removable( struct mapping *mapping ); extern struct mapping *grab_mapping_unless_removable( struct mapping *mapping );
extern void free_mapped_views( struct process *process ); extern void free_mapped_views( struct process *process );
......
...@@ -85,6 +85,7 @@ static const struct object_ops ranges_ops = ...@@ -85,6 +85,7 @@ static const struct object_ops ranges_ops =
struct memory_view struct memory_view
{ {
struct list entry; /* entry in per-process view list */ struct list entry; /* entry in per-process view list */
struct fd *fd; /* fd for mapped file */
struct ranges *committed; /* list of committed ranges in this mapping */ struct ranges *committed; /* list of committed ranges in this mapping */
unsigned int flags; /* SEC_* flags */ unsigned int flags; /* SEC_* flags */
client_ptr_t base; /* view base address (in process addr space) */ client_ptr_t base; /* view base address (in process addr space) */
...@@ -259,6 +260,7 @@ static struct memory_view *find_mapped_view( struct process *process, client_ptr ...@@ -259,6 +260,7 @@ static struct memory_view *find_mapped_view( struct process *process, client_ptr
static void free_memory_view( struct memory_view *view ) static void free_memory_view( struct memory_view *view )
{ {
if (view->fd) release_object( view->fd );
if (view->committed) release_object( view->committed ); if (view->committed) release_object( view->committed );
list_remove( &view->entry ); list_remove( &view->entry );
free( view ); free( view );
...@@ -731,13 +733,15 @@ struct mapping *get_mapping_obj( struct process *process, obj_handle_t handle, u ...@@ -731,13 +733,15 @@ struct mapping *get_mapping_obj( struct process *process, obj_handle_t handle, u
} }
/* open a new file handle to the file backing the mapping */ /* open a new file handle to the file backing the mapping */
obj_handle_t open_mapping_file( struct process *process, struct mapping *mapping, obj_handle_t open_mapping_file( struct process *process, client_ptr_t base,
unsigned int access, unsigned int sharing ) unsigned int access, unsigned int sharing )
{ {
obj_handle_t handle; obj_handle_t handle;
struct file *file = create_file_for_fd_obj( mapping->fd, access, sharing ); struct memory_view *view = find_mapped_view( process, base );
struct file *file;
if (!file) return 0; if (!view || !view->fd) return 0;
if (!(file = create_file_for_fd_obj( view->fd, access, sharing ))) return 0;
handle = alloc_handle( process, file, access, 0 ); handle = alloc_handle( process, file, access, 0 );
release_object( file ); release_object( file );
return handle; return handle;
...@@ -925,6 +929,7 @@ DECL_HANDLER(map_view) ...@@ -925,6 +929,7 @@ DECL_HANDLER(map_view)
view->size = req->size; view->size = req->size;
view->start = req->start; view->start = req->start;
view->flags = mapping->flags; view->flags = mapping->flags;
view->fd = !is_fd_removable( mapping->fd ) ? (struct fd *)grab_object( mapping->fd ) : NULL;
view->committed = mapping->committed ? (struct ranges *)grab_object( mapping->committed ) : NULL; view->committed = mapping->committed ? (struct ranges *)grab_object( mapping->committed ) : NULL;
list_add_tail( &current->process->views, &view->entry ); list_add_tail( &current->process->views, &view->entry );
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment