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 process from the context of the parent */
44 struct new_process_request
46 int inherit; /* inherit flag */
47 int inherit_all; /* inherit all handles from parent */
48 int start_flags; /* flags from startup info */
49 int hstdin; /* handle for stdin */
50 int hstdout; /* handle for stdout */
51 int hstderr; /* handle for stderr */
52 char cmd_line[0]; /* command line */
54 struct new_process_reply
56 void* pid; /* process id */
57 int handle; /* process handle (in the current process) */
61 /* Create a new thread from the context of the parent */
62 struct new_thread_request
64 void* pid; /* process id for the new thread */
65 int suspend; /* new thread should be suspended on creation */
66 int inherit; /* inherit flag */
68 struct new_thread_reply
70 void* tid; /* thread id */
71 int handle; /* thread handle (in the current process) */
75 /* Set the server debug level */
76 struct set_debug_request
78 int level; /* New debug level */
82 /* Initialize a process; called from the new process context */
83 struct init_process_request
87 struct init_process_reply
89 int start_flags; /* flags from startup info */
90 int hstdin; /* handle for stdin */
91 int hstdout; /* handle for stdout */
92 int hstderr; /* handle for stderr */
96 /* Initialize a thread; called from the child after fork()/clone() */
97 struct init_thread_request
99 int unix_pid; /* Unix pid of new thread */
101 struct init_thread_reply
103 void* pid; /* process id of the new thread's process */
104 void* tid; /* thread id of the new thread */
108 /* Terminate a process */
109 struct terminate_process_request
111 int handle; /* process handle to terminate */
112 int exit_code; /* process exit code */
116 /* Terminate a thread */
117 struct terminate_thread_request
119 int handle; /* thread handle to terminate */
120 int exit_code; /* thread exit code */
124 /* Retrieve information about a process */
125 struct get_process_info_request
127 int handle; /* process handle */
129 struct get_process_info_reply
131 void* pid; /* server process id */
132 int exit_code; /* process exit code */
133 int priority; /* priority class */
134 int process_affinity; /* process affinity mask */
135 int system_affinity; /* system affinity mask */
139 /* Set a process informations */
140 struct set_process_info_request
142 int handle; /* process handle */
143 int mask; /* setting mask (see below) */
144 int priority; /* priority class */
145 int affinity; /* affinity mask */
147 #define SET_PROCESS_INFO_PRIORITY 0x01
148 #define SET_PROCESS_INFO_AFFINITY 0x02
151 /* Retrieve information about a thread */
152 struct get_thread_info_request
154 int handle; /* thread handle */
156 struct get_thread_info_reply
158 void* tid; /* server thread id */
159 int exit_code; /* thread exit code */
160 int priority; /* thread priority level */
164 /* Set a thread informations */
165 struct set_thread_info_request
167 int handle; /* thread handle */
168 int mask; /* setting mask (see below) */
169 int priority; /* priority class */
170 int affinity; /* affinity mask */
172 #define SET_THREAD_INFO_PRIORITY 0x01
173 #define SET_THREAD_INFO_AFFINITY 0x02
176 /* Suspend a thread */
177 struct suspend_thread_request
179 int handle; /* thread handle */
181 struct suspend_thread_reply
183 int count; /* new suspend count */
187 /* Resume a thread */
188 struct resume_thread_request
190 int handle; /* thread handle */
192 struct resume_thread_reply
194 int count; /* new suspend count */
198 /* Debugger support: freeze / unfreeze */
199 struct debugger_request
201 int op; /* operation type */
204 enum debugger_op { DEBUGGER_FREEZE_ALL, DEBUGGER_UNFREEZE_ALL };
207 /* Queue an APC for a thread */
208 struct queue_apc_request
210 int handle; /* thread handle */
211 void* func; /* function to call */
212 void* param; /* param for function to call */
216 /* Close a handle for the current process */
217 struct close_handle_request
219 int handle; /* handle to close */
223 /* Get information about a handle */
224 struct get_handle_info_request
226 int handle; /* handle we are interested in */
228 struct get_handle_info_reply
230 int flags; /* handle flags */
234 /* Set a handle information */
235 struct set_handle_info_request
237 int handle; /* handle we are interested in */
238 int flags; /* new handle flags */
239 int mask; /* mask for flags to set */
243 /* Duplicate a handle */
244 struct dup_handle_request
246 int src_process; /* src process handle */
247 int src_handle; /* src handle to duplicate */
248 int dst_process; /* dst process handle */
249 unsigned int access; /* wanted access rights */
250 int inherit; /* inherit flag */
251 int options; /* duplicate options (see below) */
253 #define DUP_HANDLE_CLOSE_SOURCE DUPLICATE_CLOSE_SOURCE
254 #define DUP_HANDLE_SAME_ACCESS DUPLICATE_SAME_ACCESS
255 #define DUP_HANDLE_MAKE_GLOBAL 0x80000000 /* Not a Windows flag */
256 struct dup_handle_reply
258 int handle; /* duplicated handle in dst process */
262 /* Open a handle to a process */
263 struct open_process_request
265 void* pid; /* process id to open */
266 unsigned int access; /* wanted access rights */
267 int inherit; /* inherit flag */
269 struct open_process_reply
271 int handle; /* handle to the process */
275 /* Wait for handles */
276 struct select_request
278 int count; /* handles count */
279 int flags; /* wait flags (see below) */
280 int timeout; /* timeout in ms */
285 int signaled; /* signaled handle */
286 /* void* apcs[]; */ /* async procedures to call */
289 #define SELECT_ALERTABLE 2
290 #define SELECT_TIMEOUT 4
293 /* Create an event */
294 struct create_event_request
296 int manual_reset; /* manual reset event */
297 int initial_state; /* initial state of the event */
298 int inherit; /* inherit flag */
299 char name[0]; /* event name */
301 struct create_event_reply
303 int handle; /* handle to the event */
306 /* Event operation */
307 struct event_op_request
309 int handle; /* handle to event */
310 int op; /* event operation (see below) */
312 enum event_op { PULSE_EVENT, SET_EVENT, RESET_EVENT };
316 struct create_mutex_request
318 int owned; /* initially owned? */
319 int inherit; /* inherit flag */
320 char name[0]; /* mutex name */
322 struct create_mutex_reply
324 int handle; /* handle to the mutex */
328 /* Release a mutex */
329 struct release_mutex_request
331 int handle; /* handle to the mutex */
335 /* Create a semaphore */
336 struct create_semaphore_request
338 unsigned int initial; /* initial count */
339 unsigned int max; /* maximum count */
340 int inherit; /* inherit flag */
341 char name[0]; /* semaphore name */
343 struct create_semaphore_reply
345 int handle; /* handle to the semaphore */
349 /* Release a semaphore */
350 struct release_semaphore_request
352 int handle; /* handle to the semaphore */
353 unsigned int count; /* count to add to semaphore */
355 struct release_semaphore_reply
357 unsigned int prev_count; /* previous semaphore count */
361 /* Open a named object (event, mutex, semaphore) */
362 struct open_named_obj_request
364 int type; /* object type (see below) */
365 unsigned int access; /* wanted access rights */
366 int inherit; /* inherit flag */
367 char name[0]; /* object name */
369 enum open_named_obj { OPEN_EVENT, OPEN_MUTEX, OPEN_SEMAPHORE, OPEN_MAPPING };
371 struct open_named_obj_reply
373 int handle; /* handle to the object */
378 struct create_file_request
380 unsigned int access; /* wanted access rights */
381 int inherit; /* inherit flag */
382 unsigned int sharing; /* sharing flags */
383 int create; /* file create action */
384 unsigned int attrs; /* file attributes for creation */
385 char name[0]; /* file name */
387 struct create_file_reply
389 int handle; /* handle to the file */
393 /* Get a Unix fd to read from a file */
394 struct get_read_fd_request
396 int handle; /* handle to the file */
400 /* Get a Unix fd to write to a file */
401 struct get_write_fd_request
403 int handle; /* handle to the file */
407 /* Set a file current position */
408 struct set_file_pointer_request
410 int handle; /* handle to the file */
411 int low; /* position low word */
412 int high; /* position high word */
413 int whence; /* whence to seek */
415 struct set_file_pointer_reply
417 int low; /* new position low word */
418 int high; /* new position high word */
422 /* Truncate (or extend) a file */
423 struct truncate_file_request
425 int handle; /* handle to the file */
429 /* Set a file access and modification times */
430 struct set_file_time_request
432 int handle; /* handle to the file */
433 time_t access_time; /* last access time */
434 time_t write_time; /* last write time */
438 /* Flush a file buffers */
439 struct flush_file_request
441 int handle; /* handle to the file */
445 /* Get information about a file */
446 struct get_file_info_request
448 int handle; /* handle to the file */
450 struct get_file_info_reply
452 int type; /* file type */
453 int attr; /* file attributes */
454 time_t access_time; /* last access time */
455 time_t write_time; /* last write time */
456 int size_high; /* file size */
457 int size_low; /* file size */
458 int links; /* number of links */
459 int index_high; /* unique index */
460 int index_low; /* unique index */
461 unsigned int serial; /* volume serial number */
465 /* Lock a region of a file */
466 struct lock_file_request
468 int handle; /* handle to the file */
469 unsigned int offset_low; /* offset of start of lock */
470 unsigned int offset_high; /* offset of start of lock */
471 unsigned int count_low; /* count of bytes to lock */
472 unsigned int count_high; /* count of bytes to lock */
476 /* Unlock a region of a file */
477 struct unlock_file_request
479 int handle; /* handle to the file */
480 unsigned int offset_low; /* offset of start of unlock */
481 unsigned int offset_high; /* offset of start of unlock */
482 unsigned int count_low; /* count of bytes to unlock */
483 unsigned int count_high; /* count of bytes to unlock */
487 /* Create an anonymous pipe */
488 struct create_pipe_request
490 int inherit; /* inherit flag */
492 struct create_pipe_reply
494 int handle_read; /* handle to the read-side of the pipe */
495 int handle_write; /* handle to the write-side of the pipe */
499 /* Allocate a console for the current process */
500 struct alloc_console_request
505 /* Free the console of the current process */
506 struct free_console_request
511 /* Open a handle to the process console */
512 struct open_console_request
514 int output; /* input or output? */
515 unsigned int access; /* wanted access rights */
516 int inherit; /* inherit flag */
518 struct open_console_reply
520 int handle; /* handle to the console */
524 /* Set a console file descriptor */
525 struct set_console_fd_request
527 int handle; /* handle to the console */
528 int pid; /* pid of xterm (hack) */
532 /* Get a console mode (input or output) */
533 struct get_console_mode_request
535 int handle; /* handle to the console */
537 struct get_console_mode_reply
539 int mode; /* console mode */
543 /* Set a console mode (input or output) */
544 struct set_console_mode_request
546 int handle; /* handle to the console */
547 int mode; /* console mode */
551 /* Set info about a console (output only) */
552 struct set_console_info_request
554 int handle; /* handle to the console */
555 int mask; /* setting mask (see below) */
556 int cursor_size; /* size of cursor (percentage filled) */
557 int cursor_visible;/* cursor visibility flag */
558 char title[0]; /* console title */
560 #define SET_CONSOLE_INFO_CURSOR 0x01
561 #define SET_CONSOLE_INFO_TITLE 0x02
563 /* Get info about a console (output only) */
564 struct get_console_info_request
566 int handle; /* handle to the console */
568 struct get_console_info_reply
570 int cursor_size; /* size of cursor (percentage filled) */
571 int cursor_visible;/* cursor visibility flag */
572 int pid; /* pid of xterm (hack) */
573 /* char title[0]; */ /* console title */
577 /* Add input records to a console input queue */
578 struct write_console_input_request
580 int handle; /* handle to the console input */
581 int count; /* number of input records */
582 /* INPUT_RECORD records[0]; */ /* input records */
584 struct write_console_input_reply
586 int written; /* number of records written */
589 /* Fetch input records from a console input queue */
590 struct read_console_input_request
592 int handle; /* handle to the console input */
593 int count; /* max number of records to retrieve */
594 int flush; /* flush the retrieved records from the queue? */
596 struct read_console_input_reply
598 /* INPUT_RECORD records[0]; */ /* input records */
602 /* Create a change notification */
603 struct create_change_notification_request
605 int subtree; /* watch all the subtree */
606 int filter; /* notification filter */
608 struct create_change_notification_reply
610 int handle; /* handle to the change notification */
614 /* Create a file mapping */
615 struct create_mapping_request
617 int size_high; /* mapping size */
618 int size_low; /* mapping size */
619 int protect; /* protection flags (see below) */
620 int inherit; /* inherit flag */
621 int handle; /* file handle */
622 char name[0]; /* object name */
624 struct create_mapping_reply
626 int handle; /* handle to the mapping */
628 /* protection flags */
629 #define VPROT_READ 0x01
630 #define VPROT_WRITE 0x02
631 #define VPROT_EXEC 0x04
632 #define VPROT_WRITECOPY 0x08
633 #define VPROT_GUARD 0x10
634 #define VPROT_NOCACHE 0x20
635 #define VPROT_COMMITTED 0x40
638 /* Get information about a file mapping */
639 struct get_mapping_info_request
641 int handle; /* handle to the mapping */
643 struct get_mapping_info_reply
645 int size_high; /* mapping size */
646 int size_low; /* mapping size */
647 int protect; /* protection flags */
651 /* Create a device */
652 struct create_device_request
654 unsigned int access; /* wanted access rights */
655 int inherit; /* inherit flag */
656 int id; /* client private id */
658 struct create_device_reply
660 int handle; /* handle to the device */
664 /* Create a snapshot */
665 struct create_snapshot_request
667 int inherit; /* inherit flag */
668 int flags; /* snapshot flags (TH32CS_*) */
670 struct create_snapshot_reply
672 int handle; /* handle to the snapshot */
676 /* Get the next process from a snapshot */
677 struct next_process_request
679 int handle; /* handle to the snapshot */
680 int reset; /* reset snapshot position? */
682 struct next_process_reply
684 void* pid; /* process id */
685 int threads; /* number of threads */
686 int priority; /* process priority */
690 /* client-side functions */
692 #ifndef __WINE_SERVER__
694 #include "server/request.h"
696 /* client communication functions */
697 extern void CLIENT_SendRequest( enum request req, int pass_fd,
698 int n, ... /* arg_1, len_1, etc. */ );
699 extern unsigned int CLIENT_WaitReply( int *len, int *passed_fd,
700 int n, ... /* arg_1, len_1, etc. */ );
701 extern unsigned int CLIENT_WaitSimpleReply( void *reply, int len, int *passed_fd );
702 extern int CLIENT_InitServer(void);
705 extern int CLIENT_SetDebug( int level );
706 extern int CLIENT_DebuggerRequest( int op );
707 extern int CLIENT_InitThread(void);
708 #endif /* __WINE_SERVER__ */
710 #endif /* __WINE_SERVER_H */