Commit 67a24c8c authored by Alexandre Julliard's avatar Alexandre Julliard

Store the handle of the process exe file in the server.

Removed PROCESS_Initial().
parent 64b9d866
......@@ -94,10 +94,11 @@ typedef struct _PDB
void *server_pid; /* Server id for this process */
HANDLE *dos_handles; /* Handles mapping DOS -> Win32 */
struct _PDB *next; /* List reference - list of PDB's */
WORD winver; /* Windows version figured out by VERSION_GetVersion */
WORD winver; /* Windows version figured out by VERSION_GetVersion */
struct _SERVICETABLE *service_table; /* Service table for service thread */
HANDLE idle_event; /* event to signal, when the process is idle */
HANDLE16 main_queue; /* main message queue of the process */
HFILE exe_file; /* handle to main exe file */
} PDB;
/* Process flags */
......@@ -157,10 +158,9 @@ extern void ENV_FreeEnvironment( PDB *pdb );
/* scheduler/process.c */
extern BOOL PROCESS_Init( BOOL win32 );
extern BOOL PROCESS_IsCurrent( HANDLE handle );
extern PDB *PROCESS_Initial(void);
extern PDB *PROCESS_IdToPDB( DWORD id );
extern void PROCESS_CallUserSignalProc( UINT uCode, DWORD dwThreadId, HMODULE hModule );
extern PDB *PROCESS_Create( struct _NE_MODULE *pModule,
extern PDB *PROCESS_Create( struct _NE_MODULE *pModule, HFILE hFile,
LPCSTR cmd_line, LPCSTR env,
LPSECURITY_ATTRIBUTES psa, LPSECURITY_ATTRIBUTES tsa,
BOOL inherit, DWORD flags,
......
......@@ -114,6 +114,7 @@ struct new_process_request
IN int inherit_all; /* inherit all handles from parent */
IN int create_flags; /* creation flags */
IN int start_flags; /* flags from startup info */
IN int exe_file; /* file handle for main exe */
IN int hstdin; /* handle for stdin */
IN int hstdout; /* handle for stdout */
IN int hstderr; /* handle for stderr */
......@@ -151,6 +152,7 @@ struct init_process_request
IN void* ldt_copy; /* addr of LDT copy */
IN void* ldt_flags; /* addr of LDT flags */
OUT int start_flags; /* flags from startup info */
OUT int exe_file; /* file handle for main exe */
OUT int hstdin; /* handle for stdin */
OUT int hstdout; /* handle for stdout */
OUT int hstderr; /* handle for stderr */
......
......@@ -503,7 +503,7 @@ BOOL MZ_CreateProcess( HANDLE hFile, LPCSTR filename, LPCSTR cmdline, LPCSTR env
return FALSE;
}
inherit = TRUE; /* bad hack for inheriting the CreatePipe... */
if (!PROCESS_Create( pModule, cmdline, env,
if (!PROCESS_Create( pModule, hFile, cmdline, env,
psa, tsa, inherit, flags, startup, info ))
return FALSE;
}
......
......@@ -1072,7 +1072,7 @@ HINSTANCE16 WINAPI LoadModule16( LPCSTR name, LPVOID paramBlock )
}
SYSLEVEL_ReleaseWin16Lock();
pdb = PROCESS_Create( pModule, new_cmd_line, env,
pdb = PROCESS_Create( pModule, -1, new_cmd_line, env,
NULL, NULL, TRUE, 0, &startup, &info );
SYSLEVEL_RestoreWin16Lock();
......@@ -1136,7 +1136,7 @@ BOOL NE_CreateProcess( HANDLE hFile, LPCSTR filename, LPCSTR cmd_line, LPCSTR en
SYSLEVEL_LeaveWin16Lock();
if ( !PROCESS_Create( pModule, cmd_line, env,
if ( !PROCESS_Create( pModule, hFile, cmd_line, env,
psa, tsa, inherit, flags, startup, info ) )
return FALSE;
......
......@@ -1003,7 +1003,7 @@ BOOL PE_CreateProcess( HANDLE hFile, LPCSTR filename, LPCSTR cmd_line, LPCSTR en
pModule->module32 = hModule32;
/* Create new process */
if ( !PROCESS_Create( pModule, cmd_line, env,
if ( !PROCESS_Create( pModule, hFile, cmd_line, env,
psa, tsa, inherit, flags, startup, info ) )
return FALSE;
......
......@@ -56,6 +56,7 @@ THHOOK *pThhook = &DefaultThhook;
static UINT16 nTaskCount = 0;
static HTASK initial_task;
/***********************************************************************
* TASK_InstallTHHook
......@@ -385,6 +386,8 @@ BOOL TASK_Create( NE_MODULE *pModule, UINT16 cmdShow)
/* Enter task handle into thread and process */
pTask->teb->htask16 = pTask->teb->process->task = hTask;
if (!initial_task) initial_task = hTask;
TRACE("module='%s' cmdline='%s' task=%04x\n", name, cmd_line, hTask );
/* Add the task to the linked list */
......@@ -481,7 +484,7 @@ void TASK_KillTask( HTASK16 hTask )
* The initial task should probably install hooks or something
* to get informed about task termination :-/
*/
Callout.PostAppMessage16( PROCESS_Initial()->task, WM_NULL, 0, 0 );
Callout.PostAppMessage16( initial_task, WM_NULL, 0, 0 );
/* Remove the task from the list to be sure we never switch back to it */
TASK_UnlinkTask( hTask );
......
......@@ -65,19 +65,6 @@ void PROCESS_WalkProcess(void)
}
/***********************************************************************
* PROCESS_Initial
*
* FIXME: This works only while running all processes in the same
* address space (or, at least, the initial process is mapped
* into all address spaces as is KERNEL32 in Windows 95)
*
*/
PDB *PROCESS_Initial(void)
{
return &initial_pdb;
}
/***********************************************************************
* PROCESS_IsCurrent
*
* Check if a handle is to the current process
......@@ -255,6 +242,7 @@ static BOOL PROCESS_CreateEnvDB(void)
req->ldt_copy = ldt_copy;
req->ldt_flags = ldt_flags_copy;
if (server_call( REQ_INIT_PROCESS )) return FALSE;
pdb->exe_file = req->exe_file;
startup->dwFlags = req->start_flags;
startup->wShowWindow = req->cmd_show;
env_db->hStdin = startup->hStdInput = req->hstdin;
......@@ -529,7 +517,7 @@ void PROCESS_Start(void)
*
* Create a new process database and associated info.
*/
PDB *PROCESS_Create( NE_MODULE *pModule, LPCSTR cmd_line, LPCSTR env,
PDB *PROCESS_Create( NE_MODULE *pModule, HFILE hFile, LPCSTR cmd_line, LPCSTR env,
LPSECURITY_ATTRIBUTES psa, LPSECURITY_ATTRIBUTES tsa,
BOOL inherit, DWORD flags, STARTUPINFOA *startup,
PROCESS_INFORMATION *info )
......@@ -553,6 +541,7 @@ PDB *PROCESS_Create( NE_MODULE *pModule, LPCSTR cmd_line, LPCSTR env,
req->inherit_all = inherit;
req->create_flags = flags;
req->start_flags = startup->dwFlags;
req->exe_file = hFile;
req->event = load_done_evt;
if (startup->dwFlags & STARTF_USESTDHANDLES)
{
......
......@@ -72,6 +72,7 @@ static int set_creation_info( struct process *process, struct new_process_reques
req->inherit_all = 0;
req->create_flags = CREATE_NEW_CONSOLE;
req->start_flags = STARTF_USESTDHANDLES;
req->exe_file = -1;
req->hstdin = -1;
req->hstdout = -1;
req->hstderr = -1;
......@@ -142,6 +143,7 @@ struct thread *create_process( int fd, struct process *parent,
process->prev = NULL;
process->thread_list = NULL;
process->debugger = NULL;
process->exe_file = NULL;
process->handles = NULL;
process->exit_code = STILL_ACTIVE;
process->running_threads = 0;
......@@ -171,6 +173,14 @@ struct thread *create_process( int fd, struct process *parent,
/* alloc a handle for the process itself */
alloc_handle( process, process, PROCESS_ALL_ACCESS, 0 );
/* retrieve the main exe file */
if (process->info->exe_file != -1)
{
if (!(process->exe_file = get_file_obj( parent, process->info->exe_file,
GENERIC_READ ))) goto error;
process->info->exe_file = -1;
}
/* get the init done event */
if (process->info->event != -1)
{
......@@ -215,6 +225,7 @@ static void process_destroy( struct object *obj )
else first_process = process->next;
if (process->info) free( process->info );
if (process->init_event) release_object( process->init_event );
if (process->exe_file) release_object( process->exe_file );
}
/* dump a process on stdout for debugging purposes */
......@@ -261,6 +272,8 @@ static void process_killed( struct process *process, int exit_code )
release_object( process->handles );
process->handles = NULL;
free_console( process );
if (process->exe_file) release_object( process->exe_file );
process->exe_file = NULL;
wake_up( &process->obj, 0 );
if (!--running_processes)
{
......@@ -548,6 +561,7 @@ DECL_HANDLER(init_process)
current->process->ldt_copy = req->ldt_copy;
current->process->ldt_flags = req->ldt_flags;
current->process->info = NULL;
req->exe_file = -1;
req->start_flags = info->start_flags;
req->hstdin = info->hstdin;
req->hstdout = info->hstdout;
......@@ -555,6 +569,9 @@ DECL_HANDLER(init_process)
req->cmd_show = info->cmd_show;
req->env_ptr = info->env_ptr;
strcpy( req->cmdline, info->cmdline );
if (current->process->exe_file)
req->exe_file = alloc_handle( current->process, current->process->exe_file,
GENERIC_READ, 0 );
free( info );
}
......
......@@ -22,6 +22,7 @@ struct process
struct process *prev;
struct thread *thread_list; /* head of the thread list */
struct thread *debugger; /* thread debugging this process */
struct file *exe_file; /* main exe file */
struct object *handles; /* handle entries */
int exit_code; /* process exit code */
int running_threads; /* number of threads running in this process */
......
......@@ -203,6 +203,7 @@ static void dump_new_process_request( const struct new_process_request *req )
fprintf( stderr, " inherit_all=%d,", req->inherit_all );
fprintf( stderr, " create_flags=%d,", req->create_flags );
fprintf( stderr, " start_flags=%d,", req->start_flags );
fprintf( stderr, " exe_file=%d,", req->exe_file );
fprintf( stderr, " hstdin=%d,", req->hstdin );
fprintf( stderr, " hstdout=%d,", req->hstdout );
fprintf( stderr, " hstderr=%d,", req->hstderr );
......@@ -246,6 +247,7 @@ static void dump_init_process_request( const struct init_process_request *req )
static void dump_init_process_reply( const struct init_process_request *req )
{
fprintf( stderr, " start_flags=%d,", req->start_flags );
fprintf( stderr, " exe_file=%d,", req->exe_file );
fprintf( stderr, " hstdin=%d,", req->hstdin );
fprintf( stderr, " hstdout=%d,", req->hstdout );
fprintf( stderr, " hstderr=%d,", req->hstderr );
......
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