Fixed get_event_obj/get_file_obj to use the process parameter (thanks
[wine.git] / server / request.h
blobd34c79863953337ff481e08b121af3201acbb1e1
1 /*
2 * Wine server requests
4 * Copyright (C) 1999 Alexandre Julliard
5 */
7 #ifndef __WINE_SERVER_REQUEST_H
8 #define __WINE_SERVER_REQUEST_H
10 #ifndef __WINE_SERVER__
11 #error This file can only be used in the Wine server
12 #endif
14 #include "thread.h"
16 /* max request length */
17 #define MAX_REQUEST_LENGTH 8192
19 /* exit code passed to remove_client on communication error */
20 #define OUT_OF_MEMORY -1
21 #define BROKEN_PIPE -2
22 #define PROTOCOL_ERROR -3
24 /* request handler definition */
25 #define DECL_HANDLER(name) void req_##name( struct name##_request *req, int fd )
27 /* request functions */
29 extern void fatal_protocol_error( struct thread *thread, const char *err, ... );
30 extern void call_req_handler( struct thread *thread, enum request req, int fd );
31 extern void call_timeout_handler( void *thread );
32 extern void call_kill_handler( struct thread *thread, int exit_code );
33 extern void set_reply_fd( struct thread *thread, int pass_fd );
34 extern void send_reply( struct thread *thread );
36 extern void trace_request( enum request req, int fd );
37 extern void trace_timeout(void);
38 extern void trace_kill( int exit_code );
39 extern void trace_reply( struct thread *thread, unsigned int res, int pass_fd );
41 /* get the request buffer */
42 static inline void *get_req_ptr( struct thread *thread )
44 return thread->buffer;
47 /* get the remaining size in the request buffer for object of a given size */
48 static inline int get_req_size( const void *ptr, size_t typesize )
50 return ((char *)current->buffer + MAX_REQUEST_LENGTH - (char *)ptr) / typesize;
53 /* get the length of a request string, without going past the end of the request */
54 static inline size_t get_req_strlen( const char *str )
56 const char *p = str;
57 while (*p && (p < (char *)current->buffer + MAX_REQUEST_LENGTH - 1)) p++;
58 return p - str;
61 /* same as above for Unicode */
62 static inline size_t get_req_strlenW( const WCHAR *str )
64 const WCHAR *p = str;
65 while (*p && ((char *)p < (char *)current->buffer + MAX_REQUEST_LENGTH - 2)) p++;
66 return p - str;
69 /* Everything below this line is generated automatically by tools/make_requests */
70 /* ### make_requests begin ### */
72 DECL_HANDLER(new_process);
73 DECL_HANDLER(new_thread);
74 DECL_HANDLER(set_debug);
75 DECL_HANDLER(init_process);
76 DECL_HANDLER(init_process_done);
77 DECL_HANDLER(init_thread);
78 DECL_HANDLER(get_thread_buffer);
79 DECL_HANDLER(terminate_process);
80 DECL_HANDLER(terminate_thread);
81 DECL_HANDLER(get_process_info);
82 DECL_HANDLER(set_process_info);
83 DECL_HANDLER(get_thread_info);
84 DECL_HANDLER(set_thread_info);
85 DECL_HANDLER(suspend_thread);
86 DECL_HANDLER(resume_thread);
87 DECL_HANDLER(debugger);
88 DECL_HANDLER(queue_apc);
89 DECL_HANDLER(get_apcs);
90 DECL_HANDLER(close_handle);
91 DECL_HANDLER(get_handle_info);
92 DECL_HANDLER(set_handle_info);
93 DECL_HANDLER(dup_handle);
94 DECL_HANDLER(open_process);
95 DECL_HANDLER(select);
96 DECL_HANDLER(create_event);
97 DECL_HANDLER(event_op);
98 DECL_HANDLER(open_event);
99 DECL_HANDLER(create_mutex);
100 DECL_HANDLER(release_mutex);
101 DECL_HANDLER(open_mutex);
102 DECL_HANDLER(create_semaphore);
103 DECL_HANDLER(release_semaphore);
104 DECL_HANDLER(open_semaphore);
105 DECL_HANDLER(create_file);
106 DECL_HANDLER(alloc_file_handle);
107 DECL_HANDLER(get_read_fd);
108 DECL_HANDLER(get_write_fd);
109 DECL_HANDLER(set_file_pointer);
110 DECL_HANDLER(truncate_file);
111 DECL_HANDLER(set_file_time);
112 DECL_HANDLER(flush_file);
113 DECL_HANDLER(get_file_info);
114 DECL_HANDLER(lock_file);
115 DECL_HANDLER(unlock_file);
116 DECL_HANDLER(create_pipe);
117 DECL_HANDLER(create_socket);
118 DECL_HANDLER(accept_socket);
119 DECL_HANDLER(set_socket_event);
120 DECL_HANDLER(get_socket_event);
121 DECL_HANDLER(enable_socket_event);
122 DECL_HANDLER(alloc_console);
123 DECL_HANDLER(free_console);
124 DECL_HANDLER(open_console);
125 DECL_HANDLER(set_console_fd);
126 DECL_HANDLER(get_console_mode);
127 DECL_HANDLER(set_console_mode);
128 DECL_HANDLER(set_console_info);
129 DECL_HANDLER(get_console_info);
130 DECL_HANDLER(write_console_input);
131 DECL_HANDLER(read_console_input);
132 DECL_HANDLER(create_change_notification);
133 DECL_HANDLER(create_mapping);
134 DECL_HANDLER(open_mapping);
135 DECL_HANDLER(get_mapping_info);
136 DECL_HANDLER(create_device);
137 DECL_HANDLER(create_snapshot);
138 DECL_HANDLER(next_process);
139 DECL_HANDLER(wait_debug_event);
140 DECL_HANDLER(send_debug_event);
141 DECL_HANDLER(continue_debug_event);
142 DECL_HANDLER(debug_process);
143 DECL_HANDLER(read_process_memory);
144 DECL_HANDLER(write_process_memory);
145 DECL_HANDLER(create_key);
146 DECL_HANDLER(open_key);
147 DECL_HANDLER(delete_key);
148 DECL_HANDLER(close_key);
149 DECL_HANDLER(enum_key);
150 DECL_HANDLER(query_key_info);
151 DECL_HANDLER(set_key_value);
152 DECL_HANDLER(get_key_value);
153 DECL_HANDLER(enum_key_value);
154 DECL_HANDLER(delete_key_value);
155 DECL_HANDLER(load_registry);
156 DECL_HANDLER(save_registry);
157 DECL_HANDLER(set_registry_levels);
158 DECL_HANDLER(create_timer);
159 DECL_HANDLER(open_timer);
160 DECL_HANDLER(set_timer);
161 DECL_HANDLER(cancel_timer);
163 #ifdef WANT_REQUEST_HANDLERS
165 static const struct handler {
166 void (*handler)( void *req, int fd );
167 unsigned int min_size;
168 } req_handlers[REQ_NB_REQUESTS] = {
169 { (void(*)())req_new_process, sizeof(struct new_process_request) },
170 { (void(*)())req_new_thread, sizeof(struct new_thread_request) },
171 { (void(*)())req_set_debug, sizeof(struct set_debug_request) },
172 { (void(*)())req_init_process, sizeof(struct init_process_request) },
173 { (void(*)())req_init_process_done, sizeof(struct init_process_done_request) },
174 { (void(*)())req_init_thread, sizeof(struct init_thread_request) },
175 { (void(*)())req_get_thread_buffer, sizeof(struct get_thread_buffer_request) },
176 { (void(*)())req_terminate_process, sizeof(struct terminate_process_request) },
177 { (void(*)())req_terminate_thread, sizeof(struct terminate_thread_request) },
178 { (void(*)())req_get_process_info, sizeof(struct get_process_info_request) },
179 { (void(*)())req_set_process_info, sizeof(struct set_process_info_request) },
180 { (void(*)())req_get_thread_info, sizeof(struct get_thread_info_request) },
181 { (void(*)())req_set_thread_info, sizeof(struct set_thread_info_request) },
182 { (void(*)())req_suspend_thread, sizeof(struct suspend_thread_request) },
183 { (void(*)())req_resume_thread, sizeof(struct resume_thread_request) },
184 { (void(*)())req_debugger, sizeof(struct debugger_request) },
185 { (void(*)())req_queue_apc, sizeof(struct queue_apc_request) },
186 { (void(*)())req_get_apcs, sizeof(struct get_apcs_request) },
187 { (void(*)())req_close_handle, sizeof(struct close_handle_request) },
188 { (void(*)())req_get_handle_info, sizeof(struct get_handle_info_request) },
189 { (void(*)())req_set_handle_info, sizeof(struct set_handle_info_request) },
190 { (void(*)())req_dup_handle, sizeof(struct dup_handle_request) },
191 { (void(*)())req_open_process, sizeof(struct open_process_request) },
192 { (void(*)())req_select, sizeof(struct select_request) },
193 { (void(*)())req_create_event, sizeof(struct create_event_request) },
194 { (void(*)())req_event_op, sizeof(struct event_op_request) },
195 { (void(*)())req_open_event, sizeof(struct open_event_request) },
196 { (void(*)())req_create_mutex, sizeof(struct create_mutex_request) },
197 { (void(*)())req_release_mutex, sizeof(struct release_mutex_request) },
198 { (void(*)())req_open_mutex, sizeof(struct open_mutex_request) },
199 { (void(*)())req_create_semaphore, sizeof(struct create_semaphore_request) },
200 { (void(*)())req_release_semaphore, sizeof(struct release_semaphore_request) },
201 { (void(*)())req_open_semaphore, sizeof(struct open_semaphore_request) },
202 { (void(*)())req_create_file, sizeof(struct create_file_request) },
203 { (void(*)())req_alloc_file_handle, sizeof(struct alloc_file_handle_request) },
204 { (void(*)())req_get_read_fd, sizeof(struct get_read_fd_request) },
205 { (void(*)())req_get_write_fd, sizeof(struct get_write_fd_request) },
206 { (void(*)())req_set_file_pointer, sizeof(struct set_file_pointer_request) },
207 { (void(*)())req_truncate_file, sizeof(struct truncate_file_request) },
208 { (void(*)())req_set_file_time, sizeof(struct set_file_time_request) },
209 { (void(*)())req_flush_file, sizeof(struct flush_file_request) },
210 { (void(*)())req_get_file_info, sizeof(struct get_file_info_request) },
211 { (void(*)())req_lock_file, sizeof(struct lock_file_request) },
212 { (void(*)())req_unlock_file, sizeof(struct unlock_file_request) },
213 { (void(*)())req_create_pipe, sizeof(struct create_pipe_request) },
214 { (void(*)())req_create_socket, sizeof(struct create_socket_request) },
215 { (void(*)())req_accept_socket, sizeof(struct accept_socket_request) },
216 { (void(*)())req_set_socket_event, sizeof(struct set_socket_event_request) },
217 { (void(*)())req_get_socket_event, sizeof(struct get_socket_event_request) },
218 { (void(*)())req_enable_socket_event, sizeof(struct enable_socket_event_request) },
219 { (void(*)())req_alloc_console, sizeof(struct alloc_console_request) },
220 { (void(*)())req_free_console, sizeof(struct free_console_request) },
221 { (void(*)())req_open_console, sizeof(struct open_console_request) },
222 { (void(*)())req_set_console_fd, sizeof(struct set_console_fd_request) },
223 { (void(*)())req_get_console_mode, sizeof(struct get_console_mode_request) },
224 { (void(*)())req_set_console_mode, sizeof(struct set_console_mode_request) },
225 { (void(*)())req_set_console_info, sizeof(struct set_console_info_request) },
226 { (void(*)())req_get_console_info, sizeof(struct get_console_info_request) },
227 { (void(*)())req_write_console_input, sizeof(struct write_console_input_request) },
228 { (void(*)())req_read_console_input, sizeof(struct read_console_input_request) },
229 { (void(*)())req_create_change_notification, sizeof(struct create_change_notification_request) },
230 { (void(*)())req_create_mapping, sizeof(struct create_mapping_request) },
231 { (void(*)())req_open_mapping, sizeof(struct open_mapping_request) },
232 { (void(*)())req_get_mapping_info, sizeof(struct get_mapping_info_request) },
233 { (void(*)())req_create_device, sizeof(struct create_device_request) },
234 { (void(*)())req_create_snapshot, sizeof(struct create_snapshot_request) },
235 { (void(*)())req_next_process, sizeof(struct next_process_request) },
236 { (void(*)())req_wait_debug_event, sizeof(struct wait_debug_event_request) },
237 { (void(*)())req_send_debug_event, sizeof(struct send_debug_event_request) },
238 { (void(*)())req_continue_debug_event, sizeof(struct continue_debug_event_request) },
239 { (void(*)())req_debug_process, sizeof(struct debug_process_request) },
240 { (void(*)())req_read_process_memory, sizeof(struct read_process_memory_request) },
241 { (void(*)())req_write_process_memory, sizeof(struct write_process_memory_request) },
242 { (void(*)())req_create_key, sizeof(struct create_key_request) },
243 { (void(*)())req_open_key, sizeof(struct open_key_request) },
244 { (void(*)())req_delete_key, sizeof(struct delete_key_request) },
245 { (void(*)())req_close_key, sizeof(struct close_key_request) },
246 { (void(*)())req_enum_key, sizeof(struct enum_key_request) },
247 { (void(*)())req_query_key_info, sizeof(struct query_key_info_request) },
248 { (void(*)())req_set_key_value, sizeof(struct set_key_value_request) },
249 { (void(*)())req_get_key_value, sizeof(struct get_key_value_request) },
250 { (void(*)())req_enum_key_value, sizeof(struct enum_key_value_request) },
251 { (void(*)())req_delete_key_value, sizeof(struct delete_key_value_request) },
252 { (void(*)())req_load_registry, sizeof(struct load_registry_request) },
253 { (void(*)())req_save_registry, sizeof(struct save_registry_request) },
254 { (void(*)())req_set_registry_levels, sizeof(struct set_registry_levels_request) },
255 { (void(*)())req_create_timer, sizeof(struct create_timer_request) },
256 { (void(*)())req_open_timer, sizeof(struct open_timer_request) },
257 { (void(*)())req_set_timer, sizeof(struct set_timer_request) },
258 { (void(*)())req_cancel_timer, sizeof(struct cancel_timer_request) },
260 #endif /* WANT_REQUEST_HANDLERS */
262 /* ### make_requests end ### */
263 /* Everything above this line is generated automatically by tools/make_requests */
265 #endif /* __WINE_SERVER_REQUEST_H */