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