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 */
20 /* max msg length (including the header) */
21 #define MAX_MSG_LENGTH 16384
23 /* data structure used to pass an fd with sendmsg/recvmsg */
26 int len
; /* sizeof structure */
27 int level
; /* SOL_SOCKET */
28 int type
; /* SCM_RIGHTS */
29 int fd
; /* fd to pass */
32 /* Request structures */
34 /* following are the definitions of all the client<->server */
35 /* communication format; requests are from client to server, */
36 /* replies are from server to client. All requests must have */
37 /* a corresponding structure; the replies can be empty in */
38 /* which case it isn't necessary to define a structure. */
41 /* Create a new process from the context of the parent */
42 struct new_process_request
44 int inherit
; /* inherit flag */
45 int inherit_all
; /* inherit all handles from parent */
46 int create_flags
; /* creation flags */
47 int start_flags
; /* flags from startup info */
48 int hstdin
; /* handle for stdin */
49 int hstdout
; /* handle for stdout */
50 int hstderr
; /* handle for stderr */
51 int cmd_show
; /* main window show mode */
52 void* env_ptr
; /* pointer to environment (FIXME: hack) */
53 char cmd_line
[0]; /* command line */
55 struct new_process_reply
57 void* pid
; /* process id */
58 int handle
; /* process handle (in the current process) */
62 /* Create a new thread from the context of the parent */
63 struct new_thread_request
65 void* pid
; /* process id for the new thread */
66 int suspend
; /* new thread should be suspended on creation */
67 int inherit
; /* inherit flag */
69 struct new_thread_reply
71 void* tid
; /* thread id */
72 int handle
; /* thread handle (in the current process) */
76 /* Set the server debug level */
77 struct set_debug_request
79 int level
; /* New debug level */
83 /* Initialize a process; called from the new process context */
84 struct init_process_request
88 struct init_process_reply
90 int start_flags
; /* flags from startup info */
91 int hstdin
; /* handle for stdin */
92 int hstdout
; /* handle for stdout */
93 int hstderr
; /* handle for stderr */
94 int cmd_show
; /* main window show mode */
95 void* env_ptr
; /* pointer to environment (FIXME: hack) */
96 char cmdline
[0]; /* command line */
100 /* Initialize a thread; called from the child after fork()/clone() */
101 struct init_thread_request
103 int unix_pid
; /* Unix pid of new thread */
104 void* teb
; /* TEB of new thread (in thread address space) */
106 struct init_thread_reply
108 void* pid
; /* process id of the new thread's process */
109 void* tid
; /* thread id of the new thread */
113 /* Terminate a process */
114 struct terminate_process_request
116 int handle
; /* process handle to terminate */
117 int exit_code
; /* process exit code */
121 /* Terminate a thread */
122 struct terminate_thread_request
124 int handle
; /* thread handle to terminate */
125 int exit_code
; /* thread exit code */
129 /* Retrieve information about a process */
130 struct get_process_info_request
132 int handle
; /* process handle */
134 struct get_process_info_reply
136 void* pid
; /* server process id */
137 int exit_code
; /* process exit code */
138 int priority
; /* priority class */
139 int process_affinity
; /* process affinity mask */
140 int system_affinity
; /* system affinity mask */
144 /* Set a process informations */
145 struct set_process_info_request
147 int handle
; /* process handle */
148 int mask
; /* setting mask (see below) */
149 int priority
; /* priority class */
150 int affinity
; /* affinity mask */
152 #define SET_PROCESS_INFO_PRIORITY 0x01
153 #define SET_PROCESS_INFO_AFFINITY 0x02
156 /* Retrieve information about a thread */
157 struct get_thread_info_request
159 int handle
; /* thread handle */
161 struct get_thread_info_reply
163 void* tid
; /* server thread id */
164 int exit_code
; /* thread exit code */
165 int priority
; /* thread priority level */
169 /* Set a thread informations */
170 struct set_thread_info_request
172 int handle
; /* thread handle */
173 int mask
; /* setting mask (see below) */
174 int priority
; /* priority class */
175 int affinity
; /* affinity mask */
177 #define SET_THREAD_INFO_PRIORITY 0x01
178 #define SET_THREAD_INFO_AFFINITY 0x02
181 /* Suspend a thread */
182 struct suspend_thread_request
184 int handle
; /* thread handle */
186 struct suspend_thread_reply
188 int count
; /* new suspend count */
192 /* Resume a thread */
193 struct resume_thread_request
195 int handle
; /* thread handle */
197 struct resume_thread_reply
199 int count
; /* new suspend count */
203 /* Debugger support: freeze / unfreeze */
204 struct debugger_request
206 int op
; /* operation type */
209 enum debugger_op
{ DEBUGGER_FREEZE_ALL
, DEBUGGER_UNFREEZE_ALL
};
212 /* Queue an APC for a thread */
213 struct queue_apc_request
215 int handle
; /* thread handle */
216 void* func
; /* function to call */
217 void* param
; /* param for function to call */
221 /* Close a handle for the current process */
222 struct close_handle_request
224 int handle
; /* handle to close */
228 /* Get information about a handle */
229 struct get_handle_info_request
231 int handle
; /* handle we are interested in */
233 struct get_handle_info_reply
235 int flags
; /* handle flags */
239 /* Set a handle information */
240 struct set_handle_info_request
242 int handle
; /* handle we are interested in */
243 int flags
; /* new handle flags */
244 int mask
; /* mask for flags to set */
248 /* Duplicate a handle */
249 struct dup_handle_request
251 int src_process
; /* src process handle */
252 int src_handle
; /* src handle to duplicate */
253 int dst_process
; /* dst process handle */
254 unsigned int access
; /* wanted access rights */
255 int inherit
; /* inherit flag */
256 int options
; /* duplicate options (see below) */
258 #define DUP_HANDLE_CLOSE_SOURCE DUPLICATE_CLOSE_SOURCE
259 #define DUP_HANDLE_SAME_ACCESS DUPLICATE_SAME_ACCESS
260 #define DUP_HANDLE_MAKE_GLOBAL 0x80000000 /* Not a Windows flag */
261 struct dup_handle_reply
263 int handle
; /* duplicated handle in dst process */
267 /* Open a handle to a process */
268 struct open_process_request
270 void* pid
; /* process id to open */
271 unsigned int access
; /* wanted access rights */
272 int inherit
; /* inherit flag */
274 struct open_process_reply
276 int handle
; /* handle to the process */
280 /* Wait for handles */
281 struct select_request
283 int count
; /* handles count */
284 int flags
; /* wait flags (see below) */
285 int timeout
; /* timeout in ms */
286 int handles
[0]; /* handles to select on */
290 int signaled
; /* signaled handle */
291 void* apcs
[0]; /* async procedures to call */
294 #define SELECT_ALERTABLE 2
295 #define SELECT_TIMEOUT 4
298 /* Create an event */
299 struct create_event_request
301 int manual_reset
; /* manual reset event */
302 int initial_state
; /* initial state of the event */
303 int inherit
; /* inherit flag */
304 char name
[0]; /* event name */
306 struct create_event_reply
308 int handle
; /* handle to the event */
311 /* Event operation */
312 struct event_op_request
314 int handle
; /* handle to event */
315 int op
; /* event operation (see below) */
317 enum event_op
{ PULSE_EVENT
, SET_EVENT
, RESET_EVENT
};
321 struct open_event_request
323 unsigned int access
; /* wanted access rights */
324 int inherit
; /* inherit flag */
325 char name
[0]; /* object name */
327 struct open_event_reply
329 int handle
; /* handle to the event */
334 struct create_mutex_request
336 int owned
; /* initially owned? */
337 int inherit
; /* inherit flag */
338 char name
[0]; /* mutex name */
340 struct create_mutex_reply
342 int handle
; /* handle to the mutex */
346 /* Release a mutex */
347 struct release_mutex_request
349 int handle
; /* handle to the mutex */
354 struct open_mutex_request
356 unsigned int access
; /* wanted access rights */
357 int inherit
; /* inherit flag */
358 char name
[0]; /* object name */
360 struct open_mutex_reply
362 int handle
; /* handle to the mutex */
366 /* Create a semaphore */
367 struct create_semaphore_request
369 unsigned int initial
; /* initial count */
370 unsigned int max
; /* maximum count */
371 int inherit
; /* inherit flag */
372 char name
[0]; /* semaphore name */
374 struct create_semaphore_reply
376 int handle
; /* handle to the semaphore */
380 /* Release a semaphore */
381 struct release_semaphore_request
383 int handle
; /* handle to the semaphore */
384 unsigned int count
; /* count to add to semaphore */
386 struct release_semaphore_reply
388 unsigned int prev_count
; /* previous semaphore count */
392 /* Open a semaphore */
393 struct open_semaphore_request
395 unsigned int access
; /* wanted access rights */
396 int inherit
; /* inherit flag */
397 char name
[0]; /* object name */
399 struct open_semaphore_reply
401 int handle
; /* handle to the semaphore */
406 struct create_file_request
408 unsigned int access
; /* wanted access rights */
409 int inherit
; /* inherit flag */
410 unsigned int sharing
; /* sharing flags */
411 int create
; /* file create action */
412 unsigned int attrs
; /* file attributes for creation */
413 char name
[0]; /* file name */
415 struct create_file_reply
417 int handle
; /* handle to the file */
421 /* Get a Unix fd to read from a file */
422 struct get_read_fd_request
424 int handle
; /* handle to the file */
428 /* Get a Unix fd to write to a file */
429 struct get_write_fd_request
431 int handle
; /* handle to the file */
435 /* Set a file current position */
436 struct set_file_pointer_request
438 int handle
; /* handle to the file */
439 int low
; /* position low word */
440 int high
; /* position high word */
441 int whence
; /* whence to seek */
443 struct set_file_pointer_reply
445 int low
; /* new position low word */
446 int high
; /* new position high word */
450 /* Truncate (or extend) a file */
451 struct truncate_file_request
453 int handle
; /* handle to the file */
457 /* Set a file access and modification times */
458 struct set_file_time_request
460 int handle
; /* handle to the file */
461 time_t access_time
; /* last access time */
462 time_t write_time
; /* last write time */
466 /* Flush a file buffers */
467 struct flush_file_request
469 int handle
; /* handle to the file */
473 /* Get information about a file */
474 struct get_file_info_request
476 int handle
; /* handle to the file */
478 struct get_file_info_reply
480 int type
; /* file type */
481 int attr
; /* file attributes */
482 time_t access_time
; /* last access time */
483 time_t write_time
; /* last write time */
484 int size_high
; /* file size */
485 int size_low
; /* file size */
486 int links
; /* number of links */
487 int index_high
; /* unique index */
488 int index_low
; /* unique index */
489 unsigned int serial
; /* volume serial number */
493 /* Lock a region of a file */
494 struct lock_file_request
496 int handle
; /* handle to the file */
497 unsigned int offset_low
; /* offset of start of lock */
498 unsigned int offset_high
; /* offset of start of lock */
499 unsigned int count_low
; /* count of bytes to lock */
500 unsigned int count_high
; /* count of bytes to lock */
504 /* Unlock a region of a file */
505 struct unlock_file_request
507 int handle
; /* handle to the file */
508 unsigned int offset_low
; /* offset of start of unlock */
509 unsigned int offset_high
; /* offset of start of unlock */
510 unsigned int count_low
; /* count of bytes to unlock */
511 unsigned int count_high
; /* count of bytes to unlock */
515 /* Create an anonymous pipe */
516 struct create_pipe_request
518 int inherit
; /* inherit flag */
520 struct create_pipe_reply
522 int handle_read
; /* handle to the read-side of the pipe */
523 int handle_write
; /* handle to the write-side of the pipe */
527 /* Allocate a console for the current process */
528 struct alloc_console_request
530 unsigned int access
; /* wanted access rights */
531 int inherit
; /* inherit flag */
533 struct alloc_console_reply
535 int handle_in
; /* handle to console input */
536 int handle_out
; /* handle to console output */
540 /* Free the console of the current process */
541 struct free_console_request
547 /* Open a handle to the process console */
548 struct open_console_request
550 int output
; /* input or output? */
551 unsigned int access
; /* wanted access rights */
552 int inherit
; /* inherit flag */
554 struct open_console_reply
556 int handle
; /* handle to the console */
560 /* Set a console file descriptor */
561 struct set_console_fd_request
563 int handle
; /* handle to the console */
564 int pid
; /* pid of xterm (hack) */
568 /* Get a console mode (input or output) */
569 struct get_console_mode_request
571 int handle
; /* handle to the console */
573 struct get_console_mode_reply
575 int mode
; /* console mode */
579 /* Set a console mode (input or output) */
580 struct set_console_mode_request
582 int handle
; /* handle to the console */
583 int mode
; /* console mode */
587 /* Set info about a console (output only) */
588 struct set_console_info_request
590 int handle
; /* handle to the console */
591 int mask
; /* setting mask (see below) */
592 int cursor_size
; /* size of cursor (percentage filled) */
593 int cursor_visible
;/* cursor visibility flag */
594 char title
[0]; /* console title */
596 #define SET_CONSOLE_INFO_CURSOR 0x01
597 #define SET_CONSOLE_INFO_TITLE 0x02
599 /* Get info about a console (output only) */
600 struct get_console_info_request
602 int handle
; /* handle to the console */
604 struct get_console_info_reply
606 int cursor_size
; /* size of cursor (percentage filled) */
607 int cursor_visible
;/* cursor visibility flag */
608 int pid
; /* pid of xterm (hack) */
609 char title
[0]; /* console title */
613 /* Add input records to a console input queue */
614 struct write_console_input_request
616 int handle
; /* handle to the console input */
617 int count
; /* number of input records */
618 /* INPUT_RECORD records[0]; */ /* input records */
620 struct write_console_input_reply
622 int written
; /* number of records written */
625 /* Fetch input records from a console input queue */
626 struct read_console_input_request
628 int handle
; /* handle to the console input */
629 int count
; /* max number of records to retrieve */
630 int flush
; /* flush the retrieved records from the queue? */
632 struct read_console_input_reply
635 /* INPUT_RECORD records[0]; */ /* input records */
639 /* Create a change notification */
640 struct create_change_notification_request
642 int subtree
; /* watch all the subtree */
643 int filter
; /* notification filter */
645 struct create_change_notification_reply
647 int handle
; /* handle to the change notification */
651 /* Create a file mapping */
652 struct create_mapping_request
654 int size_high
; /* mapping size */
655 int size_low
; /* mapping size */
656 int protect
; /* protection flags (see below) */
657 int inherit
; /* inherit flag */
658 int handle
; /* file handle */
659 char name
[0]; /* object name */
661 struct create_mapping_reply
663 int handle
; /* handle to the mapping */
665 /* protection flags */
666 #define VPROT_READ 0x01
667 #define VPROT_WRITE 0x02
668 #define VPROT_EXEC 0x04
669 #define VPROT_WRITECOPY 0x08
670 #define VPROT_GUARD 0x10
671 #define VPROT_NOCACHE 0x20
672 #define VPROT_COMMITTED 0x40
676 struct open_mapping_request
678 unsigned int access
; /* wanted access rights */
679 int inherit
; /* inherit flag */
680 char name
[0]; /* object name */
682 struct open_mapping_reply
684 int handle
; /* handle to the mapping */
688 /* Get information about a file mapping */
689 struct get_mapping_info_request
691 int handle
; /* handle to the mapping */
693 struct get_mapping_info_reply
695 int size_high
; /* mapping size */
696 int size_low
; /* mapping size */
697 int protect
; /* protection flags */
701 /* Create a device */
702 struct create_device_request
704 unsigned int access
; /* wanted access rights */
705 int inherit
; /* inherit flag */
706 int id
; /* client private id */
708 struct create_device_reply
710 int handle
; /* handle to the device */
714 /* Create a snapshot */
715 struct create_snapshot_request
717 int inherit
; /* inherit flag */
718 int flags
; /* snapshot flags (TH32CS_*) */
720 struct create_snapshot_reply
722 int handle
; /* handle to the snapshot */
726 /* Get the next process from a snapshot */
727 struct next_process_request
729 int handle
; /* handle to the snapshot */
730 int reset
; /* reset snapshot position? */
732 struct next_process_reply
734 void* pid
; /* process id */
735 int threads
; /* number of threads */
736 int priority
; /* process priority */
740 /* Wait for a debug event */
741 struct wait_debug_event_request
743 int timeout
; /* timeout in ms */
745 struct wait_debug_event_reply
747 int code
; /* event code */
748 void* pid
; /* process id */
749 void* tid
; /* thread id */
750 /* followed by the event data (see below) */
754 /* Send a debug event */
755 struct send_debug_event_request
757 int code
; /* event code */
758 /* followed by the event data (see below) */
760 struct send_debug_event_reply
762 int status
; /* event continuation status */
766 /* definitions of the event data depending on the event code */
767 struct debug_event_exception
769 int code
; /* exception code */
770 int flags
; /* exception flags */
771 void *record
; /* exception record ptr */
772 void *addr
; /* exception address */
773 int nb_params
; /* exceptions parameters */
775 int first_chance
; /* first chance to handle it? */
777 struct debug_event_create_thread
779 int handle
; /* handle to the new thread */
780 void *teb
; /* thread teb (in debugged process address space) */
781 void *start
; /* thread startup routine */
783 struct debug_event_create_process
785 int file
; /* handle to the process exe file */
786 int process
; /* handle to the new process */
787 int thread
; /* handle to the new thread */
788 void *base
; /* base of executable image */
789 int dbg_offset
; /* offset of debug info in file */
790 int dbg_size
; /* size of debug info */
791 void *teb
; /* thread teb (in debugged process address space) */
792 void *start
; /* thread startup routine */
793 void *name
; /* image name (optional) */
794 int unicode
; /* is it Unicode? */
796 struct debug_event_exit
798 int exit_code
; /* thread or process exit code */
800 struct debug_event_load_dll
802 int handle
; /* file handle for the dll */
803 void *base
; /* base address of the dll */
804 int dbg_offset
; /* offset of debug info in file */
805 int dbg_size
; /* size of debug info */
806 void *name
; /* image name (optional) */
807 int unicode
; /* is it Unicode? */
809 struct debug_event_unload_dll
811 void *base
; /* base address of the dll */
813 struct debug_event_output_string
815 void *string
; /* string to display (in debugged process address space) */
816 int unicode
; /* is it Unicode? */
817 int length
; /* string length */
819 struct debug_event_rip_info
824 union debug_event_data
826 struct debug_event_exception exception
;
827 struct debug_event_create_thread create_thread
;
828 struct debug_event_create_process create_process
;
829 struct debug_event_exit exit
;
830 struct debug_event_load_dll load_dll
;
831 struct debug_event_unload_dll unload_dll
;
832 struct debug_event_output_string output_string
;
833 struct debug_event_rip_info rip_info
;
837 /* Continue a debug event */
838 struct continue_debug_event_request
840 void* pid
; /* process id to continue */
841 void* tid
; /* thread id to continue */
842 int status
; /* continuation status */
846 /* Start debugging an existing process */
847 struct debug_process_request
849 void* pid
; /* id of the process to debug */
853 /* Everything below this line is generated automatically by tools/make_requests */
854 /* ### make_requests begin ### */
863 REQ_TERMINATE_PROCESS
,
864 REQ_TERMINATE_THREAD
,
865 REQ_GET_PROCESS_INFO
,
866 REQ_SET_PROCESS_INFO
,
885 REQ_CREATE_SEMAPHORE
,
886 REQ_RELEASE_SEMAPHORE
,
891 REQ_SET_FILE_POINTER
,
903 REQ_GET_CONSOLE_MODE
,
904 REQ_SET_CONSOLE_MODE
,
905 REQ_SET_CONSOLE_INFO
,
906 REQ_GET_CONSOLE_INFO
,
907 REQ_WRITE_CONSOLE_INPUT
,
908 REQ_READ_CONSOLE_INPUT
,
909 REQ_CREATE_CHANGE_NOTIFICATION
,
912 REQ_GET_MAPPING_INFO
,
916 REQ_WAIT_DEBUG_EVENT
,
917 REQ_SEND_DEBUG_EVENT
,
918 REQ_CONTINUE_DEBUG_EVENT
,
923 /* ### make_requests end ### */
924 /* Everything above this line is generated automatically by tools/make_requests */
927 /* client-side functions */
929 #ifndef __WINE_SERVER__
933 /* make space for some data in the server arguments buffer */
934 static inline void *server_add_data( int len
)
936 void *old
= NtCurrentTeb()->buffer_args
;
937 NtCurrentTeb()->buffer_args
= (char *)old
+ len
;
941 /* maximum remaining size in the server arguments buffer */
942 static inline int server_remaining(void)
944 TEB
*teb
= NtCurrentTeb();
945 return (char *)teb
->buffer
+ teb
->buffer_size
- (char *)teb
->buffer_args
;
948 extern unsigned int server_call( enum request req
);
949 extern unsigned int server_call_fd( enum request req
, int *fd
);
951 /* client communication functions */
952 extern void CLIENT_ProtocolError( const char *err
, ... );
953 extern void CLIENT_SendRequest( enum request req
, int pass_fd
,
954 int n
, ... /* arg_1, len_1, etc. */ );
955 extern unsigned int CLIENT_WaitReply( int *len
, int *passed_fd
,
956 int n
, ... /* arg_1, len_1, etc. */ );
957 extern unsigned int CLIENT_WaitSimpleReply( void *reply
, int len
, int *passed_fd
);
958 extern int CLIENT_InitServer(void);
959 extern int CLIENT_SetDebug( int level
);
960 extern int CLIENT_DebuggerRequest( int op
);
961 extern int CLIENT_InitThread(void);
962 #endif /* __WINE_SERVER__ */
964 #endif /* __WINE_SERVER_H */