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