Store a "removable" flag instead of the full drive type in the server
file object; this way we don't need to use GetDriveTypeW in the loader code. Make sure we always have a valid builtin_load_info pointer.
This commit is contained in:
parent
146afcc98c
commit
af192f83b6
|
@ -1124,7 +1124,6 @@ static NTSTATUS load_native_dll( LPCWSTR load_path, LPCWSTR name, HANDLE file,
|
|||
DWORD len = 0;
|
||||
WINE_MODREF *wm;
|
||||
NTSTATUS status;
|
||||
UINT drive_type;
|
||||
|
||||
TRACE( "loading %s\n", debugstr_w(name) );
|
||||
|
||||
|
@ -1175,7 +1174,6 @@ static NTSTATUS load_native_dll( LPCWSTR load_path, LPCWSTR name, HANDLE file,
|
|||
/* send DLL load event */
|
||||
|
||||
nt = RtlImageNtHeader( module );
|
||||
drive_type = GetDriveTypeW( wm->ldr.FullDllName.Buffer );
|
||||
|
||||
SERVER_START_REQ( load_dll )
|
||||
{
|
||||
|
@ -1185,8 +1183,6 @@ static NTSTATUS load_native_dll( LPCWSTR load_path, LPCWSTR name, HANDLE file,
|
|||
req->dbg_offset = nt->FileHeader.PointerToSymbolTable;
|
||||
req->dbg_size = nt->FileHeader.NumberOfSymbols;
|
||||
req->name = &wm->ldr.FullDllName.Buffer;
|
||||
/* don't keep the file handle open on removable media */
|
||||
if (drive_type == DRIVE_REMOVABLE || drive_type == DRIVE_CDROM) req->handle = 0;
|
||||
wine_server_add_data( req, wm->ldr.FullDllName.Buffer, wm->ldr.FullDllName.Length );
|
||||
wine_server_call( req );
|
||||
}
|
||||
|
@ -1887,20 +1883,18 @@ PVOID WINAPI RtlImageRvaToVa( const IMAGE_NT_HEADERS *nt, HMODULE module,
|
|||
*/
|
||||
HMODULE BUILTIN32_LoadExeModule( HMODULE main )
|
||||
{
|
||||
struct builtin_load_info info, *prev_info;
|
||||
static struct builtin_load_info default_info;
|
||||
|
||||
if (!MODULE_GetSystemDirectory( &system_dir ))
|
||||
MESSAGE( "Couldn't get system dir in process init\n");
|
||||
NtCurrentTeb()->Peb->ImageBaseAddress = main;
|
||||
info.status = STATUS_SUCCESS;
|
||||
info.load_path = NtCurrentTeb()->Peb->ProcessParameters->DllPath.Buffer;
|
||||
prev_info = builtin_load_info;
|
||||
builtin_load_info = &info;
|
||||
default_info.status = STATUS_SUCCESS;
|
||||
default_info.load_path = NtCurrentTeb()->Peb->ProcessParameters->DllPath.Buffer;
|
||||
builtin_load_info = &default_info;
|
||||
wine_dll_set_callback( load_builtin_callback );
|
||||
builtin_load_info = prev_info;
|
||||
if (!NtCurrentTeb()->Peb->ImageBaseAddress)
|
||||
MESSAGE( "No built-in EXE module loaded! Did you create a .spec file?\n" );
|
||||
if (info.status != STATUS_SUCCESS)
|
||||
if (default_info.status != STATUS_SUCCESS)
|
||||
MESSAGE( "Error while processing initial modules\n");
|
||||
return NtCurrentTeb()->Peb->ImageBaseAddress;
|
||||
}
|
||||
|
|
|
@ -1404,8 +1404,7 @@ NTSTATUS WINAPI NtMapViewOfSection( HANDLE handle, HANDLE process, PVOID *addr_p
|
|||
header_size = reply->header_size;
|
||||
shared_file = reply->shared_file;
|
||||
shared_size = reply->shared_size;
|
||||
removable = (reply->drive_type == DRIVE_REMOVABLE ||
|
||||
reply->drive_type == DRIVE_CDROM);
|
||||
removable = reply->removable;
|
||||
}
|
||||
SERVER_END_REQ;
|
||||
if (res) goto error;
|
||||
|
|
|
@ -416,7 +416,7 @@ HANDLE FILE_CreateFile( LPCSTR filename, DWORD access, DWORD sharing,
|
|||
req->sharing = sharing;
|
||||
req->create = creation;
|
||||
req->attrs = attributes;
|
||||
req->drive_type = drive_type;
|
||||
req->removable = (drive_type == DRIVE_REMOVABLE || drive_type == DRIVE_CDROM);
|
||||
wine_server_add_data( req, filename, strlen(filename) );
|
||||
SetLastError(0);
|
||||
err = wine_server_call( req );
|
||||
|
|
|
@ -753,7 +753,7 @@ struct create_file_request
|
|||
unsigned int sharing;
|
||||
int create;
|
||||
unsigned int attrs;
|
||||
int drive_type;
|
||||
int removable;
|
||||
/* VARARG(filename,string); */
|
||||
};
|
||||
struct create_file_reply
|
||||
|
@ -1501,7 +1501,7 @@ struct get_mapping_info_reply
|
|||
void* base;
|
||||
obj_handle_t shared_file;
|
||||
int shared_size;
|
||||
int drive_type;
|
||||
int removable;
|
||||
};
|
||||
|
||||
|
||||
|
@ -3668,6 +3668,6 @@ union generic_reply
|
|||
struct set_global_windows_reply set_global_windows_reply;
|
||||
};
|
||||
|
||||
#define SERVER_PROTOCOL_VERSION 124
|
||||
#define SERVER_PROTOCOL_VERSION 125
|
||||
|
||||
#endif /* __WINE_WINE_SERVER_PROTOCOL_H */
|
||||
|
|
|
@ -59,7 +59,7 @@ struct file
|
|||
unsigned int access; /* file access (GENERIC_READ/WRITE) */
|
||||
unsigned int flags; /* flags (FILE_FLAG_*) */
|
||||
unsigned int sharing; /* file sharing mode */
|
||||
int drive_type; /* type of drive the file is on */
|
||||
int removable; /* is file on removable media? */
|
||||
struct async_queue read_q;
|
||||
struct async_queue write_q;
|
||||
};
|
||||
|
@ -134,7 +134,7 @@ static int check_sharing( const char *name, int hash, unsigned int access,
|
|||
/* create a file from a file descriptor */
|
||||
/* if the function fails the fd is closed */
|
||||
static struct file *create_file_for_fd( int fd, unsigned int access, unsigned int sharing,
|
||||
unsigned int attrs, int drive_type )
|
||||
unsigned int attrs, int removable )
|
||||
{
|
||||
struct file *file;
|
||||
|
||||
|
@ -145,7 +145,7 @@ static struct file *create_file_for_fd( int fd, unsigned int access, unsigned in
|
|||
file->access = access;
|
||||
file->flags = attrs;
|
||||
file->sharing = sharing;
|
||||
file->drive_type = drive_type;
|
||||
file->removable = removable;
|
||||
if (file->flags & FILE_FLAG_OVERLAPPED)
|
||||
{
|
||||
init_async_queue (&file->read_q);
|
||||
|
@ -163,7 +163,7 @@ static struct file *create_file_for_fd( int fd, unsigned int access, unsigned in
|
|||
|
||||
static struct file *create_file( const char *nameptr, size_t len, unsigned int access,
|
||||
unsigned int sharing, int create, unsigned int attrs,
|
||||
int drive_type )
|
||||
int removable )
|
||||
{
|
||||
struct file *file;
|
||||
int hash, flags;
|
||||
|
@ -205,7 +205,7 @@ static struct file *create_file( const char *nameptr, size_t len, unsigned int a
|
|||
file->access = access;
|
||||
file->flags = attrs;
|
||||
file->sharing = sharing;
|
||||
file->drive_type = drive_type;
|
||||
file->removable = removable;
|
||||
file->name = name;
|
||||
file->next = file_hash[hash];
|
||||
file_hash[hash] = file;
|
||||
|
@ -242,10 +242,10 @@ int is_same_file( struct file *file1, struct file *file2 )
|
|||
return !strcmp( file1->name, file2->name );
|
||||
}
|
||||
|
||||
/* get the type of drive the file is on */
|
||||
int get_file_drive_type( struct file *file )
|
||||
/* check if the file is on removable media */
|
||||
int is_file_removable( struct file *file )
|
||||
{
|
||||
return file->drive_type;
|
||||
return file->removable;
|
||||
}
|
||||
|
||||
/* create a temp file for anonymous mappings */
|
||||
|
@ -262,7 +262,7 @@ struct file *create_temp_file( int access )
|
|||
return NULL;
|
||||
}
|
||||
unlink( tmpfn );
|
||||
return create_file_for_fd( fd, access, 0, 0, DRIVE_FIXED );
|
||||
return create_file_for_fd( fd, access, 0, 0, FALSE );
|
||||
}
|
||||
|
||||
static void file_dump( struct object *obj, int verbose )
|
||||
|
@ -598,7 +598,7 @@ DECL_HANDLER(create_file)
|
|||
|
||||
reply->handle = 0;
|
||||
if ((file = create_file( get_req_data(), get_req_data_size(), req->access,
|
||||
req->sharing, req->create, req->attrs, req->drive_type )))
|
||||
req->sharing, req->create, req->attrs, req->removable )))
|
||||
{
|
||||
reply->handle = alloc_handle( current->process, file, req->access, req->inherit );
|
||||
release_object( file );
|
||||
|
@ -618,7 +618,7 @@ DECL_HANDLER(alloc_file_handle)
|
|||
return;
|
||||
}
|
||||
if ((file = create_file_for_fd( fd, req->access, FILE_SHARE_READ | FILE_SHARE_WRITE,
|
||||
0, DRIVE_UNKNOWN )))
|
||||
0, FALSE )))
|
||||
{
|
||||
reply->handle = alloc_handle( current->process, file, req->access, req->inherit );
|
||||
release_object( file );
|
||||
|
|
|
@ -91,7 +91,7 @@ extern struct file *get_file_obj( struct process *process, obj_handle_t handle,
|
|||
unsigned int access );
|
||||
extern int get_file_unix_fd( struct file *file );
|
||||
extern int is_same_file( struct file *file1, struct file *file2 );
|
||||
extern int get_file_drive_type( struct file *file );
|
||||
extern int is_file_removable( struct file *file );
|
||||
extern int grow_file( struct file *file, int size_high, int size_low );
|
||||
extern struct file *create_temp_file( int access );
|
||||
extern void file_set_error(void);
|
||||
|
|
|
@ -391,7 +391,7 @@ DECL_HANDLER(get_mapping_info)
|
|||
reply->base = mapping->base;
|
||||
reply->shared_file = 0;
|
||||
reply->shared_size = mapping->shared_size;
|
||||
reply->drive_type = get_file_drive_type( mapping->file );
|
||||
reply->removable = is_file_removable( mapping->file );
|
||||
if (mapping->shared_file)
|
||||
reply->shared_file = alloc_handle( current->process, mapping->shared_file,
|
||||
GENERIC_READ|GENERIC_WRITE, 0 );
|
||||
|
|
|
@ -1107,8 +1107,15 @@ DECL_HANDLER(load_dll)
|
|||
struct process_dll *dll;
|
||||
struct file *file = NULL;
|
||||
|
||||
if (req->handle &&
|
||||
!(file = get_file_obj( current->process, req->handle, GENERIC_READ ))) return;
|
||||
if (req->handle)
|
||||
{
|
||||
if (!(file = get_file_obj( current->process, req->handle, GENERIC_READ ))) return;
|
||||
if (is_file_removable( file )) /* don't keep the file open on removable media */
|
||||
{
|
||||
release_object( file );
|
||||
file = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if ((dll = process_load_dll( current->process, file, req->base,
|
||||
get_req_data(), get_req_data_size() )))
|
||||
|
|
|
@ -578,7 +578,7 @@ enum event_op { PULSE_EVENT, SET_EVENT, RESET_EVENT };
|
|||
unsigned int sharing; /* sharing flags */
|
||||
int create; /* file create action */
|
||||
unsigned int attrs; /* file attributes for creation */
|
||||
int drive_type; /* type of drive the file is on */
|
||||
int removable; /* is file on removable media? */
|
||||
VARARG(filename,string); /* file name */
|
||||
@REPLY
|
||||
obj_handle_t handle; /* handle to the file */
|
||||
|
@ -1104,7 +1104,7 @@ enum char_info_mode
|
|||
void* base; /* default base addr (for VPROT_IMAGE mapping) */
|
||||
obj_handle_t shared_file; /* shared mapping file handle */
|
||||
int shared_size; /* shared mapping size */
|
||||
int drive_type; /* type of drive the file is on */
|
||||
int removable; /* is file on removable media? */
|
||||
@END
|
||||
|
||||
|
||||
|
|
|
@ -841,7 +841,7 @@ static void dump_create_file_request( const struct create_file_request *req )
|
|||
fprintf( stderr, " sharing=%08x,", req->sharing );
|
||||
fprintf( stderr, " create=%d,", req->create );
|
||||
fprintf( stderr, " attrs=%08x,", req->attrs );
|
||||
fprintf( stderr, " drive_type=%d,", req->drive_type );
|
||||
fprintf( stderr, " removable=%d,", req->removable );
|
||||
fprintf( stderr, " filename=" );
|
||||
dump_varargs_string( cur_size );
|
||||
}
|
||||
|
@ -1348,7 +1348,7 @@ static void dump_get_mapping_info_reply( const struct get_mapping_info_reply *re
|
|||
fprintf( stderr, " base=%p,", req->base );
|
||||
fprintf( stderr, " shared_file=%p,", req->shared_file );
|
||||
fprintf( stderr, " shared_size=%d,", req->shared_size );
|
||||
fprintf( stderr, " drive_type=%d", req->drive_type );
|
||||
fprintf( stderr, " removable=%d", req->removable );
|
||||
}
|
||||
|
||||
static void dump_create_device_request( const struct create_device_request *req )
|
||||
|
|
Loading…
Reference in New Issue