1999-05-15 12:48:19 +02:00
|
|
|
/*
|
|
|
|
* Wine server processes
|
|
|
|
*
|
|
|
|
* Copyright (C) 1999 Alexandre Julliard
|
2002-03-10 00:29:33 +01:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
1999-05-15 12:48:19 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __WINE_SERVER_PROCESS_H
|
|
|
|
#define __WINE_SERVER_PROCESS_H
|
|
|
|
|
|
|
|
#include "object.h"
|
|
|
|
|
2000-05-30 22:32:06 +02:00
|
|
|
struct atom_table;
|
2002-10-03 01:49:30 +02:00
|
|
|
struct handle_table;
|
2002-05-24 23:20:27 +02:00
|
|
|
struct startup_info;
|
2015-04-03 08:19:45 +02:00
|
|
|
struct job;
|
2000-05-30 21:48:18 +02:00
|
|
|
|
2002-05-25 23:15:03 +02:00
|
|
|
/* process startup state */
|
|
|
|
enum startup_state { STARTUP_IN_PROGRESS, STARTUP_DONE, STARTUP_ABORTED };
|
|
|
|
|
1999-05-15 12:48:19 +02:00
|
|
|
/* process structures */
|
|
|
|
|
2000-03-09 19:18:41 +01:00
|
|
|
struct process_dll
|
|
|
|
{
|
2005-03-02 11:20:09 +01:00
|
|
|
struct list entry; /* entry in per-process dll list */
|
2008-12-29 16:41:44 +01:00
|
|
|
mod_handle_t base; /* dll base address (in process addr space) */
|
2008-12-29 17:10:11 +01:00
|
|
|
client_ptr_t name; /* ptr to ptr to name (in process addr space) */
|
2000-03-09 19:18:41 +01:00
|
|
|
int dbg_offset; /* debug info offset */
|
|
|
|
int dbg_size; /* debug info size */
|
2006-07-26 10:43:25 +02:00
|
|
|
data_size_t namelen; /* length of dll file name */
|
2003-09-30 03:04:19 +02:00
|
|
|
WCHAR *filename; /* dll file name */
|
2000-03-09 19:18:41 +01:00
|
|
|
};
|
|
|
|
|
2012-09-08 11:26:26 +02:00
|
|
|
struct rawinput_device_entry
|
|
|
|
{
|
|
|
|
struct list entry;
|
|
|
|
struct rawinput_device device;
|
|
|
|
};
|
|
|
|
|
1999-05-16 18:54:54 +02:00
|
|
|
struct process
|
|
|
|
{
|
|
|
|
struct object obj; /* object header */
|
2005-02-25 20:31:26 +01:00
|
|
|
struct list entry; /* entry in system-wide process list */
|
2016-04-21 12:34:07 +02:00
|
|
|
process_id_t parent_id; /* parent process id (at the time of creation) */
|
2005-03-01 11:56:18 +01:00
|
|
|
struct list thread_list; /* thread list */
|
1999-05-16 18:54:54 +02:00
|
|
|
struct thread *debugger; /* thread debugging this process */
|
2019-08-06 15:05:36 +02:00
|
|
|
struct debug_event *debug_event; /* debug event being sent to debugger */
|
2002-10-03 01:49:30 +02:00
|
|
|
struct handle_table *handles; /* handle entries */
|
2003-02-19 01:33:32 +01:00
|
|
|
struct fd *msg_fd; /* fd for sendmsg/recvmsg */
|
2003-02-01 02:38:40 +01:00
|
|
|
process_id_t id; /* id of the process */
|
|
|
|
process_id_t group_id; /* group id of the process */
|
2006-08-14 20:19:42 +02:00
|
|
|
struct timeout_user *sigkill_timeout; /* timeout for final SIGKILL */
|
2009-04-03 14:49:10 +02:00
|
|
|
enum cpu_type cpu; /* client CPU type */
|
2006-08-14 20:19:42 +02:00
|
|
|
int unix_pid; /* Unix pid for final SIGKILL */
|
1999-05-16 18:54:54 +02:00
|
|
|
int exit_code; /* process exit code */
|
|
|
|
int running_threads; /* number of threads running in this process */
|
2007-04-17 20:08:59 +02:00
|
|
|
timeout_t start_time; /* absolute time at process start */
|
|
|
|
timeout_t end_time; /* absolute time at process end */
|
2009-01-19 14:15:51 +01:00
|
|
|
affinity_t affinity; /* process affinity mask */
|
1999-05-16 18:54:54 +02:00
|
|
|
int priority; /* priority class */
|
|
|
|
int suspend; /* global process suspend count */
|
2011-10-09 23:26:03 +02:00
|
|
|
unsigned int is_system:1; /* is it a system process? */
|
|
|
|
unsigned int debug_children:1;/* also debug all child processes */
|
2013-05-06 08:39:27 +02:00
|
|
|
unsigned int is_terminating:1;/* is process terminating? */
|
2015-04-01 00:10:16 +02:00
|
|
|
struct job *job; /* job object ascoicated with this process */
|
|
|
|
struct list job_entry; /* list entry for job object */
|
2016-12-01 12:10:23 +01:00
|
|
|
struct list asyncs; /* list of async object owned by the process */
|
2003-03-18 06:04:33 +01:00
|
|
|
struct list locks; /* list of file locks owned by the process */
|
2003-12-10 05:08:06 +01:00
|
|
|
struct list classes; /* window classes owned by the process */
|
2001-11-24 00:04:58 +01:00
|
|
|
struct console_input*console; /* console input */
|
2002-05-25 23:15:03 +02:00
|
|
|
enum startup_state startup_state; /* startup state */
|
2002-05-24 23:20:27 +02:00
|
|
|
struct startup_info *startup_info; /* startup info while init is in progress */
|
2000-05-30 21:48:18 +02:00
|
|
|
struct event *idle_event; /* event for input idle */
|
2018-09-24 19:13:54 +02:00
|
|
|
struct file *exe_file; /* file handle for main exe (during startup only) */
|
2005-06-08 20:44:50 +02:00
|
|
|
obj_handle_t winstation; /* main handle to process window station */
|
2005-06-09 14:07:12 +02:00
|
|
|
obj_handle_t desktop; /* handle to desktop to use for new threads */
|
2003-07-24 02:07:00 +02:00
|
|
|
struct token *token; /* security token associated with this process */
|
2017-09-26 14:11:49 +02:00
|
|
|
struct list views; /* list of memory views */
|
2005-03-02 11:20:09 +01:00
|
|
|
struct list dlls; /* list of loaded dlls */
|
2008-12-30 23:02:33 +01:00
|
|
|
client_ptr_t peb; /* PEB address in client address space */
|
2008-12-30 22:47:48 +01:00
|
|
|
client_ptr_t ldt_copy; /* pointer to LDT copy in client addr space */
|
2016-05-02 07:39:16 +02:00
|
|
|
struct dir_cache *dir_cache; /* map of client-side directory cache */
|
2006-12-29 16:56:11 +01:00
|
|
|
unsigned int trace_data; /* opaque data used by the process tracing mechanism */
|
2012-09-08 11:26:26 +02:00
|
|
|
struct list rawinput_devices;/* list of registered rawinput devices */
|
2012-09-11 00:27:04 +02:00
|
|
|
const struct rawinput_device *rawinput_mouse; /* rawinput mouse device, if any */
|
2012-09-12 11:30:54 +02:00
|
|
|
const struct rawinput_device *rawinput_kbd; /* rawinput keyboard device, if any */
|
2019-04-19 18:24:30 +02:00
|
|
|
struct list kernel_object; /* list of kernel object pointers */
|
1999-05-16 18:54:54 +02:00
|
|
|
};
|
1999-05-15 12:48:19 +02:00
|
|
|
|
2010-05-04 20:26:53 +02:00
|
|
|
#define CPU_FLAG(cpu) (1 << (cpu))
|
2015-05-05 23:50:36 +02:00
|
|
|
#define CPU_64BIT_MASK (CPU_FLAG(CPU_x86_64) | CPU_FLAG(CPU_ARM64))
|
2010-05-04 20:26:53 +02:00
|
|
|
|
1999-05-15 12:48:19 +02:00
|
|
|
/* process functions */
|
|
|
|
|
2003-02-01 02:38:40 +01:00
|
|
|
extern unsigned int alloc_ptid( void *ptr );
|
|
|
|
extern void free_ptid( unsigned int id );
|
|
|
|
extern void *get_ptid_entry( unsigned int id );
|
2018-10-22 11:44:38 +02:00
|
|
|
extern struct process *create_process( int fd, struct process *parent, int inherit_all,
|
2020-09-22 12:24:21 +02:00
|
|
|
const struct security_descriptor *sd, const obj_handle_t *handles,
|
|
|
|
unsigned int handle_count );
|
2006-07-26 10:43:25 +02:00
|
|
|
extern data_size_t init_process( struct thread *thread );
|
2005-03-01 11:56:18 +01:00
|
|
|
extern struct thread *get_process_first_thread( struct process *process );
|
2002-10-03 21:54:57 +02:00
|
|
|
extern struct process *get_process_from_id( process_id_t id );
|
2002-05-30 22:12:58 +02:00
|
|
|
extern struct process *get_process_from_handle( obj_handle_t handle, unsigned int access );
|
1999-05-16 18:54:54 +02:00
|
|
|
extern int process_set_debugger( struct process *process, struct thread *thread );
|
2002-02-27 02:28:30 +01:00
|
|
|
extern int debugger_detach( struct process* process, struct thread* debugger );
|
2003-10-14 03:30:42 +02:00
|
|
|
extern int set_process_debug_flag( struct process *process, int flag );
|
2002-02-27 02:28:30 +01:00
|
|
|
|
1999-05-15 12:48:19 +02:00
|
|
|
extern void add_process_thread( struct process *process,
|
|
|
|
struct thread *thread );
|
|
|
|
extern void remove_process_thread( struct process *process,
|
|
|
|
struct thread *thread );
|
1999-05-16 18:54:54 +02:00
|
|
|
extern void suspend_process( struct process *process );
|
|
|
|
extern void resume_process( struct process *process );
|
2006-09-21 11:14:45 +02:00
|
|
|
extern void kill_process( struct process *process, int violent_death );
|
2001-12-04 21:17:43 +01:00
|
|
|
extern void kill_console_processes( struct thread *renderer, int exit_code );
|
1999-11-24 02:22:14 +01:00
|
|
|
extern void kill_debugged_processes( struct thread *debugger, int exit_code );
|
2002-02-27 02:28:30 +01:00
|
|
|
extern void detach_debugged_processes( struct thread *debugger );
|
2002-06-02 23:22:22 +02:00
|
|
|
extern void enum_processes( int (*cb)(struct process*, void*), void *user);
|
2006-12-29 16:56:11 +01:00
|
|
|
|
2007-05-11 12:46:32 +02:00
|
|
|
/* console functions */
|
2020-08-17 15:08:36 +02:00
|
|
|
extern obj_handle_t inherit_console( struct thread *parent_thread, obj_handle_t handle,
|
2020-08-13 16:01:08 +02:00
|
|
|
struct process *process, obj_handle_t hconin );
|
2007-05-11 12:46:32 +02:00
|
|
|
extern int free_console( struct process *process );
|
|
|
|
extern struct thread *console_get_renderer( struct console_input *console );
|
|
|
|
|
2006-12-29 20:38:49 +01:00
|
|
|
/* process tracing mechanism to use */
|
|
|
|
#ifdef __APPLE__
|
|
|
|
#define USE_MACH
|
2007-03-09 13:40:41 +01:00
|
|
|
#elif defined(__sun)
|
|
|
|
#define USE_PROCFS
|
2006-12-29 20:38:49 +01:00
|
|
|
#else
|
|
|
|
#define USE_PTRACE
|
|
|
|
#endif
|
|
|
|
|
2006-12-29 16:56:11 +01:00
|
|
|
extern void init_tracing_mechanism(void);
|
|
|
|
extern void init_process_tracing( struct process *process );
|
|
|
|
extern void finish_process_tracing( struct process *process );
|
2008-12-30 14:11:58 +01:00
|
|
|
extern int read_process_memory( struct process *process, client_ptr_t ptr, data_size_t size, char *dest );
|
|
|
|
extern int write_process_memory( struct process *process, client_ptr_t ptr, data_size_t size, const char *src );
|
1999-05-15 12:48:19 +02:00
|
|
|
|
2007-03-17 11:52:14 +01:00
|
|
|
static inline process_id_t get_process_id( struct process *process ) { return process->id; }
|
2003-02-01 02:38:40 +01:00
|
|
|
|
2007-03-17 11:52:14 +01:00
|
|
|
static inline int is_process_init_done( struct process *process )
|
2002-05-25 23:15:03 +02:00
|
|
|
{
|
|
|
|
return process->startup_state == STARTUP_DONE;
|
|
|
|
}
|
2000-03-08 13:01:30 +01:00
|
|
|
|
2007-03-17 11:52:14 +01:00
|
|
|
static inline struct process_dll *get_process_exe_module( struct process *process )
|
2006-02-16 12:13:01 +01:00
|
|
|
{
|
|
|
|
struct list *ptr = list_head( &process->dlls );
|
|
|
|
return ptr ? LIST_ENTRY( ptr, struct process_dll, entry ) : NULL;
|
|
|
|
}
|
|
|
|
|
1999-05-15 12:48:19 +02:00
|
|
|
#endif /* __WINE_SERVER_PROCESS_H */
|