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 */
165 #define SELECT_ALERTABLE 2
166 #define SELECT_TIMEOUT 4
169 /* Create an event */
170 struct create_event_request
172 int manual_reset
; /* manual reset event */
173 int initial_state
; /* initial state of the event */
174 int inherit
; /* inherit flag */
175 char name
[0]; /* event name */
177 struct create_event_reply
179 int handle
; /* handle to the event */
182 /* Event operation */
183 struct event_op_request
185 int handle
; /* handle to event */
186 int op
; /* event operation (see below) */
188 enum event_op
{ PULSE_EVENT
, SET_EVENT
, RESET_EVENT
};
192 struct create_mutex_request
194 int owned
; /* initially owned? */
195 int inherit
; /* inherit flag */
196 char name
[0]; /* mutex name */
198 struct create_mutex_reply
200 int handle
; /* handle to the mutex */
204 /* Release a mutex */
205 struct release_mutex_request
207 int handle
; /* handle to the mutex */
211 /* Create a semaphore */
212 struct create_semaphore_request
214 unsigned int initial
; /* initial count */
215 unsigned int max
; /* maximum count */
216 int inherit
; /* inherit flag */
217 char name
[0]; /* semaphore name */
219 struct create_semaphore_reply
221 int handle
; /* handle to the semaphore */
225 /* Release a semaphore */
226 struct release_semaphore_request
228 int handle
; /* handle to the semaphore */
229 unsigned int count
; /* count to add to semaphore */
231 struct release_semaphore_reply
233 unsigned int prev_count
; /* previous semaphore count */
237 /* Open a named object (event, mutex, semaphore) */
238 struct open_named_obj_request
240 int type
; /* object type (see below) */
241 unsigned int access
; /* wanted access rights */
242 int inherit
; /* inherit flag */
243 char name
[0]; /* object name */
245 enum open_named_obj
{ OPEN_EVENT
, OPEN_MUTEX
, OPEN_SEMAPHORE
, OPEN_MAPPING
};
247 struct open_named_obj_reply
249 int handle
; /* handle to the object */
254 struct create_file_request
256 unsigned int access
; /* wanted access rights */
257 int inherit
; /* inherit flag */
258 unsigned int sharing
; /* sharing flags */
259 int create
; /* file create action */
260 unsigned int attrs
; /* file attributes for creation */
261 char name
[0]; /* file name */
263 struct create_file_reply
265 int handle
; /* handle to the file */
269 /* Get a Unix fd to read from a file */
270 struct get_read_fd_request
272 int handle
; /* handle to the file */
276 /* Get a Unix fd to write to a file */
277 struct get_write_fd_request
279 int handle
; /* handle to the file */
283 /* Set a file current position */
284 struct set_file_pointer_request
286 int handle
; /* handle to the file */
287 int low
; /* position low word */
288 int high
; /* position high word */
289 int whence
; /* whence to seek */
291 struct set_file_pointer_reply
293 int low
; /* new position low word */
294 int high
; /* new position high word */
298 /* Truncate (or extend) a file */
299 struct truncate_file_request
301 int handle
; /* handle to the file */
305 /* Set a file access and modification times */
306 struct set_file_time_request
308 int handle
; /* handle to the file */
309 time_t access_time
; /* last access time */
310 time_t write_time
; /* last write time */
314 /* Flush a file buffers */
315 struct flush_file_request
317 int handle
; /* handle to the file */
321 /* Get information about a file */
322 struct get_file_info_request
324 int handle
; /* handle to the file */
326 struct get_file_info_reply
328 int type
; /* file type */
329 int attr
; /* file attributes */
330 time_t access_time
; /* last access time */
331 time_t write_time
; /* last write time */
332 int size_high
; /* file size */
333 int size_low
; /* file size */
334 int links
; /* number of links */
335 int index_high
; /* unique index */
336 int index_low
; /* unique index */
337 unsigned int serial
; /* volume serial number */
341 /* Create an anonymous pipe */
342 struct create_pipe_request
344 int inherit
; /* inherit flag */
346 struct create_pipe_reply
348 int handle_read
; /* handle to the read-side of the pipe */
349 int handle_write
; /* handle to the write-side of the pipe */
353 /* Create a console */
354 struct create_console_request
356 int inherit
; /* inherit flag */
358 struct create_console_reply
360 int handle_read
; /* handle to read from the console */
361 int handle_write
; /* handle to write to the console */
365 /* Set a console file descriptor */
366 struct set_console_fd_request
368 int handle
; /* handle to the console */
372 /* Create a change notification */
373 struct create_change_notification_request
375 int subtree
; /* watch all the subtree */
376 int filter
; /* notification filter */
378 struct create_change_notification_reply
380 int handle
; /* handle to the change notification */
384 /* Create a file mapping */
385 struct create_mapping_request
387 int size_high
; /* mapping size */
388 int size_low
; /* mapping size */
389 int protect
; /* protection flags (see below) */
390 int handle
; /* file handle */
391 char name
[0]; /* object name */
393 struct create_mapping_reply
395 int handle
; /* handle to the mapping */
397 /* protection flags */
398 #define VPROT_READ 0x01
399 #define VPROT_WRITE 0x02
400 #define VPROT_EXEC 0x04
401 #define VPROT_WRITECOPY 0x08
402 #define VPROT_GUARD 0x10
403 #define VPROT_NOCACHE 0x20
404 #define VPROT_COMMITTED 0x40
407 /* Get information about a file mapping */
408 struct get_mapping_info_request
410 int handle
; /* handle to the mapping */
412 struct get_mapping_info_reply
414 int size_high
; /* mapping size */
415 int size_low
; /* mapping size */
416 int protect
; /* protection flags */
420 /* client-side functions */
422 #ifndef __WINE_SERVER__
424 #include "server/request.h"
426 /* client communication functions */
427 extern void CLIENT_SendRequest( enum request req
, int pass_fd
,
428 int n
, ... /* arg_1, len_1, etc. */ );
429 extern unsigned int CLIENT_WaitReply( int *len
, int *passed_fd
,
430 int n
, ... /* arg_1, len_1, etc. */ );
431 extern unsigned int CLIENT_WaitSimpleReply( void *reply
, int len
, int *passed_fd
);
434 extern int CLIENT_NewThread( struct _THDB
*thdb
, int *thandle
, int *phandle
);
435 extern int CLIENT_SetDebug( int level
);
436 extern int CLIENT_InitThread(void);
437 extern int CLIENT_CloseHandle( int handle
);
438 extern int CLIENT_DuplicateHandle( int src_process
, int src_handle
, int dst_process
,
439 int dst_handle
, DWORD access
, BOOL32 inherit
, DWORD options
);
440 extern int CLIENT_OpenProcess( void *pid
, DWORD access
, BOOL32 inherit
);
441 extern int CLIENT_Select( int count
, int *handles
, int flags
, int timeout
);
442 #endif /* __WINE_SERVER__ */
444 #endif /* __WINE_SERVER_H */