Alexandre Julliard | 43c190e | 1999-05-15 10:48:19 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Wine server processes |
| 3 | * |
| 4 | * Copyright (C) 1999 Alexandre Julliard |
Alexandre Julliard | 0799c1a | 2002-03-09 23:29:33 +0000 | [diff] [blame] | 5 | * |
| 6 | * This library is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU Lesser General Public |
| 8 | * License as published by the Free Software Foundation; either |
| 9 | * version 2.1 of the License, or (at your option) any later version. |
| 10 | * |
| 11 | * This library is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 | * Lesser General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU Lesser General Public |
| 17 | * License along with this library; if not, write to the Free Software |
| 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
Alexandre Julliard | 43c190e | 1999-05-15 10:48:19 +0000 | [diff] [blame] | 19 | */ |
| 20 | |
| 21 | #ifndef __WINE_SERVER_PROCESS_H |
| 22 | #define __WINE_SERVER_PROCESS_H |
| 23 | |
Alexandre Julliard | 43c190e | 1999-05-15 10:48:19 +0000 | [diff] [blame] | 24 | #include "object.h" |
| 25 | |
Alexandre Julliard | c5e433a | 2000-05-30 19:48:18 +0000 | [diff] [blame] | 26 | struct msg_queue; |
Turchanov Sergei | 43a27e3 | 2000-05-30 20:32:06 +0000 | [diff] [blame] | 27 | struct atom_table; |
Alexandre Julliard | 526a28d | 2002-10-02 23:49:30 +0000 | [diff] [blame^] | 28 | struct handle_table; |
Alexandre Julliard | 9d80215 | 2002-05-24 21:20:27 +0000 | [diff] [blame] | 29 | struct startup_info; |
Alexandre Julliard | c5e433a | 2000-05-30 19:48:18 +0000 | [diff] [blame] | 30 | |
Alexandre Julliard | ca96de3 | 2002-05-25 21:15:03 +0000 | [diff] [blame] | 31 | /* process startup state */ |
| 32 | enum startup_state { STARTUP_IN_PROGRESS, STARTUP_DONE, STARTUP_ABORTED }; |
| 33 | |
Alexandre Julliard | 43c190e | 1999-05-15 10:48:19 +0000 | [diff] [blame] | 34 | /* process structures */ |
| 35 | |
Alexandre Julliard | 05f0b71 | 2000-03-09 18:18:41 +0000 | [diff] [blame] | 36 | struct process_dll |
| 37 | { |
| 38 | struct process_dll *next; /* per-process dll list */ |
| 39 | struct process_dll *prev; |
| 40 | struct file *file; /* dll file */ |
| 41 | void *base; /* dll base address (in process addr space) */ |
Alexandre Julliard | aeb5660 | 2002-03-22 00:21:23 +0000 | [diff] [blame] | 42 | size_t size; /* dll size */ |
Alexandre Julliard | 05f0b71 | 2000-03-09 18:18:41 +0000 | [diff] [blame] | 43 | void *name; /* ptr to ptr to name (in process addr space) */ |
| 44 | int dbg_offset; /* debug info offset */ |
| 45 | int dbg_size; /* debug info size */ |
Alexandre Julliard | aeb5660 | 2002-03-22 00:21:23 +0000 | [diff] [blame] | 46 | size_t namelen; /* length of dll file name */ |
| 47 | char *filename; /* dll file name */ |
Alexandre Julliard | 05f0b71 | 2000-03-09 18:18:41 +0000 | [diff] [blame] | 48 | }; |
| 49 | |
Alexandre Julliard | 3da5f84 | 1999-05-16 16:54:54 +0000 | [diff] [blame] | 50 | struct process |
| 51 | { |
| 52 | struct object obj; /* object header */ |
| 53 | struct process *next; /* system-wide process list */ |
| 54 | struct process *prev; |
Eric Pouech | 0b83d4c | 2001-11-23 23:04:58 +0000 | [diff] [blame] | 55 | struct process *parent; /* parent process */ |
Alexandre Julliard | 3da5f84 | 1999-05-16 16:54:54 +0000 | [diff] [blame] | 56 | struct thread *thread_list; /* head of the thread list */ |
Alexandre Julliard | 3da5f84 | 1999-05-16 16:54:54 +0000 | [diff] [blame] | 57 | struct thread *debugger; /* thread debugging this process */ |
Alexandre Julliard | 526a28d | 2002-10-02 23:49:30 +0000 | [diff] [blame^] | 58 | struct handle_table *handles; /* handle entries */ |
Alexandre Julliard | 3da5f84 | 1999-05-16 16:54:54 +0000 | [diff] [blame] | 59 | int exit_code; /* process exit code */ |
| 60 | int running_threads; /* number of threads running in this process */ |
| 61 | struct timeval start_time; /* absolute time at process start */ |
| 62 | struct timeval end_time; /* absolute time at process end */ |
| 63 | int priority; /* priority class */ |
| 64 | int affinity; /* process affinity mask */ |
| 65 | int suspend; /* global process suspend count */ |
Alexandre Julliard | d083a7b | 1999-11-29 02:10:56 +0000 | [diff] [blame] | 66 | int create_flags; /* process creation flags */ |
Eric Pouech | 0b83d4c | 2001-11-23 23:04:58 +0000 | [diff] [blame] | 67 | struct console_input*console; /* console input */ |
Alexandre Julliard | ca96de3 | 2002-05-25 21:15:03 +0000 | [diff] [blame] | 68 | enum startup_state startup_state; /* startup state */ |
Alexandre Julliard | 9d80215 | 2002-05-24 21:20:27 +0000 | [diff] [blame] | 69 | struct startup_info *startup_info; /* startup info while init is in progress */ |
Alexandre Julliard | c5e433a | 2000-05-30 19:48:18 +0000 | [diff] [blame] | 70 | struct event *idle_event; /* event for input idle */ |
| 71 | struct msg_queue *queue; /* main message queue */ |
Turchanov Sergei | 43a27e3 | 2000-05-30 20:32:06 +0000 | [diff] [blame] | 72 | struct atom_table *atom_table; /* pointer to local atom table */ |
Alexandre Julliard | 05f0b71 | 2000-03-09 18:18:41 +0000 | [diff] [blame] | 73 | struct process_dll exe; /* main exe file */ |
Alexandre Julliard | 0a7c1f6 | 2000-01-27 02:54:17 +0000 | [diff] [blame] | 74 | void *ldt_copy; /* pointer to LDT copy in client addr space */ |
| 75 | void *ldt_flags; /* pointer to LDT flags in client addr space */ |
Eric Pouech | 93bfa0d | 2002-06-02 21:22:22 +0000 | [diff] [blame] | 76 | void *group_id; /* group ID of the process */ |
Alexandre Julliard | 3da5f84 | 1999-05-16 16:54:54 +0000 | [diff] [blame] | 77 | }; |
Alexandre Julliard | 43c190e | 1999-05-15 10:48:19 +0000 | [diff] [blame] | 78 | |
| 79 | struct process_snapshot |
| 80 | { |
| 81 | struct process *process; /* process ptr */ |
Alexandre Julliard | 07d8446 | 2000-04-16 19:45:05 +0000 | [diff] [blame] | 82 | int count; /* process refcount */ |
Alexandre Julliard | 43c190e | 1999-05-15 10:48:19 +0000 | [diff] [blame] | 83 | int threads; /* number of threads */ |
| 84 | int priority; /* priority class */ |
| 85 | }; |
| 86 | |
Alexandre Julliard | 07d8446 | 2000-04-16 19:45:05 +0000 | [diff] [blame] | 87 | struct module_snapshot |
| 88 | { |
| 89 | void *base; /* module base addr */ |
Alexandre Julliard | aeb5660 | 2002-03-22 00:21:23 +0000 | [diff] [blame] | 90 | size_t size; /* module size */ |
| 91 | size_t namelen; /* length of file name */ |
| 92 | char *filename; /* module file name */ |
Alexandre Julliard | 07d8446 | 2000-04-16 19:45:05 +0000 | [diff] [blame] | 93 | }; |
| 94 | |
Alexandre Julliard | 43c190e | 1999-05-15 10:48:19 +0000 | [diff] [blame] | 95 | /* process functions */ |
| 96 | |
Alexandre Julliard | 5b4f3e8 | 2000-05-01 16:24:22 +0000 | [diff] [blame] | 97 | extern struct thread *create_process( int fd ); |
Alexandre Julliard | 43c190e | 1999-05-15 10:48:19 +0000 | [diff] [blame] | 98 | extern struct process *get_process_from_id( void *id ); |
Alexandre Julliard | 5188574 | 2002-05-30 20:12:58 +0000 | [diff] [blame] | 99 | extern struct process *get_process_from_handle( obj_handle_t handle, unsigned int access ); |
Alexandre Julliard | 3da5f84 | 1999-05-16 16:54:54 +0000 | [diff] [blame] | 100 | extern int process_set_debugger( struct process *process, struct thread *thread ); |
Eric Pouech | fbccb38 | 2002-02-27 01:28:30 +0000 | [diff] [blame] | 101 | extern int debugger_detach( struct process* process, struct thread* debugger ); |
| 102 | |
Alexandre Julliard | 43c190e | 1999-05-15 10:48:19 +0000 | [diff] [blame] | 103 | extern void add_process_thread( struct process *process, |
| 104 | struct thread *thread ); |
| 105 | extern void remove_process_thread( struct process *process, |
| 106 | struct thread *thread ); |
Alexandre Julliard | 3da5f84 | 1999-05-16 16:54:54 +0000 | [diff] [blame] | 107 | extern void suspend_process( struct process *process ); |
| 108 | extern void resume_process( struct process *process ); |
Alexandre Julliard | 40043ed | 2002-08-16 20:02:15 +0000 | [diff] [blame] | 109 | extern void kill_all_processes( struct process *skip, int exit_code ); |
Alexandre Julliard | f524240 | 2001-02-28 21:45:23 +0000 | [diff] [blame] | 110 | extern void kill_process( struct process *process, struct thread *skip, int exit_code ); |
Eric Pouech | 3940d8a | 2001-12-04 20:17:43 +0000 | [diff] [blame] | 111 | extern void kill_console_processes( struct thread *renderer, int exit_code ); |
Alexandre Julliard | 17cf810 | 1999-11-24 01:22:14 +0000 | [diff] [blame] | 112 | extern void kill_debugged_processes( struct thread *debugger, int exit_code ); |
Eric Pouech | fbccb38 | 2002-02-27 01:28:30 +0000 | [diff] [blame] | 113 | extern void detach_debugged_processes( struct thread *debugger ); |
Alexandre Julliard | 43c190e | 1999-05-15 10:48:19 +0000 | [diff] [blame] | 114 | extern struct process_snapshot *process_snap( int *count ); |
Alexandre Julliard | 07d8446 | 2000-04-16 19:45:05 +0000 | [diff] [blame] | 115 | extern struct module_snapshot *module_snap( struct process *process, int *count ); |
Eric Pouech | 93bfa0d | 2002-06-02 21:22:22 +0000 | [diff] [blame] | 116 | extern void enum_processes( int (*cb)(struct process*, void*), void *user); |
Alexandre Julliard | 43c190e | 1999-05-15 10:48:19 +0000 | [diff] [blame] | 117 | |
Alexandre Julliard | 9d80215 | 2002-05-24 21:20:27 +0000 | [diff] [blame] | 118 | inline static void *get_process_id( struct process *process ) { return process; } |
Alexandre Julliard | ca96de3 | 2002-05-25 21:15:03 +0000 | [diff] [blame] | 119 | inline static int is_process_init_done( struct process *process ) |
| 120 | { |
| 121 | return process->startup_state == STARTUP_DONE; |
| 122 | } |
Alexandre Julliard | ff81d78 | 2000-03-08 12:01:30 +0000 | [diff] [blame] | 123 | |
Alexandre Julliard | 43c190e | 1999-05-15 10:48:19 +0000 | [diff] [blame] | 124 | #endif /* __WINE_SERVER_PROCESS_H */ |