Implementation of IStorage::CopyTo and IStream::CopyTo.
[wine] / include / server.h
1 /*
2  * Wine server definitions
3  *
4  * Copyright (C) 1998 Alexandre Julliard
5  */
6
7 #ifndef __WINE_SERVER_H
8 #define __WINE_SERVER_H
9
10 #include <stdlib.h>
11 #include <time.h>
12
13 /* message header as sent on the wire */
14 struct header
15 {
16     unsigned int  len;     /* total msg length (including this header) */
17     unsigned int  type;    /* msg type */
18     unsigned int  seq;     /* sequence number */
19 };
20
21 /* max msg length (not including the header) */
22 #define MAX_MSG_LENGTH (16384 - sizeof(struct header))
23
24 /* data structure used to pass an fd with sendmsg/recvmsg */
25 struct cmsg_fd
26 {
27     int len;   /* sizeof structure */
28     int level; /* SOL_SOCKET */
29     int type;  /* SCM_RIGHTS */
30     int fd;    /* fd to pass */
31 };
32
33
34 /* Request structures */
35
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.      */
41
42
43 /* Create a new process from the context of the parent */
44 struct new_process_request
45 {
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 */
53 };
54 struct new_process_reply
55 {
56     void*        pid;          /* process id */
57     int          handle;       /* process handle (in the current process) */
58 };
59
60
61 /* Create a new thread from the context of the parent */
62 struct new_thread_request
63 {
64     void*        pid;          /* process id for the new thread */
65     int          suspend;      /* new thread should be suspended on creation */ 
66     int          inherit;      /* inherit flag */
67 };
68 struct new_thread_reply
69 {
70     void*        tid;          /* thread id */
71     int          handle;       /* thread handle (in the current process) */
72 };
73
74
75 /* Set the server debug level */
76 struct set_debug_request
77 {
78     int          level;        /* New debug level */
79 };
80
81
82 /* Initialize a process; called from the new process context */
83 struct init_process_request
84 {
85     int          dummy;
86 };
87 struct init_process_reply
88 {
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 */
93 };
94
95
96 /* Initialize a thread; called from the child after fork()/clone() */
97 struct init_thread_request
98 {
99     int          unix_pid;     /* Unix pid of new thread */
100 };
101 struct init_thread_reply
102 {
103     void*        pid;          /* process id of the new thread's process */
104     void*        tid;          /* thread id of the new thread */
105 };
106
107
108 /* Terminate a process */
109 struct terminate_process_request
110 {
111     int          handle;       /* process handle to terminate */
112     int          exit_code;    /* process exit code */
113 };
114
115
116 /* Terminate a thread */
117 struct terminate_thread_request
118 {
119     int          handle;       /* thread handle to terminate */
120     int          exit_code;    /* thread exit code */
121 };
122
123
124 /* Retrieve information about a process */
125 struct get_process_info_request
126 {
127     int          handle;       /* process handle */
128 };
129 struct get_process_info_reply
130 {
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 */
136 };
137
138
139 /* Set a process informations */
140 struct set_process_info_request
141 {
142     int          handle;       /* process handle */
143     int          mask;         /* setting mask (see below) */
144     int          priority;     /* priority class */
145     int          affinity;     /* affinity mask */
146 };
147 #define SET_PROCESS_INFO_PRIORITY 0x01
148 #define SET_PROCESS_INFO_AFFINITY 0x02
149
150
151 /* Retrieve information about a thread */
152 struct get_thread_info_request
153 {
154     int          handle;       /* thread handle */
155 };
156 struct get_thread_info_reply
157 {
158     void*        tid;          /* server thread id */
159     int          exit_code;    /* thread exit code */
160     int          priority;     /* thread priority level */
161 };
162
163
164 /* Set a thread informations */
165 struct set_thread_info_request
166 {
167     int          handle;       /* thread handle */
168     int          mask;         /* setting mask (see below) */
169     int          priority;     /* priority class */
170     int          affinity;     /* affinity mask */
171 };
172 #define SET_THREAD_INFO_PRIORITY 0x01
173 #define SET_THREAD_INFO_AFFINITY 0x02
174
175
176 /* Suspend a thread */
177 struct suspend_thread_request
178 {
179     int          handle;       /* thread handle */
180 };
181 struct suspend_thread_reply
182 {
183     int          count;        /* new suspend count */
184 };
185
186
187 /* Resume a thread */
188 struct resume_thread_request
189 {
190     int          handle;       /* thread handle */
191 };
192 struct resume_thread_reply
193 {
194     int          count;        /* new suspend count */
195 };
196
197
198 /* Debugger support: freeze / unfreeze */
199 struct debugger_request
200 {
201     int          op;           /* operation type */
202 };
203
204 enum debugger_op { DEBUGGER_FREEZE_ALL, DEBUGGER_UNFREEZE_ALL };
205
206
207 /* Queue an APC for a thread */
208 struct queue_apc_request
209 {
210     int          handle;       /* thread handle */
211     void*        func;         /* function to call */
212     void*        param;        /* param for function to call */
213 };
214
215
216 /* Close a handle for the current process */
217 struct close_handle_request
218 {
219     int          handle;       /* handle to close */
220 };
221
222
223 /* Get information about a handle */
224 struct get_handle_info_request
225 {
226     int          handle;       /* handle we are interested in */
227 };
228 struct get_handle_info_reply
229 {
230     int          flags;        /* handle flags */
231 };
232
233
234 /* Set a handle information */
235 struct set_handle_info_request
236 {
237     int          handle;       /* handle we are interested in */
238     int          flags;        /* new handle flags */
239     int          mask;         /* mask for flags to set */
240 };
241
242
243 /* Duplicate a handle */
244 struct dup_handle_request
245 {
246     int          src_process;  /* src process handle */
247     int          src_handle;   /* src handle to duplicate */
248     int          dst_process;  /* dst process handle */
249     unsigned int access;       /* wanted access rights */
250     int          inherit;      /* inherit flag */
251     int          options;      /* duplicate options (see below) */
252 };
253 #define DUP_HANDLE_CLOSE_SOURCE  DUPLICATE_CLOSE_SOURCE
254 #define DUP_HANDLE_SAME_ACCESS   DUPLICATE_SAME_ACCESS
255 #define DUP_HANDLE_MAKE_GLOBAL   0x80000000  /* Not a Windows flag */
256 struct dup_handle_reply
257 {
258     int          handle;       /* duplicated handle in dst process */
259 };
260
261
262 /* Open a handle to a process */
263 struct open_process_request
264 {
265     void*        pid;          /* process id to open */
266     unsigned int access;       /* wanted access rights */
267     int          inherit;      /* inherit flag */
268 };
269 struct open_process_reply
270 {
271     int          handle;       /* handle to the process */
272 };
273
274
275 /* Wait for handles */
276 struct select_request
277 {
278     int          count;        /* handles count */
279     int          flags;        /* wait flags (see below) */
280     int          timeout;      /* timeout in ms */
281     /* int handles[] */
282 };
283 struct select_reply
284 {
285     int          signaled;     /* signaled handle */
286 /*  void*        apcs[]; */    /* async procedures to call */
287 };
288 #define SELECT_ALL       1
289 #define SELECT_ALERTABLE 2
290 #define SELECT_TIMEOUT   4
291
292
293 /* Create an event */
294 struct create_event_request
295 {
296     int          manual_reset;  /* manual reset event */
297     int          initial_state; /* initial state of the event */
298     int          inherit;       /* inherit flag */
299     char         name[0];       /* event name */
300 };
301 struct create_event_reply
302 {
303     int          handle;        /* handle to the event */
304 };
305
306 /* Event operation */
307 struct event_op_request
308 {
309     int           handle;       /* handle to event */
310     int           op;           /* event operation (see below) */
311 };
312 enum event_op { PULSE_EVENT, SET_EVENT, RESET_EVENT };
313
314
315 /* Create a mutex */
316 struct create_mutex_request
317 {
318     int          owned;         /* initially owned? */
319     int          inherit;       /* inherit flag */
320     char         name[0];       /* mutex name */
321 };
322 struct create_mutex_reply
323 {
324     int          handle;        /* handle to the mutex */
325 };
326
327
328 /* Release a mutex */
329 struct release_mutex_request
330 {
331     int          handle;        /* handle to the mutex */
332 };
333
334
335 /* Create a semaphore */
336 struct create_semaphore_request
337 {
338     unsigned int initial;       /* initial count */
339     unsigned int max;           /* maximum count */
340     int          inherit;       /* inherit flag */
341     char         name[0];       /* semaphore name */
342 };
343 struct create_semaphore_reply
344 {
345     int          handle;        /* handle to the semaphore */
346 };
347
348
349 /* Release a semaphore */
350 struct release_semaphore_request
351 {
352     int          handle;        /* handle to the semaphore */
353     unsigned int count;         /* count to add to semaphore */
354 };
355 struct release_semaphore_reply
356 {
357     unsigned int prev_count;    /* previous semaphore count */
358 };
359
360
361 /* Open a named object (event, mutex, semaphore) */
362 struct open_named_obj_request
363 {
364     int          type;          /* object type (see below) */
365     unsigned int access;        /* wanted access rights */
366     int          inherit;       /* inherit flag */
367     char         name[0];       /* object name */
368 };
369 enum open_named_obj { OPEN_EVENT, OPEN_MUTEX, OPEN_SEMAPHORE, OPEN_MAPPING };
370
371 struct open_named_obj_reply
372 {
373     int          handle;        /* handle to the object */
374 };
375
376
377 /* Create a file */
378 struct create_file_request
379 {
380     unsigned int access;        /* wanted access rights */
381     int          inherit;       /* inherit flag */
382     unsigned int sharing;       /* sharing flags */
383     int          create;        /* file create action */
384     unsigned int attrs;         /* file attributes for creation */
385     char         name[0];       /* file name */
386 };
387 struct create_file_reply
388 {
389     int          handle;        /* handle to the file */
390 };
391
392
393 /* Get a Unix fd to read from a file */
394 struct get_read_fd_request
395 {
396     int          handle;        /* handle to the file */
397 };
398
399
400 /* Get a Unix fd to write to a file */
401 struct get_write_fd_request
402 {
403     int          handle;        /* handle to the file */
404 };
405
406
407 /* Set a file current position */
408 struct set_file_pointer_request
409 {
410     int          handle;        /* handle to the file */
411     int          low;           /* position low word */
412     int          high;          /* position high word */
413     int          whence;        /* whence to seek */
414 };
415 struct set_file_pointer_reply
416 {
417     int          low;           /* new position low word */
418     int          high;          /* new position high word */
419 };
420
421
422 /* Truncate (or extend) a file */
423 struct truncate_file_request
424 {
425     int          handle;        /* handle to the file */
426 };
427
428
429 /* Set a file access and modification times */
430 struct set_file_time_request
431 {
432     int          handle;        /* handle to the file */
433     time_t       access_time;   /* last access time */
434     time_t       write_time;    /* last write time */
435 };
436
437
438 /* Flush a file buffers */
439 struct flush_file_request
440 {
441     int          handle;        /* handle to the file */
442 };
443
444
445 /* Get information about a file */
446 struct get_file_info_request
447 {
448     int          handle;        /* handle to the file */
449 };
450 struct get_file_info_reply
451 {
452     int          type;          /* file type */
453     int          attr;          /* file attributes */
454     time_t       access_time;   /* last access time */
455     time_t       write_time;    /* last write time */
456     int          size_high;     /* file size */
457     int          size_low;      /* file size */
458     int          links;         /* number of links */
459     int          index_high;    /* unique index */
460     int          index_low;     /* unique index */
461     unsigned int serial;        /* volume serial number */
462 };
463
464
465 /* Lock a region of a file */
466 struct lock_file_request
467 {
468     int          handle;        /* handle to the file */
469     unsigned int offset_low;    /* offset of start of lock */
470     unsigned int offset_high;   /* offset of start of lock */
471     unsigned int count_low;     /* count of bytes to lock */
472     unsigned int count_high;    /* count of bytes to lock */
473 };
474
475
476 /* Unlock a region of a file */
477 struct unlock_file_request
478 {
479     int          handle;        /* handle to the file */
480     unsigned int offset_low;    /* offset of start of unlock */
481     unsigned int offset_high;   /* offset of start of unlock */
482     unsigned int count_low;     /* count of bytes to unlock */
483     unsigned int count_high;    /* count of bytes to unlock */
484 };
485
486
487 /* Create an anonymous pipe */
488 struct create_pipe_request
489 {
490     int          inherit;       /* inherit flag */
491 };
492 struct create_pipe_reply
493 {
494     int          handle_read;   /* handle to the read-side of the pipe */
495     int          handle_write;  /* handle to the write-side of the pipe */
496 };
497
498
499 /* Allocate a console for the current process */
500 struct alloc_console_request
501 {
502 };
503
504
505 /* Free the console of the current process */
506 struct free_console_request
507 {
508 };
509
510
511 /* Open a handle to the process console */
512 struct open_console_request
513 {
514     int          output;        /* input or output? */
515     unsigned int access;        /* wanted access rights */
516     int          inherit;       /* inherit flag */
517 };
518 struct open_console_reply
519 {
520     int          handle;        /* handle to the console */
521 };
522
523
524 /* Set a console file descriptor */
525 struct set_console_fd_request
526 {
527     int          handle;        /* handle to the console */
528     int          pid;           /* pid of xterm (hack) */
529 };
530
531
532 /* Get a console mode (input or output) */
533 struct get_console_mode_request
534 {
535     int          handle;        /* handle to the console */
536 };
537 struct get_console_mode_reply
538 {
539     int          mode;          /* console mode */
540 };
541
542
543 /* Set a console mode (input or output) */
544 struct set_console_mode_request
545 {
546     int          handle;        /* handle to the console */
547     int          mode;          /* console mode */
548 };
549
550
551 /* Set info about a console (output only) */
552 struct set_console_info_request
553 {
554     int          handle;        /* handle to the console */
555     int          mask;          /* setting mask (see below) */
556     int          cursor_size;   /* size of cursor (percentage filled) */
557     int          cursor_visible;/* cursor visibility flag */
558     char         title[0];      /* console title */
559 };
560 #define SET_CONSOLE_INFO_CURSOR 0x01
561 #define SET_CONSOLE_INFO_TITLE  0x02
562
563 /* Get info about a console (output only) */
564 struct get_console_info_request
565 {
566     int          handle;        /* handle to the console */
567 };
568 struct get_console_info_reply
569 {
570     int          cursor_size;   /* size of cursor (percentage filled) */
571     int          cursor_visible;/* cursor visibility flag */
572     int          pid;           /* pid of xterm (hack) */
573 /*  char         title[0]; */   /* console title */
574 };
575
576
577 /* Add input records to a console input queue */
578 struct write_console_input_request
579 {
580     int          handle;        /* handle to the console input */
581     int          count;         /* number of input records */
582 /*  INPUT_RECORD records[0]; */ /* input records */
583 };
584 struct write_console_input_reply
585 {
586     int          written;       /* number of records written */
587 };
588
589 /* Fetch input records from a console input queue */
590 struct read_console_input_request
591 {
592     int          handle;        /* handle to the console input */
593     int          count;         /* max number of records to retrieve */
594     int          flush;         /* flush the retrieved records from the queue? */
595 };
596 struct read_console_input_reply
597 {
598 /*  INPUT_RECORD records[0]; */ /* input records */
599 };
600
601
602 /* Create a change notification */
603 struct create_change_notification_request
604 {
605     int          subtree;       /* watch all the subtree */
606     int          filter;        /* notification filter */
607 };
608 struct create_change_notification_reply
609 {
610     int          handle;        /* handle to the change notification */
611 };
612
613
614 /* Create a file mapping */
615 struct create_mapping_request
616 {
617     int          size_high;     /* mapping size */
618     int          size_low;      /* mapping size */
619     int          protect;       /* protection flags (see below) */
620     int          inherit;       /* inherit flag */
621     int          handle;        /* file handle */
622     char         name[0];       /* object name */
623 };
624 struct create_mapping_reply
625 {
626     int          handle;        /* handle to the mapping */
627 };
628 /* protection flags */
629 #define VPROT_READ       0x01
630 #define VPROT_WRITE      0x02
631 #define VPROT_EXEC       0x04
632 #define VPROT_WRITECOPY  0x08
633 #define VPROT_GUARD      0x10
634 #define VPROT_NOCACHE    0x20
635 #define VPROT_COMMITTED  0x40
636
637
638 /* Get information about a file mapping */
639 struct get_mapping_info_request
640 {
641     int          handle;        /* handle to the mapping */
642 };
643 struct get_mapping_info_reply
644 {
645     int          size_high;     /* mapping size */
646     int          size_low;      /* mapping size */
647     int          protect;       /* protection flags */
648 };
649
650
651 /* Create a device */
652 struct create_device_request
653 {
654     unsigned int access;        /* wanted access rights */
655     int          inherit;       /* inherit flag */
656     int          id;            /* client private id */
657 };
658 struct create_device_reply
659 {
660     int          handle;        /* handle to the device */
661 };
662
663
664 /* Create a snapshot */
665 struct create_snapshot_request
666 {
667     int          inherit;       /* inherit flag */
668     int          flags;         /* snapshot flags (TH32CS_*) */
669 };
670 struct create_snapshot_reply
671 {
672     int          handle;        /* handle to the snapshot */
673 };
674
675
676 /* Get the next process from a snapshot */
677 struct next_process_request
678 {
679     int          handle;        /* handle to the snapshot */
680     int          reset;         /* reset snapshot position? */
681 };
682 struct next_process_reply
683 {
684     void*        pid;          /* process id */
685     int          threads;      /* number of threads */
686     int          priority;     /* process priority */
687 };
688
689
690 /* client-side functions */
691
692 #ifndef __WINE_SERVER__
693
694 #include "server/request.h"
695
696 /* client communication functions */
697 extern void CLIENT_SendRequest( enum request req, int pass_fd,
698                                 int n, ... /* arg_1, len_1, etc. */ );
699 extern unsigned int CLIENT_WaitReply( int *len, int *passed_fd,
700                                       int n, ... /* arg_1, len_1, etc. */ );
701 extern unsigned int CLIENT_WaitSimpleReply( void *reply, int len, int *passed_fd );
702 extern int CLIENT_InitServer(void);
703
704 struct _THDB;
705 extern int CLIENT_SetDebug( int level );
706 extern int CLIENT_DebuggerRequest( int op );
707 extern int CLIENT_InitThread(void);
708 #endif  /* __WINE_SERVER__ */
709
710 #endif  /* __WINE_SERVER_H */