Added support for ReadProcessMemory through the server.
[wine/wine-kai.git] / server / thread.h
blob2d5c7a38875aa739402ed87e54ccb55cebb5eb9b
1 /*
2 * Wine server threads
4 * Copyright (C) 1998 Alexandre Julliard
5 */
7 #ifndef __WINE_SERVER_THREAD_H
8 #define __WINE_SERVER_THREAD_H
10 #ifndef __WINE_SERVER__
11 #error This file can only be used in the Wine server
12 #endif
14 #include "object.h"
16 /* thread structure */
18 struct process;
19 struct thread_wait;
20 struct thread_apc;
21 struct mutex;
22 struct debug_ctx;
23 struct debug_event;
25 enum run_state
27 RUNNING, /* running normally */
28 SLEEPING, /* sleeping waiting for a request to terminate */
29 TERMINATED /* terminated */
33 struct thread
35 struct object obj; /* object header */
36 struct thread *next; /* system-wide thread list */
37 struct thread *prev;
38 struct thread *proc_next; /* per-process thread list */
39 struct thread *proc_prev;
40 struct process *process;
41 struct mutex *mutex; /* list of currently owned mutexes */
42 struct debug_ctx *debug_ctx; /* debugger context if this thread is a debugger */
43 struct process *debug_first; /* head of debugged processes list */
44 struct debug_event *debug_event; /* pending debug event for this thread */
45 struct thread_wait *wait; /* current wait condition if sleeping */
46 struct thread_apc *apc; /* list of async procedure calls */
47 int apc_count; /* number of outstanding APCs */
48 int error; /* current error code */
49 enum run_state state; /* running state */
50 int attached; /* is thread attached with ptrace? */
51 int exit_code; /* thread exit code */
52 struct client *client; /* client for socket communications */
53 int unix_pid; /* Unix pid of client */
54 void *teb; /* TEB address (in client address space) */
55 int priority; /* priority level */
56 int affinity; /* affinity mask */
57 int suspend; /* suspend count */
58 void *buffer; /* buffer for communication with the client */
59 enum request last_req; /* last request received (for debugging) */
62 extern struct thread *current;
64 /* thread functions */
66 extern void create_initial_thread( int fd );
67 extern struct thread *get_thread_from_id( void *id );
68 extern struct thread *get_thread_from_handle( int handle, unsigned int access );
69 extern void wait4_thread( struct thread *thread, int wait );
70 extern void stop_thread( struct thread *thread );
71 extern void continue_thread( struct thread *thread );
72 extern int suspend_thread( struct thread *thread, int check_limit );
73 extern int resume_thread( struct thread *thread );
74 extern void suspend_all_threads( void );
75 extern void resume_all_threads( void );
76 extern int add_queue( struct object *obj, struct wait_queue_entry *entry );
77 extern void remove_queue( struct object *obj, struct wait_queue_entry *entry );
78 extern void kill_thread( struct thread *thread, int exit_code );
79 extern void thread_killed( struct thread *thread, int exit_code );
80 extern void thread_timeout(void);
81 extern void wake_up( struct object *obj, int max );
83 static inline int get_error(void) { return current->error; }
84 static inline void set_error( int err ) { current->error = err; }
85 static inline void clear_error(void) { set_error(0); }
87 #endif /* __WINE_SERVER_THREAD_H */