Rearrange winver detection code and cache the winver value we
[wine.git] / include / server.h
blob01dedc8fa2e921639d2ff67a3946ace7361ead80
1 /*
2 * Wine server definitions
4 * Copyright (C) 1998 Alexandre Julliard
5 */
7 #ifndef __WINE_SERVER_H
8 #define __WINE_SERVER_H
10 #include <stdlib.h>
11 #include <time.h>
13 /* message header as sent on the wire */
14 struct header
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 */
25 struct cmsg_fd
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
91 int dummy;
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 */
293 struct select_reply
295 int signaled; /* signaled handle */
296 void* apcs[0]; /* async procedures to call */
298 #define SELECT_ALL 1
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 };
325 /* Open an 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 */
338 /* Create a mutex */
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 */
358 /* Open a 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 */
410 /* Create a file */
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
535 unsigned int access; /* wanted access rights */
536 int inherit; /* inherit flag */
538 struct alloc_console_reply
540 int handle_in; /* handle to console input */
541 int handle_out; /* handle to console output */
545 /* Free the console of the current process */
546 struct free_console_request
548 int dummy;
552 /* Open a handle to the process console */
553 struct open_console_request
555 int output; /* input or output? */
556 unsigned int access; /* wanted access rights */
557 int inherit; /* inherit flag */
559 struct open_console_reply
561 int handle; /* handle to the console */
565 /* Set a console file descriptor */
566 struct set_console_fd_request
568 int handle; /* handle to the console */
569 int pid; /* pid of xterm (hack) */
573 /* Get a console mode (input or output) */
574 struct get_console_mode_request
576 int handle; /* handle to the console */
578 struct get_console_mode_reply
580 int mode; /* console mode */
584 /* Set a console mode (input or output) */
585 struct set_console_mode_request
587 int handle; /* handle to the console */
588 int mode; /* console mode */
592 /* Set info about a console (output only) */
593 struct set_console_info_request
595 int handle; /* handle to the console */
596 int mask; /* setting mask (see below) */
597 int cursor_size; /* size of cursor (percentage filled) */
598 int cursor_visible;/* cursor visibility flag */
599 char title[0]; /* console title */
601 #define SET_CONSOLE_INFO_CURSOR 0x01
602 #define SET_CONSOLE_INFO_TITLE 0x02
604 /* Get info about a console (output only) */
605 struct get_console_info_request
607 int handle; /* handle to the console */
609 struct get_console_info_reply
611 int cursor_size; /* size of cursor (percentage filled) */
612 int cursor_visible;/* cursor visibility flag */
613 int pid; /* pid of xterm (hack) */
614 char title[0]; /* console title */
618 /* Add input records to a console input queue */
619 struct write_console_input_request
621 int handle; /* handle to the console input */
622 int count; /* number of input records */
623 /* INPUT_RECORD records[0]; */ /* input records */
625 struct write_console_input_reply
627 int written; /* number of records written */
630 /* Fetch input records from a console input queue */
631 struct read_console_input_request
633 int handle; /* handle to the console input */
634 int count; /* max number of records to retrieve */
635 int flush; /* flush the retrieved records from the queue? */
637 struct read_console_input_reply
639 int dummy;
640 /* INPUT_RECORD records[0]; */ /* input records */
644 /* Create a change notification */
645 struct create_change_notification_request
647 int subtree; /* watch all the subtree */
648 int filter; /* notification filter */
650 struct create_change_notification_reply
652 int handle; /* handle to the change notification */
656 /* Create a file mapping */
657 struct create_mapping_request
659 int size_high; /* mapping size */
660 int size_low; /* mapping size */
661 int protect; /* protection flags (see below) */
662 int inherit; /* inherit flag */
663 int handle; /* file handle */
664 char name[0]; /* object name */
666 struct create_mapping_reply
668 int handle; /* handle to the mapping */
670 /* protection flags */
671 #define VPROT_READ 0x01
672 #define VPROT_WRITE 0x02
673 #define VPROT_EXEC 0x04
674 #define VPROT_WRITECOPY 0x08
675 #define VPROT_GUARD 0x10
676 #define VPROT_NOCACHE 0x20
677 #define VPROT_COMMITTED 0x40
680 /* Open a mapping */
681 struct open_mapping_request
683 unsigned int access; /* wanted access rights */
684 int inherit; /* inherit flag */
685 char name[0]; /* object name */
687 struct open_mapping_reply
689 int handle; /* handle to the mapping */
693 /* Get information about a file mapping */
694 struct get_mapping_info_request
696 int handle; /* handle to the mapping */
698 struct get_mapping_info_reply
700 int size_high; /* mapping size */
701 int size_low; /* mapping size */
702 int protect; /* protection flags */
706 /* Create a device */
707 struct create_device_request
709 unsigned int access; /* wanted access rights */
710 int inherit; /* inherit flag */
711 int id; /* client private id */
713 struct create_device_reply
715 int handle; /* handle to the device */
719 /* Create a snapshot */
720 struct create_snapshot_request
722 int inherit; /* inherit flag */
723 int flags; /* snapshot flags (TH32CS_*) */
725 struct create_snapshot_reply
727 int handle; /* handle to the snapshot */
731 /* Get the next process from a snapshot */
732 struct next_process_request
734 int handle; /* handle to the snapshot */
735 int reset; /* reset snapshot position? */
737 struct next_process_reply
739 void* pid; /* process id */
740 int threads; /* number of threads */
741 int priority; /* process priority */
745 /* Wait for a debug event */
746 struct wait_debug_event_request
748 int timeout; /* timeout in ms */
750 struct wait_debug_event_reply
752 int code; /* event code */
753 void* pid; /* process id */
754 void* tid; /* thread id */
755 /* followed by the event data (see below) */
759 /* Send a debug event */
760 struct send_debug_event_request
762 int code; /* event code */
763 /* followed by the event data (see below) */
765 struct send_debug_event_reply
767 int status; /* event continuation status */
771 /* definitions of the event data depending on the event code */
772 struct debug_event_exception
774 int code; /* exception code */
775 int flags; /* exception flags */
776 void *record; /* exception record ptr */
777 void *addr; /* exception address */
778 int nb_params; /* exceptions parameters */
779 int params[15];
780 int first_chance; /* first chance to handle it? */
782 struct debug_event_create_thread
784 int handle; /* handle to the new thread */
785 void *teb; /* thread teb (in debugged process address space) */
786 void *start; /* thread startup routine */
788 struct debug_event_create_process
790 int file; /* handle to the process exe file */
791 int process; /* handle to the new process */
792 int thread; /* handle to the new thread */
793 void *base; /* base of executable image */
794 int dbg_offset; /* offset of debug info in file */
795 int dbg_size; /* size of debug info */
796 void *teb; /* thread teb (in debugged process address space) */
797 void *start; /* thread startup routine */
798 void *name; /* image name (optional) */
799 int unicode; /* is it Unicode? */
801 struct debug_event_exit
803 int exit_code; /* thread or process exit code */
805 struct debug_event_load_dll
807 int handle; /* file handle for the dll */
808 void *base; /* base address of the dll */
809 int dbg_offset; /* offset of debug info in file */
810 int dbg_size; /* size of debug info */
811 void *name; /* image name (optional) */
812 int unicode; /* is it Unicode? */
814 struct debug_event_unload_dll
816 void *base; /* base address of the dll */
818 struct debug_event_output_string
820 void *string; /* string to display (in debugged process address space) */
821 int unicode; /* is it Unicode? */
822 int length; /* string length */
824 struct debug_event_rip_info
826 int error; /* ??? */
827 int type; /* ??? */
829 union debug_event_data
831 struct debug_event_exception exception;
832 struct debug_event_create_thread create_thread;
833 struct debug_event_create_process create_process;
834 struct debug_event_exit exit;
835 struct debug_event_load_dll load_dll;
836 struct debug_event_unload_dll unload_dll;
837 struct debug_event_output_string output_string;
838 struct debug_event_rip_info rip_info;
842 /* Continue a debug event */
843 struct continue_debug_event_request
845 void* pid; /* process id to continue */
846 void* tid; /* thread id to continue */
847 int status; /* continuation status */
851 /* Start debugging an existing process */
852 struct debug_process_request
854 void* pid; /* id of the process to debug */
858 /* requests definitions */
859 #include "server/request.h"
861 /* client-side functions */
863 #ifndef __WINE_SERVER__
865 /* client communication functions */
866 extern void CLIENT_ProtocolError( const char *err, ... );
867 extern void CLIENT_SendRequest( enum request req, int pass_fd,
868 int n, ... /* arg_1, len_1, etc. */ );
869 extern unsigned int CLIENT_WaitReply( int *len, int *passed_fd,
870 int n, ... /* arg_1, len_1, etc. */ );
871 extern unsigned int CLIENT_WaitSimpleReply( void *reply, int len, int *passed_fd );
872 extern int CLIENT_InitServer(void);
873 extern int CLIENT_SetDebug( int level );
874 extern int CLIENT_DebuggerRequest( int op );
875 extern int CLIENT_InitThread(void);
876 #endif /* __WINE_SERVER__ */
878 #endif /* __WINE_SERVER_H */