Fixed a couple of memcpy errors.
[wine.git] / include / server.h
blob228c4bb0623bff87a9f39ae3ac446183e0959707
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
504 int dummy;
508 /* Free the console of the current process */
509 struct free_console_request
511 int dummy;
515 /* Open a handle to the process console */
516 struct open_console_request
518 int output; /* input or output? */
519 unsigned int access; /* wanted access rights */
520 int inherit; /* inherit flag */
522 struct open_console_reply
524 int handle; /* handle to the console */
528 /* Set a console file descriptor */
529 struct set_console_fd_request
531 int handle; /* handle to the console */
532 int pid; /* pid of xterm (hack) */
536 /* Get a console mode (input or output) */
537 struct get_console_mode_request
539 int handle; /* handle to the console */
541 struct get_console_mode_reply
543 int mode; /* console mode */
547 /* Set a console mode (input or output) */
548 struct set_console_mode_request
550 int handle; /* handle to the console */
551 int mode; /* console mode */
555 /* Set info about a console (output only) */
556 struct set_console_info_request
558 int handle; /* handle to the console */
559 int mask; /* setting mask (see below) */
560 int cursor_size; /* size of cursor (percentage filled) */
561 int cursor_visible;/* cursor visibility flag */
562 char title[0]; /* console title */
564 #define SET_CONSOLE_INFO_CURSOR 0x01
565 #define SET_CONSOLE_INFO_TITLE 0x02
567 /* Get info about a console (output only) */
568 struct get_console_info_request
570 int handle; /* handle to the console */
572 struct get_console_info_reply
574 int cursor_size; /* size of cursor (percentage filled) */
575 int cursor_visible;/* cursor visibility flag */
576 int pid; /* pid of xterm (hack) */
577 /* char title[0]; */ /* console title */
581 /* Add input records to a console input queue */
582 struct write_console_input_request
584 int handle; /* handle to the console input */
585 int count; /* number of input records */
586 /* INPUT_RECORD records[0]; */ /* input records */
588 struct write_console_input_reply
590 int written; /* number of records written */
593 /* Fetch input records from a console input queue */
594 struct read_console_input_request
596 int handle; /* handle to the console input */
597 int count; /* max number of records to retrieve */
598 int flush; /* flush the retrieved records from the queue? */
600 struct read_console_input_reply
602 int dummy;
603 /* INPUT_RECORD records[0]; */ /* input records */
607 /* Create a change notification */
608 struct create_change_notification_request
610 int subtree; /* watch all the subtree */
611 int filter; /* notification filter */
613 struct create_change_notification_reply
615 int handle; /* handle to the change notification */
619 /* Create a file mapping */
620 struct create_mapping_request
622 int size_high; /* mapping size */
623 int size_low; /* mapping size */
624 int protect; /* protection flags (see below) */
625 int inherit; /* inherit flag */
626 int handle; /* file handle */
627 char name[0]; /* object name */
629 struct create_mapping_reply
631 int handle; /* handle to the mapping */
633 /* protection flags */
634 #define VPROT_READ 0x01
635 #define VPROT_WRITE 0x02
636 #define VPROT_EXEC 0x04
637 #define VPROT_WRITECOPY 0x08
638 #define VPROT_GUARD 0x10
639 #define VPROT_NOCACHE 0x20
640 #define VPROT_COMMITTED 0x40
643 /* Get information about a file mapping */
644 struct get_mapping_info_request
646 int handle; /* handle to the mapping */
648 struct get_mapping_info_reply
650 int size_high; /* mapping size */
651 int size_low; /* mapping size */
652 int protect; /* protection flags */
656 /* Create a device */
657 struct create_device_request
659 unsigned int access; /* wanted access rights */
660 int inherit; /* inherit flag */
661 int id; /* client private id */
663 struct create_device_reply
665 int handle; /* handle to the device */
669 /* Create a snapshot */
670 struct create_snapshot_request
672 int inherit; /* inherit flag */
673 int flags; /* snapshot flags (TH32CS_*) */
675 struct create_snapshot_reply
677 int handle; /* handle to the snapshot */
681 /* Get the next process from a snapshot */
682 struct next_process_request
684 int handle; /* handle to the snapshot */
685 int reset; /* reset snapshot position? */
687 struct next_process_reply
689 void* pid; /* process id */
690 int threads; /* number of threads */
691 int priority; /* process priority */
695 /* client-side functions */
697 #ifndef __WINE_SERVER__
699 #include "server/request.h"
701 /* client communication functions */
702 extern void CLIENT_SendRequest( enum request req, int pass_fd,
703 int n, ... /* arg_1, len_1, etc. */ );
704 extern unsigned int CLIENT_WaitReply( int *len, int *passed_fd,
705 int n, ... /* arg_1, len_1, etc. */ );
706 extern unsigned int CLIENT_WaitSimpleReply( void *reply, int len, int *passed_fd );
707 extern int CLIENT_InitServer(void);
709 struct _THDB;
710 extern int CLIENT_SetDebug( int level );
711 extern int CLIENT_DebuggerRequest( int op );
712 extern int CLIENT_InitThread(void);
713 #endif /* __WINE_SERVER__ */
715 #endif /* __WINE_SERVER_H */