ntdll: Moved the check for removable file in load_dll to the server.
This commit is contained in:
parent
c255bf4676
commit
5bd513640b
|
@ -1438,9 +1438,6 @@ static NTSTATUS load_native_dll( LPCWSTR load_path, LPCWSTR name, HANDLE file,
|
||||||
|
|
||||||
nt = RtlImageNtHeader( module );
|
nt = RtlImageNtHeader( module );
|
||||||
|
|
||||||
/* don't keep the file open if the mapping is from removable media */
|
|
||||||
if (!VIRTUAL_HasMapping( module )) file = 0;
|
|
||||||
|
|
||||||
SERVER_START_REQ( load_dll )
|
SERVER_START_REQ( load_dll )
|
||||||
{
|
{
|
||||||
req->handle = file;
|
req->handle = file;
|
||||||
|
|
|
@ -111,7 +111,6 @@ extern NTSTATUS DIR_get_unix_cwd( char **cwd );
|
||||||
|
|
||||||
/* virtual memory */
|
/* virtual memory */
|
||||||
extern NTSTATUS VIRTUAL_HandleFault(LPCVOID addr);
|
extern NTSTATUS VIRTUAL_HandleFault(LPCVOID addr);
|
||||||
extern BOOL VIRTUAL_HasMapping( LPCVOID addr );
|
|
||||||
extern void VIRTUAL_SetForceExec( BOOL enable );
|
extern void VIRTUAL_SetForceExec( BOOL enable );
|
||||||
extern void VIRTUAL_UseLargeAddressSpace(void);
|
extern void VIRTUAL_UseLargeAddressSpace(void);
|
||||||
|
|
||||||
|
|
|
@ -1291,22 +1291,6 @@ NTSTATUS VIRTUAL_HandleFault( LPCVOID addr )
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/***********************************************************************
|
|
||||||
* VIRTUAL_HasMapping
|
|
||||||
*
|
|
||||||
* Check if the specified view has an associated file mapping.
|
|
||||||
*/
|
|
||||||
BOOL VIRTUAL_HasMapping( LPCVOID addr )
|
|
||||||
{
|
|
||||||
FILE_VIEW *view;
|
|
||||||
BOOL ret = FALSE;
|
|
||||||
|
|
||||||
RtlEnterCriticalSection( &csVirtual );
|
|
||||||
if ((view = VIRTUAL_FindView( addr ))) ret = (view->mapping != 0);
|
|
||||||
RtlLeaveCriticalSection( &csVirtual );
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* VIRTUAL_SetForceExec
|
* VIRTUAL_SetForceExec
|
||||||
|
|
|
@ -1668,6 +1668,12 @@ int is_same_file_fd( struct fd *fd1, struct fd *fd2 )
|
||||||
return fd1->inode == fd2->inode;
|
return fd1->inode == fd2->inode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* check if fd is on a removable device */
|
||||||
|
int is_fd_removable( struct fd *fd )
|
||||||
|
{
|
||||||
|
return (fd->inode && fd->inode->device->removable);
|
||||||
|
}
|
||||||
|
|
||||||
/* handler for close_handle that refuses to close fd-associated handles in other processes */
|
/* handler for close_handle that refuses to close fd-associated handles in other processes */
|
||||||
int fd_close_handle( struct object *obj, struct process *process, obj_handle_t handle )
|
int fd_close_handle( struct object *obj, struct process *process, obj_handle_t handle )
|
||||||
{
|
{
|
||||||
|
@ -1966,7 +1972,7 @@ DECL_HANDLER(get_handle_fd)
|
||||||
reply->type = fd->fd_ops->get_file_info( fd, &reply->flags );
|
reply->type = fd->fd_ops->get_file_info( fd, &reply->flags );
|
||||||
if (reply->type != FD_TYPE_INVALID)
|
if (reply->type != FD_TYPE_INVALID)
|
||||||
{
|
{
|
||||||
if (fd->inode && fd->inode->device->removable) reply->flags |= FD_FLAG_REMOVABLE;
|
if (is_fd_removable(fd)) reply->flags |= FD_FLAG_REMOVABLE;
|
||||||
if (!req->cached)
|
if (!req->cached)
|
||||||
{
|
{
|
||||||
int unix_fd = get_unix_fd( fd );
|
int unix_fd = get_unix_fd( fd );
|
||||||
|
|
|
@ -319,6 +319,12 @@ int get_file_unix_fd( struct file *file )
|
||||||
return get_unix_fd( file->fd );
|
return get_unix_fd( file->fd );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct file *grab_file_unless_removable( struct file *file )
|
||||||
|
{
|
||||||
|
if (is_fd_removable( file->fd )) return NULL;
|
||||||
|
return (struct file *)grab_object( file );
|
||||||
|
}
|
||||||
|
|
||||||
/* extend a file beyond the current end of file */
|
/* extend a file beyond the current end of file */
|
||||||
static int extend_file( struct file *file, file_pos_t new_size )
|
static int extend_file( struct file *file, file_pos_t new_size )
|
||||||
{
|
{
|
||||||
|
|
|
@ -55,6 +55,7 @@ extern void *get_fd_user( struct fd *fd );
|
||||||
extern void set_fd_user( struct fd *fd, const struct fd_ops *ops, struct object *user );
|
extern void set_fd_user( struct fd *fd, const struct fd_ops *ops, struct object *user );
|
||||||
extern int get_unix_fd( struct fd *fd );
|
extern int get_unix_fd( struct fd *fd );
|
||||||
extern int is_same_file_fd( struct fd *fd1, struct fd *fd2 );
|
extern int is_same_file_fd( struct fd *fd1, struct fd *fd2 );
|
||||||
|
extern int is_fd_removable( struct fd *fd );
|
||||||
extern int fd_close_handle( struct object *obj, struct process *process, obj_handle_t handle );
|
extern int fd_close_handle( struct object *obj, struct process *process, obj_handle_t handle );
|
||||||
extern void fd_poll_event( struct fd *fd, int event );
|
extern void fd_poll_event( struct fd *fd, int event );
|
||||||
extern int check_fd_events( struct fd *fd, int events );
|
extern int check_fd_events( struct fd *fd, int events );
|
||||||
|
@ -104,6 +105,7 @@ extern struct file *get_file_obj( struct process *process, obj_handle_t handle,
|
||||||
unsigned int access );
|
unsigned int access );
|
||||||
extern int get_file_unix_fd( struct file *file );
|
extern int get_file_unix_fd( struct file *file );
|
||||||
extern int is_same_file( struct file *file1, struct file *file2 );
|
extern int is_same_file( struct file *file1, struct file *file2 );
|
||||||
|
extern struct file *grab_file_unless_removable( struct file *file );
|
||||||
extern int grow_file( struct file *file, file_pos_t size );
|
extern int grow_file( struct file *file, file_pos_t size );
|
||||||
extern struct file *create_temp_file( int access );
|
extern struct file *create_temp_file( int access );
|
||||||
extern void file_set_error(void);
|
extern void file_set_error(void);
|
||||||
|
|
|
@ -492,7 +492,7 @@ static struct process_dll *process_load_dll( struct process *process, struct fil
|
||||||
free( dll );
|
free( dll );
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (file) dll->file = (struct file *)grab_object( file );
|
if (file) dll->file = grab_file_unless_removable( file );
|
||||||
list_add_tail( &process->dlls, &dll->entry );
|
list_add_tail( &process->dlls, &dll->entry );
|
||||||
}
|
}
|
||||||
return dll;
|
return dll;
|
||||||
|
|
Loading…
Reference in New Issue