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

Removed PROCESS_Initial().
This commit is contained in:
Alexandre Julliard 2000-02-18 21:54:32 +00:00
parent 64b9d86669
commit 67a24c8cfb
10 changed files with 36 additions and 22 deletions

View File

@ -94,10 +94,11 @@ typedef struct _PDB
void *server_pid; /* Server id for this process */ void *server_pid; /* Server id for this process */
HANDLE *dos_handles; /* Handles mapping DOS -> Win32 */ HANDLE *dos_handles; /* Handles mapping DOS -> Win32 */
struct _PDB *next; /* List reference - list of PDB's */ 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 */ struct _SERVICETABLE *service_table; /* Service table for service thread */
HANDLE idle_event; /* event to signal, when the process is idle */ HANDLE idle_event; /* event to signal, when the process is idle */
HANDLE16 main_queue; /* main message queue of the process */ HANDLE16 main_queue; /* main message queue of the process */
HFILE exe_file; /* handle to main exe file */
} PDB; } PDB;
/* Process flags */ /* Process flags */
@ -157,10 +158,9 @@ extern void ENV_FreeEnvironment( PDB *pdb );
/* scheduler/process.c */ /* scheduler/process.c */
extern BOOL PROCESS_Init( BOOL win32 ); extern BOOL PROCESS_Init( BOOL win32 );
extern BOOL PROCESS_IsCurrent( HANDLE handle ); extern BOOL PROCESS_IsCurrent( HANDLE handle );
extern PDB *PROCESS_Initial(void);
extern PDB *PROCESS_IdToPDB( DWORD id ); extern PDB *PROCESS_IdToPDB( DWORD id );
extern void PROCESS_CallUserSignalProc( UINT uCode, DWORD dwThreadId, HMODULE hModule ); 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, LPCSTR cmd_line, LPCSTR env,
LPSECURITY_ATTRIBUTES psa, LPSECURITY_ATTRIBUTES tsa, LPSECURITY_ATTRIBUTES psa, LPSECURITY_ATTRIBUTES tsa,
BOOL inherit, DWORD flags, BOOL inherit, DWORD flags,

View File

@ -114,6 +114,7 @@ struct new_process_request
IN int inherit_all; /* inherit all handles from parent */ IN int inherit_all; /* inherit all handles from parent */
IN int create_flags; /* creation flags */ IN int create_flags; /* creation flags */
IN int start_flags; /* flags from startup info */ 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 hstdin; /* handle for stdin */
IN int hstdout; /* handle for stdout */ IN int hstdout; /* handle for stdout */
IN int hstderr; /* handle for stderr */ 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_copy; /* addr of LDT copy */
IN void* ldt_flags; /* addr of LDT flags */ IN void* ldt_flags; /* addr of LDT flags */
OUT int start_flags; /* flags from startup info */ 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 hstdin; /* handle for stdin */
OUT int hstdout; /* handle for stdout */ OUT int hstdout; /* handle for stdout */
OUT int hstderr; /* handle for stderr */ OUT int hstderr; /* handle for stderr */

View File

@ -503,7 +503,7 @@ BOOL MZ_CreateProcess( HANDLE hFile, LPCSTR filename, LPCSTR cmdline, LPCSTR env
return FALSE; return FALSE;
} }
inherit = TRUE; /* bad hack for inheriting the CreatePipe... */ 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 )) psa, tsa, inherit, flags, startup, info ))
return FALSE; return FALSE;
} }

View File

@ -1072,7 +1072,7 @@ HINSTANCE16 WINAPI LoadModule16( LPCSTR name, LPVOID paramBlock )
} }
SYSLEVEL_ReleaseWin16Lock(); 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 ); NULL, NULL, TRUE, 0, &startup, &info );
SYSLEVEL_RestoreWin16Lock(); SYSLEVEL_RestoreWin16Lock();
@ -1136,7 +1136,7 @@ BOOL NE_CreateProcess( HANDLE hFile, LPCSTR filename, LPCSTR cmd_line, LPCSTR en
SYSLEVEL_LeaveWin16Lock(); SYSLEVEL_LeaveWin16Lock();
if ( !PROCESS_Create( pModule, cmd_line, env, if ( !PROCESS_Create( pModule, hFile, cmd_line, env,
psa, tsa, inherit, flags, startup, info ) ) psa, tsa, inherit, flags, startup, info ) )
return FALSE; return FALSE;

View File

@ -1003,7 +1003,7 @@ BOOL PE_CreateProcess( HANDLE hFile, LPCSTR filename, LPCSTR cmd_line, LPCSTR en
pModule->module32 = hModule32; pModule->module32 = hModule32;
/* Create new process */ /* Create new process */
if ( !PROCESS_Create( pModule, cmd_line, env, if ( !PROCESS_Create( pModule, hFile, cmd_line, env,
psa, tsa, inherit, flags, startup, info ) ) psa, tsa, inherit, flags, startup, info ) )
return FALSE; return FALSE;

View File

@ -56,6 +56,7 @@ THHOOK *pThhook = &DefaultThhook;
static UINT16 nTaskCount = 0; static UINT16 nTaskCount = 0;
static HTASK initial_task;
/*********************************************************************** /***********************************************************************
* TASK_InstallTHHook * TASK_InstallTHHook
@ -385,6 +386,8 @@ BOOL TASK_Create( NE_MODULE *pModule, UINT16 cmdShow)
/* Enter task handle into thread and process */ /* Enter task handle into thread and process */
pTask->teb->htask16 = pTask->teb->process->task = hTask; 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 ); TRACE("module='%s' cmdline='%s' task=%04x\n", name, cmd_line, hTask );
/* Add the task to the linked list */ /* 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 * The initial task should probably install hooks or something
* to get informed about task termination :-/ * 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 */ /* Remove the task from the list to be sure we never switch back to it */
TASK_UnlinkTask( hTask ); TASK_UnlinkTask( hTask );

View File

@ -64,19 +64,6 @@ void PROCESS_WalkProcess(void)
return; return;
} }
/***********************************************************************
* 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 * PROCESS_IsCurrent
* *
@ -255,6 +242,7 @@ static BOOL PROCESS_CreateEnvDB(void)
req->ldt_copy = ldt_copy; req->ldt_copy = ldt_copy;
req->ldt_flags = ldt_flags_copy; req->ldt_flags = ldt_flags_copy;
if (server_call( REQ_INIT_PROCESS )) return FALSE; if (server_call( REQ_INIT_PROCESS )) return FALSE;
pdb->exe_file = req->exe_file;
startup->dwFlags = req->start_flags; startup->dwFlags = req->start_flags;
startup->wShowWindow = req->cmd_show; startup->wShowWindow = req->cmd_show;
env_db->hStdin = startup->hStdInput = req->hstdin; env_db->hStdin = startup->hStdInput = req->hstdin;
@ -529,7 +517,7 @@ void PROCESS_Start(void)
* *
* Create a new process database and associated info. * 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, LPSECURITY_ATTRIBUTES psa, LPSECURITY_ATTRIBUTES tsa,
BOOL inherit, DWORD flags, STARTUPINFOA *startup, BOOL inherit, DWORD flags, STARTUPINFOA *startup,
PROCESS_INFORMATION *info ) PROCESS_INFORMATION *info )
@ -553,6 +541,7 @@ PDB *PROCESS_Create( NE_MODULE *pModule, LPCSTR cmd_line, LPCSTR env,
req->inherit_all = inherit; req->inherit_all = inherit;
req->create_flags = flags; req->create_flags = flags;
req->start_flags = startup->dwFlags; req->start_flags = startup->dwFlags;
req->exe_file = hFile;
req->event = load_done_evt; req->event = load_done_evt;
if (startup->dwFlags & STARTF_USESTDHANDLES) if (startup->dwFlags & STARTF_USESTDHANDLES)
{ {

View File

@ -72,6 +72,7 @@ static int set_creation_info( struct process *process, struct new_process_reques
req->inherit_all = 0; req->inherit_all = 0;
req->create_flags = CREATE_NEW_CONSOLE; req->create_flags = CREATE_NEW_CONSOLE;
req->start_flags = STARTF_USESTDHANDLES; req->start_flags = STARTF_USESTDHANDLES;
req->exe_file = -1;
req->hstdin = -1; req->hstdin = -1;
req->hstdout = -1; req->hstdout = -1;
req->hstderr = -1; req->hstderr = -1;
@ -142,6 +143,7 @@ struct thread *create_process( int fd, struct process *parent,
process->prev = NULL; process->prev = NULL;
process->thread_list = NULL; process->thread_list = NULL;
process->debugger = NULL; process->debugger = NULL;
process->exe_file = NULL;
process->handles = NULL; process->handles = NULL;
process->exit_code = STILL_ACTIVE; process->exit_code = STILL_ACTIVE;
process->running_threads = 0; 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 a handle for the process itself */
alloc_handle( process, process, PROCESS_ALL_ACCESS, 0 ); 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 */ /* get the init done event */
if (process->info->event != -1) if (process->info->event != -1)
{ {
@ -215,6 +225,7 @@ static void process_destroy( struct object *obj )
else first_process = process->next; else first_process = process->next;
if (process->info) free( process->info ); if (process->info) free( process->info );
if (process->init_event) release_object( process->init_event ); 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 */ /* 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 ); release_object( process->handles );
process->handles = NULL; process->handles = NULL;
free_console( process ); free_console( process );
if (process->exe_file) release_object( process->exe_file );
process->exe_file = NULL;
wake_up( &process->obj, 0 ); wake_up( &process->obj, 0 );
if (!--running_processes) if (!--running_processes)
{ {
@ -548,6 +561,7 @@ DECL_HANDLER(init_process)
current->process->ldt_copy = req->ldt_copy; current->process->ldt_copy = req->ldt_copy;
current->process->ldt_flags = req->ldt_flags; current->process->ldt_flags = req->ldt_flags;
current->process->info = NULL; current->process->info = NULL;
req->exe_file = -1;
req->start_flags = info->start_flags; req->start_flags = info->start_flags;
req->hstdin = info->hstdin; req->hstdin = info->hstdin;
req->hstdout = info->hstdout; req->hstdout = info->hstdout;
@ -555,6 +569,9 @@ DECL_HANDLER(init_process)
req->cmd_show = info->cmd_show; req->cmd_show = info->cmd_show;
req->env_ptr = info->env_ptr; req->env_ptr = info->env_ptr;
strcpy( req->cmdline, info->cmdline ); 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 ); free( info );
} }

View File

@ -22,6 +22,7 @@ struct process
struct process *prev; struct process *prev;
struct thread *thread_list; /* head of the thread list */ struct thread *thread_list; /* head of the thread list */
struct thread *debugger; /* thread debugging this process */ struct thread *debugger; /* thread debugging this process */
struct file *exe_file; /* main exe file */
struct object *handles; /* handle entries */ struct object *handles; /* handle entries */
int exit_code; /* process exit code */ int exit_code; /* process exit code */
int running_threads; /* number of threads running in this process */ int running_threads; /* number of threads running in this process */

View File

@ -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, " inherit_all=%d,", req->inherit_all );
fprintf( stderr, " create_flags=%d,", req->create_flags ); fprintf( stderr, " create_flags=%d,", req->create_flags );
fprintf( stderr, " start_flags=%d,", req->start_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, " hstdin=%d,", req->hstdin );
fprintf( stderr, " hstdout=%d,", req->hstdout ); fprintf( stderr, " hstdout=%d,", req->hstdout );
fprintf( stderr, " hstderr=%d,", req->hstderr ); 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 ) static void dump_init_process_reply( const struct init_process_request *req )
{ {
fprintf( stderr, " start_flags=%d,", req->start_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, " hstdin=%d,", req->hstdin );
fprintf( stderr, " hstdout=%d,", req->hstdout ); fprintf( stderr, " hstdout=%d,", req->hstdout );
fprintf( stderr, " hstderr=%d,", req->hstderr ); fprintf( stderr, " hstderr=%d,", req->hstderr );