Alexandre Julliard <julliard(a)winehq.com> writes:
> It's used at least in debug events, so yes it's possible that the
> debugger will try to use the handle to read the file. Probably better
> to close it completely when on removable media; and we'll need to do
> this for dlls too. I'll try to come up with something.
OK how about this?
Index: loader/pe_image.c
===================================================================
RCS file: /opt/cvs-commit/wine/loader/pe_image.c,v
retrieving revision 1.99
diff -u -r1.99 pe_image.c
--- loader/pe_image.c 2001/10/02 17:49:20 1.99
+++ loader/pe_image.c 2001/10/24 19:39:21
@@ -667,6 +667,12 @@
if (nt->FileHeader.Characteristics & IMAGE_FILE_DLL)
{
+ if (hFile)
+ {
+ UINT drive_type = GetDriveTypeA( wm->short_filename );
+ /* don't keep the file handle open on removable media */
+ if (drive_type == DRIVE_REMOVABLE || drive_type == DRIVE_CDROM) hFile = 0;
+ }
SERVER_START_REQ( load_dll )
{
req->handle = hFile;
Index: scheduler/process.c
===================================================================
RCS file: /opt/cvs-commit/wine/scheduler/process.c,v
retrieving revision 1.162
diff -u -r1.162 process.c
--- scheduler/process.c 2001/10/03 18:40:10 1.162
+++ scheduler/process.c 2001/10/24 19:39:22
@@ -327,6 +327,17 @@
lstrcpynA( main_exe_name, full_argv0, sizeof(main_exe_name) );
}
+ if (main_exe_file)
+ {
+ UINT drive_type = GetDriveTypeA( main_exe_name );
+ if (drive_type == DRIVE_REMOVABLE || drive_type == DRIVE_CDROM)
+ {
+ /* don't keep the file handle open on removable media */
+ CloseHandle( main_exe_file );
+ main_exe_file = 0;
+ }
+ }
+
/* Retrieve entry point address */
entry = (LPTHREAD_START_ROUTINE)((char*)current_process.module +
PE_HEADER(current_process.module)->OptionalHeader.AddressOfEntryPoint);
Index: server/process.c
===================================================================
RCS file: /opt/cvs-commit/wine/server/process.c,v
retrieving revision 1.70
diff -u -r1.70 process.c
--- server/process.c 2001/07/14 00:50:30 1.70
+++ server/process.c 2001/10/24 19:39:22
@@ -788,8 +788,9 @@
/* signal the end of the process initialization */
DECL_HANDLER(init_process_done)
{
- struct file *file;
+ struct file *file = NULL;
struct process *process = current->process;
+
if (!process->init_event)
{
fatal_protocol_error( current, "init_process_done: no event\n" );
@@ -798,11 +799,10 @@
process->exe.base = req->module;
process->exe.name = req->name;
- if (req->exe_file && (file = get_file_obj( current->process, req->exe_file, GENERIC_READ )))
- {
- if (process->exe.file) release_object( process->exe.file );
- process->exe.file = file;
- }
+ if (req->exe_file) file = get_file_obj( current->process, req->exe_file, GENERIC_READ );
+ if (process->exe.file) release_object( process->exe.file );
+ process->exe.file = file;
+
generate_startup_debug_events( current->process, req->entry );
set_event( process->init_event );
release_object( process->init_event );
--
Alexandre Julliard
julliard(a)winehq.com