2 * Wine server processes
4 * Copyright (C) 1999 Alexandre Julliard
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.
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.
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #ifndef __WINE_SERVER_PROCESS_H
22 #define __WINE_SERVER_PROCESS_H
31 /* process startup state */
32 enum startup_state { STARTUP_IN_PROGRESS, STARTUP_DONE, STARTUP_ABORTED };
34 /* process structures */
38 struct list entry; /* entry in per-process dll list */
39 struct file *file; /* dll file */
40 void *base; /* dll base address (in process addr space) */
41 size_t size; /* dll size */
42 void *name; /* ptr to ptr to name (in process addr space) */
43 int dbg_offset; /* debug info offset */
44 int dbg_size; /* debug info size */
45 data_size_t namelen; /* length of dll file name */
46 WCHAR *filename; /* dll file name */
51 struct object obj; /* object header */
52 struct list entry; /* entry in system-wide process list */
53 struct process *parent; /* parent process */
54 struct list thread_list; /* thread list */
55 struct thread *debugger; /* thread debugging this process */
56 struct handle_table *handles; /* handle entries */
57 struct fd *msg_fd; /* fd for sendmsg/recvmsg */
58 process_id_t id; /* id of the process */
59 process_id_t group_id; /* group id of the process */
60 struct timeout_user *sigkill_timeout; /* timeout for final SIGKILL */
61 int unix_pid; /* Unix pid for final SIGKILL */
62 int exit_code; /* process exit code */
63 int running_threads; /* number of threads running in this process */
64 struct timeval start_time; /* absolute time at process start */
65 struct timeval end_time; /* absolute time at process end */
66 int priority; /* priority class */
67 int affinity; /* process affinity mask */
68 int suspend; /* global process suspend count */
69 unsigned int create_flags; /* process creation flags */
70 struct list locks; /* list of file locks owned by the process */
71 struct list classes; /* window classes owned by the process */
72 struct console_input*console; /* console input */
73 enum startup_state startup_state; /* startup state */
74 struct startup_info *startup_info; /* startup info while init is in progress */
75 struct event *idle_event; /* event for input idle */
76 struct msg_queue *queue; /* main message queue */
77 obj_handle_t winstation; /* main handle to process window station */
78 obj_handle_t desktop; /* handle to desktop to use for new threads */
79 struct token *token; /* security token associated with this process */
80 struct list dlls; /* list of loaded dlls */
81 void *peb; /* PEB address in client address space */
82 void *ldt_copy; /* pointer to LDT copy in client addr space */
85 struct process_snapshot
87 struct process *process; /* process ptr */
88 int count; /* process refcount */
89 int threads; /* number of threads */
90 int priority; /* priority class */
91 int handles; /* number of handles */
94 struct module_snapshot
96 void *base; /* module base addr */
97 size_t size; /* module size */
98 data_size_t namelen; /* length of file name */
99 WCHAR *filename; /* module file name */
102 /* process functions */
104 extern unsigned int alloc_ptid( void *ptr );
105 extern void free_ptid( unsigned int id );
106 extern void *get_ptid_entry( unsigned int id );
107 extern struct thread *create_process( int fd, struct thread *parent_thread, int inherit_all );
108 extern data_size_t init_process( struct thread *thread );
109 extern struct thread *get_process_first_thread( struct process *process );
110 extern struct process *get_process_from_id( process_id_t id );
111 extern struct process *get_process_from_handle( obj_handle_t handle, unsigned int access );
112 extern int process_set_debugger( struct process *process, struct thread *thread );
113 extern int debugger_detach( struct process* process, struct thread* debugger );
114 extern int set_process_debug_flag( struct process *process, int flag );
116 extern void add_process_thread( struct process *process,
117 struct thread *thread );
118 extern void remove_process_thread( struct process *process,
119 struct thread *thread );
120 extern void suspend_process( struct process *process );
121 extern void resume_process( struct process *process );
122 extern void kill_all_processes( struct process *skip, int exit_code );
123 extern void kill_process( struct process *process, int violent_death );
124 extern void kill_console_processes( struct thread *renderer, int exit_code );
125 extern void kill_debugged_processes( struct thread *debugger, int exit_code );
126 extern void break_process( struct process *process );
127 extern void detach_debugged_processes( struct thread *debugger );
128 extern struct process_snapshot *process_snap( int *count );
129 extern struct module_snapshot *module_snap( struct process *process, int *count );
130 extern void enum_processes( int (*cb)(struct process*, void*), void *user);
131 extern int read_process_memory( struct process *process, const void *ptr, data_size_t size, char *dest );
132 extern int write_process_memory( struct process *process, void *ptr, data_size_t size, const char *src );
134 inline static process_id_t get_process_id( struct process *process ) { return process->id; }
136 inline static int is_process_init_done( struct process *process )
138 return process->startup_state == STARTUP_DONE;
141 inline static struct process_dll *get_process_exe_module( struct process *process )
143 struct list *ptr = list_head( &process->dlls );
144 return ptr ? LIST_ENTRY( ptr, struct process_dll, entry ) : NULL;
147 #endif /* __WINE_SERVER_PROCESS_H */