Export the wine server functions from ntdll.
[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 #define VARARG(name,func) /*nothing*/
26
27 struct request_header
28 {
29     IN  int            req;          /* request code */
30     IN  unsigned short fixed_size;   /* size of the fixed part of the request */
31     IN  unsigned short var_size;     /* size of the variable part of the request */
32     OUT unsigned int   error;        /* error result */
33 };
34 #define REQUEST_HEADER  struct request_header header
35
36
37 /* placeholder structure for the maximum allowed request size */
38 /* this is used to construct the generic_request union */
39 struct request_max_size
40 {
41     int pad[16]; /* the max request size is 16 ints */
42 };
43
44 /* max size of the variable part of a request */
45 #define REQUEST_MAX_VAR_SIZE  1024
46
47 /* a path name for server requests (Unicode) */
48 typedef WCHAR path_t[MAX_PATH+1];
49
50
51 /* definitions of the event data depending on the event code */
52 struct debug_event_exception
53 {
54     EXCEPTION_RECORD record;   /* exception record */
55     int              first;    /* first chance exception? */
56 };
57 struct debug_event_create_thread
58 {
59     int         handle;     /* handle to the new thread */
60     void       *teb;        /* thread teb (in debugged process address space) */
61     void       *start;      /* thread startup routine */
62 };
63 struct debug_event_create_process
64 {
65     int         file;       /* handle to the process exe file */
66     int         process;    /* handle to the new process */
67     int         thread;     /* handle to the new thread */
68     void       *base;       /* base of executable image */
69     int         dbg_offset; /* offset of debug info in file */
70     int         dbg_size;   /* size of debug info */
71     void       *teb;        /* thread teb (in debugged process address space) */
72     void       *start;      /* thread startup routine */
73     void       *name;       /* image name (optional) */
74     int         unicode;    /* is it Unicode? */
75 };
76 struct debug_event_exit
77 {
78     int         exit_code;  /* thread or process exit code */
79 };
80 struct debug_event_load_dll
81 {
82     int         handle;     /* file handle for the dll */
83     void       *base;       /* base address of the dll */
84     int         dbg_offset; /* offset of debug info in file */
85     int         dbg_size;   /* size of debug info */
86     void       *name;       /* image name (optional) */
87     int         unicode;    /* is it Unicode? */
88 };
89 struct debug_event_unload_dll
90 {
91     void       *base;       /* base address of the dll */
92 };
93 struct debug_event_output_string
94 {
95     void       *string;     /* string to display (in debugged process address space) */
96     int         unicode;    /* is it Unicode? */
97     int         length;     /* string length */
98 };
99 struct debug_event_rip_info
100 {
101     int         error;      /* ??? */
102     int         type;       /* ??? */
103 };
104 union debug_event_data
105 {
106     struct debug_event_exception      exception;
107     struct debug_event_create_thread  create_thread;
108     struct debug_event_create_process create_process;
109     struct debug_event_exit           exit;
110     struct debug_event_load_dll       load_dll;
111     struct debug_event_unload_dll     unload_dll;
112     struct debug_event_output_string  output_string;
113     struct debug_event_rip_info       rip_info;
114 };
115
116 /* debug event data */
117 typedef struct
118 {
119     int                      code;   /* event code */
120     union debug_event_data   info;   /* event information */
121 } debug_event_t;
122
123
124 /* Create a new process from the context of the parent */
125 struct new_process_request
126 {
127     REQUEST_HEADER;                /* request header */
128     IN  int          inherit_all;  /* inherit all handles from parent */
129     IN  int          create_flags; /* creation flags */
130     IN  int          start_flags;  /* flags from startup info */
131     IN  int          exe_file;     /* file handle for main exe */
132     IN  int          hstdin;       /* handle for stdin */
133     IN  int          hstdout;      /* handle for stdout */
134     IN  int          hstderr;      /* handle for stderr */
135     IN  int          cmd_show;     /* main window show mode */
136     IN  int          alloc_fd;     /* create the fd pair right now? */
137     IN  VARARG(filename,string);   /* file name of main exe */
138 };
139
140
141 /* Wait for the new process to start */
142 struct wait_process_request
143 {
144     REQUEST_HEADER;                /* request header */
145     IN  int          pinherit;     /* process handle inherit flag */
146     IN  int          tinherit;     /* thread handle inherit flag */
147     IN  int          timeout;      /* wait timeout */
148     IN  int          cancel;       /* cancel the process creation? */
149     OUT void*        pid;          /* process id */
150     OUT int          phandle;      /* process handle (in the current process) */
151     OUT void*        tid;          /* thread id */
152     OUT int          thandle;      /* thread handle (in the current process) */
153     OUT int          event;        /* event handle to signal startup */
154 };
155
156
157 /* Create a new thread from the context of the parent */
158 struct new_thread_request
159 {
160     REQUEST_HEADER;                /* request header */
161     IN  int          suspend;      /* new thread should be suspended on creation */ 
162     IN  int          inherit;      /* inherit flag */
163     OUT void*        tid;          /* thread id */
164     OUT int          handle;       /* thread handle (in the current process) */
165 };
166
167
168 /* Signal that we are finished booting on the client side */
169 struct boot_done_request
170 {
171     REQUEST_HEADER;                /* request header */
172     IN  int          debug_level;  /* new debug level */
173 };
174
175
176 /* Initialize a process; called from the new process context */
177 struct init_process_request
178 {
179     REQUEST_HEADER;                /* request header */
180     IN  void*        ldt_copy;     /* addr of LDT copy */
181     IN  int          ppid;         /* parent Unix pid */
182     OUT int          start_flags;  /* flags from startup info */
183     OUT unsigned int server_start; /* server start time (GetTickCount) */
184     OUT int          exe_file;     /* file handle for main exe */
185     OUT int          hstdin;       /* handle for stdin */
186     OUT int          hstdout;      /* handle for stdout */
187     OUT int          hstderr;      /* handle for stderr */
188     OUT int          cmd_show;     /* main window show mode */
189     OUT VARARG(filename,string);   /* file name of main exe */
190 };
191
192
193 /* Signal the end of the process initialization */
194 struct init_process_done_request
195 {
196     REQUEST_HEADER;                /* request header */
197     IN  void*        module;       /* main module base address */
198     IN  void*        entry;        /* process entry point */
199     IN  void*        name;         /* ptr to ptr to name (in process addr space) */
200     IN  int          gui;          /* is it a GUI process? */
201     OUT int          debugged;     /* being debugged? */
202 };
203
204
205 /* Initialize a thread; called from the child after fork()/clone() */
206 struct init_thread_request
207 {
208     REQUEST_HEADER;                /* request header */
209     IN  int          unix_pid;     /* Unix pid of new thread */
210     IN  void*        teb;          /* TEB of new thread (in thread address space) */
211     IN  void*        entry;        /* thread entry point (in thread address space) */
212 };
213
214
215 /* Retrieve the thread buffer file descriptor */
216 /* The reply to this request is the first thing a newly */
217 /* created thread gets (without having to request it) */
218 struct get_thread_buffer_request
219 {
220     REQUEST_HEADER;                /* request header */
221     OUT void*        pid;          /* process id of the new thread's process */
222     OUT void*        tid;          /* thread id of the new thread */
223     OUT int          boot;         /* is this the boot thread? */
224     OUT int          version;      /* protocol version */
225 };
226
227
228 /* Terminate a process */
229 struct terminate_process_request
230 {
231     REQUEST_HEADER;                /* request header */
232     IN  int          handle;       /* process handle to terminate */
233     IN  int          exit_code;    /* process exit code */
234     OUT int          self;         /* suicide? */
235 };
236
237
238 /* Terminate a thread */
239 struct terminate_thread_request
240 {
241     REQUEST_HEADER;                /* request header */
242     IN  int          handle;       /* thread handle to terminate */
243     IN  int          exit_code;    /* thread exit code */
244     OUT int          self;         /* suicide? */
245     OUT int          last;         /* last thread in this process? */
246 };
247
248
249 /* Retrieve information about a process */
250 struct get_process_info_request
251 {
252     REQUEST_HEADER;                    /* request header */
253     IN  int          handle;           /* process handle */
254     OUT void*        pid;              /* server process id */
255     OUT int          debugged;         /* debugged? */
256     OUT int          exit_code;        /* process exit code */
257     OUT int          priority;         /* priority class */
258     OUT int          process_affinity; /* process affinity mask */
259     OUT int          system_affinity;  /* system affinity mask */
260 };
261
262
263 /* Set a process informations */
264 struct set_process_info_request
265 {
266     REQUEST_HEADER;                /* request header */
267     IN  int          handle;       /* process handle */
268     IN  int          mask;         /* setting mask (see below) */
269     IN  int          priority;     /* priority class */
270     IN  int          affinity;     /* affinity mask */
271 };
272 #define SET_PROCESS_INFO_PRIORITY 0x01
273 #define SET_PROCESS_INFO_AFFINITY 0x02
274
275
276 /* Retrieve information about a thread */
277 struct get_thread_info_request
278 {
279     REQUEST_HEADER;                /* request header */
280     IN  int          handle;       /* thread handle */
281     IN  void*        tid_in;       /* thread id (optional) */
282     OUT void*        tid;          /* server thread id */
283     OUT void*        teb;          /* thread teb pointer */
284     OUT int          exit_code;    /* thread exit code */
285     OUT int          priority;     /* thread priority level */
286 };
287
288
289 /* Set a thread informations */
290 struct set_thread_info_request
291 {
292     REQUEST_HEADER;                /* request header */
293     IN  int          handle;       /* thread handle */
294     IN  int          mask;         /* setting mask (see below) */
295     IN  int          priority;     /* priority class */
296     IN  int          affinity;     /* affinity mask */
297 };
298 #define SET_THREAD_INFO_PRIORITY 0x01
299 #define SET_THREAD_INFO_AFFINITY 0x02
300
301
302 /* Suspend a thread */
303 struct suspend_thread_request
304 {
305     REQUEST_HEADER;                /* request header */
306     IN  int          handle;       /* thread handle */
307     OUT int          count;        /* new suspend count */
308 };
309
310
311 /* Resume a thread */
312 struct resume_thread_request
313 {
314     REQUEST_HEADER;                /* request header */
315     IN  int          handle;       /* thread handle */
316     OUT int          count;        /* new suspend count */
317 };
318
319
320 /* Notify the server that a dll has been loaded */
321 struct load_dll_request
322 {
323     REQUEST_HEADER;                /* request header */
324     IN  int          handle;       /* file handle */
325     IN  void*        base;         /* base address */
326     IN  int          dbg_offset;   /* debug info offset */
327     IN  int          dbg_size;     /* debug info size */
328     IN  void*        name;         /* ptr to ptr to name (in process addr space) */
329 };
330
331
332 /* Notify the server that a dll is being unloaded */
333 struct unload_dll_request
334 {
335     REQUEST_HEADER;                /* request header */
336     IN  void*        base;         /* base address */
337 };
338
339
340 /* Queue an APC for a thread */
341 struct queue_apc_request
342 {
343     REQUEST_HEADER;                /* request header */
344     IN  int          handle;       /* thread handle */
345     IN  void*        func;         /* function to call */
346     IN  void*        param;        /* param for function to call */
347 };
348
349
350 /* Get next APC to call */
351 struct get_apc_request
352 {
353     REQUEST_HEADER;                /* request header */
354     OUT void*        func;         /* function to call */
355     OUT int          type;         /* function type */
356     OUT VARARG(args,ptrs);         /* function arguments */
357 };
358 enum apc_type { APC_NONE, APC_USER, APC_TIMER, APC_ASYNC };
359
360
361 /* Close a handle for the current process */
362 struct close_handle_request
363 {
364     REQUEST_HEADER;                /* request header */
365     IN  int          handle;       /* handle to close */
366 };
367
368
369 /* Get information about a handle */
370 struct get_handle_info_request
371 {
372     REQUEST_HEADER;                /* request header */
373     IN  int          handle;       /* handle we are interested in */
374     OUT int          flags;        /* handle flags */
375 };
376
377
378 /* Set a handle information */
379 struct set_handle_info_request
380 {
381     REQUEST_HEADER;                /* request header */
382     IN  int          handle;       /* handle we are interested in */
383     IN  int          flags;        /* new handle flags */
384     IN  int          mask;         /* mask for flags to set */
385 };
386
387
388 /* Duplicate a handle */
389 struct dup_handle_request
390 {
391     REQUEST_HEADER;                /* request header */
392     IN  int          src_process;  /* src process handle */
393     IN  int          src_handle;   /* src handle to duplicate */
394     IN  int          dst_process;  /* dst process handle */
395     IN  unsigned int access;       /* wanted access rights */
396     IN  int          inherit;      /* inherit flag */
397     IN  int          options;      /* duplicate options (see below) */
398     OUT int          handle;       /* duplicated handle in dst process */
399 };
400 #define DUP_HANDLE_CLOSE_SOURCE  DUPLICATE_CLOSE_SOURCE
401 #define DUP_HANDLE_SAME_ACCESS   DUPLICATE_SAME_ACCESS
402 #define DUP_HANDLE_MAKE_GLOBAL   0x80000000  /* Not a Windows flag */
403
404
405 /* Open a handle to a process */
406 struct open_process_request
407 {
408     REQUEST_HEADER;                /* request header */
409     IN  void*        pid;          /* process id to open */
410     IN  unsigned int access;       /* wanted access rights */
411     IN  int          inherit;      /* inherit flag */
412     OUT int          handle;       /* handle to the process */
413 };
414
415
416 /* Wait for handles */
417 struct select_request
418 {
419     REQUEST_HEADER;                /* request header */
420     IN  int          flags;        /* wait flags (see below) */
421     IN  int          timeout;      /* timeout in ms */
422     OUT int          signaled;     /* signaled handle */
423     IN  VARARG(handles,ints);      /* handles to select on */
424 };
425 #define SELECT_ALL       1
426 #define SELECT_ALERTABLE 2
427 #define SELECT_TIMEOUT   4
428
429
430 /* Create an event */
431 struct create_event_request
432 {
433     REQUEST_HEADER;                 /* request header */
434     IN  int          manual_reset;  /* manual reset event */
435     IN  int          initial_state; /* initial state of the event */
436     IN  int          inherit;       /* inherit flag */
437     OUT int          handle;        /* handle to the event */
438     IN  VARARG(name,unicode_str);   /* object name */
439 };
440
441 /* Event operation */
442 struct event_op_request
443 {
444     REQUEST_HEADER;                 /* request header */
445     IN  int           handle;       /* handle to event */
446     IN  int           op;           /* event operation (see below) */
447 };
448 enum event_op { PULSE_EVENT, SET_EVENT, RESET_EVENT };
449
450
451 /* Open an event */
452 struct open_event_request
453 {
454     REQUEST_HEADER;                 /* request header */
455     IN  unsigned int access;        /* wanted access rights */
456     IN  int          inherit;       /* inherit flag */
457     OUT int          handle;        /* handle to the event */
458     IN  VARARG(name,unicode_str);   /* object name */
459 };
460
461
462 /* Create a mutex */
463 struct create_mutex_request
464 {
465     REQUEST_HEADER;                 /* request header */
466     IN  int          owned;         /* initially owned? */
467     IN  int          inherit;       /* inherit flag */
468     OUT int          handle;        /* handle to the mutex */
469     IN  VARARG(name,unicode_str);   /* object name */
470 };
471
472
473 /* Release a mutex */
474 struct release_mutex_request
475 {
476     REQUEST_HEADER;                 /* request header */
477     IN  int          handle;        /* handle to the mutex */
478 };
479
480
481 /* Open a mutex */
482 struct open_mutex_request
483 {
484     REQUEST_HEADER;                 /* request header */
485     IN  unsigned int access;        /* wanted access rights */
486     IN  int          inherit;       /* inherit flag */
487     OUT int          handle;        /* handle to the mutex */
488     IN  VARARG(name,unicode_str);   /* object name */
489 };
490
491
492 /* Create a semaphore */
493 struct create_semaphore_request
494 {
495     REQUEST_HEADER;                 /* request header */
496     IN  unsigned int initial;       /* initial count */
497     IN  unsigned int max;           /* maximum count */
498     IN  int          inherit;       /* inherit flag */
499     OUT int          handle;        /* handle to the semaphore */
500     IN  VARARG(name,unicode_str);   /* object name */
501 };
502
503
504 /* Release a semaphore */
505 struct release_semaphore_request
506 {
507     REQUEST_HEADER;                 /* request header */
508     IN  int          handle;        /* handle to the semaphore */
509     IN  unsigned int count;         /* count to add to semaphore */
510     OUT unsigned int prev_count;    /* previous semaphore count */
511 };
512
513
514 /* Open a semaphore */
515 struct open_semaphore_request
516 {
517     REQUEST_HEADER;                 /* request header */
518     IN  unsigned int access;        /* wanted access rights */
519     IN  int          inherit;       /* inherit flag */
520     OUT int          handle;        /* handle to the semaphore */
521     IN  VARARG(name,unicode_str);   /* object name */
522 };
523
524
525 /* Create a file */
526 struct create_file_request
527 {
528     REQUEST_HEADER;                 /* request header */
529     IN  unsigned int access;        /* wanted access rights */
530     IN  int          inherit;       /* inherit flag */
531     IN  unsigned int sharing;       /* sharing flags */
532     IN  int          create;        /* file create action */
533     IN  unsigned int attrs;         /* file attributes for creation */
534     OUT int          handle;        /* handle to the file */
535     IN  VARARG(filename,string);    /* file name */
536 };
537
538
539 /* Allocate a file handle for a Unix fd */
540 struct alloc_file_handle_request
541 {
542     REQUEST_HEADER;                 /* request header */
543     IN  unsigned int access;        /* wanted access rights */
544     OUT int          handle;        /* handle to the file */
545 };
546
547
548 /* Get a Unix fd to read from a file */
549 struct get_read_fd_request
550 {
551     REQUEST_HEADER;                 /* request header */
552     IN  int          handle;        /* handle to the file */
553 };
554
555
556 /* Get a Unix fd to write to a file */
557 struct get_write_fd_request
558 {
559     REQUEST_HEADER;                 /* request header */
560     IN  int          handle;        /* handle to the file */
561 };
562
563
564 /* Set a file current position */
565 struct set_file_pointer_request
566 {
567     REQUEST_HEADER;                 /* request header */
568     IN  int          handle;        /* handle to the file */
569     IN  int          low;           /* position low word */
570     IN  int          high;          /* position high word */
571     IN  int          whence;        /* whence to seek */
572     OUT int          new_low;       /* new position low word */
573     OUT int          new_high;      /* new position high word */
574 };
575
576
577 /* Truncate (or extend) a file */
578 struct truncate_file_request
579 {
580     REQUEST_HEADER;                 /* request header */
581     IN  int          handle;        /* handle to the file */
582 };
583
584
585 /* Set a file access and modification times */
586 struct set_file_time_request
587 {
588     REQUEST_HEADER;                 /* request header */
589     IN  int          handle;        /* handle to the file */
590     IN  time_t       access_time;   /* last access time */
591     IN  time_t       write_time;    /* last write time */
592 };
593
594
595 /* Flush a file buffers */
596 struct flush_file_request
597 {
598     REQUEST_HEADER;                 /* request header */
599     IN  int          handle;        /* handle to the file */
600 };
601
602
603 /* Get information about a file */
604 struct get_file_info_request
605 {
606     REQUEST_HEADER;                 /* request header */
607     IN  int          handle;        /* handle to the file */
608     OUT int          type;          /* file type */
609     OUT int          attr;          /* file attributes */
610     OUT time_t       access_time;   /* last access time */
611     OUT time_t       write_time;    /* last write time */
612     OUT int          size_high;     /* file size */
613     OUT int          size_low;      /* file size */
614     OUT int          links;         /* number of links */
615     OUT int          index_high;    /* unique index */
616     OUT int          index_low;     /* unique index */
617     OUT unsigned int serial;        /* volume serial number */
618 };
619
620
621 /* Lock a region of a file */
622 struct lock_file_request
623 {
624     REQUEST_HEADER;                 /* request header */
625     IN  int          handle;        /* handle to the file */
626     IN  unsigned int offset_low;    /* offset of start of lock */
627     IN  unsigned int offset_high;   /* offset of start of lock */
628     IN  unsigned int count_low;     /* count of bytes to lock */
629     IN  unsigned int count_high;    /* count of bytes to lock */
630 };
631
632
633 /* Unlock a region of a file */
634 struct unlock_file_request
635 {
636     REQUEST_HEADER;                 /* request header */
637     IN  int          handle;        /* handle to the file */
638     IN  unsigned int offset_low;    /* offset of start of unlock */
639     IN  unsigned int offset_high;   /* offset of start of unlock */
640     IN  unsigned int count_low;     /* count of bytes to unlock */
641     IN  unsigned int count_high;    /* count of bytes to unlock */
642 };
643
644
645 /* Create an anonymous pipe */
646 struct create_pipe_request
647 {
648     REQUEST_HEADER;                 /* request header */
649     IN  int          inherit;       /* inherit flag */
650     OUT int          handle_read;   /* handle to the read-side of the pipe */
651     OUT int          handle_write;  /* handle to the write-side of the pipe */
652 };
653
654
655 /* Create a socket */
656 struct create_socket_request
657 {
658     REQUEST_HEADER;                 /* request header */
659     IN  unsigned int access;        /* wanted access rights */
660     IN  int          inherit;       /* inherit flag */
661     IN  int          family;        /* family, see socket manpage */
662     IN  int          type;          /* type, see socket manpage */
663     IN  int          protocol;      /* protocol, see socket manpage */
664     OUT int          handle;        /* handle to the new socket */
665 };
666
667
668 /* Accept a socket */
669 struct accept_socket_request
670 {
671     REQUEST_HEADER;                 /* request header */
672     IN  int          lhandle;       /* handle to the listening socket */
673     IN  unsigned int access;        /* wanted access rights */
674     IN  int          inherit;       /* inherit flag */
675     OUT int          handle;        /* handle to the new socket */
676 };
677
678
679 /* Set socket event parameters */
680 struct set_socket_event_request
681 {
682     REQUEST_HEADER;                 /* request header */
683     IN  int          handle;        /* handle to the socket */
684     IN  unsigned int mask;          /* event mask */
685     IN  int          event;         /* event object */
686 };
687
688
689 /* Get socket event parameters */
690 struct get_socket_event_request
691 {
692     REQUEST_HEADER;                 /* request header */
693     IN  int          handle;        /* handle to the socket */
694     IN  int          service;       /* clear pending? */
695     IN  int          s_event;       /* "expected" event object */
696     IN  int          c_event;       /* event to clear */
697     OUT unsigned int mask;          /* event mask */
698     OUT unsigned int pmask;         /* pending events */
699     OUT unsigned int state;         /* status bits */
700     OUT VARARG(errors,ints);        /* event errors */
701 };
702
703
704 /* Reenable pending socket events */
705 struct enable_socket_event_request
706 {
707     REQUEST_HEADER;                 /* request header */
708     IN  int          handle;        /* handle to the socket */
709     IN  unsigned int mask;          /* events to re-enable */
710     IN  unsigned int sstate;        /* status bits to set */
711     IN  unsigned int cstate;        /* status bits to clear */
712 };
713
714
715 /* Allocate a console for the current process */
716 struct alloc_console_request
717 {
718     REQUEST_HEADER;                 /* request header */
719     IN  unsigned int access;        /* wanted access rights */
720     IN  int          inherit;       /* inherit flag */
721     OUT int          handle_in;     /* handle to console input */
722     OUT int          handle_out;    /* handle to console output */
723 };
724
725
726 /* Free the console of the current process */
727 struct free_console_request
728 {
729     REQUEST_HEADER;                 /* request header */
730 };
731
732
733 /* Open a handle to the process console */
734 struct open_console_request
735 {
736     REQUEST_HEADER;                 /* request header */
737     IN  int          output;        /* input or output? */
738     IN  unsigned int access;        /* wanted access rights */
739     IN  int          inherit;       /* inherit flag */
740     OUT int          handle;        /* handle to the console */
741 };
742
743
744 /* Set a console file descriptor */
745 struct set_console_fd_request
746 {
747     REQUEST_HEADER;                 /* request header */
748     IN  int          handle;        /* handle to the console */
749     IN  int          file_handle;   /* handle of file to use as file descriptor */
750     IN  int          pid;           /* pid of xterm (hack) */
751 };
752
753
754 /* Get a console mode (input or output) */
755 struct get_console_mode_request
756 {
757     REQUEST_HEADER;                 /* request header */
758     IN  int          handle;        /* handle to the console */
759     OUT int          mode;          /* console mode */
760 };
761
762
763 /* Set a console mode (input or output) */
764 struct set_console_mode_request
765 {
766     REQUEST_HEADER;                 /* request header */
767     IN  int          handle;        /* handle to the console */
768     IN  int          mode;          /* console mode */
769 };
770
771
772 /* Set info about a console (output only) */
773 struct set_console_info_request
774 {
775     REQUEST_HEADER;                 /* request header */
776     IN  int          handle;        /* handle to the console */
777     IN  int          mask;          /* setting mask (see below) */
778     IN  int          cursor_size;   /* size of cursor (percentage filled) */
779     IN  int          cursor_visible;/* cursor visibility flag */
780     IN  VARARG(title,string);       /* console title */
781 };
782 #define SET_CONSOLE_INFO_CURSOR 0x01
783 #define SET_CONSOLE_INFO_TITLE  0x02
784
785 /* Get info about a console (output only) */
786 struct get_console_info_request
787 {
788     REQUEST_HEADER;                 /* request header */
789     IN  int          handle;        /* handle to the console */
790     OUT int          cursor_size;   /* size of cursor (percentage filled) */
791     OUT int          cursor_visible;/* cursor visibility flag */
792     OUT int          pid;           /* pid of xterm (hack) */
793     OUT VARARG(title,string);       /* console title */
794 };
795
796
797 /* Add input records to a console input queue */
798 struct write_console_input_request
799 {
800     REQUEST_HEADER;                 /* request header */
801     IN  int          handle;        /* handle to the console input */
802     OUT int          written;       /* number of records written */
803     IN  VARARG(rec,input_records);  /* input records */
804 };
805
806 /* Fetch input records from a console input queue */
807 struct read_console_input_request
808 {
809     REQUEST_HEADER;                 /* request header */
810     IN  int          handle;        /* handle to the console input */
811     IN  int          flush;         /* flush the retrieved records from the queue? */
812     OUT int          read;          /* number of records read */
813     OUT VARARG(rec,input_records);  /* input records */
814 };
815
816
817 /* Create a change notification */
818 struct create_change_notification_request
819 {
820     REQUEST_HEADER;                 /* request header */
821     IN  int          subtree;       /* watch all the subtree */
822     IN  int          filter;        /* notification filter */
823     OUT int          handle;        /* handle to the change notification */
824 };
825
826
827 /* Create a file mapping */
828 struct create_mapping_request
829 {
830     REQUEST_HEADER;                 /* request header */
831     IN  int          size_high;     /* mapping size */
832     IN  int          size_low;      /* mapping size */
833     IN  int          protect;       /* protection flags (see below) */
834     IN  int          inherit;       /* inherit flag */
835     IN  int          file_handle;   /* file handle */
836     OUT int          handle;        /* handle to the mapping */
837     IN  VARARG(name,unicode_str);   /* object name */
838 };
839 /* protection flags */
840 #define VPROT_READ       0x01
841 #define VPROT_WRITE      0x02
842 #define VPROT_EXEC       0x04
843 #define VPROT_WRITECOPY  0x08
844 #define VPROT_GUARD      0x10
845 #define VPROT_NOCACHE    0x20
846 #define VPROT_COMMITTED  0x40
847 #define VPROT_IMAGE      0x80
848
849
850 /* Open a mapping */
851 struct open_mapping_request
852 {
853     REQUEST_HEADER;                 /* request header */
854     IN  unsigned int access;        /* wanted access rights */
855     IN  int          inherit;       /* inherit flag */
856     OUT int          handle;        /* handle to the mapping */
857     IN  VARARG(name,unicode_str);   /* object name */
858 };
859
860
861 /* Get information about a file mapping */
862 struct get_mapping_info_request
863 {
864     REQUEST_HEADER;                 /* request header */
865     IN  int          handle;        /* handle to the mapping */
866     OUT int          size_high;     /* mapping size */
867     OUT int          size_low;      /* mapping size */
868     OUT int          protect;       /* protection flags */
869     OUT int          header_size;   /* header size (for VPROT_IMAGE mapping) */
870     OUT void*        base;          /* default base addr (for VPROT_IMAGE mapping) */
871     OUT int          shared_file;   /* shared mapping file handle */
872     OUT int          shared_size;   /* shared mapping size */
873 };
874
875
876 /* Create a device */
877 struct create_device_request
878 {
879     REQUEST_HEADER;                 /* request header */
880     IN  unsigned int access;        /* wanted access rights */
881     IN  int          inherit;       /* inherit flag */
882     IN  int          id;            /* client private id */
883     OUT int          handle;        /* handle to the device */
884 };
885
886
887 /* Create a snapshot */
888 struct create_snapshot_request
889 {
890     REQUEST_HEADER;                 /* request header */
891     IN  int          inherit;       /* inherit flag */
892     IN  int          flags;         /* snapshot flags (TH32CS_*) */
893     IN  void*        pid;           /* process id */
894     OUT int          handle;        /* handle to the snapshot */
895 };
896
897
898 /* Get the next process from a snapshot */
899 struct next_process_request
900 {
901     REQUEST_HEADER;                 /* request header */
902     IN  int          handle;        /* handle to the snapshot */
903     IN  int          reset;         /* reset snapshot position? */
904     OUT int          count;         /* process usage count */
905     OUT void*        pid;           /* process id */
906     OUT int          threads;       /* number of threads */
907     OUT int          priority;      /* process priority */
908 };
909
910
911 /* Get the next thread from a snapshot */
912 struct next_thread_request
913 {
914     REQUEST_HEADER;                 /* request header */
915     IN  int          handle;        /* handle to the snapshot */
916     IN  int          reset;         /* reset snapshot position? */
917     OUT int          count;         /* thread usage count */
918     OUT void*        pid;           /* process id */
919     OUT void*        tid;           /* thread id */
920     OUT int          base_pri;      /* base priority */
921     OUT int          delta_pri;     /* delta priority */
922 };
923
924
925 /* Get the next module from a snapshot */
926 struct next_module_request
927 {
928     REQUEST_HEADER;                 /* request header */
929     IN  int          handle;        /* handle to the snapshot */
930     IN  int          reset;         /* reset snapshot position? */
931     OUT void*        pid;           /* process id */
932     OUT void*        base;          /* module base address */
933 };
934
935
936 /* Wait for a debug event */
937 struct wait_debug_event_request
938 {
939     REQUEST_HEADER;                /* request header */
940     IN  int           timeout;     /* timeout in ms */
941     OUT void*         pid;         /* process id */
942     OUT void*         tid;         /* thread id */
943     OUT VARARG(event,debug_event); /* debug event data */
944 };
945
946
947 /* Send an exception event */
948 struct exception_event_request
949 {
950     REQUEST_HEADER;                /* request header */
951     IN  int              first;    /* first chance exception? */
952     OUT int              status;   /* event continuation status */
953     IN  VARARG(record,exc_event);  /* thread context followed by exception record */
954     OUT VARARG(context,context);   /* modified thread context */
955 };
956
957
958 /* Send an output string to the debugger */
959 struct output_debug_string_request
960 {
961     REQUEST_HEADER;                /* request header */
962     IN  void*         string;      /* string to display (in debugged process address space) */
963     IN  int           unicode;     /* is it Unicode? */
964     IN  int           length;      /* string length */
965 };
966
967
968 /* Continue a debug event */
969 struct continue_debug_event_request
970 {
971     REQUEST_HEADER;                /* request header */
972     IN  void*        pid;          /* process id to continue */
973     IN  void*        tid;          /* thread id to continue */
974     IN  int          status;       /* continuation status */
975 };
976
977
978 /* Start debugging an existing process */
979 struct debug_process_request
980 {
981     REQUEST_HEADER;                /* request header */
982     IN  void*        pid;          /* id of the process to debug */
983 };
984
985
986 /* Read data from a process address space */
987 struct read_process_memory_request
988 {
989     REQUEST_HEADER;                /* request header */
990     IN  int          handle;       /* process handle */
991     IN  void*        addr;         /* addr to read from (must be int-aligned) */
992     IN  int          len;          /* number of ints to read */
993     OUT VARARG(data,bytes);        /* result data */
994 };
995
996
997 /* Write data to a process address space */
998 struct write_process_memory_request
999 {
1000     REQUEST_HEADER;                /* request header */
1001     IN  int          handle;       /* process handle */
1002     IN  void*        addr;         /* addr to write to (must be int-aligned) */
1003     IN  int          len;          /* number of ints to write */
1004     IN  unsigned int first_mask;   /* mask for first word */
1005     IN  unsigned int last_mask;    /* mask for last word */
1006     IN  VARARG(data,bytes);        /* result data */
1007 };
1008
1009
1010 /* Create a registry key */
1011 struct create_key_request
1012 {
1013     REQUEST_HEADER;                /* request header */
1014     IN  int          parent;       /* handle to the parent key */
1015     IN  unsigned int access;       /* desired access rights */
1016     IN  unsigned int options;      /* creation options */
1017     IN  time_t       modif;        /* last modification time */
1018     OUT int          hkey;         /* handle to the created key */
1019     OUT int          created;      /* has it been newly created? */
1020     IN  VARARG(name,unicode_len_str);  /* key name */
1021     IN  VARARG(class,unicode_str);     /* class name */
1022 };
1023
1024 /* Open a registry key */
1025 struct open_key_request
1026 {
1027     REQUEST_HEADER;                /* request header */
1028     IN  int          parent;       /* handle to the parent key */
1029     IN  unsigned int access;       /* desired access rights */
1030     OUT int          hkey;         /* handle to the open key */
1031     IN  VARARG(name,unicode_str);  /* key name */
1032 };
1033
1034
1035 /* Delete a registry key */
1036 struct delete_key_request
1037 {
1038     REQUEST_HEADER;                /* request header */
1039     IN  int          hkey;         /* handle to the key */
1040 };
1041
1042
1043 /* Enumerate registry subkeys */
1044 struct enum_key_request
1045 {
1046     REQUEST_HEADER;                /* request header */
1047     IN  int          hkey;         /* handle to registry key */
1048     IN  int          index;        /* index of subkey (or -1 for current key) */
1049     IN  int          full;         /* return the full info? */
1050     OUT int          subkeys;      /* number of subkeys */
1051     OUT int          max_subkey;   /* longest subkey name */
1052     OUT int          max_class;    /* longest class name */
1053     OUT int          values;       /* number of values */
1054     OUT int          max_value;    /* longest value name */
1055     OUT int          max_data;     /* longest value data */
1056     OUT time_t       modif;        /* last modification time */
1057     OUT VARARG(name,unicode_len_str);  /* key name */
1058     OUT VARARG(class,unicode_str);     /* class name */
1059 };
1060
1061
1062 /* Set a value of a registry key */
1063 struct set_key_value_request
1064 {
1065     REQUEST_HEADER;                /* request header */
1066     IN  int          hkey;         /* handle to registry key */
1067     IN  int          type;         /* value type */
1068     IN  unsigned int total;        /* total value len */
1069     IN  unsigned int offset;       /* offset for setting data */
1070     IN  VARARG(name,unicode_len_str);  /* value name */
1071     IN  VARARG(data,bytes);        /* value data */
1072 };
1073
1074
1075 /* Retrieve the value of a registry key */
1076 struct get_key_value_request
1077 {
1078     REQUEST_HEADER;                /* request header */
1079     IN  int          hkey;         /* handle to registry key */
1080     IN  unsigned int offset;       /* offset for getting data */
1081     OUT int          type;         /* value type */
1082     OUT int          len;          /* value data len */
1083     IN  VARARG(name,unicode_len_str);  /* value name */
1084     OUT VARARG(data,bytes);        /* value data */
1085 };
1086
1087
1088 /* Enumerate a value of a registry key */
1089 struct enum_key_value_request
1090 {
1091     REQUEST_HEADER;                /* request header */
1092     IN  int          hkey;         /* handle to registry key */
1093     IN  int          index;        /* value index */
1094     IN  unsigned int offset;       /* offset for getting data */
1095     OUT int          type;         /* value type */
1096     OUT int          len;          /* value data len */
1097     OUT path_t       name;         /* value name */
1098     OUT unsigned char data[1];     /* value data */
1099 };
1100
1101
1102 /* Delete a value of a registry key */
1103 struct delete_key_value_request
1104 {
1105     REQUEST_HEADER;                /* request header */
1106     IN  int          hkey;         /* handle to registry key */
1107     IN  VARARG(name,unicode_str);  /* value name */
1108 };
1109
1110
1111 /* Load a registry branch from a file */
1112 struct load_registry_request
1113 {
1114     REQUEST_HEADER;                /* request header */
1115     IN  int          hkey;         /* root key to load to */
1116     IN  int          file;         /* file to load from */
1117     IN  VARARG(name,unicode_str);  /* subkey name */
1118 };
1119
1120
1121 /* Save a registry branch to a file */
1122 struct save_registry_request
1123 {
1124     REQUEST_HEADER;                /* request header */
1125     IN  int          hkey;         /* key to save */
1126     IN  int          file;         /* file to save to */
1127 };
1128
1129
1130 /* Save a registry branch at server exit */
1131 struct save_registry_atexit_request
1132 {
1133     REQUEST_HEADER;                /* request header */
1134     IN  int          hkey;         /* key to save */
1135     IN  VARARG(file,string);       /* file to save to */
1136 };
1137
1138
1139 /* Set the current and saving level for the registry */
1140 struct set_registry_levels_request
1141 {
1142     REQUEST_HEADER;                /* request header */
1143     IN  int          current;      /* new current level */
1144     IN  int          saving;       /* new saving level */
1145     IN  int          period;       /* duration between periodic saves (milliseconds) */
1146 };
1147
1148
1149 /* Create a waitable timer */
1150 struct create_timer_request
1151 {
1152     REQUEST_HEADER;                 /* request header */
1153     IN  int          inherit;       /* inherit flag */
1154     IN  int          manual;        /* manual reset */
1155     OUT int          handle;        /* handle to the timer */
1156     IN  VARARG(name,unicode_str);   /* object name */
1157 };
1158
1159
1160 /* Open a waitable timer */
1161 struct open_timer_request
1162 {
1163     REQUEST_HEADER;                 /* request header */
1164     IN  unsigned int access;        /* wanted access rights */
1165     IN  int          inherit;       /* inherit flag */
1166     OUT int          handle;        /* handle to the timer */
1167     IN  VARARG(name,unicode_str);   /* object name */
1168 };
1169
1170 /* Set a waitable timer */
1171 struct set_timer_request
1172 {
1173     REQUEST_HEADER;                 /* request header */
1174     IN  int          handle;        /* handle to the timer */
1175     IN  int          sec;           /* next expiration absolute time */
1176     IN  int          usec;          /* next expiration absolute time */
1177     IN  int          period;        /* timer period in ms */
1178     IN  void*        callback;      /* callback function */
1179     IN  void*        arg;           /* callback argument */
1180 };
1181
1182 /* Cancel a waitable timer */
1183 struct cancel_timer_request
1184 {
1185     REQUEST_HEADER;                 /* request header */
1186     IN  int          handle;        /* handle to the timer */
1187 };
1188
1189
1190 /* Retrieve the current context of a thread */
1191 struct get_thread_context_request
1192 {
1193     REQUEST_HEADER;                /* request header */
1194     IN  int          handle;       /* thread handle */
1195     IN  unsigned int flags;        /* context flags */
1196     OUT VARARG(context,context);   /* thread context */
1197 };
1198
1199
1200 /* Set the current context of a thread */
1201 struct set_thread_context_request
1202 {
1203     REQUEST_HEADER;                /* request header */
1204     IN  int          handle;       /* thread handle */
1205     IN  unsigned int flags;        /* context flags */
1206     IN  VARARG(context,context);   /* thread context */
1207 };
1208
1209
1210 /* Fetch a selector entry for a thread */
1211 struct get_selector_entry_request
1212 {
1213     REQUEST_HEADER;                /* request header */
1214     IN  int           handle;      /* thread handle */
1215     IN  int           entry;       /* LDT entry */
1216     OUT unsigned int  base;        /* selector base */
1217     OUT unsigned int  limit;       /* selector limit */
1218     OUT unsigned char flags;       /* selector flags */
1219 };
1220
1221
1222 /* Add an atom */
1223 struct add_atom_request
1224 {
1225     REQUEST_HEADER;                /* request header */
1226     IN  int           local;       /* is atom in local process table? */
1227     OUT int           atom;        /* resulting atom */
1228     IN  VARARG(name,unicode_str);  /* atom name */
1229 };
1230
1231
1232 /* Delete an atom */
1233 struct delete_atom_request
1234 {
1235     REQUEST_HEADER;                /* request header */
1236     IN  int           atom;        /* atom handle */
1237     IN  int           local;       /* is atom in local process table? */
1238 };
1239
1240
1241 /* Find an atom */
1242 struct find_atom_request
1243 {
1244     REQUEST_HEADER;                /* request header */
1245     IN  int          local;        /* is atom in local process table? */
1246     OUT int          atom;         /* atom handle */
1247     IN  VARARG(name,unicode_str);  /* atom name */
1248 };
1249
1250
1251 /* Get an atom name */
1252 struct get_atom_name_request
1253 {
1254     REQUEST_HEADER;                /* request header */
1255     IN  int          atom;         /* atom handle */
1256     IN  int          local;        /* is atom in local process table? */
1257     OUT int          count;        /* atom lock count */
1258     OUT VARARG(name,unicode_str);  /* atom name */
1259 };
1260
1261
1262 /* Init the process atom table */
1263 struct init_atom_table_request
1264 {
1265     REQUEST_HEADER;                /* request header */
1266     IN  int          entries;      /* number of entries */
1267 };
1268
1269
1270 /* Get the message queue of the current thread */
1271 struct get_msg_queue_request
1272 {
1273     REQUEST_HEADER;                /* request header */
1274     OUT int          handle;       /* handle to the queue */
1275 };
1276
1277 /* Wake up a message queue */
1278 struct wake_queue_request
1279 {
1280     REQUEST_HEADER;                /* request header */
1281     IN  int          handle;       /* handle to the queue */
1282     IN  unsigned int bits;         /* wake bits */
1283 };
1284
1285 /* Wait for a process to start waiting on input */
1286 struct wait_input_idle_request
1287 {
1288     REQUEST_HEADER;                /* request header */
1289     IN  int          handle;       /* process handle */
1290     IN  int          timeout;      /* timeout */
1291     OUT int          event;        /* handle to idle event */
1292 };
1293
1294 struct create_serial_request
1295 {
1296     REQUEST_HEADER;                /* request header */
1297     IN  unsigned int access;       /* wanted access rights */
1298     IN  int          inherit;      /* inherit flag */
1299     IN  unsigned int sharing;      /* sharing flags */
1300     OUT int          handle;       /* handle to the port */
1301     IN  VARARG(name,string);       /* file name */
1302 };
1303
1304 struct get_serial_info_request
1305 {
1306     REQUEST_HEADER;                /* request header */
1307     IN  int          handle;       /* handle to comm port */
1308     OUT unsigned int readinterval;
1309     OUT unsigned int readconst;
1310     OUT unsigned int readmult;
1311     OUT unsigned int writeconst;
1312     OUT unsigned int writemult;
1313     OUT unsigned int eventmask;
1314     OUT unsigned int commerror;
1315 };
1316
1317 struct set_serial_info_request
1318 {
1319     REQUEST_HEADER;                /* request header */
1320     IN  int          handle;       /* handle to comm port */
1321     IN  int          flags;        /* bitmask to set values (see below) */
1322     IN  unsigned int readinterval;
1323     IN  unsigned int readconst;
1324     IN  unsigned int readmult;
1325     IN  unsigned int writeconst;
1326     IN  unsigned int writemult;
1327     IN  unsigned int eventmask;
1328     IN  unsigned int commerror;
1329 };
1330 #define SERIALINFO_SET_TIMEOUTS  0x01
1331 #define SERIALINFO_SET_MASK      0x02
1332 #define SERIALINFO_SET_ERROR     0x04
1333
1334 struct create_async_request
1335 {
1336     REQUEST_HEADER;                /* request header */
1337     IN  int          file_handle;  /* handle to comm port */
1338     IN  void*        overlapped;
1339     IN  void*        buffer;
1340     IN  int          count;
1341     IN  void*        func;
1342     IN  int          type;
1343     OUT int          ov_handle;
1344 };
1345 #define ASYNC_TYPE_READ  0x01
1346 #define ASYNC_TYPE_WRITE 0x02
1347 #define ASYNC_TYPE_WAIT  0x03
1348
1349 /*
1350  * Used by service thread to tell the server that the current
1351  * operation has completed
1352  */
1353 struct async_result_request
1354 {
1355     REQUEST_HEADER;                /* request header */
1356     IN  int          ov_handle;
1357     IN  int          result;       /* NT status code */
1358 };
1359
1360 /* Everything below this line is generated automatically by tools/make_requests */
1361 /* ### make_requests begin ### */
1362
1363 enum request
1364 {
1365     REQ_NEW_PROCESS,
1366     REQ_WAIT_PROCESS,
1367     REQ_NEW_THREAD,
1368     REQ_BOOT_DONE,
1369     REQ_INIT_PROCESS,
1370     REQ_INIT_PROCESS_DONE,
1371     REQ_INIT_THREAD,
1372     REQ_GET_THREAD_BUFFER,
1373     REQ_TERMINATE_PROCESS,
1374     REQ_TERMINATE_THREAD,
1375     REQ_GET_PROCESS_INFO,
1376     REQ_SET_PROCESS_INFO,
1377     REQ_GET_THREAD_INFO,
1378     REQ_SET_THREAD_INFO,
1379     REQ_SUSPEND_THREAD,
1380     REQ_RESUME_THREAD,
1381     REQ_LOAD_DLL,
1382     REQ_UNLOAD_DLL,
1383     REQ_QUEUE_APC,
1384     REQ_GET_APC,
1385     REQ_CLOSE_HANDLE,
1386     REQ_GET_HANDLE_INFO,
1387     REQ_SET_HANDLE_INFO,
1388     REQ_DUP_HANDLE,
1389     REQ_OPEN_PROCESS,
1390     REQ_SELECT,
1391     REQ_CREATE_EVENT,
1392     REQ_EVENT_OP,
1393     REQ_OPEN_EVENT,
1394     REQ_CREATE_MUTEX,
1395     REQ_RELEASE_MUTEX,
1396     REQ_OPEN_MUTEX,
1397     REQ_CREATE_SEMAPHORE,
1398     REQ_RELEASE_SEMAPHORE,
1399     REQ_OPEN_SEMAPHORE,
1400     REQ_CREATE_FILE,
1401     REQ_ALLOC_FILE_HANDLE,
1402     REQ_GET_READ_FD,
1403     REQ_GET_WRITE_FD,
1404     REQ_SET_FILE_POINTER,
1405     REQ_TRUNCATE_FILE,
1406     REQ_SET_FILE_TIME,
1407     REQ_FLUSH_FILE,
1408     REQ_GET_FILE_INFO,
1409     REQ_LOCK_FILE,
1410     REQ_UNLOCK_FILE,
1411     REQ_CREATE_PIPE,
1412     REQ_CREATE_SOCKET,
1413     REQ_ACCEPT_SOCKET,
1414     REQ_SET_SOCKET_EVENT,
1415     REQ_GET_SOCKET_EVENT,
1416     REQ_ENABLE_SOCKET_EVENT,
1417     REQ_ALLOC_CONSOLE,
1418     REQ_FREE_CONSOLE,
1419     REQ_OPEN_CONSOLE,
1420     REQ_SET_CONSOLE_FD,
1421     REQ_GET_CONSOLE_MODE,
1422     REQ_SET_CONSOLE_MODE,
1423     REQ_SET_CONSOLE_INFO,
1424     REQ_GET_CONSOLE_INFO,
1425     REQ_WRITE_CONSOLE_INPUT,
1426     REQ_READ_CONSOLE_INPUT,
1427     REQ_CREATE_CHANGE_NOTIFICATION,
1428     REQ_CREATE_MAPPING,
1429     REQ_OPEN_MAPPING,
1430     REQ_GET_MAPPING_INFO,
1431     REQ_CREATE_DEVICE,
1432     REQ_CREATE_SNAPSHOT,
1433     REQ_NEXT_PROCESS,
1434     REQ_NEXT_THREAD,
1435     REQ_NEXT_MODULE,
1436     REQ_WAIT_DEBUG_EVENT,
1437     REQ_EXCEPTION_EVENT,
1438     REQ_OUTPUT_DEBUG_STRING,
1439     REQ_CONTINUE_DEBUG_EVENT,
1440     REQ_DEBUG_PROCESS,
1441     REQ_READ_PROCESS_MEMORY,
1442     REQ_WRITE_PROCESS_MEMORY,
1443     REQ_CREATE_KEY,
1444     REQ_OPEN_KEY,
1445     REQ_DELETE_KEY,
1446     REQ_ENUM_KEY,
1447     REQ_SET_KEY_VALUE,
1448     REQ_GET_KEY_VALUE,
1449     REQ_ENUM_KEY_VALUE,
1450     REQ_DELETE_KEY_VALUE,
1451     REQ_LOAD_REGISTRY,
1452     REQ_SAVE_REGISTRY,
1453     REQ_SAVE_REGISTRY_ATEXIT,
1454     REQ_SET_REGISTRY_LEVELS,
1455     REQ_CREATE_TIMER,
1456     REQ_OPEN_TIMER,
1457     REQ_SET_TIMER,
1458     REQ_CANCEL_TIMER,
1459     REQ_GET_THREAD_CONTEXT,
1460     REQ_SET_THREAD_CONTEXT,
1461     REQ_GET_SELECTOR_ENTRY,
1462     REQ_ADD_ATOM,
1463     REQ_DELETE_ATOM,
1464     REQ_FIND_ATOM,
1465     REQ_GET_ATOM_NAME,
1466     REQ_INIT_ATOM_TABLE,
1467     REQ_GET_MSG_QUEUE,
1468     REQ_WAKE_QUEUE,
1469     REQ_WAIT_INPUT_IDLE,
1470     REQ_CREATE_SERIAL,
1471     REQ_GET_SERIAL_INFO,
1472     REQ_SET_SERIAL_INFO,
1473     REQ_CREATE_ASYNC,
1474     REQ_ASYNC_RESULT,
1475     REQ_NB_REQUESTS
1476 };
1477
1478 union generic_request
1479 {
1480     struct request_max_size max_size;
1481     struct request_header header;
1482     struct new_process_request new_process;
1483     struct wait_process_request wait_process;
1484     struct new_thread_request new_thread;
1485     struct boot_done_request boot_done;
1486     struct init_process_request init_process;
1487     struct init_process_done_request init_process_done;
1488     struct init_thread_request init_thread;
1489     struct get_thread_buffer_request get_thread_buffer;
1490     struct terminate_process_request terminate_process;
1491     struct terminate_thread_request terminate_thread;
1492     struct get_process_info_request get_process_info;
1493     struct set_process_info_request set_process_info;
1494     struct get_thread_info_request get_thread_info;
1495     struct set_thread_info_request set_thread_info;
1496     struct suspend_thread_request suspend_thread;
1497     struct resume_thread_request resume_thread;
1498     struct load_dll_request load_dll;
1499     struct unload_dll_request unload_dll;
1500     struct queue_apc_request queue_apc;
1501     struct get_apc_request get_apc;
1502     struct close_handle_request close_handle;
1503     struct get_handle_info_request get_handle_info;
1504     struct set_handle_info_request set_handle_info;
1505     struct dup_handle_request dup_handle;
1506     struct open_process_request open_process;
1507     struct select_request select;
1508     struct create_event_request create_event;
1509     struct event_op_request event_op;
1510     struct open_event_request open_event;
1511     struct create_mutex_request create_mutex;
1512     struct release_mutex_request release_mutex;
1513     struct open_mutex_request open_mutex;
1514     struct create_semaphore_request create_semaphore;
1515     struct release_semaphore_request release_semaphore;
1516     struct open_semaphore_request open_semaphore;
1517     struct create_file_request create_file;
1518     struct alloc_file_handle_request alloc_file_handle;
1519     struct get_read_fd_request get_read_fd;
1520     struct get_write_fd_request get_write_fd;
1521     struct set_file_pointer_request set_file_pointer;
1522     struct truncate_file_request truncate_file;
1523     struct set_file_time_request set_file_time;
1524     struct flush_file_request flush_file;
1525     struct get_file_info_request get_file_info;
1526     struct lock_file_request lock_file;
1527     struct unlock_file_request unlock_file;
1528     struct create_pipe_request create_pipe;
1529     struct create_socket_request create_socket;
1530     struct accept_socket_request accept_socket;
1531     struct set_socket_event_request set_socket_event;
1532     struct get_socket_event_request get_socket_event;
1533     struct enable_socket_event_request enable_socket_event;
1534     struct alloc_console_request alloc_console;
1535     struct free_console_request free_console;
1536     struct open_console_request open_console;
1537     struct set_console_fd_request set_console_fd;
1538     struct get_console_mode_request get_console_mode;
1539     struct set_console_mode_request set_console_mode;
1540     struct set_console_info_request set_console_info;
1541     struct get_console_info_request get_console_info;
1542     struct write_console_input_request write_console_input;
1543     struct read_console_input_request read_console_input;
1544     struct create_change_notification_request create_change_notification;
1545     struct create_mapping_request create_mapping;
1546     struct open_mapping_request open_mapping;
1547     struct get_mapping_info_request get_mapping_info;
1548     struct create_device_request create_device;
1549     struct create_snapshot_request create_snapshot;
1550     struct next_process_request next_process;
1551     struct next_thread_request next_thread;
1552     struct next_module_request next_module;
1553     struct wait_debug_event_request wait_debug_event;
1554     struct exception_event_request exception_event;
1555     struct output_debug_string_request output_debug_string;
1556     struct continue_debug_event_request continue_debug_event;
1557     struct debug_process_request debug_process;
1558     struct read_process_memory_request read_process_memory;
1559     struct write_process_memory_request write_process_memory;
1560     struct create_key_request create_key;
1561     struct open_key_request open_key;
1562     struct delete_key_request delete_key;
1563     struct enum_key_request enum_key;
1564     struct set_key_value_request set_key_value;
1565     struct get_key_value_request get_key_value;
1566     struct enum_key_value_request enum_key_value;
1567     struct delete_key_value_request delete_key_value;
1568     struct load_registry_request load_registry;
1569     struct save_registry_request save_registry;
1570     struct save_registry_atexit_request save_registry_atexit;
1571     struct set_registry_levels_request set_registry_levels;
1572     struct create_timer_request create_timer;
1573     struct open_timer_request open_timer;
1574     struct set_timer_request set_timer;
1575     struct cancel_timer_request cancel_timer;
1576     struct get_thread_context_request get_thread_context;
1577     struct set_thread_context_request set_thread_context;
1578     struct get_selector_entry_request get_selector_entry;
1579     struct add_atom_request add_atom;
1580     struct delete_atom_request delete_atom;
1581     struct find_atom_request find_atom;
1582     struct get_atom_name_request get_atom_name;
1583     struct init_atom_table_request init_atom_table;
1584     struct get_msg_queue_request get_msg_queue;
1585     struct wake_queue_request wake_queue;
1586     struct wait_input_idle_request wait_input_idle;
1587     struct create_serial_request create_serial;
1588     struct get_serial_info_request get_serial_info;
1589     struct set_serial_info_request set_serial_info;
1590     struct create_async_request create_async;
1591     struct async_result_request async_result;
1592 };
1593
1594 #define SERVER_PROTOCOL_VERSION 28
1595
1596 /* ### make_requests end ### */
1597 /* Everything above this line is generated automatically by tools/make_requests */
1598
1599 #undef REQUEST_HEADER
1600 #undef VARARG
1601
1602 /* format of the server buffer */
1603 struct server_buffer_info
1604 {
1605     volatile unsigned int cur_req;    /* offset of the current request */
1606     volatile unsigned int cur_pos;    /* first available position in buffer */
1607 };
1608
1609 /* client-side functions */
1610
1611 #ifndef __WINE_SERVER__
1612
1613 #include "thread.h"
1614 #include "ntddk.h"
1615 #include "wine/exception.h"
1616
1617 /* client communication functions */
1618
1619 extern unsigned int wine_server_call( enum request req );
1620 extern unsigned int server_call_fd( enum request req, int fd_out, int *fd_in );
1621 extern void server_protocol_error( const char *err, ... ) WINE_NORETURN;
1622 extern void *wine_server_alloc_req( size_t fixed_size, size_t var_size );
1623 extern const char *get_config_dir(void);
1624
1625 /* compatibility macros */
1626 #define server_alloc_req(f,v) wine_server_alloc_req(f,v)
1627 #define server_call_noerr(req) wine_server_call(req)
1628
1629 /* get a pointer to the request buffer */
1630 static inline void WINE_UNUSED *get_req_buffer(void)
1631 {
1632     return NtCurrentTeb()->buffer;
1633 }
1634
1635 /* maximum remaining size in the server buffer */
1636 static inline int WINE_UNUSED server_remaining( const void *ptr )
1637 {
1638     return (char *)NtCurrentTeb()->buffer_info - (char *)ptr;
1639 }
1640
1641 /* do a server call and set the last error code */
1642 inline static unsigned int server_call( enum request req )
1643 {
1644     unsigned int res = wine_server_call( req );
1645     if (res) SetLastError( RtlNtStatusToDosError(res) );
1646     return res;
1647 }
1648
1649 /* get a pointer to the variable part of the request */
1650 inline static void *server_data_ptr( const void *req )
1651 {
1652     return (union generic_request *)req + 1;
1653 }
1654
1655 /* get the size of the variable part of the request */
1656 inline static size_t server_data_size( const void *req )
1657 {
1658     return ((struct request_header *)req)->var_size;
1659 }
1660
1661
1662 /* exception support for server calls */
1663
1664 extern DWORD __wine_server_exception_handler( PEXCEPTION_RECORD record, EXCEPTION_FRAME *frame,
1665                                               CONTEXT *context, EXCEPTION_FRAME **pdispatcher );
1666
1667 struct __server_exception_frame
1668 {
1669     EXCEPTION_FRAME           frame;
1670     struct server_buffer_info info;  /* saved buffer information */
1671 };
1672
1673 #define SERVER_START_REQ \
1674     do { \
1675         struct __server_exception_frame __f; \
1676         __f.frame.Handler = __wine_server_exception_handler; \
1677         __f.info = *NtCurrentTeb()->buffer_info; \
1678         __wine_push_frame( &__f.frame ); \
1679         do {
1680
1681 #define SERVER_END_REQ \
1682         } while(0); \
1683         *NtCurrentTeb()->buffer_info = __f.info; \
1684         __wine_pop_frame( &__f.frame ); \
1685     } while(0);
1686
1687 extern int CLIENT_InitServer(void);
1688 extern int CLIENT_BootDone( int debug_level );
1689 extern int CLIENT_IsBootThread(void);
1690 extern int CLIENT_InitThread(void);
1691 #endif  /* __WINE_SERVER__ */
1692
1693 #endif  /* __WINE_SERVER_H */