Bug fixes.
[wine/multimedia.git] / include / server.h
blob4581dbce5bd4b3b9cb80ba9deececca94641c624
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 */
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 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
86 int dummy;
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 void* env_ptr; /* pointer to environment (FIXME: hack) */
98 /* Initialize a thread; called from the child after fork()/clone() */
99 struct init_thread_request
101 int unix_pid; /* Unix pid of new thread */
103 struct init_thread_reply
105 void* pid; /* process id of the new thread's process */
106 void* tid; /* thread id of the new thread */
110 /* Terminate a process */
111 struct terminate_process_request
113 int handle; /* process handle to terminate */
114 int exit_code; /* process exit code */
118 /* Terminate a thread */
119 struct terminate_thread_request
121 int handle; /* thread handle to terminate */
122 int exit_code; /* thread exit code */
126 /* Retrieve information about a process */
127 struct get_process_info_request
129 int handle; /* process handle */
131 struct get_process_info_reply
133 void* pid; /* server process id */
134 int exit_code; /* process exit code */
135 int priority; /* priority class */
136 int process_affinity; /* process affinity mask */
137 int system_affinity; /* system affinity mask */
141 /* Set a process informations */
142 struct set_process_info_request
144 int handle; /* process handle */
145 int mask; /* setting mask (see below) */
146 int priority; /* priority class */
147 int affinity; /* affinity mask */
149 #define SET_PROCESS_INFO_PRIORITY 0x01
150 #define SET_PROCESS_INFO_AFFINITY 0x02
153 /* Retrieve information about a thread */
154 struct get_thread_info_request
156 int handle; /* thread handle */
158 struct get_thread_info_reply
160 void* tid; /* server thread id */
161 int exit_code; /* thread exit code */
162 int priority; /* thread priority level */
166 /* Set a thread informations */
167 struct set_thread_info_request
169 int handle; /* thread handle */
170 int mask; /* setting mask (see below) */
171 int priority; /* priority class */
172 int affinity; /* affinity mask */
174 #define SET_THREAD_INFO_PRIORITY 0x01
175 #define SET_THREAD_INFO_AFFINITY 0x02
178 /* Suspend a thread */
179 struct suspend_thread_request
181 int handle; /* thread handle */
183 struct suspend_thread_reply
185 int count; /* new suspend count */
189 /* Resume a thread */
190 struct resume_thread_request
192 int handle; /* thread handle */
194 struct resume_thread_reply
196 int count; /* new suspend count */
200 /* Debugger support: freeze / unfreeze */
201 struct debugger_request
203 int op; /* operation type */
206 enum debugger_op { DEBUGGER_FREEZE_ALL, DEBUGGER_UNFREEZE_ALL };
209 /* Queue an APC for a thread */
210 struct queue_apc_request
212 int handle; /* thread handle */
213 void* func; /* function to call */
214 void* param; /* param for function to call */
218 /* Close a handle for the current process */
219 struct close_handle_request
221 int handle; /* handle to close */
225 /* Get information about a handle */
226 struct get_handle_info_request
228 int handle; /* handle we are interested in */
230 struct get_handle_info_reply
232 int flags; /* handle flags */
236 /* Set a handle information */
237 struct set_handle_info_request
239 int handle; /* handle we are interested in */
240 int flags; /* new handle flags */
241 int mask; /* mask for flags to set */
245 /* Duplicate a handle */
246 struct dup_handle_request
248 int src_process; /* src process handle */
249 int src_handle; /* src handle to duplicate */
250 int dst_process; /* dst process handle */
251 unsigned int access; /* wanted access rights */
252 int inherit; /* inherit flag */
253 int options; /* duplicate options (see below) */
255 #define DUP_HANDLE_CLOSE_SOURCE DUPLICATE_CLOSE_SOURCE
256 #define DUP_HANDLE_SAME_ACCESS DUPLICATE_SAME_ACCESS
257 #define DUP_HANDLE_MAKE_GLOBAL 0x80000000 /* Not a Windows flag */
258 struct dup_handle_reply
260 int handle; /* duplicated handle in dst process */
264 /* Open a handle to a process */
265 struct open_process_request
267 void* pid; /* process id to open */
268 unsigned int access; /* wanted access rights */
269 int inherit; /* inherit flag */
271 struct open_process_reply
273 int handle; /* handle to the process */
277 /* Wait for handles */
278 struct select_request
280 int count; /* handles count */
281 int flags; /* wait flags (see below) */
282 int timeout; /* timeout in ms */
283 /* int handles[] */
285 struct select_reply
287 int signaled; /* signaled handle */
288 /* void* apcs[]; */ /* async procedures to call */
290 #define SELECT_ALL 1
291 #define SELECT_ALERTABLE 2
292 #define SELECT_TIMEOUT 4
295 /* Create an event */
296 struct create_event_request
298 int manual_reset; /* manual reset event */
299 int initial_state; /* initial state of the event */
300 int inherit; /* inherit flag */
301 char name[0]; /* event name */
303 struct create_event_reply
305 int handle; /* handle to the event */
308 /* Event operation */
309 struct event_op_request
311 int handle; /* handle to event */
312 int op; /* event operation (see below) */
314 enum event_op { PULSE_EVENT, SET_EVENT, RESET_EVENT };
317 /* Create a mutex */
318 struct create_mutex_request
320 int owned; /* initially owned? */
321 int inherit; /* inherit flag */
322 char name[0]; /* mutex name */
324 struct create_mutex_reply
326 int handle; /* handle to the mutex */
330 /* Release a mutex */
331 struct release_mutex_request
333 int handle; /* handle to the mutex */
337 /* Create a semaphore */
338 struct create_semaphore_request
340 unsigned int initial; /* initial count */
341 unsigned int max; /* maximum count */
342 int inherit; /* inherit flag */
343 char name[0]; /* semaphore name */
345 struct create_semaphore_reply
347 int handle; /* handle to the semaphore */
351 /* Release a semaphore */
352 struct release_semaphore_request
354 int handle; /* handle to the semaphore */
355 unsigned int count; /* count to add to semaphore */
357 struct release_semaphore_reply
359 unsigned int prev_count; /* previous semaphore count */
363 /* Open a named object (event, mutex, semaphore) */
364 struct open_named_obj_request
366 int type; /* object type (see below) */
367 unsigned int access; /* wanted access rights */
368 int inherit; /* inherit flag */
369 char name[0]; /* object name */
371 enum open_named_obj { OPEN_EVENT, OPEN_MUTEX, OPEN_SEMAPHORE, OPEN_MAPPING };
373 struct open_named_obj_reply
375 int handle; /* handle to the object */
379 /* Create a file */
380 struct create_file_request
382 unsigned int access; /* wanted access rights */
383 int inherit; /* inherit flag */
384 unsigned int sharing; /* sharing flags */
385 int create; /* file create action */
386 unsigned int attrs; /* file attributes for creation */
387 char name[0]; /* file name */
389 struct create_file_reply
391 int handle; /* handle to the file */
395 /* Get a Unix fd to read from a file */
396 struct get_read_fd_request
398 int handle; /* handle to the file */
402 /* Get a Unix fd to write to a file */
403 struct get_write_fd_request
405 int handle; /* handle to the file */
409 /* Set a file current position */
410 struct set_file_pointer_request
412 int handle; /* handle to the file */
413 int low; /* position low word */
414 int high; /* position high word */
415 int whence; /* whence to seek */
417 struct set_file_pointer_reply
419 int low; /* new position low word */
420 int high; /* new position high word */
424 /* Truncate (or extend) a file */
425 struct truncate_file_request
427 int handle; /* handle to the file */
431 /* Set a file access and modification times */
432 struct set_file_time_request
434 int handle; /* handle to the file */
435 time_t access_time; /* last access time */
436 time_t write_time; /* last write time */
440 /* Flush a file buffers */
441 struct flush_file_request
443 int handle; /* handle to the file */
447 /* Get information about a file */
448 struct get_file_info_request
450 int handle; /* handle to the file */
452 struct get_file_info_reply
454 int type; /* file type */
455 int attr; /* file attributes */
456 time_t access_time; /* last access time */
457 time_t write_time; /* last write time */
458 int size_high; /* file size */
459 int size_low; /* file size */
460 int links; /* number of links */
461 int index_high; /* unique index */
462 int index_low; /* unique index */
463 unsigned int serial; /* volume serial number */
467 /* Lock a region of a file */
468 struct lock_file_request
470 int handle; /* handle to the file */
471 unsigned int offset_low; /* offset of start of lock */
472 unsigned int offset_high; /* offset of start of lock */
473 unsigned int count_low; /* count of bytes to lock */
474 unsigned int count_high; /* count of bytes to lock */
478 /* Unlock a region of a file */
479 struct unlock_file_request
481 int handle; /* handle to the file */
482 unsigned int offset_low; /* offset of start of unlock */
483 unsigned int offset_high; /* offset of start of unlock */
484 unsigned int count_low; /* count of bytes to unlock */
485 unsigned int count_high; /* count of bytes to unlock */
489 /* Create an anonymous pipe */
490 struct create_pipe_request
492 int inherit; /* inherit flag */
494 struct create_pipe_reply
496 int handle_read; /* handle to the read-side of the pipe */
497 int handle_write; /* handle to the write-side of the pipe */
501 /* Allocate a console for the current process */
502 struct alloc_console_request
507 /* Free the console of the current process */
508 struct free_console_request
513 /* Open a handle to the process console */
514 struct open_console_request
516 int output; /* input or output? */
517 unsigned int access; /* wanted access rights */
518 int inherit; /* inherit flag */
520 struct open_console_reply
522 int handle; /* handle to the console */
526 /* Set a console file descriptor */
527 struct set_console_fd_request
529 int handle; /* handle to the console */
530 int pid; /* pid of xterm (hack) */
534 /* Get a console mode (input or output) */
535 struct get_console_mode_request
537 int handle; /* handle to the console */
539 struct get_console_mode_reply
541 int mode; /* console mode */
545 /* Set a console mode (input or output) */
546 struct set_console_mode_request
548 int handle; /* handle to the console */
549 int mode; /* console mode */
553 /* Set info about a console (output only) */
554 struct set_console_info_request
556 int handle; /* handle to the console */
557 int mask; /* setting mask (see below) */
558 int cursor_size; /* size of cursor (percentage filled) */
559 int cursor_visible;/* cursor visibility flag */
560 char title[0]; /* console title */
562 #define SET_CONSOLE_INFO_CURSOR 0x01
563 #define SET_CONSOLE_INFO_TITLE 0x02
565 /* Get info about a console (output only) */
566 struct get_console_info_request
568 int handle; /* handle to the console */
570 struct get_console_info_reply
572 int cursor_size; /* size of cursor (percentage filled) */
573 int cursor_visible;/* cursor visibility flag */
574 int pid; /* pid of xterm (hack) */
575 /* char title[0]; */ /* console title */
579 /* Add input records to a console input queue */
580 struct write_console_input_request
582 int handle; /* handle to the console input */
583 int count; /* number of input records */
584 /* INPUT_RECORD records[0]; */ /* input records */
586 struct write_console_input_reply
588 int written; /* number of records written */
591 /* Fetch input records from a console input queue */
592 struct read_console_input_request
594 int handle; /* handle to the console input */
595 int count; /* max number of records to retrieve */
596 int flush; /* flush the retrieved records from the queue? */
598 struct read_console_input_reply
600 /* INPUT_RECORD records[0]; */ /* input records */
604 /* Create a change notification */
605 struct create_change_notification_request
607 int subtree; /* watch all the subtree */
608 int filter; /* notification filter */
610 struct create_change_notification_reply
612 int handle; /* handle to the change notification */
616 /* Create a file mapping */
617 struct create_mapping_request
619 int size_high; /* mapping size */
620 int size_low; /* mapping size */
621 int protect; /* protection flags (see below) */
622 int inherit; /* inherit flag */
623 int handle; /* file handle */
624 char name[0]; /* object name */
626 struct create_mapping_reply
628 int handle; /* handle to the mapping */
630 /* protection flags */
631 #define VPROT_READ 0x01
632 #define VPROT_WRITE 0x02
633 #define VPROT_EXEC 0x04
634 #define VPROT_WRITECOPY 0x08
635 #define VPROT_GUARD 0x10
636 #define VPROT_NOCACHE 0x20
637 #define VPROT_COMMITTED 0x40
640 /* Get information about a file mapping */
641 struct get_mapping_info_request
643 int handle; /* handle to the mapping */
645 struct get_mapping_info_reply
647 int size_high; /* mapping size */
648 int size_low; /* mapping size */
649 int protect; /* protection flags */
653 /* Create a device */
654 struct create_device_request
656 unsigned int access; /* wanted access rights */
657 int inherit; /* inherit flag */
658 int id; /* client private id */
660 struct create_device_reply
662 int handle; /* handle to the device */
666 /* Create a snapshot */
667 struct create_snapshot_request
669 int inherit; /* inherit flag */
670 int flags; /* snapshot flags (TH32CS_*) */
672 struct create_snapshot_reply
674 int handle; /* handle to the snapshot */
678 /* Get the next process from a snapshot */
679 struct next_process_request
681 int handle; /* handle to the snapshot */
682 int reset; /* reset snapshot position? */
684 struct next_process_reply
686 void* pid; /* process id */
687 int threads; /* number of threads */
688 int priority; /* process priority */
692 /* client-side functions */
694 #ifndef __WINE_SERVER__
696 #include "server/request.h"
698 /* client communication functions */
699 extern void CLIENT_SendRequest( enum request req, int pass_fd,
700 int n, ... /* arg_1, len_1, etc. */ );
701 extern unsigned int CLIENT_WaitReply( int *len, int *passed_fd,
702 int n, ... /* arg_1, len_1, etc. */ );
703 extern unsigned int CLIENT_WaitSimpleReply( void *reply, int len, int *passed_fd );
704 extern int CLIENT_InitServer(void);
706 struct _THDB;
707 extern int CLIENT_SetDebug( int level );
708 extern int CLIENT_DebuggerRequest( int op );
709 extern int CLIENT_InitThread(void);
710 #endif /* __WINE_SERVER__ */
712 #endif /* __WINE_SERVER_H */