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 /* Queue an APC for a thread */
199 struct queue_apc_request
201 int handle
; /* thread handle */
202 void* func
; /* function to call */
203 void* param
; /* param for function to call */
207 /* Close a handle for the current process */
208 struct close_handle_request
210 int handle
; /* handle to close */
214 /* Get information about a handle */
215 struct get_handle_info_request
217 int handle
; /* handle we are interested in */
219 struct get_handle_info_reply
221 int flags
; /* handle flags */
225 /* Set a handle information */
226 struct set_handle_info_request
228 int handle
; /* handle we are interested in */
229 int flags
; /* new handle flags */
230 int mask
; /* mask for flags to set */
234 /* Duplicate a handle */
235 struct dup_handle_request
237 int src_process
; /* src process handle */
238 int src_handle
; /* src handle to duplicate */
239 int dst_process
; /* dst process handle */
240 unsigned int access
; /* wanted access rights */
241 int inherit
; /* inherit flag */
242 int options
; /* duplicate options (see below) */
244 #define DUP_HANDLE_CLOSE_SOURCE DUPLICATE_CLOSE_SOURCE
245 #define DUP_HANDLE_SAME_ACCESS DUPLICATE_SAME_ACCESS
246 #define DUP_HANDLE_MAKE_GLOBAL 0x80000000 /* Not a Windows flag */
247 struct dup_handle_reply
249 int handle
; /* duplicated handle in dst process */
253 /* Open a handle to a process */
254 struct open_process_request
256 void* pid
; /* process id to open */
257 unsigned int access
; /* wanted access rights */
258 int inherit
; /* inherit flag */
260 struct open_process_reply
262 int handle
; /* handle to the process */
266 /* Wait for handles */
267 struct select_request
269 int count
; /* handles count */
270 int flags
; /* wait flags (see below) */
271 int timeout
; /* timeout in ms */
276 int signaled
; /* signaled handle */
277 /* void* apcs[]; */ /* async procedures to call */
280 #define SELECT_ALERTABLE 2
281 #define SELECT_TIMEOUT 4
284 /* Create an event */
285 struct create_event_request
287 int manual_reset
; /* manual reset event */
288 int initial_state
; /* initial state of the event */
289 int inherit
; /* inherit flag */
290 char name
[0]; /* event name */
292 struct create_event_reply
294 int handle
; /* handle to the event */
297 /* Event operation */
298 struct event_op_request
300 int handle
; /* handle to event */
301 int op
; /* event operation (see below) */
303 enum event_op
{ PULSE_EVENT
, SET_EVENT
, RESET_EVENT
};
307 struct create_mutex_request
309 int owned
; /* initially owned? */
310 int inherit
; /* inherit flag */
311 char name
[0]; /* mutex name */
313 struct create_mutex_reply
315 int handle
; /* handle to the mutex */
319 /* Release a mutex */
320 struct release_mutex_request
322 int handle
; /* handle to the mutex */
326 /* Create a semaphore */
327 struct create_semaphore_request
329 unsigned int initial
; /* initial count */
330 unsigned int max
; /* maximum count */
331 int inherit
; /* inherit flag */
332 char name
[0]; /* semaphore name */
334 struct create_semaphore_reply
336 int handle
; /* handle to the semaphore */
340 /* Release a semaphore */
341 struct release_semaphore_request
343 int handle
; /* handle to the semaphore */
344 unsigned int count
; /* count to add to semaphore */
346 struct release_semaphore_reply
348 unsigned int prev_count
; /* previous semaphore count */
352 /* Open a named object (event, mutex, semaphore) */
353 struct open_named_obj_request
355 int type
; /* object type (see below) */
356 unsigned int access
; /* wanted access rights */
357 int inherit
; /* inherit flag */
358 char name
[0]; /* object name */
360 enum open_named_obj
{ OPEN_EVENT
, OPEN_MUTEX
, OPEN_SEMAPHORE
, OPEN_MAPPING
};
362 struct open_named_obj_reply
364 int handle
; /* handle to the object */
369 struct create_file_request
371 unsigned int access
; /* wanted access rights */
372 int inherit
; /* inherit flag */
373 unsigned int sharing
; /* sharing flags */
374 int create
; /* file create action */
375 unsigned int attrs
; /* file attributes for creation */
376 char name
[0]; /* file name */
378 struct create_file_reply
380 int handle
; /* handle to the file */
384 /* Get a Unix fd to read from a file */
385 struct get_read_fd_request
387 int handle
; /* handle to the file */
391 /* Get a Unix fd to write to a file */
392 struct get_write_fd_request
394 int handle
; /* handle to the file */
398 /* Set a file current position */
399 struct set_file_pointer_request
401 int handle
; /* handle to the file */
402 int low
; /* position low word */
403 int high
; /* position high word */
404 int whence
; /* whence to seek */
406 struct set_file_pointer_reply
408 int low
; /* new position low word */
409 int high
; /* new position high word */
413 /* Truncate (or extend) a file */
414 struct truncate_file_request
416 int handle
; /* handle to the file */
420 /* Set a file access and modification times */
421 struct set_file_time_request
423 int handle
; /* handle to the file */
424 time_t access_time
; /* last access time */
425 time_t write_time
; /* last write time */
429 /* Flush a file buffers */
430 struct flush_file_request
432 int handle
; /* handle to the file */
436 /* Get information about a file */
437 struct get_file_info_request
439 int handle
; /* handle to the file */
441 struct get_file_info_reply
443 int type
; /* file type */
444 int attr
; /* file attributes */
445 time_t access_time
; /* last access time */
446 time_t write_time
; /* last write time */
447 int size_high
; /* file size */
448 int size_low
; /* file size */
449 int links
; /* number of links */
450 int index_high
; /* unique index */
451 int index_low
; /* unique index */
452 unsigned int serial
; /* volume serial number */
456 /* Lock a region of a file */
457 struct lock_file_request
459 int handle
; /* handle to the file */
460 unsigned int offset_low
; /* offset of start of lock */
461 unsigned int offset_high
; /* offset of start of lock */
462 unsigned int count_low
; /* count of bytes to lock */
463 unsigned int count_high
; /* count of bytes to lock */
467 /* Unlock a region of a file */
468 struct unlock_file_request
470 int handle
; /* handle to the file */
471 unsigned int offset_low
; /* offset of start of unlock */
472 unsigned int offset_high
; /* offset of start of unlock */
473 unsigned int count_low
; /* count of bytes to unlock */
474 unsigned int count_high
; /* count of bytes to unlock */
478 /* Create an anonymous pipe */
479 struct create_pipe_request
481 int inherit
; /* inherit flag */
483 struct create_pipe_reply
485 int handle_read
; /* handle to the read-side of the pipe */
486 int handle_write
; /* handle to the write-side of the pipe */
490 /* Allocate a console for the current process */
491 struct alloc_console_request
496 /* Free the console of the current process */
497 struct free_console_request
502 /* Open a handle to the process console */
503 struct open_console_request
505 int output
; /* input or output? */
506 unsigned int access
; /* wanted access rights */
507 int inherit
; /* inherit flag */
509 struct open_console_reply
511 int handle
; /* handle to the console */
515 /* Set a console file descriptor */
516 struct set_console_fd_request
518 int handle
; /* handle to the console */
519 int pid
; /* pid of xterm (hack) */
523 /* Get a console mode (input or output) */
524 struct get_console_mode_request
526 int handle
; /* handle to the console */
528 struct get_console_mode_reply
530 int mode
; /* console mode */
534 /* Set a console mode (input or output) */
535 struct set_console_mode_request
537 int handle
; /* handle to the console */
538 int mode
; /* console mode */
542 /* Set info about a console (output only) */
543 struct set_console_info_request
545 int handle
; /* handle to the console */
546 int mask
; /* setting mask (see below) */
547 int cursor_size
; /* size of cursor (percentage filled) */
548 int cursor_visible
;/* cursor visibility flag */
549 char title
[0]; /* console title */
551 #define SET_CONSOLE_INFO_CURSOR 0x01
552 #define SET_CONSOLE_INFO_TITLE 0x02
554 /* Get info about a console (output only) */
555 struct get_console_info_request
557 int handle
; /* handle to the console */
559 struct get_console_info_reply
561 int cursor_size
; /* size of cursor (percentage filled) */
562 int cursor_visible
;/* cursor visibility flag */
563 int pid
; /* pid of xterm (hack) */
564 /* char title[0]; */ /* console title */
568 /* Add input records to a console input queue */
569 struct write_console_input_request
571 int handle
; /* handle to the console input */
572 int count
; /* number of input records */
573 /* INPUT_RECORD records[0]; */ /* input records */
575 struct write_console_input_reply
577 int written
; /* number of records written */
580 /* Fetch input records from a console input queue */
581 struct read_console_input_request
583 int handle
; /* handle to the console input */
584 int count
; /* max number of records to retrieve */
585 int flush
; /* flush the retrieved records from the queue? */
587 struct read_console_input_reply
589 /* INPUT_RECORD records[0]; */ /* input records */
593 /* Create a change notification */
594 struct create_change_notification_request
596 int subtree
; /* watch all the subtree */
597 int filter
; /* notification filter */
599 struct create_change_notification_reply
601 int handle
; /* handle to the change notification */
605 /* Create a file mapping */
606 struct create_mapping_request
608 int size_high
; /* mapping size */
609 int size_low
; /* mapping size */
610 int protect
; /* protection flags (see below) */
611 int inherit
; /* inherit flag */
612 int handle
; /* file handle */
613 char name
[0]; /* object name */
615 struct create_mapping_reply
617 int handle
; /* handle to the mapping */
619 /* protection flags */
620 #define VPROT_READ 0x01
621 #define VPROT_WRITE 0x02
622 #define VPROT_EXEC 0x04
623 #define VPROT_WRITECOPY 0x08
624 #define VPROT_GUARD 0x10
625 #define VPROT_NOCACHE 0x20
626 #define VPROT_COMMITTED 0x40
629 /* Get information about a file mapping */
630 struct get_mapping_info_request
632 int handle
; /* handle to the mapping */
634 struct get_mapping_info_reply
636 int size_high
; /* mapping size */
637 int size_low
; /* mapping size */
638 int protect
; /* protection flags */
642 /* Create a device */
643 struct create_device_request
645 unsigned int access
; /* wanted access rights */
646 int inherit
; /* inherit flag */
647 int id
; /* client private id */
649 struct create_device_reply
651 int handle
; /* handle to the device */
655 /* Create a snapshot */
656 struct create_snapshot_request
658 int inherit
; /* inherit flag */
659 int flags
; /* snapshot flags (TH32CS_*) */
661 struct create_snapshot_reply
663 int handle
; /* handle to the snapshot */
667 /* Get the next process from a snapshot */
668 struct next_process_request
670 int handle
; /* handle to the snapshot */
671 int reset
; /* reset snapshot position? */
673 struct next_process_reply
675 void* pid
; /* process id */
676 int threads
; /* number of threads */
677 int priority
; /* process priority */
681 /* client-side functions */
683 #ifndef __WINE_SERVER__
685 #include "server/request.h"
687 /* client communication functions */
688 extern void CLIENT_SendRequest( enum request req
, int pass_fd
,
689 int n
, ... /* arg_1, len_1, etc. */ );
690 extern unsigned int CLIENT_WaitReply( int *len
, int *passed_fd
,
691 int n
, ... /* arg_1, len_1, etc. */ );
692 extern unsigned int CLIENT_WaitSimpleReply( void *reply
, int len
, int *passed_fd
);
693 extern int CLIENT_InitServer(void);
696 extern int CLIENT_SetDebug( int level
);
697 extern int CLIENT_InitThread(void);
698 #endif /* __WINE_SERVER__ */
700 #endif /* __WINE_SERVER_H */