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 */
97 int priority
; /* priority class */
98 int process_affinity
; /* process affinity mask */
99 int system_affinity
; /* system affinity mask */
103 /* Set a process informations */
104 struct set_process_info_request
106 int handle
; /* process handle */
107 int mask
; /* setting mask (see below) */
108 int priority
; /* priority class */
109 int affinity
; /* affinity mask */
111 #define SET_PROCESS_INFO_PRIORITY 0x01
112 #define SET_PROCESS_INFO_AFFINITY 0x02
115 /* Retrieve information about a thread */
116 struct get_thread_info_request
118 int handle
; /* thread handle */
120 struct get_thread_info_reply
122 void* pid
; /* server thread id */
123 int exit_code
; /* thread exit code */
124 int priority
; /* thread priority level */
128 /* Set a thread informations */
129 struct set_thread_info_request
131 int handle
; /* thread handle */
132 int mask
; /* setting mask (see below) */
133 int priority
; /* priority class */
134 int affinity
; /* affinity mask */
136 #define SET_THREAD_INFO_PRIORITY 0x01
137 #define SET_THREAD_INFO_AFFINITY 0x02
140 /* Suspend a thread */
141 struct suspend_thread_request
143 int handle
; /* thread handle */
145 struct suspend_thread_reply
147 int count
; /* new suspend count */
151 /* Resume a thread */
152 struct resume_thread_request
154 int handle
; /* thread handle */
156 struct resume_thread_reply
158 int count
; /* new suspend count */
162 /* Queue an APC for a thread */
163 struct queue_apc_request
165 int handle
; /* thread handle */
166 void* func
; /* function to call */
167 void* param
; /* param for function to call */
171 /* Close a handle for the current process */
172 struct close_handle_request
174 int handle
; /* handle to close */
178 /* Get information about a handle */
179 struct get_handle_info_request
181 int handle
; /* handle we are interested in */
183 struct get_handle_info_reply
185 int flags
; /* handle flags */
189 /* Set a handle information */
190 struct set_handle_info_request
192 int handle
; /* handle we are interested in */
193 int flags
; /* new handle flags */
194 int mask
; /* mask for flags to set */
198 /* Duplicate a handle */
199 struct dup_handle_request
201 int src_process
; /* src process handle */
202 int src_handle
; /* src handle to duplicate */
203 int dst_process
; /* dst process handle */
204 int dst_handle
; /* handle to duplicate to (or -1 for any) */
205 unsigned int access
; /* wanted access rights */
206 int inherit
; /* inherit flag */
207 int options
; /* duplicate options (see below) */
209 #define DUP_HANDLE_CLOSE_SOURCE DUPLICATE_CLOSE_SOURCE
210 #define DUP_HANDLE_SAME_ACCESS DUPLICATE_SAME_ACCESS
211 #define DUP_HANDLE_MAKE_GLOBAL 0x80000000 /* Not a Windows flag */
212 struct dup_handle_reply
214 int handle
; /* duplicated handle in dst process */
218 /* Open a handle to a process */
219 struct open_process_request
221 void* pid
; /* process id to open */
222 unsigned int access
; /* wanted access rights */
223 int inherit
; /* inherit flag */
225 struct open_process_reply
227 int handle
; /* handle to the process */
231 /* Wait for handles */
232 struct select_request
234 int count
; /* handles count */
235 int flags
; /* wait flags (see below) */
236 int timeout
; /* timeout in ms */
241 int signaled
; /* signaled handle */
242 /* void* apcs[]; */ /* async procedures to call */
245 #define SELECT_ALERTABLE 2
246 #define SELECT_TIMEOUT 4
249 /* Create an event */
250 struct create_event_request
252 int manual_reset
; /* manual reset event */
253 int initial_state
; /* initial state of the event */
254 int inherit
; /* inherit flag */
255 char name
[0]; /* event name */
257 struct create_event_reply
259 int handle
; /* handle to the event */
262 /* Event operation */
263 struct event_op_request
265 int handle
; /* handle to event */
266 int op
; /* event operation (see below) */
268 enum event_op
{ PULSE_EVENT
, SET_EVENT
, RESET_EVENT
};
272 struct create_mutex_request
274 int owned
; /* initially owned? */
275 int inherit
; /* inherit flag */
276 char name
[0]; /* mutex name */
278 struct create_mutex_reply
280 int handle
; /* handle to the mutex */
284 /* Release a mutex */
285 struct release_mutex_request
287 int handle
; /* handle to the mutex */
291 /* Create a semaphore */
292 struct create_semaphore_request
294 unsigned int initial
; /* initial count */
295 unsigned int max
; /* maximum count */
296 int inherit
; /* inherit flag */
297 char name
[0]; /* semaphore name */
299 struct create_semaphore_reply
301 int handle
; /* handle to the semaphore */
305 /* Release a semaphore */
306 struct release_semaphore_request
308 int handle
; /* handle to the semaphore */
309 unsigned int count
; /* count to add to semaphore */
311 struct release_semaphore_reply
313 unsigned int prev_count
; /* previous semaphore count */
317 /* Open a named object (event, mutex, semaphore) */
318 struct open_named_obj_request
320 int type
; /* object type (see below) */
321 unsigned int access
; /* wanted access rights */
322 int inherit
; /* inherit flag */
323 char name
[0]; /* object name */
325 enum open_named_obj
{ OPEN_EVENT
, OPEN_MUTEX
, OPEN_SEMAPHORE
, OPEN_MAPPING
};
327 struct open_named_obj_reply
329 int handle
; /* handle to the object */
334 struct create_file_request
336 unsigned int access
; /* wanted access rights */
337 int inherit
; /* inherit flag */
338 unsigned int sharing
; /* sharing flags */
339 int create
; /* file create action */
340 unsigned int attrs
; /* file attributes for creation */
341 char name
[0]; /* file name */
343 struct create_file_reply
345 int handle
; /* handle to the file */
349 /* Get a Unix fd to read from a file */
350 struct get_read_fd_request
352 int handle
; /* handle to the file */
356 /* Get a Unix fd to write to a file */
357 struct get_write_fd_request
359 int handle
; /* handle to the file */
363 /* Set a file current position */
364 struct set_file_pointer_request
366 int handle
; /* handle to the file */
367 int low
; /* position low word */
368 int high
; /* position high word */
369 int whence
; /* whence to seek */
371 struct set_file_pointer_reply
373 int low
; /* new position low word */
374 int high
; /* new position high word */
378 /* Truncate (or extend) a file */
379 struct truncate_file_request
381 int handle
; /* handle to the file */
385 /* Set a file access and modification times */
386 struct set_file_time_request
388 int handle
; /* handle to the file */
389 time_t access_time
; /* last access time */
390 time_t write_time
; /* last write time */
394 /* Flush a file buffers */
395 struct flush_file_request
397 int handle
; /* handle to the file */
401 /* Get information about a file */
402 struct get_file_info_request
404 int handle
; /* handle to the file */
406 struct get_file_info_reply
408 int type
; /* file type */
409 int attr
; /* file attributes */
410 time_t access_time
; /* last access time */
411 time_t write_time
; /* last write time */
412 int size_high
; /* file size */
413 int size_low
; /* file size */
414 int links
; /* number of links */
415 int index_high
; /* unique index */
416 int index_low
; /* unique index */
417 unsigned int serial
; /* volume serial number */
421 /* Lock a region of a file */
422 struct lock_file_request
424 int handle
; /* handle to the file */
425 unsigned int offset_low
; /* offset of start of lock */
426 unsigned int offset_high
; /* offset of start of lock */
427 unsigned int count_low
; /* count of bytes to lock */
428 unsigned int count_high
; /* count of bytes to lock */
432 /* Unlock a region of a file */
433 struct unlock_file_request
435 int handle
; /* handle to the file */
436 unsigned int offset_low
; /* offset of start of unlock */
437 unsigned int offset_high
; /* offset of start of unlock */
438 unsigned int count_low
; /* count of bytes to unlock */
439 unsigned int count_high
; /* count of bytes to unlock */
443 /* Create an anonymous pipe */
444 struct create_pipe_request
446 int inherit
; /* inherit flag */
448 struct create_pipe_reply
450 int handle_read
; /* handle to the read-side of the pipe */
451 int handle_write
; /* handle to the write-side of the pipe */
455 /* Allocate a console for the current process */
456 struct alloc_console_request
461 /* Free the console of the current process */
462 struct free_console_request
467 /* Open a handle to the process console */
468 struct open_console_request
470 int output
; /* input or output? */
471 unsigned int access
; /* wanted access rights */
472 int inherit
; /* inherit flag */
474 struct open_console_reply
476 int handle
; /* handle to the console */
480 /* Set a console file descriptor */
481 struct set_console_fd_request
483 int handle
; /* handle to the console */
484 int pid
; /* pid of xterm (hack) */
488 /* Get a console mode (input or output) */
489 struct get_console_mode_request
491 int handle
; /* handle to the console */
493 struct get_console_mode_reply
495 int mode
; /* console mode */
499 /* Set a console mode (input or output) */
500 struct set_console_mode_request
502 int handle
; /* handle to the console */
503 int mode
; /* console mode */
507 /* Set info about a console (output only) */
508 struct set_console_info_request
510 int handle
; /* handle to the console */
511 int mask
; /* setting mask (see below) */
512 int cursor_size
; /* size of cursor (percentage filled) */
513 int cursor_visible
;/* cursor visibility flag */
514 char title
[0]; /* console title */
516 #define SET_CONSOLE_INFO_CURSOR 0x01
517 #define SET_CONSOLE_INFO_TITLE 0x02
519 /* Get info about a console (output only) */
520 struct get_console_info_request
522 int handle
; /* handle to the console */
524 struct get_console_info_reply
526 int cursor_size
; /* size of cursor (percentage filled) */
527 int cursor_visible
;/* cursor visibility flag */
528 int pid
; /* pid of xterm (hack) */
529 /* char title[0]; */ /* console title */
533 /* Add input records to a console input queue */
534 struct write_console_input_request
536 int handle
; /* handle to the console input */
537 int count
; /* number of input records */
538 /* INPUT_RECORD records[0]; */ /* input records */
540 struct write_console_input_reply
542 int written
; /* number of records written */
545 /* Fetch input records from a console input queue */
546 struct read_console_input_request
548 int handle
; /* handle to the console input */
549 int count
; /* max number of records to retrieve */
550 int flush
; /* flush the retrieved records from the queue? */
552 struct read_console_input_reply
554 /* INPUT_RECORD records[0]; */ /* input records */
558 /* Create a change notification */
559 struct create_change_notification_request
561 int subtree
; /* watch all the subtree */
562 int filter
; /* notification filter */
564 struct create_change_notification_reply
566 int handle
; /* handle to the change notification */
570 /* Create a file mapping */
571 struct create_mapping_request
573 int size_high
; /* mapping size */
574 int size_low
; /* mapping size */
575 int protect
; /* protection flags (see below) */
576 int handle
; /* file handle */
577 char name
[0]; /* object name */
579 struct create_mapping_reply
581 int handle
; /* handle to the mapping */
583 /* protection flags */
584 #define VPROT_READ 0x01
585 #define VPROT_WRITE 0x02
586 #define VPROT_EXEC 0x04
587 #define VPROT_WRITECOPY 0x08
588 #define VPROT_GUARD 0x10
589 #define VPROT_NOCACHE 0x20
590 #define VPROT_COMMITTED 0x40
593 /* Get information about a file mapping */
594 struct get_mapping_info_request
596 int handle
; /* handle to the mapping */
598 struct get_mapping_info_reply
600 int size_high
; /* mapping size */
601 int size_low
; /* mapping size */
602 int protect
; /* protection flags */
606 /* Create a device */
607 struct create_device_request
609 unsigned int access
; /* wanted access rights */
610 int inherit
; /* inherit flag */
611 int id
; /* client private id */
613 struct create_device_reply
615 int handle
; /* handle to the device */
619 /* Create a snapshot */
620 struct create_snapshot_request
622 int inherit
; /* inherit flag */
623 int flags
; /* snapshot flags (TH32CS_*) */
625 struct create_snapshot_reply
627 int handle
; /* handle to the snapshot */
631 /* Get the next process from a snapshot */
632 struct next_process_request
634 int handle
; /* handle to the snapshot */
635 int reset
; /* reset snapshot position? */
637 struct next_process_reply
639 void* pid
; /* process id */
640 int threads
; /* number of threads */
641 int priority
; /* process priority */
645 /* client-side functions */
647 #ifndef __WINE_SERVER__
649 #include "server/request.h"
651 /* client communication functions */
652 extern void CLIENT_SendRequest( enum request req
, int pass_fd
,
653 int n
, ... /* arg_1, len_1, etc. */ );
654 extern unsigned int CLIENT_WaitReply( int *len
, int *passed_fd
,
655 int n
, ... /* arg_1, len_1, etc. */ );
656 extern unsigned int CLIENT_WaitSimpleReply( void *reply
, int len
, int *passed_fd
);
659 extern int CLIENT_NewThread( struct _THDB
*thdb
, int *thandle
, int *phandle
);
660 extern int CLIENT_SetDebug( int level
);
661 extern int CLIENT_InitThread(void);
662 #endif /* __WINE_SERVER__ */
664 #endif /* __WINE_SERVER_H */