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 */
33 /* request handler definition */
34 #define DECL_HANDLER(name) \
35 void req_##name( struct name##_request *req, void *data, int len, int fd )
37 /* Request structures */
39 /* following are the definitions of all the client<->server */
40 /* communication format; requests are from client to server, */
41 /* replies are from server to client. All requests must have */
42 /* a corresponding structure; the replies can be empty in */
43 /* which case it isn't necessary to define a structure. */
46 /* Create a new process from the context of the parent */
47 struct new_process_request
49 int inherit; /* inherit flag */
50 int inherit_all; /* inherit all handles from parent */
51 int create_flags; /* creation flags */
52 int start_flags; /* flags from startup info */
53 int hstdin; /* handle for stdin */
54 int hstdout; /* handle for stdout */
55 int hstderr; /* handle for stderr */
56 int cmd_show; /* main window show mode */
57 void* env_ptr; /* pointer to environment (FIXME: hack) */
58 char cmd_line[0]; /* command line */
60 struct new_process_reply
62 void* pid; /* process id */
63 int handle; /* process handle (in the current process) */
67 /* Create a new thread from the context of the parent */
68 struct new_thread_request
70 void* pid; /* process id for the new thread */
71 int suspend; /* new thread should be suspended on creation */
72 int inherit; /* inherit flag */
74 struct new_thread_reply
76 void* tid; /* thread id */
77 int handle; /* thread handle (in the current process) */
81 /* Set the server debug level */
82 struct set_debug_request
84 int level; /* New debug level */
88 /* Initialize a process; called from the new process context */
89 struct init_process_request
93 struct init_process_reply
95 int start_flags; /* flags from startup info */
96 int hstdin; /* handle for stdin */
97 int hstdout; /* handle for stdout */
98 int hstderr; /* handle for stderr */
99 int cmd_show; /* main window show mode */
100 void* env_ptr; /* pointer to environment (FIXME: hack) */
101 char cmdline[0]; /* command line */
105 /* Initialize a thread; called from the child after fork()/clone() */
106 struct init_thread_request
108 int unix_pid; /* Unix pid of new thread */
109 void* teb; /* TEB of new thread (in thread address space) */
111 struct init_thread_reply
113 void* pid; /* process id of the new thread's process */
114 void* tid; /* thread id of the new thread */
118 /* Terminate a process */
119 struct terminate_process_request
121 int handle; /* process handle to terminate */
122 int exit_code; /* process exit code */
126 /* Terminate a thread */
127 struct terminate_thread_request
129 int handle; /* thread handle to terminate */
130 int exit_code; /* thread exit code */
134 /* Retrieve information about a process */
135 struct get_process_info_request
137 int handle; /* process handle */
139 struct get_process_info_reply
141 void* pid; /* server process id */
142 int exit_code; /* process exit code */
143 int priority; /* priority class */
144 int process_affinity; /* process affinity mask */
145 int system_affinity; /* system affinity mask */
149 /* Set a process informations */
150 struct set_process_info_request
152 int handle; /* process handle */
153 int mask; /* setting mask (see below) */
154 int priority; /* priority class */
155 int affinity; /* affinity mask */
157 #define SET_PROCESS_INFO_PRIORITY 0x01
158 #define SET_PROCESS_INFO_AFFINITY 0x02
161 /* Retrieve information about a thread */
162 struct get_thread_info_request
164 int handle; /* thread handle */
166 struct get_thread_info_reply
168 void* tid; /* server thread id */
169 int exit_code; /* thread exit code */
170 int priority; /* thread priority level */
174 /* Set a thread informations */
175 struct set_thread_info_request
177 int handle; /* thread handle */
178 int mask; /* setting mask (see below) */
179 int priority; /* priority class */
180 int affinity; /* affinity mask */
182 #define SET_THREAD_INFO_PRIORITY 0x01
183 #define SET_THREAD_INFO_AFFINITY 0x02
186 /* Suspend a thread */
187 struct suspend_thread_request
189 int handle; /* thread handle */
191 struct suspend_thread_reply
193 int count; /* new suspend count */
197 /* Resume a thread */
198 struct resume_thread_request
200 int handle; /* thread handle */
202 struct resume_thread_reply
204 int count; /* new suspend count */
208 /* Debugger support: freeze / unfreeze */
209 struct debugger_request
211 int op; /* operation type */
214 enum debugger_op { DEBUGGER_FREEZE_ALL, DEBUGGER_UNFREEZE_ALL };
217 /* Queue an APC for a thread */
218 struct queue_apc_request
220 int handle; /* thread handle */
221 void* func; /* function to call */
222 void* param; /* param for function to call */
226 /* Close a handle for the current process */
227 struct close_handle_request
229 int handle; /* handle to close */
233 /* Get information about a handle */
234 struct get_handle_info_request
236 int handle; /* handle we are interested in */
238 struct get_handle_info_reply
240 int flags; /* handle flags */
244 /* Set a handle information */
245 struct set_handle_info_request
247 int handle; /* handle we are interested in */
248 int flags; /* new handle flags */
249 int mask; /* mask for flags to set */
253 /* Duplicate a handle */
254 struct dup_handle_request
256 int src_process; /* src process handle */
257 int src_handle; /* src handle to duplicate */
258 int dst_process; /* dst process handle */
259 unsigned int access; /* wanted access rights */
260 int inherit; /* inherit flag */
261 int options; /* duplicate options (see below) */
263 #define DUP_HANDLE_CLOSE_SOURCE DUPLICATE_CLOSE_SOURCE
264 #define DUP_HANDLE_SAME_ACCESS DUPLICATE_SAME_ACCESS
265 #define DUP_HANDLE_MAKE_GLOBAL 0x80000000 /* Not a Windows flag */
266 struct dup_handle_reply
268 int handle; /* duplicated handle in dst process */
272 /* Open a handle to a process */
273 struct open_process_request
275 void* pid; /* process id to open */
276 unsigned int access; /* wanted access rights */
277 int inherit; /* inherit flag */
279 struct open_process_reply
281 int handle; /* handle to the process */
285 /* Wait for handles */
286 struct select_request
288 int count; /* handles count */
289 int flags; /* wait flags (see below) */
290 int timeout; /* timeout in ms */
291 int handles[0]; /* handles to select on */
295 int signaled; /* signaled handle */
296 void* apcs[0]; /* async procedures to call */
299 #define SELECT_ALERTABLE 2
300 #define SELECT_TIMEOUT 4
303 /* Create an event */
304 struct create_event_request
306 int manual_reset; /* manual reset event */
307 int initial_state; /* initial state of the event */
308 int inherit; /* inherit flag */
309 char name[0]; /* event name */
311 struct create_event_reply
313 int handle; /* handle to the event */
316 /* Event operation */
317 struct event_op_request
319 int handle; /* handle to event */
320 int op; /* event operation (see below) */
322 enum event_op { PULSE_EVENT, SET_EVENT, RESET_EVENT };
326 struct open_event_request
328 unsigned int access; /* wanted access rights */
329 int inherit; /* inherit flag */
330 char name[0]; /* object name */
332 struct open_event_reply
334 int handle; /* handle to the event */
339 struct create_mutex_request
341 int owned; /* initially owned? */
342 int inherit; /* inherit flag */
343 char name[0]; /* mutex name */
345 struct create_mutex_reply
347 int handle; /* handle to the mutex */
351 /* Release a mutex */
352 struct release_mutex_request
354 int handle; /* handle to the mutex */
359 struct open_mutex_request
361 unsigned int access; /* wanted access rights */
362 int inherit; /* inherit flag */
363 char name[0]; /* object name */
365 struct open_mutex_reply
367 int handle; /* handle to the mutex */
371 /* Create a semaphore */
372 struct create_semaphore_request
374 unsigned int initial; /* initial count */
375 unsigned int max; /* maximum count */
376 int inherit; /* inherit flag */
377 char name[0]; /* semaphore name */
379 struct create_semaphore_reply
381 int handle; /* handle to the semaphore */
385 /* Release a semaphore */
386 struct release_semaphore_request
388 int handle; /* handle to the semaphore */
389 unsigned int count; /* count to add to semaphore */
391 struct release_semaphore_reply
393 unsigned int prev_count; /* previous semaphore count */
397 /* Open a semaphore */
398 struct open_semaphore_request
400 unsigned int access; /* wanted access rights */
401 int inherit; /* inherit flag */
402 char name[0]; /* object name */
404 struct open_semaphore_reply
406 int handle; /* handle to the semaphore */
411 struct create_file_request
413 unsigned int access; /* wanted access rights */
414 int inherit; /* inherit flag */
415 unsigned int sharing; /* sharing flags */
416 int create; /* file create action */
417 unsigned int attrs; /* file attributes for creation */
418 char name[0]; /* file name */
420 struct create_file_reply
422 int handle; /* handle to the file */
426 /* Get a Unix fd to read from a file */
427 struct get_read_fd_request
429 int handle; /* handle to the file */
433 /* Get a Unix fd to write to a file */
434 struct get_write_fd_request
436 int handle; /* handle to the file */
440 /* Set a file current position */
441 struct set_file_pointer_request
443 int handle; /* handle to the file */
444 int low; /* position low word */
445 int high; /* position high word */
446 int whence; /* whence to seek */
448 struct set_file_pointer_reply
450 int low; /* new position low word */
451 int high; /* new position high word */
455 /* Truncate (or extend) a file */
456 struct truncate_file_request
458 int handle; /* handle to the file */
462 /* Set a file access and modification times */
463 struct set_file_time_request
465 int handle; /* handle to the file */
466 time_t access_time; /* last access time */
467 time_t write_time; /* last write time */
471 /* Flush a file buffers */
472 struct flush_file_request
474 int handle; /* handle to the file */
478 /* Get information about a file */
479 struct get_file_info_request
481 int handle; /* handle to the file */
483 struct get_file_info_reply
485 int type; /* file type */
486 int attr; /* file attributes */
487 time_t access_time; /* last access time */
488 time_t write_time; /* last write time */
489 int size_high; /* file size */
490 int size_low; /* file size */
491 int links; /* number of links */
492 int index_high; /* unique index */
493 int index_low; /* unique index */
494 unsigned int serial; /* volume serial number */
498 /* Lock a region of a file */
499 struct lock_file_request
501 int handle; /* handle to the file */
502 unsigned int offset_low; /* offset of start of lock */
503 unsigned int offset_high; /* offset of start of lock */
504 unsigned int count_low; /* count of bytes to lock */
505 unsigned int count_high; /* count of bytes to lock */
509 /* Unlock a region of a file */
510 struct unlock_file_request
512 int handle; /* handle to the file */
513 unsigned int offset_low; /* offset of start of unlock */
514 unsigned int offset_high; /* offset of start of unlock */
515 unsigned int count_low; /* count of bytes to unlock */
516 unsigned int count_high; /* count of bytes to unlock */
520 /* Create an anonymous pipe */
521 struct create_pipe_request
523 int inherit; /* inherit flag */
525 struct create_pipe_reply
527 int handle_read; /* handle to the read-side of the pipe */
528 int handle_write; /* handle to the write-side of the pipe */
532 /* Allocate a console for the current process */
533 struct alloc_console_request
539 /* Free the console of the current process */
540 struct free_console_request
546 /* Open a handle to the process console */
547 struct open_console_request
549 int output; /* input or output? */
550 unsigned int access; /* wanted access rights */
551 int inherit; /* inherit flag */
553 struct open_console_reply
555 int handle; /* handle to the console */
559 /* Set a console file descriptor */
560 struct set_console_fd_request
562 int handle; /* handle to the console */
563 int pid; /* pid of xterm (hack) */
567 /* Get a console mode (input or output) */
568 struct get_console_mode_request
570 int handle; /* handle to the console */
572 struct get_console_mode_reply
574 int mode; /* console mode */
578 /* Set a console mode (input or output) */
579 struct set_console_mode_request
581 int handle; /* handle to the console */
582 int mode; /* console mode */
586 /* Set info about a console (output only) */
587 struct set_console_info_request
589 int handle; /* handle to the console */
590 int mask; /* setting mask (see below) */
591 int cursor_size; /* size of cursor (percentage filled) */
592 int cursor_visible;/* cursor visibility flag */
593 char title[0]; /* console title */
595 #define SET_CONSOLE_INFO_CURSOR 0x01
596 #define SET_CONSOLE_INFO_TITLE 0x02
598 /* Get info about a console (output only) */
599 struct get_console_info_request
601 int handle; /* handle to the console */
603 struct get_console_info_reply
605 int cursor_size; /* size of cursor (percentage filled) */
606 int cursor_visible;/* cursor visibility flag */
607 int pid; /* pid of xterm (hack) */
608 /* char title[0]; */ /* console title */
612 /* Add input records to a console input queue */
613 struct write_console_input_request
615 int handle; /* handle to the console input */
616 int count; /* number of input records */
617 /* INPUT_RECORD records[0]; */ /* input records */
619 struct write_console_input_reply
621 int written; /* number of records written */
624 /* Fetch input records from a console input queue */
625 struct read_console_input_request
627 int handle; /* handle to the console input */
628 int count; /* max number of records to retrieve */
629 int flush; /* flush the retrieved records from the queue? */
631 struct read_console_input_reply
634 /* INPUT_RECORD records[0]; */ /* input records */
638 /* Create a change notification */
639 struct create_change_notification_request
641 int subtree; /* watch all the subtree */
642 int filter; /* notification filter */
644 struct create_change_notification_reply
646 int handle; /* handle to the change notification */
650 /* Create a file mapping */
651 struct create_mapping_request
653 int size_high; /* mapping size */
654 int size_low; /* mapping size */
655 int protect; /* protection flags (see below) */
656 int inherit; /* inherit flag */
657 int handle; /* file handle */
658 char name[0]; /* object name */
660 struct create_mapping_reply
662 int handle; /* handle to the mapping */
664 /* protection flags */
665 #define VPROT_READ 0x01
666 #define VPROT_WRITE 0x02
667 #define VPROT_EXEC 0x04
668 #define VPROT_WRITECOPY 0x08
669 #define VPROT_GUARD 0x10
670 #define VPROT_NOCACHE 0x20
671 #define VPROT_COMMITTED 0x40
675 struct open_mapping_request
677 unsigned int access; /* wanted access rights */
678 int inherit; /* inherit flag */
679 char name[0]; /* object name */
681 struct open_mapping_reply
683 int handle; /* handle to the mapping */
687 /* Get information about a file mapping */
688 struct get_mapping_info_request
690 int handle; /* handle to the mapping */
692 struct get_mapping_info_reply
694 int size_high; /* mapping size */
695 int size_low; /* mapping size */
696 int protect; /* protection flags */
700 /* Create a device */
701 struct create_device_request
703 unsigned int access; /* wanted access rights */
704 int inherit; /* inherit flag */
705 int id; /* client private id */
707 struct create_device_reply
709 int handle; /* handle to the device */
713 /* Create a snapshot */
714 struct create_snapshot_request
716 int inherit; /* inherit flag */
717 int flags; /* snapshot flags (TH32CS_*) */
719 struct create_snapshot_reply
721 int handle; /* handle to the snapshot */
725 /* Get the next process from a snapshot */
726 struct next_process_request
728 int handle; /* handle to the snapshot */
729 int reset; /* reset snapshot position? */
731 struct next_process_reply
733 void* pid; /* process id */
734 int threads; /* number of threads */
735 int priority; /* process priority */
739 /* Wait for a debug event */
740 struct wait_debug_event_request
742 int timeout; /* timeout in ms */
744 struct wait_debug_event_reply
746 int code; /* event code */
747 void* pid; /* process id */
748 void* tid; /* thread id */
749 /* followed by the event data (see below) */
753 /* Send a debug event */
754 struct send_debug_event_request
756 int code; /* event code */
757 /* followed by the event data (see below) */
759 struct send_debug_event_reply
761 int status; /* event continuation status */
765 /* definitions of the event data depending on the event code */
766 struct debug_event_exception
768 int code; /* exception code */
769 int flags; /* exception flags */
770 void *record; /* exception record ptr */
771 void *addr; /* exception address */
772 int nb_params; /* exceptions parameters */
774 int first_chance; /* first chance to handle it? */
776 struct debug_event_create_thread
778 int handle; /* handle to the new thread */
779 void *teb; /* thread teb (in debugged process address space) */
780 void *start; /* thread startup routine */
782 struct debug_event_create_process
784 int file; /* handle to the process exe file */
785 int process; /* handle to the new process */
786 int thread; /* handle to the new thread */
787 void *base; /* base of executable image */
788 int dbg_offset; /* offset of debug info in file */
789 int dbg_size; /* size of debug info */
790 void *teb; /* thread teb (in debugged process address space) */
791 void *start; /* thread startup routine */
792 void *name; /* image name (optional) */
793 int unicode; /* is it Unicode? */
795 struct debug_event_exit
797 int exit_code; /* thread or process exit code */
799 struct debug_event_load_dll
801 int handle; /* file handle for the dll */
802 void *base; /* base address of the dll */
803 int dbg_offset; /* offset of debug info in file */
804 int dbg_size; /* size of debug info */
805 void *name; /* image name (optional) */
806 int unicode; /* is it Unicode? */
808 struct debug_event_unload_dll
810 void *base; /* base address of the dll */
812 struct debug_event_output_string
814 void *string; /* string to display (in debugged process address space) */
815 int unicode; /* is it Unicode? */
816 int length; /* string length */
818 struct debug_event_rip_info
823 union debug_event_data
825 struct debug_event_exception exception;
826 struct debug_event_create_thread create_thread;
827 struct debug_event_create_process create_process;
828 struct debug_event_exit exit;
829 struct debug_event_load_dll load_dll;
830 struct debug_event_unload_dll unload_dll;
831 struct debug_event_output_string output_string;
832 struct debug_event_rip_info rip_info;
836 /* Continue a debug event */
837 struct continue_debug_event_request
839 void* pid; /* process id to continue */
840 void* tid; /* thread id to continue */
841 int status; /* continuation status */
845 /* Start debugging an existing process */
846 struct debug_process_request
848 void* pid; /* id of the process to debug */
852 /* requests definitions */
853 #include "server/request.h"
855 /* client-side functions */
857 #ifndef __WINE_SERVER__
859 /* client communication functions */
860 extern void CLIENT_ProtocolError( const char *err, ... );
861 extern void CLIENT_SendRequest( enum request req, int pass_fd,
862 int n, ... /* arg_1, len_1, etc. */ );
863 extern unsigned int CLIENT_WaitReply( int *len, int *passed_fd,
864 int n, ... /* arg_1, len_1, etc. */ );
865 extern unsigned int CLIENT_WaitSimpleReply( void *reply, int len, int *passed_fd );
866 extern int CLIENT_InitServer(void);
867 extern int CLIENT_SetDebug( int level );
868 extern int CLIENT_DebuggerRequest( int op );
869 extern int CLIENT_InitThread(void);
870 #endif /* __WINE_SERVER__ */
872 #endif /* __WINE_SERVER_H */