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