Added support for the Win32 Console interface to the main DOSVM event
[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 #include "winbase.h"
13
14 /* Request structures */
15
16 /* Following are the definitions of all the client<->server   */
17 /* communication format; if you make any change in this file, */
18 /* you must run tools/make_requests again. */
19
20
21 /* These empty macros are used by tools/make_requests */
22 /* to generate the request/reply tracing functions */
23 #define IN  /*nothing*/
24 #define OUT /*nothing*/
25
26
27 /* a path name for server requests (Unicode) */
28 typedef WCHAR path_t[MAX_PATH+1];
29
30
31 /* definitions of the event data depending on the event code */
32 struct debug_event_exception
33 {
34     EXCEPTION_RECORD record;   /* exception record */
35     int              first;    /* first chance exception? */
36 };
37 struct debug_event_create_thread
38 {
39     int         handle;     /* handle to the new thread */
40     void       *teb;        /* thread teb (in debugged process address space) */
41     void       *start;      /* thread startup routine */
42 };
43 struct debug_event_create_process
44 {
45     int         file;       /* handle to the process exe file */
46     int         process;    /* handle to the new process */
47     int         thread;     /* handle to the new thread */
48     void       *base;       /* base of executable image */
49     int         dbg_offset; /* offset of debug info in file */
50     int         dbg_size;   /* size of debug info */
51     void       *teb;        /* thread teb (in debugged process address space) */
52     void       *start;      /* thread startup routine */
53     void       *name;       /* image name (optional) */
54     int         unicode;    /* is it Unicode? */
55 };
56 struct debug_event_exit
57 {
58     int         exit_code;  /* thread or process exit code */
59 };
60 struct debug_event_load_dll
61 {
62     int         handle;     /* file handle for the dll */
63     void       *base;       /* base address of the dll */
64     int         dbg_offset; /* offset of debug info in file */
65     int         dbg_size;   /* size of debug info */
66     void       *name;       /* image name (optional) */
67     int         unicode;    /* is it Unicode? */
68 };
69 struct debug_event_unload_dll
70 {
71     void       *base;       /* base address of the dll */
72 };
73 struct debug_event_output_string
74 {
75     void       *string;     /* string to display (in debugged process address space) */
76     int         unicode;    /* is it Unicode? */
77     int         length;     /* string length */
78 };
79 struct debug_event_rip_info
80 {
81     int         error;      /* ??? */
82     int         type;       /* ??? */
83 };
84 union debug_event_data
85 {
86     struct debug_event_exception      exception;
87     struct debug_event_create_thread  create_thread;
88     struct debug_event_create_process create_process;
89     struct debug_event_exit           exit;
90     struct debug_event_load_dll       load_dll;
91     struct debug_event_unload_dll     unload_dll;
92     struct debug_event_output_string  output_string;
93     struct debug_event_rip_info       rip_info;
94 };
95
96 /* debug event data */
97 typedef struct
98 {
99     int                      code;   /* event code */
100     union debug_event_data   info;   /* event information */
101 } debug_event_t;
102
103
104 /* Create a new process from the context of the parent */
105 struct new_process_request
106 {
107     IN  int          inherit_all;  /* inherit all handles from parent */
108     IN  int          create_flags; /* creation flags */
109     IN  int          start_flags;  /* flags from startup info */
110     IN  int          exe_file;     /* file handle for main exe */
111     IN  int          hstdin;       /* handle for stdin */
112     IN  int          hstdout;      /* handle for stdout */
113     IN  int          hstderr;      /* handle for stderr */
114     IN  int          cmd_show;     /* main window show mode */
115     IN  int          alloc_fd;     /* create the fd pair right now? */
116     IN  char         filename[1];  /* file name of main exe */
117 };
118
119
120 /* Wait for the new process to start */
121 struct wait_process_request
122 {
123     IN  int          pinherit;     /* process handle inherit flag */
124     IN  int          tinherit;     /* thread handle inherit flag */
125     IN  int          timeout;      /* wait timeout */
126     IN  int          cancel;       /* cancel the process creation? */
127     OUT void*        pid;          /* process id */
128     OUT int          phandle;      /* process handle (in the current process) */
129     OUT void*        tid;          /* thread id */
130     OUT int          thandle;      /* thread handle (in the current process) */
131     OUT int          event;        /* event handle to signal startup */
132 };
133
134
135 /* Create a new thread from the context of the parent */
136 struct new_thread_request
137 {
138     IN  int          suspend;      /* new thread should be suspended on creation */ 
139     IN  int          inherit;      /* inherit flag */
140     OUT void*        tid;          /* thread id */
141     OUT int          handle;       /* thread handle (in the current process) */
142 };
143
144
145 /* Signal that we are finished booting on the client side */
146 struct boot_done_request
147 {
148     IN  int          debug_level;  /* new debug level */
149 };
150
151
152 /* Initialize a process; called from the new process context */
153 struct init_process_request
154 {
155     IN  void*        ldt_copy;     /* addr of LDT copy */
156     IN  void*        ldt_flags;    /* addr of LDT flags */
157     IN  int          ppid;         /* parent Unix pid */
158     OUT int          start_flags;  /* flags from startup info */
159     OUT int          exe_file;     /* file handle for main exe */
160     OUT int          hstdin;       /* handle for stdin */
161     OUT int          hstdout;      /* handle for stdout */
162     OUT int          hstderr;      /* handle for stderr */
163     OUT int          cmd_show;     /* main window show mode */
164     OUT char         filename[1];  /* file name of main exe */
165 };
166
167
168 /* Signal the end of the process initialization */
169 struct init_process_done_request
170 {
171     IN  void*        module;       /* main module base address */
172     IN  void*        entry;        /* process entry point */
173     IN  void*        name;         /* ptr to ptr to name (in process addr space) */
174     IN  int          gui;          /* is it a GUI process? */
175     OUT int          debugged;     /* being debugged? */
176 };
177
178
179 /* Initialize a thread; called from the child after fork()/clone() */
180 struct init_thread_request
181 {
182     IN  int          unix_pid;     /* Unix pid of new thread */
183     IN  void*        teb;          /* TEB of new thread (in thread address space) */
184     IN  void*        entry;        /* thread entry point (in thread address space) */
185 };
186
187
188 /* Retrieve the thread buffer file descriptor */
189 /* The reply to this request is the first thing a newly */
190 /* created thread gets (without having to request it) */
191 struct get_thread_buffer_request
192 {
193     OUT void*        pid;          /* process id of the new thread's process */
194     OUT void*        tid;          /* thread id of the new thread */
195     OUT int          boot;         /* is this the boot thread? */
196     OUT int          version;      /* protocol version */
197 };
198
199
200 /* Terminate a process */
201 struct terminate_process_request
202 {
203     IN  int          handle;       /* process handle to terminate */
204     IN  int          exit_code;    /* process exit code */
205     OUT int          self;         /* suicide? */
206 };
207
208
209 /* Terminate a thread */
210 struct terminate_thread_request
211 {
212     IN  int          handle;       /* thread handle to terminate */
213     IN  int          exit_code;    /* thread exit code */
214     OUT int          self;         /* suicide? */
215     OUT int          last;         /* last thread in this process? */
216 };
217
218
219 /* Retrieve information about a process */
220 struct get_process_info_request
221 {
222     IN  int          handle;           /* process handle */
223     OUT void*        pid;              /* server process id */
224     OUT int          debugged;         /* debugged? */
225     OUT int          exit_code;        /* process exit code */
226     OUT int          priority;         /* priority class */
227     OUT int          process_affinity; /* process affinity mask */
228     OUT int          system_affinity;  /* system affinity mask */
229 };
230
231
232 /* Set a process informations */
233 struct set_process_info_request
234 {
235     IN  int          handle;       /* process handle */
236     IN  int          mask;         /* setting mask (see below) */
237     IN  int          priority;     /* priority class */
238     IN  int          affinity;     /* affinity mask */
239 };
240 #define SET_PROCESS_INFO_PRIORITY 0x01
241 #define SET_PROCESS_INFO_AFFINITY 0x02
242
243
244 /* Retrieve information about a thread */
245 struct get_thread_info_request
246 {
247     IN  int          handle;       /* thread handle */
248     IN  void*        tid_in;       /* thread id (optional) */
249     OUT void*        tid;          /* server thread id */
250     OUT void*        teb;          /* thread teb pointer */
251     OUT int          exit_code;    /* thread exit code */
252     OUT int          priority;     /* thread priority level */
253 };
254
255
256 /* Set a thread informations */
257 struct set_thread_info_request
258 {
259     IN  int          handle;       /* thread handle */
260     IN  int          mask;         /* setting mask (see below) */
261     IN  int          priority;     /* priority class */
262     IN  int          affinity;     /* affinity mask */
263 };
264 #define SET_THREAD_INFO_PRIORITY 0x01
265 #define SET_THREAD_INFO_AFFINITY 0x02
266
267
268 /* Suspend a thread */
269 struct suspend_thread_request
270 {
271     IN  int          handle;       /* thread handle */
272     OUT int          count;        /* new suspend count */
273 };
274
275
276 /* Resume a thread */
277 struct resume_thread_request
278 {
279     IN  int          handle;       /* thread handle */
280     OUT int          count;        /* new suspend count */
281 };
282
283
284 /* Notify the server that a dll has been loaded */
285 struct load_dll_request
286 {
287     IN  int          handle;       /* file handle */
288     IN  void*        base;         /* base address */
289     IN  int          dbg_offset;   /* debug info offset */
290     IN  int          dbg_size;     /* debug info size */
291     IN  void*        name;         /* ptr to ptr to name (in process addr space) */
292 };
293
294
295 /* Notify the server that a dll is being unloaded */
296 struct unload_dll_request
297 {
298     IN  void*        base;         /* base address */
299 };
300
301
302 /* Queue an APC for a thread */
303 struct queue_apc_request
304 {
305     IN  int          handle;       /* thread handle */
306     IN  void*        func;         /* function to call */
307     IN  void*        param;        /* param for function to call */
308 };
309
310
311 /* Get list of APC to call */
312 struct get_apcs_request
313 {
314     OUT int          count;        /* number of apcs */
315     OUT void*        apcs[1];      /* async procedures to call */
316 };
317
318
319 /* Close a handle for the current process */
320 struct close_handle_request
321 {
322     IN  int          handle;       /* handle to close */
323 };
324
325
326 /* Get information about a handle */
327 struct get_handle_info_request
328 {
329     IN  int          handle;       /* handle we are interested in */
330     OUT int          flags;        /* handle flags */
331 };
332
333
334 /* Set a handle information */
335 struct set_handle_info_request
336 {
337     IN  int          handle;       /* handle we are interested in */
338     IN  int          flags;        /* new handle flags */
339     IN  int          mask;         /* mask for flags to set */
340 };
341
342
343 /* Duplicate a handle */
344 struct dup_handle_request
345 {
346     IN  int          src_process;  /* src process handle */
347     IN  int          src_handle;   /* src handle to duplicate */
348     IN  int          dst_process;  /* dst process handle */
349     IN  unsigned int access;       /* wanted access rights */
350     IN  int          inherit;      /* inherit flag */
351     IN  int          options;      /* duplicate options (see below) */
352     OUT int          handle;       /* duplicated handle in dst process */
353 };
354 #define DUP_HANDLE_CLOSE_SOURCE  DUPLICATE_CLOSE_SOURCE
355 #define DUP_HANDLE_SAME_ACCESS   DUPLICATE_SAME_ACCESS
356 #define DUP_HANDLE_MAKE_GLOBAL   0x80000000  /* Not a Windows flag */
357
358
359 /* Open a handle to a process */
360 struct open_process_request
361 {
362     IN  void*        pid;          /* process id to open */
363     IN  unsigned int access;       /* wanted access rights */
364     IN  int          inherit;      /* inherit flag */
365     OUT int          handle;       /* handle to the process */
366 };
367
368
369 /* Wait for handles */
370 struct select_request
371 {
372     IN  int          count;        /* handles count */
373     IN  int          flags;        /* wait flags (see below) */
374     IN  int          timeout;      /* timeout in ms */
375     OUT int          signaled;     /* signaled handle */
376     IN  int          handles[1];   /* handles to select on */
377 };
378 #define SELECT_ALL       1
379 #define SELECT_ALERTABLE 2
380 #define SELECT_TIMEOUT   4
381
382
383 /* Create an event */
384 struct create_event_request
385 {
386     IN  int          manual_reset;  /* manual reset event */
387     IN  int          initial_state; /* initial state of the event */
388     IN  int          inherit;       /* inherit flag */
389     OUT int          handle;        /* handle to the event */
390     IN  WCHAR        name[1];       /* event name */
391 };
392
393 /* Event operation */
394 struct event_op_request
395 {
396     IN  int           handle;       /* handle to event */
397     IN  int           op;           /* event operation (see below) */
398 };
399 enum event_op { PULSE_EVENT, SET_EVENT, RESET_EVENT };
400
401
402 /* Open an event */
403 struct open_event_request
404 {
405     IN  unsigned int access;        /* wanted access rights */
406     IN  int          inherit;       /* inherit flag */
407     OUT int          handle;        /* handle to the event */
408     IN  WCHAR        name[1];       /* object name */
409 };
410
411
412 /* Create a mutex */
413 struct create_mutex_request
414 {
415     IN  int          owned;         /* initially owned? */
416     IN  int          inherit;       /* inherit flag */
417     OUT int          handle;        /* handle to the mutex */
418     IN  WCHAR        name[1];       /* mutex name */
419 };
420
421
422 /* Release a mutex */
423 struct release_mutex_request
424 {
425     IN  int          handle;        /* handle to the mutex */
426 };
427
428
429 /* Open a mutex */
430 struct open_mutex_request
431 {
432     IN  unsigned int access;        /* wanted access rights */
433     IN  int          inherit;       /* inherit flag */
434     OUT int          handle;        /* handle to the mutex */
435     IN  WCHAR        name[1];       /* object name */
436 };
437
438
439 /* Create a semaphore */
440 struct create_semaphore_request
441 {
442     IN  unsigned int initial;       /* initial count */
443     IN  unsigned int max;           /* maximum count */
444     IN  int          inherit;       /* inherit flag */
445     OUT int          handle;        /* handle to the semaphore */
446     IN  WCHAR        name[1];       /* semaphore name */
447 };
448
449
450 /* Release a semaphore */
451 struct release_semaphore_request
452 {
453     IN  int          handle;        /* handle to the semaphore */
454     IN  unsigned int count;         /* count to add to semaphore */
455     OUT unsigned int prev_count;    /* previous semaphore count */
456 };
457
458
459 /* Open a semaphore */
460 struct open_semaphore_request
461 {
462     IN  unsigned int access;        /* wanted access rights */
463     IN  int          inherit;       /* inherit flag */
464     OUT int          handle;        /* handle to the semaphore */
465     IN  WCHAR        name[1];       /* object name */
466 };
467
468
469 /* Create a file */
470 struct create_file_request
471 {
472     IN  unsigned int access;        /* wanted access rights */
473     IN  int          inherit;       /* inherit flag */
474     IN  unsigned int sharing;       /* sharing flags */
475     IN  int          create;        /* file create action */
476     IN  unsigned int attrs;         /* file attributes for creation */
477     OUT int          handle;        /* handle to the file */
478     IN  char         name[1];       /* file name */
479 };
480
481
482 /* Allocate a file handle for a Unix fd */
483 struct alloc_file_handle_request
484 {
485     IN  unsigned int access;        /* wanted access rights */
486     OUT int          handle;        /* handle to the file */
487 };
488
489
490 /* Get a Unix fd to read from a file */
491 struct get_read_fd_request
492 {
493     IN  int          handle;        /* handle to the file */
494 };
495
496
497 /* Get a Unix fd to write to a file */
498 struct get_write_fd_request
499 {
500     IN  int          handle;        /* handle to the file */
501 };
502
503
504 /* Set a file current position */
505 struct set_file_pointer_request
506 {
507     IN  int          handle;        /* handle to the file */
508     IN  int          low;           /* position low word */
509     IN  int          high;          /* position high word */
510     IN  int          whence;        /* whence to seek */
511     OUT int          new_low;       /* new position low word */
512     OUT int          new_high;      /* new position high word */
513 };
514
515
516 /* Truncate (or extend) a file */
517 struct truncate_file_request
518 {
519     IN  int          handle;        /* handle to the file */
520 };
521
522
523 /* Set a file access and modification times */
524 struct set_file_time_request
525 {
526     IN  int          handle;        /* handle to the file */
527     IN  time_t       access_time;   /* last access time */
528     IN  time_t       write_time;    /* last write time */
529 };
530
531
532 /* Flush a file buffers */
533 struct flush_file_request
534 {
535     IN  int          handle;        /* handle to the file */
536 };
537
538
539 /* Get information about a file */
540 struct get_file_info_request
541 {
542     IN  int          handle;        /* handle to the file */
543     OUT int          type;          /* file type */
544     OUT int          attr;          /* file attributes */
545     OUT time_t       access_time;   /* last access time */
546     OUT time_t       write_time;    /* last write time */
547     OUT int          size_high;     /* file size */
548     OUT int          size_low;      /* file size */
549     OUT int          links;         /* number of links */
550     OUT int          index_high;    /* unique index */
551     OUT int          index_low;     /* unique index */
552     OUT unsigned int serial;        /* volume serial number */
553 };
554
555
556 /* Lock a region of a file */
557 struct lock_file_request
558 {
559     IN  int          handle;        /* handle to the file */
560     IN  unsigned int offset_low;    /* offset of start of lock */
561     IN  unsigned int offset_high;   /* offset of start of lock */
562     IN  unsigned int count_low;     /* count of bytes to lock */
563     IN  unsigned int count_high;    /* count of bytes to lock */
564 };
565
566
567 /* Unlock a region of a file */
568 struct unlock_file_request
569 {
570     IN  int          handle;        /* handle to the file */
571     IN  unsigned int offset_low;    /* offset of start of unlock */
572     IN  unsigned int offset_high;   /* offset of start of unlock */
573     IN  unsigned int count_low;     /* count of bytes to unlock */
574     IN  unsigned int count_high;    /* count of bytes to unlock */
575 };
576
577
578 /* Create an anonymous pipe */
579 struct create_pipe_request
580 {
581     IN  int          inherit;       /* inherit flag */
582     OUT int          handle_read;   /* handle to the read-side of the pipe */
583     OUT int          handle_write;  /* handle to the write-side of the pipe */
584 };
585
586
587 /* Create a socket */
588 struct create_socket_request
589 {
590     IN  unsigned int access;        /* wanted access rights */
591     IN  int          inherit;       /* inherit flag */
592     IN  int          family;        /* family, see socket manpage */
593     IN  int          type;          /* type, see socket manpage */
594     IN  int          protocol;      /* protocol, see socket manpage */
595     OUT int          handle;        /* handle to the new socket */
596 };
597
598
599 /* Accept a socket */
600 struct accept_socket_request
601 {
602     IN  int          lhandle;       /* handle to the listening socket */
603     IN  unsigned int access;        /* wanted access rights */
604     IN  int          inherit;       /* inherit flag */
605     OUT int          handle;        /* handle to the new socket */
606 };
607
608
609 /* Set socket event parameters */
610 struct set_socket_event_request
611 {
612     IN  int          handle;        /* handle to the socket */
613     IN  unsigned int mask;          /* event mask */
614     IN  int          event;         /* event object */
615 };
616
617
618 /* Get socket event parameters */
619 struct get_socket_event_request
620 {
621     IN  int          handle;        /* handle to the socket */
622     IN  int          service;       /* clear pending? */
623     IN  int          s_event;       /* "expected" event object */
624     IN  int          c_event;       /* event to clear */
625     OUT unsigned int mask;          /* event mask */
626     OUT unsigned int pmask;         /* pending events */
627     OUT unsigned int state;         /* status bits */
628     OUT int          errors[1];     /* event errors */
629 };
630
631
632 /* Reenable pending socket events */
633 struct enable_socket_event_request
634 {
635     IN  int          handle;        /* handle to the socket */
636     IN  unsigned int mask;          /* events to re-enable */
637     IN  unsigned int sstate;        /* status bits to set */
638     IN  unsigned int cstate;        /* status bits to clear */
639 };
640
641
642 /* Allocate a console for the current process */
643 struct alloc_console_request
644 {
645     IN  unsigned int access;        /* wanted access rights */
646     IN  int          inherit;       /* inherit flag */
647     OUT int          handle_in;     /* handle to console input */
648     OUT int          handle_out;    /* handle to console output */
649 };
650
651
652 /* Free the console of the current process */
653 struct free_console_request
654 {
655     IN  int dummy;
656 };
657
658
659 /* Open a handle to the process console */
660 struct open_console_request
661 {
662     IN  int          output;        /* input or output? */
663     IN  unsigned int access;        /* wanted access rights */
664     IN  int          inherit;       /* inherit flag */
665     OUT int          handle;        /* handle to the console */
666 };
667
668
669 /* Set a console file descriptor */
670 struct set_console_fd_request
671 {
672     IN  int          handle;        /* handle to the console */
673     IN  int          file_handle;   /* handle of file to use as file descriptor */
674     IN  int          pid;           /* pid of xterm (hack) */
675 };
676
677
678 /* Get a console mode (input or output) */
679 struct get_console_mode_request
680 {
681     IN  int          handle;        /* handle to the console */
682     OUT int          mode;          /* console mode */
683 };
684
685
686 /* Set a console mode (input or output) */
687 struct set_console_mode_request
688 {
689     IN  int          handle;        /* handle to the console */
690     IN  int          mode;          /* console mode */
691 };
692
693
694 /* Set info about a console (output only) */
695 struct set_console_info_request
696 {
697     IN  int          handle;        /* handle to the console */
698     IN  int          mask;          /* setting mask (see below) */
699     IN  int          cursor_size;   /* size of cursor (percentage filled) */
700     IN  int          cursor_visible;/* cursor visibility flag */
701     IN  char         title[1];      /* console title */
702 };
703 #define SET_CONSOLE_INFO_CURSOR 0x01
704 #define SET_CONSOLE_INFO_TITLE  0x02
705
706 /* Get info about a console (output only) */
707 struct get_console_info_request
708 {
709     IN  int          handle;        /* handle to the console */
710     OUT int          cursor_size;   /* size of cursor (percentage filled) */
711     OUT int          cursor_visible;/* cursor visibility flag */
712     OUT int          pid;           /* pid of xterm (hack) */
713     OUT char         title[1];      /* console title */
714 };
715
716
717 /* Add input records to a console input queue */
718 struct write_console_input_request
719 {
720     IN  int          handle;        /* handle to the console input */
721     IN  int          count;         /* number of input records */
722     OUT int          written;       /* number of records written */
723  /* INPUT_RECORD records[0]; */     /* input records */
724 };
725
726 /* Fetch input records from a console input queue */
727 struct read_console_input_request
728 {
729     IN  int          handle;        /* handle to the console input */
730     IN  int          count;         /* max number of records to retrieve */
731     IN  int          flush;         /* flush the retrieved records from the queue? */
732     OUT int          read;          /* number of records read */
733  /* INPUT_RECORD records[0]; */     /* input records */
734 };
735
736
737 /* Create a change notification */
738 struct create_change_notification_request
739 {
740     IN  int          subtree;       /* watch all the subtree */
741     IN  int          filter;        /* notification filter */
742     OUT int          handle;        /* handle to the change notification */
743 };
744
745
746 /* Create a file mapping */
747 struct create_mapping_request
748 {
749     IN  int          size_high;     /* mapping size */
750     IN  int          size_low;      /* mapping size */
751     IN  int          protect;       /* protection flags (see below) */
752     IN  int          inherit;       /* inherit flag */
753     IN  int          file_handle;   /* file handle */
754     OUT int          handle;        /* handle to the mapping */
755     IN  WCHAR        name[1];       /* object name */
756 };
757 /* protection flags */
758 #define VPROT_READ       0x01
759 #define VPROT_WRITE      0x02
760 #define VPROT_EXEC       0x04
761 #define VPROT_WRITECOPY  0x08
762 #define VPROT_GUARD      0x10
763 #define VPROT_NOCACHE    0x20
764 #define VPROT_COMMITTED  0x40
765
766
767 /* Open a mapping */
768 struct open_mapping_request
769 {
770     IN  unsigned int access;        /* wanted access rights */
771     IN  int          inherit;       /* inherit flag */
772     OUT int          handle;        /* handle to the mapping */
773     IN  WCHAR        name[1];       /* object name */
774 };
775
776
777 /* Get information about a file mapping */
778 struct get_mapping_info_request
779 {
780     IN  int          handle;        /* handle to the mapping */
781     OUT int          size_high;     /* mapping size */
782     OUT int          size_low;      /* mapping size */
783     OUT int          protect;       /* protection flags */
784 };
785
786
787 /* Create a device */
788 struct create_device_request
789 {
790     IN  unsigned int access;        /* wanted access rights */
791     IN  int          inherit;       /* inherit flag */
792     IN  int          id;            /* client private id */
793     OUT int          handle;        /* handle to the device */
794 };
795
796
797 /* Create a snapshot */
798 struct create_snapshot_request
799 {
800     IN  int          inherit;       /* inherit flag */
801     IN  int          flags;         /* snapshot flags (TH32CS_*) */
802     IN  void*        pid;           /* process id */
803     OUT int          handle;        /* handle to the snapshot */
804 };
805
806
807 /* Get the next process from a snapshot */
808 struct next_process_request
809 {
810     IN  int          handle;        /* handle to the snapshot */
811     IN  int          reset;         /* reset snapshot position? */
812     OUT int          count;         /* process usage count */
813     OUT void*        pid;           /* process id */
814     OUT int          threads;       /* number of threads */
815     OUT int          priority;      /* process priority */
816 };
817
818
819 /* Get the next thread from a snapshot */
820 struct next_thread_request
821 {
822     IN  int          handle;        /* handle to the snapshot */
823     IN  int          reset;         /* reset snapshot position? */
824     OUT int          count;         /* thread usage count */
825     OUT void*        pid;           /* process id */
826     OUT void*        tid;           /* thread id */
827     OUT int          base_pri;      /* base priority */
828     OUT int          delta_pri;     /* delta priority */
829 };
830
831
832 /* Get the next module from a snapshot */
833 struct next_module_request
834 {
835     IN  int          handle;        /* handle to the snapshot */
836     IN  int          reset;         /* reset snapshot position? */
837     OUT void*        pid;           /* process id */
838     OUT void*        base;          /* module base address */
839 };
840
841
842 /* Wait for a debug event */
843 struct wait_debug_event_request
844 {
845     IN  int           timeout;     /* timeout in ms */
846     OUT void*         pid;         /* process id */
847     OUT void*         tid;         /* thread id */
848     OUT debug_event_t event;       /* debug event data */
849 };
850
851
852 /* Send an exception event */
853 struct exception_event_request
854 {
855     IN  EXCEPTION_RECORD record;   /* exception record */
856     IN  int              first;    /* first chance exception? */
857     IN  CONTEXT          context;  /* thread context */
858     OUT int              status;   /* event continuation status */
859 };
860
861
862 /* Send an output string to the debugger */
863 struct output_debug_string_request
864 {
865     IN  void*         string;      /* string to display (in debugged process address space) */
866     IN  int           unicode;     /* is it Unicode? */
867     IN  int           length;      /* string length */
868 };
869
870
871 /* Continue a debug event */
872 struct continue_debug_event_request
873 {
874     IN  void*        pid;          /* process id to continue */
875     IN  void*        tid;          /* thread id to continue */
876     IN  int          status;       /* continuation status */
877 };
878
879
880 /* Start debugging an existing process */
881 struct debug_process_request
882 {
883     IN  void*        pid;          /* id of the process to debug */
884 };
885
886
887 /* Read data from a process address space */
888 struct read_process_memory_request
889 {
890     IN  int          handle;       /* process handle */
891     IN  void*        addr;         /* addr to read from (must be int-aligned) */
892     IN  int          len;          /* number of ints to read */
893     OUT unsigned int data[1];      /* result data */
894 };
895
896
897 /* Write data to a process address space */
898 struct write_process_memory_request
899 {
900     IN  int          handle;       /* process handle */
901     IN  void*        addr;         /* addr to write to (must be int-aligned) */
902     IN  int          len;          /* number of ints to write */
903     IN  unsigned int first_mask;   /* mask for first word */
904     IN  unsigned int last_mask;    /* mask for last word */
905     IN  unsigned int data[1];      /* data to write */
906 };
907
908
909 /* Create a registry key */
910 struct create_key_request
911 {
912     IN  int          parent;       /* handle to the parent key */
913     IN  unsigned int access;       /* desired access rights */
914     IN  unsigned int options;      /* creation options */
915     IN  time_t       modif;        /* last modification time */
916     OUT int          hkey;         /* handle to the created key */
917     OUT int          created;      /* has it been newly created? */
918     IN  path_t       name;         /* key name */
919     IN  WCHAR        class[1];     /* class name */
920 };
921
922
923 /* Open a registry key */
924 struct open_key_request
925 {
926     IN  int          parent;       /* handle to the parent key */
927     IN  unsigned int access;       /* desired access rights */
928     OUT int          hkey;         /* handle to the open key */
929     IN  path_t       name;         /* key name */
930 };
931
932
933 /* Delete a registry key */
934 struct delete_key_request
935 {
936     IN  int          hkey;         /* handle to the parent key */
937     IN  path_t       name;         /* key name */
938 };
939
940
941 /* Close a registry key */
942 struct close_key_request
943 {
944     IN  int          hkey;          /* key to close */
945 };
946
947
948 /* Enumerate registry subkeys */
949 struct enum_key_request
950 {
951     IN  int          hkey;         /* handle to registry key */
952     IN  int          index;        /* index of subkey */
953     OUT time_t       modif;        /* last modification time */
954     OUT path_t       name;         /* subkey name */
955     OUT WCHAR        class[1];     /* class name */
956 };
957
958
959 /* Query information about a registry key */
960 struct query_key_info_request
961 {
962     IN  int          hkey;         /* handle to registry key */
963     OUT int          subkeys;      /* number of subkeys */
964     OUT int          max_subkey;   /* longest subkey name */
965     OUT int          max_class;    /* longest class name */
966     OUT int          values;       /* number of values */
967     OUT int          max_value;    /* longest value name */
968     OUT int          max_data;     /* longest value data */
969     OUT time_t       modif;        /* last modification time */
970     OUT path_t       name;         /* key name */
971     OUT WCHAR        class[1];     /* class name */
972 };
973
974
975 /* Set a value of a registry key */
976 struct set_key_value_request
977 {
978     IN  int          hkey;         /* handle to registry key */
979     IN  int          type;         /* value type */
980     IN  unsigned int total;        /* total value len */
981     IN  unsigned int offset;       /* offset for setting data */
982     IN  unsigned int len;          /* value data len */
983     IN  path_t       name;         /* value name */
984     IN  unsigned char data[1];     /* value data */
985 };
986
987
988 /* Retrieve the value of a registry key */
989 struct get_key_value_request
990 {
991     IN  int          hkey;         /* handle to registry key */
992     IN  unsigned int offset;       /* offset for getting data */
993     OUT int          type;         /* value type */
994     OUT int          len;          /* value data len */
995     IN  WCHAR        name[1];      /* value name */
996     OUT unsigned char data[1];     /* value data */
997 };
998
999
1000 /* Enumerate a value of a registry key */
1001 struct enum_key_value_request
1002 {
1003     IN  int          hkey;         /* handle to registry key */
1004     IN  int          index;        /* value index */
1005     IN  unsigned int offset;       /* offset for getting data */
1006     OUT int          type;         /* value type */
1007     OUT int          len;          /* value data len */
1008     OUT path_t       name;         /* value name */
1009     OUT unsigned char data[1];     /* value data */
1010 };
1011
1012
1013 /* Delete a value of a registry key */
1014 struct delete_key_value_request
1015 {
1016     IN  int          hkey;         /* handle to registry key */
1017     IN  path_t       name;         /* value name */
1018 };
1019
1020
1021 /* Load a registry branch from a file */
1022 struct load_registry_request
1023 {
1024     IN  int          hkey;         /* root key to load to */
1025     IN  int          file;         /* file to load from */
1026     IN  path_t       name;         /* subkey name */
1027 };
1028
1029
1030 /* Save a registry branch to a file */
1031 struct save_registry_request
1032 {
1033     IN  int          hkey;         /* key to save */
1034     IN  int          file;         /* file to save to */
1035 };
1036
1037
1038 /* Save a registry branch at server exit */
1039 struct save_registry_atexit_request
1040 {
1041     IN  int          hkey;         /* key to save */
1042     IN  char         file[1];      /* file to save to */
1043 };
1044
1045
1046 /* Set the current and saving level for the registry */
1047 struct set_registry_levels_request
1048 {
1049     IN  int          current;      /* new current level */
1050     IN  int          saving;       /* new saving level */
1051     IN  int          period;       /* duration between periodic saves (milliseconds) */
1052 };
1053
1054
1055 /* Create a waitable timer */
1056 struct create_timer_request
1057 {
1058     IN  int          inherit;       /* inherit flag */
1059     IN  int          manual;        /* manual reset */
1060     OUT int          handle;        /* handle to the timer */
1061     IN  WCHAR        name[1];       /* timer name */
1062 };
1063
1064
1065 /* Open a waitable timer */
1066 struct open_timer_request
1067 {
1068     IN  unsigned int access;        /* wanted access rights */
1069     IN  int          inherit;       /* inherit flag */
1070     OUT int          handle;        /* handle to the timer */
1071     IN  WCHAR        name[1];       /* timer name */
1072 };
1073
1074 /* Set a waitable timer */
1075 struct set_timer_request
1076 {
1077     IN  int          handle;        /* handle to the timer */
1078     IN  int          sec;           /* next expiration absolute time */
1079     IN  int          usec;          /* next expiration absolute time */
1080     IN  int          period;        /* timer period in ms */
1081     IN  void*        callback;      /* callback function */
1082     IN  void*        arg;           /* callback argument */
1083 };
1084
1085 /* Cancel a waitable timer */
1086 struct cancel_timer_request
1087 {
1088     IN  int          handle;        /* handle to the timer */
1089 };
1090
1091
1092 /* Retrieve the current context of a thread */
1093 struct get_thread_context_request
1094 {
1095     IN  int          handle;       /* thread handle */
1096     IN  unsigned int flags;        /* context flags */
1097     OUT CONTEXT      context;      /* thread context */
1098 };
1099
1100
1101 /* Set the current context of a thread */
1102 struct set_thread_context_request
1103 {
1104     IN  int          handle;       /* thread handle */
1105     IN  unsigned int flags;        /* context flags */
1106     IN  CONTEXT      context;      /* thread context */
1107 };
1108
1109
1110 /* Fetch a selector entry for a thread */
1111 struct get_selector_entry_request
1112 {
1113     IN  int           handle;      /* thread handle */
1114     IN  int           entry;       /* LDT entry */
1115     OUT unsigned int  base;        /* selector base */
1116     OUT unsigned int  limit;       /* selector limit */
1117     OUT unsigned char flags;       /* selector flags */
1118 };
1119
1120
1121 /* Add an atom */
1122 struct add_atom_request
1123 {
1124     IN  int           local;       /* is atom in local process table? */
1125     OUT int           atom;        /* resulting atom */
1126     IN  WCHAR         name[1];     /* atom name */
1127 };
1128
1129
1130 /* Delete an atom */
1131 struct delete_atom_request
1132 {
1133     IN  int           atom;        /* atom handle */
1134     IN  int           local;       /* is atom in local process table? */
1135 };
1136
1137
1138 /* Find an atom */
1139 struct find_atom_request
1140 {
1141     IN  int          local;        /* is atom in local process table? */
1142     OUT int          atom;         /* atom handle */
1143     IN  WCHAR        name[1];      /* atom name */
1144 };
1145
1146
1147 /* Get an atom name */
1148 struct get_atom_name_request
1149 {
1150     IN  int          atom;         /* atom handle */
1151     IN  int          local;        /* is atom in local process table? */
1152     OUT int          count;        /* atom lock count */
1153     OUT WCHAR        name[1];      /* atom name */
1154 };
1155
1156
1157 /* Init the process atom table */
1158 struct init_atom_table_request
1159 {
1160     IN  int          entries;      /* number of entries */
1161 };
1162
1163
1164 /* Get the message queue of the current thread */
1165 struct get_msg_queue_request
1166 {
1167     OUT int          handle;       /* handle to the queue */
1168 };
1169
1170 /* Wake up a message queue */
1171 struct wake_queue_request
1172 {
1173     IN  int          handle;       /* handle to the queue */
1174     IN  unsigned int bits;         /* wake bits */
1175 };
1176
1177 /* Wait for a process to start waiting on input */
1178 struct wait_input_idle_request
1179 {
1180     IN  int          handle;       /* process handle */
1181     IN  int          timeout;      /* timeout */
1182     OUT int          event;        /* handle to idle event */
1183 };
1184
1185
1186 /* Everything below this line is generated automatically by tools/make_requests */
1187 /* ### make_requests begin ### */
1188
1189 enum request
1190 {
1191     REQ_NEW_PROCESS,
1192     REQ_WAIT_PROCESS,
1193     REQ_NEW_THREAD,
1194     REQ_BOOT_DONE,
1195     REQ_INIT_PROCESS,
1196     REQ_INIT_PROCESS_DONE,
1197     REQ_INIT_THREAD,
1198     REQ_GET_THREAD_BUFFER,
1199     REQ_TERMINATE_PROCESS,
1200     REQ_TERMINATE_THREAD,
1201     REQ_GET_PROCESS_INFO,
1202     REQ_SET_PROCESS_INFO,
1203     REQ_GET_THREAD_INFO,
1204     REQ_SET_THREAD_INFO,
1205     REQ_SUSPEND_THREAD,
1206     REQ_RESUME_THREAD,
1207     REQ_LOAD_DLL,
1208     REQ_UNLOAD_DLL,
1209     REQ_QUEUE_APC,
1210     REQ_GET_APCS,
1211     REQ_CLOSE_HANDLE,
1212     REQ_GET_HANDLE_INFO,
1213     REQ_SET_HANDLE_INFO,
1214     REQ_DUP_HANDLE,
1215     REQ_OPEN_PROCESS,
1216     REQ_SELECT,
1217     REQ_CREATE_EVENT,
1218     REQ_EVENT_OP,
1219     REQ_OPEN_EVENT,
1220     REQ_CREATE_MUTEX,
1221     REQ_RELEASE_MUTEX,
1222     REQ_OPEN_MUTEX,
1223     REQ_CREATE_SEMAPHORE,
1224     REQ_RELEASE_SEMAPHORE,
1225     REQ_OPEN_SEMAPHORE,
1226     REQ_CREATE_FILE,
1227     REQ_ALLOC_FILE_HANDLE,
1228     REQ_GET_READ_FD,
1229     REQ_GET_WRITE_FD,
1230     REQ_SET_FILE_POINTER,
1231     REQ_TRUNCATE_FILE,
1232     REQ_SET_FILE_TIME,
1233     REQ_FLUSH_FILE,
1234     REQ_GET_FILE_INFO,
1235     REQ_LOCK_FILE,
1236     REQ_UNLOCK_FILE,
1237     REQ_CREATE_PIPE,
1238     REQ_CREATE_SOCKET,
1239     REQ_ACCEPT_SOCKET,
1240     REQ_SET_SOCKET_EVENT,
1241     REQ_GET_SOCKET_EVENT,
1242     REQ_ENABLE_SOCKET_EVENT,
1243     REQ_ALLOC_CONSOLE,
1244     REQ_FREE_CONSOLE,
1245     REQ_OPEN_CONSOLE,
1246     REQ_SET_CONSOLE_FD,
1247     REQ_GET_CONSOLE_MODE,
1248     REQ_SET_CONSOLE_MODE,
1249     REQ_SET_CONSOLE_INFO,
1250     REQ_GET_CONSOLE_INFO,
1251     REQ_WRITE_CONSOLE_INPUT,
1252     REQ_READ_CONSOLE_INPUT,
1253     REQ_CREATE_CHANGE_NOTIFICATION,
1254     REQ_CREATE_MAPPING,
1255     REQ_OPEN_MAPPING,
1256     REQ_GET_MAPPING_INFO,
1257     REQ_CREATE_DEVICE,
1258     REQ_CREATE_SNAPSHOT,
1259     REQ_NEXT_PROCESS,
1260     REQ_NEXT_THREAD,
1261     REQ_NEXT_MODULE,
1262     REQ_WAIT_DEBUG_EVENT,
1263     REQ_EXCEPTION_EVENT,
1264     REQ_OUTPUT_DEBUG_STRING,
1265     REQ_CONTINUE_DEBUG_EVENT,
1266     REQ_DEBUG_PROCESS,
1267     REQ_READ_PROCESS_MEMORY,
1268     REQ_WRITE_PROCESS_MEMORY,
1269     REQ_CREATE_KEY,
1270     REQ_OPEN_KEY,
1271     REQ_DELETE_KEY,
1272     REQ_CLOSE_KEY,
1273     REQ_ENUM_KEY,
1274     REQ_QUERY_KEY_INFO,
1275     REQ_SET_KEY_VALUE,
1276     REQ_GET_KEY_VALUE,
1277     REQ_ENUM_KEY_VALUE,
1278     REQ_DELETE_KEY_VALUE,
1279     REQ_LOAD_REGISTRY,
1280     REQ_SAVE_REGISTRY,
1281     REQ_SAVE_REGISTRY_ATEXIT,
1282     REQ_SET_REGISTRY_LEVELS,
1283     REQ_CREATE_TIMER,
1284     REQ_OPEN_TIMER,
1285     REQ_SET_TIMER,
1286     REQ_CANCEL_TIMER,
1287     REQ_GET_THREAD_CONTEXT,
1288     REQ_SET_THREAD_CONTEXT,
1289     REQ_GET_SELECTOR_ENTRY,
1290     REQ_ADD_ATOM,
1291     REQ_DELETE_ATOM,
1292     REQ_FIND_ATOM,
1293     REQ_GET_ATOM_NAME,
1294     REQ_INIT_ATOM_TABLE,
1295     REQ_GET_MSG_QUEUE,
1296     REQ_WAKE_QUEUE,
1297     REQ_WAIT_INPUT_IDLE,
1298     REQ_NB_REQUESTS
1299 };
1300
1301 #define SERVER_PROTOCOL_VERSION 15
1302
1303 /* ### make_requests end ### */
1304 /* Everything above this line is generated automatically by tools/make_requests */
1305
1306
1307 /* client-side functions */
1308
1309 #ifndef __WINE_SERVER__
1310
1311 #include "thread.h"
1312 #include "ntddk.h"
1313
1314 /* client communication functions */
1315
1316 extern unsigned int server_call_noerr( enum request req );
1317 extern unsigned int server_call_fd( enum request req, int fd_out, int *fd_in );
1318 extern void server_protocol_error( const char *err, ... ) WINE_NORETURN;
1319 extern const char *get_config_dir(void);
1320
1321 /* get a pointer to the request buffer */
1322 static inline void WINE_UNUSED *get_req_buffer(void)
1323 {
1324     return NtCurrentTeb()->buffer;
1325 }
1326
1327 /* maximum remaining size in the server buffer */
1328 static inline int WINE_UNUSED server_remaining( const void *ptr )
1329 {
1330     return (char *)NtCurrentTeb()->buffer + NtCurrentTeb()->buffer_size - (char *)ptr;
1331 }
1332
1333 /* do a server call and set the last error code */
1334 static inline int server_call( enum request req )
1335 {
1336     unsigned int res = server_call_noerr( req );
1337     if (res) SetLastError( RtlNtStatusToDosError(res) );
1338     return res;
1339 }
1340
1341 /* copy a Unicode string to the server buffer */
1342 static inline void server_strcpyW( WCHAR *dst, const WCHAR *src )
1343 {
1344     if (src)
1345     {
1346         WCHAR *end = (WCHAR *)((char *)NtCurrentTeb()->buffer + NtCurrentTeb()->buffer_size) - 1;
1347         while ((dst < end) && *src) *dst++ = *src++;
1348     }
1349     *dst = 0;
1350 }
1351
1352 /* copy and convert an ASCII string to the server buffer */
1353 static inline void server_strcpyAtoW( WCHAR *dst, const char *src )
1354 {
1355     if (src)
1356     {
1357         WCHAR *end = (WCHAR *)((char *)NtCurrentTeb()->buffer + NtCurrentTeb()->buffer_size) - 1;
1358         while ((dst < end) && *src) *dst++ = (WCHAR)(unsigned char)*src++;
1359     }
1360     *dst = 0;
1361 }
1362
1363 extern int CLIENT_InitServer(void);
1364 extern int CLIENT_BootDone( int debug_level );
1365 extern int CLIENT_IsBootThread(void);
1366 extern int CLIENT_InitThread(void);
1367 #endif  /* __WINE_SERVER__ */
1368
1369 #endif  /* __WINE_SERVER_H */