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 void* env_ptr
; /* pointer to environment (FIXME: hack) */
57 char cmd_line
[0]; /* command line */
59 struct new_process_reply
61 void* pid
; /* process id */
62 int handle
; /* process handle (in the current process) */
66 /* Create a new thread from the context of the parent */
67 struct new_thread_request
69 void* pid
; /* process id for the new thread */
70 int suspend
; /* new thread should be suspended on creation */
71 int inherit
; /* inherit flag */
73 struct new_thread_reply
75 void* tid
; /* thread id */
76 int handle
; /* thread handle (in the current process) */
80 /* Set the server debug level */
81 struct set_debug_request
83 int level
; /* New debug level */
87 /* Initialize a process; called from the new process context */
88 struct init_process_request
92 struct init_process_reply
94 int start_flags
; /* flags from startup info */
95 int hstdin
; /* handle for stdin */
96 int hstdout
; /* handle for stdout */
97 int hstderr
; /* handle for stderr */
98 void* env_ptr
; /* pointer to environment (FIXME: hack) */
102 /* Initialize a thread; called from the child after fork()/clone() */
103 struct init_thread_request
105 int unix_pid
; /* Unix pid of new thread */
106 void* teb
; /* TEB of new thread (in thread address space) */
108 struct init_thread_reply
110 void* pid
; /* process id of the new thread's process */
111 void* tid
; /* thread id of the new thread */
115 /* Terminate a process */
116 struct terminate_process_request
118 int handle
; /* process handle to terminate */
119 int exit_code
; /* process exit code */
123 /* Terminate a thread */
124 struct terminate_thread_request
126 int handle
; /* thread handle to terminate */
127 int exit_code
; /* thread exit code */
131 /* Retrieve information about a process */
132 struct get_process_info_request
134 int handle
; /* process handle */
136 struct get_process_info_reply
138 void* pid
; /* server process id */
139 int exit_code
; /* process exit code */
140 int priority
; /* priority class */
141 int process_affinity
; /* process affinity mask */
142 int system_affinity
; /* system affinity mask */
146 /* Set a process informations */
147 struct set_process_info_request
149 int handle
; /* process handle */
150 int mask
; /* setting mask (see below) */
151 int priority
; /* priority class */
152 int affinity
; /* affinity mask */
154 #define SET_PROCESS_INFO_PRIORITY 0x01
155 #define SET_PROCESS_INFO_AFFINITY 0x02
158 /* Retrieve information about a thread */
159 struct get_thread_info_request
161 int handle
; /* thread handle */
163 struct get_thread_info_reply
165 void* tid
; /* server thread id */
166 int exit_code
; /* thread exit code */
167 int priority
; /* thread priority level */
171 /* Set a thread informations */
172 struct set_thread_info_request
174 int handle
; /* thread handle */
175 int mask
; /* setting mask (see below) */
176 int priority
; /* priority class */
177 int affinity
; /* affinity mask */
179 #define SET_THREAD_INFO_PRIORITY 0x01
180 #define SET_THREAD_INFO_AFFINITY 0x02
183 /* Suspend a thread */
184 struct suspend_thread_request
186 int handle
; /* thread handle */
188 struct suspend_thread_reply
190 int count
; /* new suspend count */
194 /* Resume a thread */
195 struct resume_thread_request
197 int handle
; /* thread handle */
199 struct resume_thread_reply
201 int count
; /* new suspend count */
205 /* Debugger support: freeze / unfreeze */
206 struct debugger_request
208 int op
; /* operation type */
211 enum debugger_op
{ DEBUGGER_FREEZE_ALL
, DEBUGGER_UNFREEZE_ALL
};
214 /* Queue an APC for a thread */
215 struct queue_apc_request
217 int handle
; /* thread handle */
218 void* func
; /* function to call */
219 void* param
; /* param for function to call */
223 /* Close a handle for the current process */
224 struct close_handle_request
226 int handle
; /* handle to close */
230 /* Get information about a handle */
231 struct get_handle_info_request
233 int handle
; /* handle we are interested in */
235 struct get_handle_info_reply
237 int flags
; /* handle flags */
241 /* Set a handle information */
242 struct set_handle_info_request
244 int handle
; /* handle we are interested in */
245 int flags
; /* new handle flags */
246 int mask
; /* mask for flags to set */
250 /* Duplicate a handle */
251 struct dup_handle_request
253 int src_process
; /* src process handle */
254 int src_handle
; /* src handle to duplicate */
255 int dst_process
; /* dst process handle */
256 unsigned int access
; /* wanted access rights */
257 int inherit
; /* inherit flag */
258 int options
; /* duplicate options (see below) */
260 #define DUP_HANDLE_CLOSE_SOURCE DUPLICATE_CLOSE_SOURCE
261 #define DUP_HANDLE_SAME_ACCESS DUPLICATE_SAME_ACCESS
262 #define DUP_HANDLE_MAKE_GLOBAL 0x80000000 /* Not a Windows flag */
263 struct dup_handle_reply
265 int handle
; /* duplicated handle in dst process */
269 /* Open a handle to a process */
270 struct open_process_request
272 void* pid
; /* process id to open */
273 unsigned int access
; /* wanted access rights */
274 int inherit
; /* inherit flag */
276 struct open_process_reply
278 int handle
; /* handle to the process */
282 /* Wait for handles */
283 struct select_request
285 int count
; /* handles count */
286 int flags
; /* wait flags (see below) */
287 int timeout
; /* timeout in ms */
292 int signaled
; /* signaled handle */
293 /* void* apcs[]; */ /* async procedures to call */
296 #define SELECT_ALERTABLE 2
297 #define SELECT_TIMEOUT 4
300 /* Create an event */
301 struct create_event_request
303 int manual_reset
; /* manual reset event */
304 int initial_state
; /* initial state of the event */
305 int inherit
; /* inherit flag */
306 char name
[0]; /* event name */
308 struct create_event_reply
310 int handle
; /* handle to the event */
313 /* Event operation */
314 struct event_op_request
316 int handle
; /* handle to event */
317 int op
; /* event operation (see below) */
319 enum event_op
{ PULSE_EVENT
, SET_EVENT
, RESET_EVENT
};
323 struct open_event_request
325 unsigned int access
; /* wanted access rights */
326 int inherit
; /* inherit flag */
327 char name
[0]; /* object name */
329 struct open_event_reply
331 int handle
; /* handle to the event */
336 struct create_mutex_request
338 int owned
; /* initially owned? */
339 int inherit
; /* inherit flag */
340 char name
[0]; /* mutex name */
342 struct create_mutex_reply
344 int handle
; /* handle to the mutex */
348 /* Release a mutex */
349 struct release_mutex_request
351 int handle
; /* handle to the mutex */
356 struct open_mutex_request
358 unsigned int access
; /* wanted access rights */
359 int inherit
; /* inherit flag */
360 char name
[0]; /* object name */
362 struct open_mutex_reply
364 int handle
; /* handle to the mutex */
368 /* Create a semaphore */
369 struct create_semaphore_request
371 unsigned int initial
; /* initial count */
372 unsigned int max
; /* maximum count */
373 int inherit
; /* inherit flag */
374 char name
[0]; /* semaphore name */
376 struct create_semaphore_reply
378 int handle
; /* handle to the semaphore */
382 /* Release a semaphore */
383 struct release_semaphore_request
385 int handle
; /* handle to the semaphore */
386 unsigned int count
; /* count to add to semaphore */
388 struct release_semaphore_reply
390 unsigned int prev_count
; /* previous semaphore count */
394 /* Open a semaphore */
395 struct open_semaphore_request
397 unsigned int access
; /* wanted access rights */
398 int inherit
; /* inherit flag */
399 char name
[0]; /* object name */
401 struct open_semaphore_reply
403 int handle
; /* handle to the semaphore */
408 struct create_file_request
410 unsigned int access
; /* wanted access rights */
411 int inherit
; /* inherit flag */
412 unsigned int sharing
; /* sharing flags */
413 int create
; /* file create action */
414 unsigned int attrs
; /* file attributes for creation */
415 char name
[0]; /* file name */
417 struct create_file_reply
419 int handle
; /* handle to the file */
423 /* Get a Unix fd to read from a file */
424 struct get_read_fd_request
426 int handle
; /* handle to the file */
430 /* Get a Unix fd to write to a file */
431 struct get_write_fd_request
433 int handle
; /* handle to the file */
437 /* Set a file current position */
438 struct set_file_pointer_request
440 int handle
; /* handle to the file */
441 int low
; /* position low word */
442 int high
; /* position high word */
443 int whence
; /* whence to seek */
445 struct set_file_pointer_reply
447 int low
; /* new position low word */
448 int high
; /* new position high word */
452 /* Truncate (or extend) a file */
453 struct truncate_file_request
455 int handle
; /* handle to the file */
459 /* Set a file access and modification times */
460 struct set_file_time_request
462 int handle
; /* handle to the file */
463 time_t access_time
; /* last access time */
464 time_t write_time
; /* last write time */
468 /* Flush a file buffers */
469 struct flush_file_request
471 int handle
; /* handle to the file */
475 /* Get information about a file */
476 struct get_file_info_request
478 int handle
; /* handle to the file */
480 struct get_file_info_reply
482 int type
; /* file type */
483 int attr
; /* file attributes */
484 time_t access_time
; /* last access time */
485 time_t write_time
; /* last write time */
486 int size_high
; /* file size */
487 int size_low
; /* file size */
488 int links
; /* number of links */
489 int index_high
; /* unique index */
490 int index_low
; /* unique index */
491 unsigned int serial
; /* volume serial number */
495 /* Lock a region of a file */
496 struct lock_file_request
498 int handle
; /* handle to the file */
499 unsigned int offset_low
; /* offset of start of lock */
500 unsigned int offset_high
; /* offset of start of lock */
501 unsigned int count_low
; /* count of bytes to lock */
502 unsigned int count_high
; /* count of bytes to lock */
506 /* Unlock a region of a file */
507 struct unlock_file_request
509 int handle
; /* handle to the file */
510 unsigned int offset_low
; /* offset of start of unlock */
511 unsigned int offset_high
; /* offset of start of unlock */
512 unsigned int count_low
; /* count of bytes to unlock */
513 unsigned int count_high
; /* count of bytes to unlock */
517 /* Create an anonymous pipe */
518 struct create_pipe_request
520 int inherit
; /* inherit flag */
522 struct create_pipe_reply
524 int handle_read
; /* handle to the read-side of the pipe */
525 int handle_write
; /* handle to the write-side of the pipe */
529 /* Allocate a console for the current process */
530 struct alloc_console_request
536 /* Free the console of the current process */
537 struct free_console_request
543 /* Open a handle to the process console */
544 struct open_console_request
546 int output
; /* input or output? */
547 unsigned int access
; /* wanted access rights */
548 int inherit
; /* inherit flag */
550 struct open_console_reply
552 int handle
; /* handle to the console */
556 /* Set a console file descriptor */
557 struct set_console_fd_request
559 int handle
; /* handle to the console */
560 int pid
; /* pid of xterm (hack) */
564 /* Get a console mode (input or output) */
565 struct get_console_mode_request
567 int handle
; /* handle to the console */
569 struct get_console_mode_reply
571 int mode
; /* console mode */
575 /* Set a console mode (input or output) */
576 struct set_console_mode_request
578 int handle
; /* handle to the console */
579 int mode
; /* console mode */
583 /* Set info about a console (output only) */
584 struct set_console_info_request
586 int handle
; /* handle to the console */
587 int mask
; /* setting mask (see below) */
588 int cursor_size
; /* size of cursor (percentage filled) */
589 int cursor_visible
;/* cursor visibility flag */
590 char title
[0]; /* console title */
592 #define SET_CONSOLE_INFO_CURSOR 0x01
593 #define SET_CONSOLE_INFO_TITLE 0x02
595 /* Get info about a console (output only) */
596 struct get_console_info_request
598 int handle
; /* handle to the console */
600 struct get_console_info_reply
602 int cursor_size
; /* size of cursor (percentage filled) */
603 int cursor_visible
;/* cursor visibility flag */
604 int pid
; /* pid of xterm (hack) */
605 /* char title[0]; */ /* console title */
609 /* Add input records to a console input queue */
610 struct write_console_input_request
612 int handle
; /* handle to the console input */
613 int count
; /* number of input records */
614 /* INPUT_RECORD records[0]; */ /* input records */
616 struct write_console_input_reply
618 int written
; /* number of records written */
621 /* Fetch input records from a console input queue */
622 struct read_console_input_request
624 int handle
; /* handle to the console input */
625 int count
; /* max number of records to retrieve */
626 int flush
; /* flush the retrieved records from the queue? */
628 struct read_console_input_reply
631 /* INPUT_RECORD records[0]; */ /* input records */
635 /* Create a change notification */
636 struct create_change_notification_request
638 int subtree
; /* watch all the subtree */
639 int filter
; /* notification filter */
641 struct create_change_notification_reply
643 int handle
; /* handle to the change notification */
647 /* Create a file mapping */
648 struct create_mapping_request
650 int size_high
; /* mapping size */
651 int size_low
; /* mapping size */
652 int protect
; /* protection flags (see below) */
653 int inherit
; /* inherit flag */
654 int handle
; /* file handle */
655 char name
[0]; /* object name */
657 struct create_mapping_reply
659 int handle
; /* handle to the mapping */
661 /* protection flags */
662 #define VPROT_READ 0x01
663 #define VPROT_WRITE 0x02
664 #define VPROT_EXEC 0x04
665 #define VPROT_WRITECOPY 0x08
666 #define VPROT_GUARD 0x10
667 #define VPROT_NOCACHE 0x20
668 #define VPROT_COMMITTED 0x40
672 struct open_mapping_request
674 unsigned int access
; /* wanted access rights */
675 int inherit
; /* inherit flag */
676 char name
[0]; /* object name */
678 struct open_mapping_reply
680 int handle
; /* handle to the mapping */
684 /* Get information about a file mapping */
685 struct get_mapping_info_request
687 int handle
; /* handle to the mapping */
689 struct get_mapping_info_reply
691 int size_high
; /* mapping size */
692 int size_low
; /* mapping size */
693 int protect
; /* protection flags */
697 /* Create a device */
698 struct create_device_request
700 unsigned int access
; /* wanted access rights */
701 int inherit
; /* inherit flag */
702 int id
; /* client private id */
704 struct create_device_reply
706 int handle
; /* handle to the device */
710 /* Create a snapshot */
711 struct create_snapshot_request
713 int inherit
; /* inherit flag */
714 int flags
; /* snapshot flags (TH32CS_*) */
716 struct create_snapshot_reply
718 int handle
; /* handle to the snapshot */
722 /* Get the next process from a snapshot */
723 struct next_process_request
725 int handle
; /* handle to the snapshot */
726 int reset
; /* reset snapshot position? */
728 struct next_process_reply
730 void* pid
; /* process id */
731 int threads
; /* number of threads */
732 int priority
; /* process priority */
736 /* Wait for a debug event */
737 struct wait_debug_event_request
739 int timeout
; /* timeout in ms */
741 struct wait_debug_event_reply
743 int code
; /* event code */
744 void* pid
; /* process id */
745 void* tid
; /* thread id */
746 /* followed by the event data (see below) */
750 /* Send a debug event */
751 struct send_debug_event_request
753 int code
; /* event code */
754 /* followed by the event data (see below) */
756 struct send_debug_event_reply
758 int status
; /* event continuation status */
762 /* definitions of the event data depending on the event code */
763 struct debug_event_exception
765 int code
; /* exception code */
766 int flags
; /* exception flags */
767 void *record
; /* exception record ptr */
768 void *addr
; /* exception address */
769 int nb_params
; /* exceptions parameters */
771 int first_chance
; /* first chance to handle it? */
773 struct debug_event_create_thread
775 int handle
; /* handle to the new thread */
776 void *teb
; /* thread teb (in debugged process address space) */
777 void *start
; /* thread startup routine */
779 struct debug_event_create_process
781 int file
; /* handle to the process exe file */
782 int process
; /* handle to the new process */
783 int thread
; /* handle to the new thread */
784 void *base
; /* base of executable image */
785 int dbg_offset
; /* offset of debug info in file */
786 int dbg_size
; /* size of debug info */
787 void *teb
; /* thread teb (in debugged process address space) */
788 void *start
; /* thread startup routine */
789 void *name
; /* image name (optional) */
790 int unicode
; /* is it Unicode? */
792 struct debug_event_exit
794 int exit_code
; /* thread or process exit code */
796 struct debug_event_load_dll
798 int handle
; /* file handle for the dll */
799 void *base
; /* base address of the dll */
800 int dbg_offset
; /* offset of debug info in file */
801 int dbg_size
; /* size of debug info */
802 void *name
; /* image name (optional) */
803 int unicode
; /* is it Unicode? */
805 struct debug_event_unload_dll
807 void *base
; /* base address of the dll */
809 struct debug_event_output_string
811 void *string
; /* string to display (in debugged process address space) */
812 int unicode
; /* is it Unicode? */
813 int length
; /* string length */
815 struct debug_event_rip_info
820 union debug_event_data
822 struct debug_event_exception exception
;
823 struct debug_event_create_thread create_thread
;
824 struct debug_event_create_process create_process
;
825 struct debug_event_exit exit
;
826 struct debug_event_load_dll load_dll
;
827 struct debug_event_unload_dll unload_dll
;
828 struct debug_event_output_string output_string
;
829 struct debug_event_rip_info rip_info
;
833 /* Continue a debug event */
834 struct continue_debug_event_request
836 void* pid
; /* process id to continue */
837 void* tid
; /* thread id to continue */
838 int status
; /* continuation status */
842 /* Start debugging an existing process */
843 struct debug_process_request
845 void* pid
; /* id of the process to debug */
849 /* requests definitions */
850 #include "server/request.h"
852 /* client-side functions */
854 #ifndef __WINE_SERVER__
856 /* client communication functions */
857 extern void CLIENT_ProtocolError( const char *err
, ... );
858 extern void CLIENT_SendRequest( enum request req
, int pass_fd
,
859 int n
, ... /* arg_1, len_1, etc. */ );
860 extern unsigned int CLIENT_WaitReply( int *len
, int *passed_fd
,
861 int n
, ... /* arg_1, len_1, etc. */ );
862 extern unsigned int CLIENT_WaitSimpleReply( void *reply
, int len
, int *passed_fd
);
863 extern int CLIENT_InitServer(void);
864 extern int CLIENT_SetDebug( int level
);
865 extern int CLIENT_DebuggerRequest( int op
);
866 extern int CLIENT_InitThread(void);
867 #endif /* __WINE_SERVER__ */
869 #endif /* __WINE_SERVER_H */