2 * Wine server definitions
4 * Copyright (C) 1998 Alexandre Julliard
7 #ifndef __WINE_SERVER_H
8 #define __WINE_SERVER_H
13 /* message header as sent on the wire */
16 unsigned int len
; /* total msg length (including this header) */
17 unsigned int type
; /* msg type */
18 unsigned int seq
; /* sequence number */
21 /* max msg length (not including the header) */
22 #define MAX_MSG_LENGTH (16384 - sizeof(struct header))
24 /* data structure used to pass an fd with sendmsg/recvmsg */
27 int len
; /* sizeof structure */
28 int level
; /* SOL_SOCKET */
29 int type
; /* SCM_RIGHTS */
30 int fd
; /* fd to pass */
34 /* Request structures */
36 /* following are the definitions of all the client<->server */
37 /* communication format; requests are from client to server, */
38 /* replies are from server to client. All requests must have */
39 /* a corresponding structure; the replies can be empty in */
40 /* which case it isn't necessary to define a structure. */
43 /* Create a new thread from the context of the parent */
44 struct new_thread_request
46 void* pid
; /* process id for the new thread (or 0 if none yet) */
48 struct new_thread_reply
50 void* tid
; /* thread id */
51 int thandle
; /* thread handle (in the current process) */
52 void* pid
; /* process id (created if necessary) */
53 int phandle
; /* process handle (in the current process) */
57 /* Set the server debug level */
58 struct set_debug_request
60 int level
; /* New debug level */
64 /* Initialize a thread; called from the child after fork()/clone() */
65 struct init_thread_request
67 int unix_pid
; /* Unix pid of new thread */
68 char cmd_line
[0]; /* Thread command line */
72 /* Terminate a process */
73 struct terminate_process_request
75 int handle
; /* process handle to terminate */
76 int exit_code
; /* process exit code */
80 /* Terminate a thread */
81 struct terminate_thread_request
83 int handle
; /* thread handle to terminate */
84 int exit_code
; /* thread exit code */
88 /* Retrieve information about a process */
89 struct get_process_info_request
91 int handle
; /* process handle */
93 struct get_process_info_reply
95 void* pid
; /* server process id */
96 int exit_code
; /* process exit code */
100 /* Retrieve information about a thread */
101 struct get_thread_info_request
103 int handle
; /* thread handle */
105 struct get_thread_info_reply
107 void* pid
; /* server thread id */
108 int exit_code
; /* thread exit code */
112 /* Close a handle for the current process */
113 struct close_handle_request
115 int handle
; /* handle to close */
119 /* Duplicate a handle */
120 struct dup_handle_request
122 int src_process
; /* src process handle */
123 int src_handle
; /* src handle to duplicate */
124 int dst_process
; /* dst process handle */
125 int dst_handle
; /* handle to duplicate to (or -1 for any) */
126 unsigned int access
; /* wanted access rights */
127 int inherit
; /* inherit flag */
128 int options
; /* duplicate options (see below) */
130 #define DUP_HANDLE_CLOSE_SOURCE DUPLICATE_CLOSE_SOURCE
131 #define DUP_HANDLE_SAME_ACCESS DUPLICATE_SAME_ACCESS
132 #define DUP_HANDLE_MAKE_GLOBAL 0x80000000 /* Not a Windows flag */
133 struct dup_handle_reply
135 int handle
; /* duplicated handle in dst process */
139 /* Open a handle to a process */
140 struct open_process_request
142 void* pid
; /* process id to open */
143 unsigned int access
; /* wanted access rights */
144 int inherit
; /* inherit flag */
146 struct open_process_reply
148 int handle
; /* handle to the process */
152 /* Wait for handles */
153 struct select_request
155 int count
; /* handles count */
156 int flags
; /* wait flags (see below) */
157 int timeout
; /* timeout in ms */
162 int signaled
; /* signaled handle */
166 #define SELECT_ALERTABLE 4
167 #define SELECT_TIMEOUT 8
170 /* Create an event */
171 struct create_event_request
173 int manual_reset
; /* manual reset event */
174 int initial_state
; /* initial state of the event */
175 int inherit
; /* inherit flag */
176 char name
[0]; /* event name */
178 struct create_event_reply
180 int handle
; /* handle to the event */
183 /* Event operation */
184 struct event_op_request
186 int handle
; /* handle to event */
187 int op
; /* event operation (see below) */
189 enum event_op
{ PULSE_EVENT
, SET_EVENT
, RESET_EVENT
};
193 struct create_mutex_request
195 int owned
; /* initially owned? */
196 int inherit
; /* inherit flag */
197 char name
[0]; /* mutex name */
199 struct create_mutex_reply
201 int handle
; /* handle to the mutex */
205 /* Release a mutex */
206 struct release_mutex_request
208 int handle
; /* handle to the mutex */
212 /* Create a semaphore */
213 struct create_semaphore_request
215 unsigned int initial
; /* initial count */
216 unsigned int max
; /* maximum count */
217 int inherit
; /* inherit flag */
218 char name
[0]; /* semaphore name */
220 struct create_semaphore_reply
222 int handle
; /* handle to the semaphore */
226 /* Release a semaphore */
227 struct release_semaphore_request
229 int handle
; /* handle to the semaphore */
230 unsigned int count
; /* count to add to semaphore */
232 struct release_semaphore_reply
234 unsigned int prev_count
; /* previous semaphore count */
238 /* Open a named object (event, mutex, semaphore) */
239 struct open_named_obj_request
241 int type
; /* object type (see below) */
242 unsigned int access
; /* wanted access rights */
243 int inherit
; /* inherit flag */
244 char name
[0]; /* object name */
246 enum open_named_obj
{ OPEN_EVENT
, OPEN_MUTEX
, OPEN_SEMAPHORE
};
248 struct open_named_obj_reply
250 int handle
; /* handle to the object */
255 struct create_file_request
257 unsigned int access
; /* wanted access rights */
258 int inherit
; /* inherit flag */
260 struct create_file_reply
262 int handle
; /* handle to the file */
266 /* Get a Unix handle to a file */
267 struct get_unix_handle_request
269 int handle
; /* handle to the file */
270 unsigned int access
; /* desired access */
274 /* Get a Unix fd to read from a file */
275 struct get_read_fd_request
277 int handle
; /* handle to the file */
281 /* Get a Unix fd to write to a file */
282 struct get_write_fd_request
284 int handle
; /* handle to the file */
288 /* Set a file current position */
289 struct set_file_pointer_request
291 int handle
; /* handle to the file */
292 int low
; /* position low word */
293 int high
; /* position high word */
294 int whence
; /* whence to seek */
296 struct set_file_pointer_reply
298 int low
; /* new position low word */
299 int high
; /* new position high word */
303 /* Truncate (or extend) a file */
304 struct truncate_file_request
306 int handle
; /* handle to the file */
310 /* Flush a file buffers */
311 struct flush_file_request
313 int handle
; /* handle to the file */
317 /* Get information about a file */
318 struct get_file_info_request
320 int handle
; /* handle to the file */
322 struct get_file_info_reply
324 int attr
; /* file attributes */
325 time_t access_time
; /* last access time */
326 time_t write_time
; /* last write time */
327 int size_high
; /* file size */
328 int size_low
; /* file size */
329 int links
; /* number of links */
330 int index_high
; /* unique index */
331 int index_low
; /* unique index */
332 unsigned int serial
; /* volume serial number */
336 /* Create an anonymous pipe */
337 struct create_pipe_request
339 int inherit
; /* inherit flag */
341 struct create_pipe_reply
343 int handle_read
; /* handle to the read-side of the pipe */
344 int handle_write
; /* handle to the write-side of the pipe */
348 /* Create a console */
349 struct create_console_request
351 int inherit
; /* inherit flag */
353 struct create_console_reply
355 int handle_read
; /* handle to read from the console */
356 int handle_write
; /* handle to write to the console */
360 /* Set a console file descriptor */
361 struct set_console_fd_request
363 int handle
; /* handle to the console */
367 /* Create a console */
368 struct create_change_notification_request
370 int subtree
; /* watch all the subtree */
371 int filter
; /* notification filter */
373 struct create_change_notification_reply
375 int handle
; /* handle to the change notification */
379 /* client-side functions */
381 #ifndef __WINE_SERVER__
383 #include "server/request.h"
385 /* client communication functions */
386 #define CHECK_LEN(len,wanted) \
387 if ((len) == (wanted)) ; \
388 else CLIENT_ProtocolError( __FUNCTION__ ": len %d != %d\n", (len), (wanted) );
389 extern void CLIENT_ProtocolError( const char *err
, ... );
390 extern void CLIENT_SendRequest( enum request req
, int pass_fd
,
391 int n
, ... /* arg_1, len_1, etc. */ );
392 extern unsigned int CLIENT_WaitReply( int *len
, int *passed_fd
,
393 int n
, ... /* arg_1, len_1, etc. */ );
396 extern int CLIENT_NewThread( struct _THDB
*thdb
, int *thandle
, int *phandle
);
397 extern int CLIENT_SetDebug( int level
);
398 extern int CLIENT_InitThread(void);
399 extern int CLIENT_CloseHandle( int handle
);
400 extern int CLIENT_DuplicateHandle( int src_process
, int src_handle
, int dst_process
,
401 int dst_handle
, DWORD access
, BOOL32 inherit
, DWORD options
);
402 extern int CLIENT_GetThreadInfo( int handle
, struct get_thread_info_reply
*reply
);
403 extern int CLIENT_GetProcessInfo( int handle
, struct get_process_info_reply
*reply
);
404 extern int CLIENT_OpenProcess( void *pid
, DWORD access
, BOOL32 inherit
);
405 extern int CLIENT_Select( int count
, int *handles
, int flags
, int timeout
);
406 #endif /* __WINE_SERVER__ */
408 #endif /* __WINE_SERVER_H */