webservices: Implement WsCreateXmlBuffer.
[wine.git] / server / process.h
blobfa7f60df50cde165dab9fbd037d3c9de5064ccbd
1 /*
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
24 #include "object.h"
26 struct atom_table;
27 struct handle_table;
28 struct startup_info;
29 struct job;
31 /* process startup state */
32 enum startup_state { STARTUP_IN_PROGRESS, STARTUP_DONE, STARTUP_ABORTED };
34 /* process structures */
36 struct process_dll
38 struct list entry; /* entry in per-process dll list */
39 struct mapping *mapping; /* dll file */
40 mod_handle_t base; /* dll base address (in process addr space) */
41 client_ptr_t name; /* ptr to ptr to name (in process addr space) */
42 data_size_t size; /* dll size */
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 */
49 struct rawinput_device_entry
51 struct list entry;
52 struct rawinput_device device;
55 struct process
57 struct object obj; /* object header */
58 struct list entry; /* entry in system-wide process list */
59 struct process *parent; /* parent process */
60 struct list thread_list; /* thread list */
61 struct thread *debugger; /* thread debugging this process */
62 struct handle_table *handles; /* handle entries */
63 struct fd *msg_fd; /* fd for sendmsg/recvmsg */
64 process_id_t id; /* id of the process */
65 process_id_t group_id; /* group id of the process */
66 struct timeout_user *sigkill_timeout; /* timeout for final SIGKILL */
67 enum cpu_type cpu; /* client CPU type */
68 int unix_pid; /* Unix pid for final SIGKILL */
69 int exit_code; /* process exit code */
70 int running_threads; /* number of threads running in this process */
71 timeout_t start_time; /* absolute time at process start */
72 timeout_t end_time; /* absolute time at process end */
73 affinity_t affinity; /* process affinity mask */
74 int priority; /* priority class */
75 int suspend; /* global process suspend count */
76 unsigned int is_system:1; /* is it a system process? */
77 unsigned int debug_children:1;/* also debug all child processes */
78 unsigned int is_terminating:1;/* is process terminating? */
79 struct job *job; /* job object ascoicated with this process */
80 struct list job_entry; /* list entry for job object */
81 struct list locks; /* list of file locks owned by the process */
82 struct list classes; /* window classes owned by the process */
83 struct console_input*console; /* console input */
84 enum startup_state startup_state; /* startup state */
85 struct startup_info *startup_info; /* startup info while init is in progress */
86 struct event *idle_event; /* event for input idle */
87 obj_handle_t winstation; /* main handle to process window station */
88 obj_handle_t desktop; /* handle to desktop to use for new threads */
89 struct token *token; /* security token associated with this process */
90 struct list dlls; /* list of loaded dlls */
91 client_ptr_t peb; /* PEB address in client address space */
92 client_ptr_t ldt_copy; /* pointer to LDT copy in client addr space */
93 unsigned int trace_data; /* opaque data used by the process tracing mechanism */
94 struct list rawinput_devices;/* list of registered rawinput devices */
95 const struct rawinput_device *rawinput_mouse; /* rawinput mouse device, if any */
96 const struct rawinput_device *rawinput_kbd; /* rawinput keyboard device, if any */
99 struct process_snapshot
101 struct process *process; /* process ptr */
102 int count; /* process refcount */
103 int threads; /* number of threads */
104 int priority; /* priority class */
105 int handles; /* number of handles */
106 int unix_pid; /* Unix pid */
109 #define CPU_FLAG(cpu) (1 << (cpu))
110 #define CPU_64BIT_MASK (CPU_FLAG(CPU_x86_64) | CPU_FLAG(CPU_ARM64))
112 /* process functions */
114 extern unsigned int alloc_ptid( void *ptr );
115 extern void free_ptid( unsigned int id );
116 extern void *get_ptid_entry( unsigned int id );
117 extern struct thread *create_process( int fd, struct thread *parent_thread, int inherit_all );
118 extern data_size_t init_process( struct thread *thread );
119 extern struct thread *get_process_first_thread( struct process *process );
120 extern struct process *get_process_from_id( process_id_t id );
121 extern struct process *get_process_from_handle( obj_handle_t handle, unsigned int access );
122 extern int process_set_debugger( struct process *process, struct thread *thread );
123 extern int debugger_detach( struct process* process, struct thread* debugger );
124 extern int set_process_debug_flag( struct process *process, int flag );
126 extern void add_process_thread( struct process *process,
127 struct thread *thread );
128 extern void remove_process_thread( struct process *process,
129 struct thread *thread );
130 extern void suspend_process( struct process *process );
131 extern void resume_process( struct process *process );
132 extern void kill_process( struct process *process, int violent_death );
133 extern void kill_console_processes( struct thread *renderer, int exit_code );
134 extern void kill_debugged_processes( struct thread *debugger, int exit_code );
135 extern void break_process( struct process *process );
136 extern void detach_debugged_processes( struct thread *debugger );
137 extern struct process_snapshot *process_snap( int *count );
138 extern void enum_processes( int (*cb)(struct process*, void*), void *user);
140 /* console functions */
141 extern void inherit_console(struct thread *parent_thread, struct process *process, obj_handle_t hconin);
142 extern int free_console( struct process *process );
143 extern struct thread *console_get_renderer( struct console_input *console );
145 /* process tracing mechanism to use */
146 #ifdef __APPLE__
147 #define USE_MACH
148 #elif defined(__sun)
149 #define USE_PROCFS
150 #else
151 #define USE_PTRACE
152 #endif
154 extern void init_tracing_mechanism(void);
155 extern void init_process_tracing( struct process *process );
156 extern void finish_process_tracing( struct process *process );
157 extern int read_process_memory( struct process *process, client_ptr_t ptr, data_size_t size, char *dest );
158 extern int write_process_memory( struct process *process, client_ptr_t ptr, data_size_t size, const char *src );
160 static inline process_id_t get_process_id( struct process *process ) { return process->id; }
162 static inline int is_process_init_done( struct process *process )
164 return process->startup_state == STARTUP_DONE;
167 static inline struct process_dll *get_process_exe_module( struct process *process )
169 struct list *ptr = list_head( &process->dlls );
170 return ptr ? LIST_ENTRY( ptr, struct process_dll, entry ) : NULL;
173 #endif /* __WINE_SERVER_PROCESS_H */