Don't keep main exe and dlls handles open when the file is on
removable media.
This commit is contained in:
parent
850c9dd6bd
commit
ac2e4f1e3d
|
@ -667,6 +667,12 @@ WINE_MODREF *PE_CreateModule( HMODULE hModule, LPCSTR filename, DWORD flags,
|
|||
|
||||
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;
|
||||
|
|
|
@ -319,6 +319,7 @@ static void start_process(void)
|
|||
int debugged, console_app;
|
||||
LPTHREAD_START_ROUTINE entry;
|
||||
WINE_MODREF *wm;
|
||||
HFILE main_file = main_exe_file;
|
||||
|
||||
/* use original argv[0] as name for the main module */
|
||||
if (!main_exe_name[0])
|
||||
|
@ -327,6 +328,13 @@ static void start_process(void)
|
|||
lstrcpynA( main_exe_name, full_argv0, sizeof(main_exe_name) );
|
||||
}
|
||||
|
||||
if (main_file)
|
||||
{
|
||||
UINT drive_type = GetDriveTypeA( main_exe_name );
|
||||
/* don't keep the file handle open on removable media */
|
||||
if (drive_type == DRIVE_REMOVABLE || drive_type == DRIVE_CDROM) main_file = 0;
|
||||
}
|
||||
|
||||
/* Retrieve entry point address */
|
||||
entry = (LPTHREAD_START_ROUTINE)((char*)current_process.module +
|
||||
PE_HEADER(current_process.module)->OptionalHeader.AddressOfEntryPoint);
|
||||
|
@ -340,7 +348,7 @@ static void start_process(void)
|
|||
req->entry = entry;
|
||||
/* API requires a double indirection */
|
||||
req->name = &main_exe_name_ptr;
|
||||
req->exe_file = main_exe_file;
|
||||
req->exe_file = main_file;
|
||||
req->gui = !console_app;
|
||||
SERVER_CALL();
|
||||
debugged = req->debugged;
|
||||
|
@ -357,6 +365,8 @@ static void start_process(void)
|
|||
goto error;
|
||||
wm->refCount++;
|
||||
|
||||
if (main_exe_file) CloseHandle( main_exe_file ); /* we no longer need it */
|
||||
|
||||
RtlAcquirePebLock();
|
||||
PE_InitTls();
|
||||
MODULE_DllProcessAttach( NULL, (LPVOID)1 );
|
||||
|
|
|
@ -788,8 +788,9 @@ DECL_HANDLER(init_process)
|
|||
/* 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 @@ DECL_HANDLER(init_process_done)
|
|||
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 (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 );
|
||||
|
|
Loading…
Reference in New Issue