user32: Popup menu position fixes.
[wine] / server / process.h
CommitLineData
43c190e7
AJ
1/*
2 * Wine server processes
3 *
4 * Copyright (C) 1999 Alexandre Julliard
0799c1a7
AJ
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
360a3f91 18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
43c190e7
AJ
19 */
20
21#ifndef __WINE_SERVER_PROCESS_H
22#define __WINE_SERVER_PROCESS_H
23
43c190e7
AJ
24#include "object.h"
25
c5e433a3 26struct msg_queue;
43a27e36 27struct atom_table;
526a28de 28struct handle_table;
9d802152 29struct startup_info;
c5e433a3 30
ca96de34
AJ
31/* process startup state */
32enum startup_state { STARTUP_IN_PROGRESS, STARTUP_DONE, STARTUP_ABORTED };
33
43c190e7
AJ
34/* process structures */
35
05f0b71b
AJ
36struct process_dll
37{
a9e0fb1b 38 struct list entry; /* entry in per-process dll list */
05f0b71b
AJ
39 struct file *file; /* dll file */
40 void *base; /* dll base address (in process addr space) */
aeb56605 41 size_t size; /* dll size */
05f0b71b
AJ
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 */
aeb56605 45 size_t namelen; /* length of dll file name */
c30cefb2 46 WCHAR *filename; /* dll file name */
05f0b71b
AJ
47};
48
3da5f84d
AJ
49struct process
50{
51 struct object obj; /* object header */
48c0d51d 52 struct list entry; /* entry in system-wide process list */
0b83d4cb 53 struct process *parent; /* parent process */
0502638e 54 struct list thread_list; /* thread list */
3da5f84d 55 struct thread *debugger; /* thread debugging this process */
526a28de 56 struct handle_table *handles; /* handle entries */
e66207eb 57 struct fd *msg_fd; /* fd for sendmsg/recvmsg */
91befe1d
AJ
58 process_id_t id; /* id of the process */
59 process_id_t group_id; /* group id of the process */
3da5f84d
AJ
60 int exit_code; /* process exit code */
61 int running_threads; /* number of threads running in this process */
62 struct timeval start_time; /* absolute time at process start */
63 struct timeval end_time; /* absolute time at process end */
64 int priority; /* priority class */
65 int affinity; /* process affinity mask */
66 int suspend; /* global process suspend count */
01caa5e6 67 unsigned int create_flags; /* process creation flags */
ce613493 68 struct list locks; /* list of file locks owned by the process */
bfce151a 69 struct list classes; /* window classes owned by the process */
0b83d4cb 70 struct console_input*console; /* console input */
ca96de34 71 enum startup_state startup_state; /* startup state */
9d802152 72 struct startup_info *startup_info; /* startup info while init is in progress */
c5e433a3
AJ
73 struct event *idle_event; /* event for input idle */
74 struct msg_queue *queue; /* main message queue */
1bf96e09 75 obj_handle_t winstation; /* main handle to process window station */
78a3e633 76 obj_handle_t desktop; /* handle to desktop to use for new threads */
36cd6f5d 77 struct token *token; /* security token associated with this process */
a9e0fb1b 78 struct list dlls; /* list of loaded dlls */
e55d5937 79 void *peb; /* PEB address in client address space */
0a7c1f6c 80 void *ldt_copy; /* pointer to LDT copy in client addr space */
3da5f84d 81};
43c190e7
AJ
82
83struct process_snapshot
84{
85 struct process *process; /* process ptr */
07d84469 86 int count; /* process refcount */
43c190e7
AJ
87 int threads; /* number of threads */
88 int priority; /* priority class */
9fd54b28 89 int handles; /* number of handles */
43c190e7
AJ
90};
91
07d84469
AJ
92struct module_snapshot
93{
94 void *base; /* module base addr */
aeb56605
AJ
95 size_t size; /* module size */
96 size_t namelen; /* length of file name */
c30cefb2 97 WCHAR *filename; /* module file name */
07d84469
AJ
98};
99
43c190e7
AJ
100/* process functions */
101
91befe1d
AJ
102extern unsigned int alloc_ptid( void *ptr );
103extern void free_ptid( unsigned int id );
104extern void *get_ptid_entry( unsigned int id );
5b4f3e8d 105extern struct thread *create_process( int fd );
11ad6a0a 106extern size_t init_process( struct thread *thread );
0502638e 107extern struct thread *get_process_first_thread( struct process *process );
54f22873 108extern struct process *get_process_from_id( process_id_t id );
51885749 109extern struct process *get_process_from_handle( obj_handle_t handle, unsigned int access );
3da5f84d 110extern int process_set_debugger( struct process *process, struct thread *thread );
fbccb38e 111extern int debugger_detach( struct process* process, struct thread* debugger );
e55d5937 112extern int set_process_debug_flag( struct process *process, int flag );
fbccb38e 113
43c190e7
AJ
114extern void add_process_thread( struct process *process,
115 struct thread *thread );
116extern void remove_process_thread( struct process *process,
117 struct thread *thread );
3da5f84d
AJ
118extern void suspend_process( struct process *process );
119extern void resume_process( struct process *process );
40043ed2 120extern void kill_all_processes( struct process *skip, int exit_code );
f5242405 121extern void kill_process( struct process *process, struct thread *skip, int exit_code );
3940d8a2 122extern void kill_console_processes( struct thread *renderer, int exit_code );
17cf8101 123extern void kill_debugged_processes( struct thread *debugger, int exit_code );
17de8290 124extern void break_process( struct process *process );
fbccb38e 125extern void detach_debugged_processes( struct thread *debugger );
43c190e7 126extern struct process_snapshot *process_snap( int *count );
07d84469 127extern struct module_snapshot *module_snap( struct process *process, int *count );
93bfa0d6 128extern void enum_processes( int (*cb)(struct process*, void*), void *user);
cb70931f
AJ
129extern int read_process_memory( struct process *process, const void *ptr, size_t size, char *dest );
130extern int write_process_memory( struct process *process, void *ptr, size_t size, const char *src );
43c190e7 131
91befe1d
AJ
132inline static process_id_t get_process_id( struct process *process ) { return process->id; }
133
ca96de34
AJ
134inline static int is_process_init_done( struct process *process )
135{
136 return process->startup_state == STARTUP_DONE;
137}
ff81d787 138
e6374cbe
AJ
139inline static struct process_dll *get_process_exe_module( struct process *process )
140{
141 struct list *ptr = list_head( &process->dlls );
142 return ptr ? LIST_ENTRY( ptr, struct process_dll, entry ) : NULL;
143}
144
43c190e7 145#endif /* __WINE_SERVER_PROCESS_H */