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 */
53 struct new_process_reply
55 void* pid
; /* process id */
56 int handle
; /* process handle (in the current process) */
60 /* Create a new thread from the context of the parent */
61 struct new_thread_request
63 void* pid
; /* process id for the new thread */
64 int suspend
; /* new thread should be suspended on creation */
65 int inherit
; /* inherit flag */
67 struct new_thread_reply
69 void* tid
; /* thread id */
70 int handle
; /* thread handle (in the current process) */
74 /* Set the server debug level */
75 struct set_debug_request
77 int level
; /* New debug level */
81 /* Initialize a process; called from the new process context */
82 struct init_process_request
86 struct init_process_reply
88 int start_flags
; /* flags from startup info */
89 int hstdin
; /* handle for stdin */
90 int hstdout
; /* handle for stdout */
91 int hstderr
; /* handle for stderr */
95 /* Initialize a thread; called from the child after fork()/clone() */
96 struct init_thread_request
98 int unix_pid
; /* Unix pid of new thread */
100 struct init_thread_reply
102 void* pid
; /* process id of the new thread's process */
103 void* tid
; /* thread id of the new thread */
107 /* Terminate a process */
108 struct terminate_process_request
110 int handle
; /* process handle to terminate */
111 int exit_code
; /* process exit code */
115 /* Terminate a thread */
116 struct terminate_thread_request
118 int handle
; /* thread handle to terminate */
119 int exit_code
; /* thread exit code */
123 /* Retrieve information about a process */
124 struct get_process_info_request
126 int handle
; /* process handle */
128 struct get_process_info_reply
130 void* pid
; /* server process id */
131 int exit_code
; /* process exit code */
132 int priority
; /* priority class */
133 int process_affinity
; /* process affinity mask */
134 int system_affinity
; /* system affinity mask */
138 /* Set a process informations */
139 struct set_process_info_request
141 int handle
; /* process handle */
142 int mask
; /* setting mask (see below) */
143 int priority
; /* priority class */
144 int affinity
; /* affinity mask */
146 #define SET_PROCESS_INFO_PRIORITY 0x01
147 #define SET_PROCESS_INFO_AFFINITY 0x02
150 /* Retrieve information about a thread */
151 struct get_thread_info_request
153 int handle
; /* thread handle */
155 struct get_thread_info_reply
157 void* tid
; /* server thread id */
158 int exit_code
; /* thread exit code */
159 int priority
; /* thread priority level */
163 /* Set a thread informations */
164 struct set_thread_info_request
166 int handle
; /* thread handle */
167 int mask
; /* setting mask (see below) */
168 int priority
; /* priority class */
169 int affinity
; /* affinity mask */
171 #define SET_THREAD_INFO_PRIORITY 0x01
172 #define SET_THREAD_INFO_AFFINITY 0x02
175 /* Suspend a thread */
176 struct suspend_thread_request
178 int handle
; /* thread handle */
180 struct suspend_thread_reply
182 int count
; /* new suspend count */
186 /* Resume a thread */
187 struct resume_thread_request
189 int handle
; /* thread handle */
191 struct resume_thread_reply
193 int count
; /* new suspend count */
197 /* Queue an APC for a thread */
198 struct queue_apc_request
200 int handle
; /* thread handle */
201 void* func
; /* function to call */
202 void* param
; /* param for function to call */
206 /* Close a handle for the current process */
207 struct close_handle_request
209 int handle
; /* handle to close */
213 /* Get information about a handle */
214 struct get_handle_info_request
216 int handle
; /* handle we are interested in */
218 struct get_handle_info_reply
220 int flags
; /* handle flags */
224 /* Set a handle information */
225 struct set_handle_info_request
227 int handle
; /* handle we are interested in */
228 int flags
; /* new handle flags */
229 int mask
; /* mask for flags to set */
233 /* Duplicate a handle */
234 struct dup_handle_request
236 int src_process
; /* src process handle */
237 int src_handle
; /* src handle to duplicate */
238 int dst_process
; /* dst process handle */
239 unsigned int access
; /* wanted access rights */
240 int inherit
; /* inherit flag */
241 int options
; /* duplicate options (see below) */
243 #define DUP_HANDLE_CLOSE_SOURCE DUPLICATE_CLOSE_SOURCE
244 #define DUP_HANDLE_SAME_ACCESS DUPLICATE_SAME_ACCESS
245 #define DUP_HANDLE_MAKE_GLOBAL 0x80000000 /* Not a Windows flag */
246 struct dup_handle_reply
248 int handle
; /* duplicated handle in dst process */
252 /* Open a handle to a process */
253 struct open_process_request
255 void* pid
; /* process id to open */
256 unsigned int access
; /* wanted access rights */
257 int inherit
; /* inherit flag */
259 struct open_process_reply
261 int handle
; /* handle to the process */
265 /* Wait for handles */
266 struct select_request
268 int count
; /* handles count */
269 int flags
; /* wait flags (see below) */
270 int timeout
; /* timeout in ms */
275 int signaled
; /* signaled handle */
276 /* void* apcs[]; */ /* async procedures to call */
279 #define SELECT_ALERTABLE 2
280 #define SELECT_TIMEOUT 4
283 /* Create an event */
284 struct create_event_request
286 int manual_reset
; /* manual reset event */
287 int initial_state
; /* initial state of the event */
288 int inherit
; /* inherit flag */
289 char name
[0]; /* event name */
291 struct create_event_reply
293 int handle
; /* handle to the event */
296 /* Event operation */
297 struct event_op_request
299 int handle
; /* handle to event */
300 int op
; /* event operation (see below) */
302 enum event_op
{ PULSE_EVENT
, SET_EVENT
, RESET_EVENT
};
306 struct create_mutex_request
308 int owned
; /* initially owned? */
309 int inherit
; /* inherit flag */
310 char name
[0]; /* mutex name */
312 struct create_mutex_reply
314 int handle
; /* handle to the mutex */
318 /* Release a mutex */
319 struct release_mutex_request
321 int handle
; /* handle to the mutex */
325 /* Create a semaphore */
326 struct create_semaphore_request
328 unsigned int initial
; /* initial count */
329 unsigned int max
; /* maximum count */
330 int inherit
; /* inherit flag */
331 char name
[0]; /* semaphore name */
333 struct create_semaphore_reply
335 int handle
; /* handle to the semaphore */
339 /* Release a semaphore */
340 struct release_semaphore_request
342 int handle
; /* handle to the semaphore */
343 unsigned int count
; /* count to add to semaphore */
345 struct release_semaphore_reply
347 unsigned int prev_count
; /* previous semaphore count */
351 /* Open a named object (event, mutex, semaphore) */
352 struct open_named_obj_request
354 int type
; /* object type (see below) */
355 unsigned int access
; /* wanted access rights */
356 int inherit
; /* inherit flag */
357 char name
[0]; /* object name */
359 enum open_named_obj
{ OPEN_EVENT
, OPEN_MUTEX
, OPEN_SEMAPHORE
, OPEN_MAPPING
};
361 struct open_named_obj_reply
363 int handle
; /* handle to the object */
368 struct create_file_request
370 unsigned int access
; /* wanted access rights */
371 int inherit
; /* inherit flag */
372 unsigned int sharing
; /* sharing flags */
373 int create
; /* file create action */
374 unsigned int attrs
; /* file attributes for creation */
375 char name
[0]; /* file name */
377 struct create_file_reply
379 int handle
; /* handle to the file */
383 /* Get a Unix fd to read from a file */
384 struct get_read_fd_request
386 int handle
; /* handle to the file */
390 /* Get a Unix fd to write to a file */
391 struct get_write_fd_request
393 int handle
; /* handle to the file */
397 /* Set a file current position */
398 struct set_file_pointer_request
400 int handle
; /* handle to the file */
401 int low
; /* position low word */
402 int high
; /* position high word */
403 int whence
; /* whence to seek */
405 struct set_file_pointer_reply
407 int low
; /* new position low word */
408 int high
; /* new position high word */
412 /* Truncate (or extend) a file */
413 struct truncate_file_request
415 int handle
; /* handle to the file */
419 /* Set a file access and modification times */
420 struct set_file_time_request
422 int handle
; /* handle to the file */
423 time_t access_time
; /* last access time */
424 time_t write_time
; /* last write time */
428 /* Flush a file buffers */
429 struct flush_file_request
431 int handle
; /* handle to the file */
435 /* Get information about a file */
436 struct get_file_info_request
438 int handle
; /* handle to the file */
440 struct get_file_info_reply
442 int type
; /* file type */
443 int attr
; /* file attributes */
444 time_t access_time
; /* last access time */
445 time_t write_time
; /* last write time */
446 int size_high
; /* file size */
447 int size_low
; /* file size */
448 int links
; /* number of links */
449 int index_high
; /* unique index */
450 int index_low
; /* unique index */
451 unsigned int serial
; /* volume serial number */
455 /* Lock a region of a file */
456 struct lock_file_request
458 int handle
; /* handle to the file */
459 unsigned int offset_low
; /* offset of start of lock */
460 unsigned int offset_high
; /* offset of start of lock */
461 unsigned int count_low
; /* count of bytes to lock */
462 unsigned int count_high
; /* count of bytes to lock */
466 /* Unlock a region of a file */
467 struct unlock_file_request
469 int handle
; /* handle to the file */
470 unsigned int offset_low
; /* offset of start of unlock */
471 unsigned int offset_high
; /* offset of start of unlock */
472 unsigned int count_low
; /* count of bytes to unlock */
473 unsigned int count_high
; /* count of bytes to unlock */
477 /* Create an anonymous pipe */
478 struct create_pipe_request
480 int inherit
; /* inherit flag */
482 struct create_pipe_reply
484 int handle_read
; /* handle to the read-side of the pipe */
485 int handle_write
; /* handle to the write-side of the pipe */
489 /* Allocate a console for the current process */
490 struct alloc_console_request
495 /* Free the console of the current process */
496 struct free_console_request
501 /* Open a handle to the process console */
502 struct open_console_request
504 int output
; /* input or output? */
505 unsigned int access
; /* wanted access rights */
506 int inherit
; /* inherit flag */
508 struct open_console_reply
510 int handle
; /* handle to the console */
514 /* Set a console file descriptor */
515 struct set_console_fd_request
517 int handle
; /* handle to the console */
518 int pid
; /* pid of xterm (hack) */
522 /* Get a console mode (input or output) */
523 struct get_console_mode_request
525 int handle
; /* handle to the console */
527 struct get_console_mode_reply
529 int mode
; /* console mode */
533 /* Set a console mode (input or output) */
534 struct set_console_mode_request
536 int handle
; /* handle to the console */
537 int mode
; /* console mode */
541 /* Set info about a console (output only) */
542 struct set_console_info_request
544 int handle
; /* handle to the console */
545 int mask
; /* setting mask (see below) */
546 int cursor_size
; /* size of cursor (percentage filled) */
547 int cursor_visible
;/* cursor visibility flag */
548 char title
[0]; /* console title */
550 #define SET_CONSOLE_INFO_CURSOR 0x01
551 #define SET_CONSOLE_INFO_TITLE 0x02
553 /* Get info about a console (output only) */
554 struct get_console_info_request
556 int handle
; /* handle to the console */
558 struct get_console_info_reply
560 int cursor_size
; /* size of cursor (percentage filled) */
561 int cursor_visible
;/* cursor visibility flag */
562 int pid
; /* pid of xterm (hack) */
563 /* char title[0]; */ /* console title */
567 /* Add input records to a console input queue */
568 struct write_console_input_request
570 int handle
; /* handle to the console input */
571 int count
; /* number of input records */
572 /* INPUT_RECORD records[0]; */ /* input records */
574 struct write_console_input_reply
576 int written
; /* number of records written */
579 /* Fetch input records from a console input queue */
580 struct read_console_input_request
582 int handle
; /* handle to the console input */
583 int count
; /* max number of records to retrieve */
584 int flush
; /* flush the retrieved records from the queue? */
586 struct read_console_input_reply
588 /* INPUT_RECORD records[0]; */ /* input records */
592 /* Create a change notification */
593 struct create_change_notification_request
595 int subtree
; /* watch all the subtree */
596 int filter
; /* notification filter */
598 struct create_change_notification_reply
600 int handle
; /* handle to the change notification */
604 /* Create a file mapping */
605 struct create_mapping_request
607 int size_high
; /* mapping size */
608 int size_low
; /* mapping size */
609 int protect
; /* protection flags (see below) */
610 int inherit
; /* inherit flag */
611 int handle
; /* file handle */
612 char name
[0]; /* object name */
614 struct create_mapping_reply
616 int handle
; /* handle to the mapping */
618 /* protection flags */
619 #define VPROT_READ 0x01
620 #define VPROT_WRITE 0x02
621 #define VPROT_EXEC 0x04
622 #define VPROT_WRITECOPY 0x08
623 #define VPROT_GUARD 0x10
624 #define VPROT_NOCACHE 0x20
625 #define VPROT_COMMITTED 0x40
628 /* Get information about a file mapping */
629 struct get_mapping_info_request
631 int handle
; /* handle to the mapping */
633 struct get_mapping_info_reply
635 int size_high
; /* mapping size */
636 int size_low
; /* mapping size */
637 int protect
; /* protection flags */
641 /* Create a device */
642 struct create_device_request
644 unsigned int access
; /* wanted access rights */
645 int inherit
; /* inherit flag */
646 int id
; /* client private id */
648 struct create_device_reply
650 int handle
; /* handle to the device */
654 /* Create a snapshot */
655 struct create_snapshot_request
657 int inherit
; /* inherit flag */
658 int flags
; /* snapshot flags (TH32CS_*) */
660 struct create_snapshot_reply
662 int handle
; /* handle to the snapshot */
666 /* Get the next process from a snapshot */
667 struct next_process_request
669 int handle
; /* handle to the snapshot */
670 int reset
; /* reset snapshot position? */
672 struct next_process_reply
674 void* pid
; /* process id */
675 int threads
; /* number of threads */
676 int priority
; /* process priority */
680 /* client-side functions */
682 #ifndef __WINE_SERVER__
684 #include "server/request.h"
686 /* client communication functions */
687 extern void CLIENT_SendRequest( enum request req
, int pass_fd
,
688 int n
, ... /* arg_1, len_1, etc. */ );
689 extern unsigned int CLIENT_WaitReply( int *len
, int *passed_fd
,
690 int n
, ... /* arg_1, len_1, etc. */ );
691 extern unsigned int CLIENT_WaitSimpleReply( void *reply
, int len
, int *passed_fd
);
692 extern int CLIENT_InitServer(void);
695 extern int CLIENT_SetDebug( int level
);
696 extern int CLIENT_InitThread(void);
697 #endif /* __WINE_SERVER__ */
699 #endif /* __WINE_SERVER_H */