- better support for ExecuteBuffers
[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 /* Duplicate a handle */
179 struct dup_handle_request
180 {
181     int          src_process;  /* src process handle */
182     int          src_handle;   /* src handle to duplicate */
183     int          dst_process;  /* dst process handle */
184     int          dst_handle;   /* handle to duplicate to (or -1 for any) */
185     unsigned int access;       /* wanted access rights */
186     int          inherit;      /* inherit flag */
187     int          options;      /* duplicate options (see below) */
188 };
189 #define DUP_HANDLE_CLOSE_SOURCE  DUPLICATE_CLOSE_SOURCE
190 #define DUP_HANDLE_SAME_ACCESS   DUPLICATE_SAME_ACCESS
191 #define DUP_HANDLE_MAKE_GLOBAL   0x80000000  /* Not a Windows flag */
192 struct dup_handle_reply
193 {
194     int          handle;       /* duplicated handle in dst process */
195 };
196
197
198 /* Open a handle to a process */
199 struct open_process_request
200 {
201     void*        pid;          /* process id to open */
202     unsigned int access;       /* wanted access rights */
203     int          inherit;      /* inherit flag */
204 };
205 struct open_process_reply
206 {
207     int          handle;       /* handle to the process */
208 };
209
210
211 /* Wait for handles */
212 struct select_request
213 {
214     int          count;        /* handles count */
215     int          flags;        /* wait flags (see below) */
216     int          timeout;      /* timeout in ms */
217     /* int handles[] */
218 };
219 struct select_reply
220 {
221     int          signaled;     /* signaled handle */
222 /*  void*        apcs[]; */    /* async procedures to call */
223 };
224 #define SELECT_ALL       1
225 #define SELECT_ALERTABLE 2
226 #define SELECT_TIMEOUT   4
227
228
229 /* Create an event */
230 struct create_event_request
231 {
232     int          manual_reset;  /* manual reset event */
233     int          initial_state; /* initial state of the event */
234     int          inherit;       /* inherit flag */
235     char         name[0];       /* event name */
236 };
237 struct create_event_reply
238 {
239     int          handle;        /* handle to the event */
240 };
241
242 /* Event operation */
243 struct event_op_request
244 {
245     int           handle;       /* handle to event */
246     int           op;           /* event operation (see below) */
247 };
248 enum event_op { PULSE_EVENT, SET_EVENT, RESET_EVENT };
249
250
251 /* Create a mutex */
252 struct create_mutex_request
253 {
254     int          owned;         /* initially owned? */
255     int          inherit;       /* inherit flag */
256     char         name[0];       /* mutex name */
257 };
258 struct create_mutex_reply
259 {
260     int          handle;        /* handle to the mutex */
261 };
262
263
264 /* Release a mutex */
265 struct release_mutex_request
266 {
267     int          handle;        /* handle to the mutex */
268 };
269
270
271 /* Create a semaphore */
272 struct create_semaphore_request
273 {
274     unsigned int initial;       /* initial count */
275     unsigned int max;           /* maximum count */
276     int          inherit;       /* inherit flag */
277     char         name[0];       /* semaphore name */
278 };
279 struct create_semaphore_reply
280 {
281     int          handle;        /* handle to the semaphore */
282 };
283
284
285 /* Release a semaphore */
286 struct release_semaphore_request
287 {
288     int          handle;        /* handle to the semaphore */
289     unsigned int count;         /* count to add to semaphore */
290 };
291 struct release_semaphore_reply
292 {
293     unsigned int prev_count;    /* previous semaphore count */
294 };
295
296
297 /* Open a named object (event, mutex, semaphore) */
298 struct open_named_obj_request
299 {
300     int          type;          /* object type (see below) */
301     unsigned int access;        /* wanted access rights */
302     int          inherit;       /* inherit flag */
303     char         name[0];       /* object name */
304 };
305 enum open_named_obj { OPEN_EVENT, OPEN_MUTEX, OPEN_SEMAPHORE, OPEN_MAPPING };
306
307 struct open_named_obj_reply
308 {
309     int          handle;        /* handle to the object */
310 };
311
312
313 /* Create a file */
314 struct create_file_request
315 {
316     unsigned int access;        /* wanted access rights */
317     int          inherit;       /* inherit flag */
318     unsigned int sharing;       /* sharing flags */
319     int          create;        /* file create action */
320     unsigned int attrs;         /* file attributes for creation */
321     char         name[0];       /* file name */
322 };
323 struct create_file_reply
324 {
325     int          handle;        /* handle to the file */
326 };
327
328
329 /* Get a Unix fd to read from a file */
330 struct get_read_fd_request
331 {
332     int          handle;        /* handle to the file */
333 };
334
335
336 /* Get a Unix fd to write to a file */
337 struct get_write_fd_request
338 {
339     int          handle;        /* handle to the file */
340 };
341
342
343 /* Set a file current position */
344 struct set_file_pointer_request
345 {
346     int          handle;        /* handle to the file */
347     int          low;           /* position low word */
348     int          high;          /* position high word */
349     int          whence;        /* whence to seek */
350 };
351 struct set_file_pointer_reply
352 {
353     int          low;           /* new position low word */
354     int          high;          /* new position high word */
355 };
356
357
358 /* Truncate (or extend) a file */
359 struct truncate_file_request
360 {
361     int          handle;        /* handle to the file */
362 };
363
364
365 /* Set a file access and modification times */
366 struct set_file_time_request
367 {
368     int          handle;        /* handle to the file */
369     time_t       access_time;   /* last access time */
370     time_t       write_time;    /* last write time */
371 };
372
373
374 /* Flush a file buffers */
375 struct flush_file_request
376 {
377     int          handle;        /* handle to the file */
378 };
379
380
381 /* Get information about a file */
382 struct get_file_info_request
383 {
384     int          handle;        /* handle to the file */
385 };
386 struct get_file_info_reply
387 {
388     int          type;          /* file type */
389     int          attr;          /* file attributes */
390     time_t       access_time;   /* last access time */
391     time_t       write_time;    /* last write time */
392     int          size_high;     /* file size */
393     int          size_low;      /* file size */
394     int          links;         /* number of links */
395     int          index_high;    /* unique index */
396     int          index_low;     /* unique index */
397     unsigned int serial;        /* volume serial number */
398 };
399
400
401 /* Lock a region of a file */
402 struct lock_file_request
403 {
404     int          handle;        /* handle to the file */
405     unsigned int offset_low;    /* offset of start of lock */
406     unsigned int offset_high;   /* offset of start of lock */
407     unsigned int count_low;     /* count of bytes to lock */
408     unsigned int count_high;    /* count of bytes to lock */
409 };
410
411
412 /* Unlock a region of a file */
413 struct unlock_file_request
414 {
415     int          handle;        /* handle to the file */
416     unsigned int offset_low;    /* offset of start of unlock */
417     unsigned int offset_high;   /* offset of start of unlock */
418     unsigned int count_low;     /* count of bytes to unlock */
419     unsigned int count_high;    /* count of bytes to unlock */
420 };
421
422
423 /* Create an anonymous pipe */
424 struct create_pipe_request
425 {
426     int          inherit;       /* inherit flag */
427 };
428 struct create_pipe_reply
429 {
430     int          handle_read;   /* handle to the read-side of the pipe */
431     int          handle_write;  /* handle to the write-side of the pipe */
432 };
433
434
435 /* Allocate a console for the current process */
436 struct alloc_console_request
437 {
438 };
439
440
441 /* Free the console of the current process */
442 struct free_console_request
443 {
444 };
445
446
447 /* Open a handle to the process console */
448 struct open_console_request
449 {
450     int          output;        /* input or output? */
451     unsigned int access;        /* wanted access rights */
452     int          inherit;       /* inherit flag */
453 };
454 struct open_console_reply
455 {
456     int          handle;        /* handle to the console */
457 };
458
459
460 /* Set a console file descriptor */
461 struct set_console_fd_request
462 {
463     int          handle;        /* handle to the console */
464     int          pid;           /* pid of xterm (hack) */
465 };
466
467
468 /* Get a console mode (input or output) */
469 struct get_console_mode_request
470 {
471     int          handle;        /* handle to the console */
472 };
473 struct get_console_mode_reply
474 {
475     int          mode;          /* console mode */
476 };
477
478
479 /* Set a console mode (input or output) */
480 struct set_console_mode_request
481 {
482     int          handle;        /* handle to the console */
483     int          mode;          /* console mode */
484 };
485
486
487 /* Set info about a console (output only) */
488 struct set_console_info_request
489 {
490     int          handle;        /* handle to the console */
491     int          mask;          /* setting mask (see below) */
492     int          cursor_size;   /* size of cursor (percentage filled) */
493     int          cursor_visible;/* cursor visibility flag */
494     char         title[0];      /* console title */
495 };
496 #define SET_CONSOLE_INFO_CURSOR 0x01
497 #define SET_CONSOLE_INFO_TITLE  0x02
498
499 /* Get info about a console (output only) */
500 struct get_console_info_request
501 {
502     int          handle;        /* handle to the console */
503 };
504 struct get_console_info_reply
505 {
506     int          cursor_size;   /* size of cursor (percentage filled) */
507     int          cursor_visible;/* cursor visibility flag */
508     int          pid;           /* pid of xterm (hack) */
509 /*  char         title[0]; */   /* console title */
510 };
511
512
513 /* Create a change notification */
514 struct create_change_notification_request
515 {
516     int          subtree;       /* watch all the subtree */
517     int          filter;        /* notification filter */
518 };
519 struct create_change_notification_reply
520 {
521     int          handle;        /* handle to the change notification */
522 };
523
524
525 /* Create a file mapping */
526 struct create_mapping_request
527 {
528     int          size_high;     /* mapping size */
529     int          size_low;      /* mapping size */
530     int          protect;       /* protection flags (see below) */
531     int          handle;        /* file handle */
532     char         name[0];       /* object name */
533 };
534 struct create_mapping_reply
535 {
536     int          handle;        /* handle to the mapping */
537 };
538 /* protection flags */
539 #define VPROT_READ       0x01
540 #define VPROT_WRITE      0x02
541 #define VPROT_EXEC       0x04
542 #define VPROT_WRITECOPY  0x08
543 #define VPROT_GUARD      0x10
544 #define VPROT_NOCACHE    0x20
545 #define VPROT_COMMITTED  0x40
546
547
548 /* Get information about a file mapping */
549 struct get_mapping_info_request
550 {
551     int          handle;        /* handle to the mapping */
552 };
553 struct get_mapping_info_reply
554 {
555     int          size_high;     /* mapping size */
556     int          size_low;      /* mapping size */
557     int          protect;       /* protection flags */
558 };
559
560
561 /* Create a device */
562 struct create_device_request
563 {
564     unsigned int access;        /* wanted access rights */
565     int          inherit;       /* inherit flag */
566     int          id;            /* client private id */
567 };
568 struct create_device_reply
569 {
570     int          handle;        /* handle to the device */
571 };
572
573
574 /* client-side functions */
575
576 #ifndef __WINE_SERVER__
577
578 #include "server/request.h"
579
580 /* client communication functions */
581 extern void CLIENT_SendRequest( enum request req, int pass_fd,
582                                 int n, ... /* arg_1, len_1, etc. */ );
583 extern unsigned int CLIENT_WaitReply( int *len, int *passed_fd,
584                                       int n, ... /* arg_1, len_1, etc. */ );
585 extern unsigned int CLIENT_WaitSimpleReply( void *reply, int len, int *passed_fd );
586
587 struct _THDB;
588 extern int CLIENT_NewThread( struct _THDB *thdb, int *thandle, int *phandle );
589 extern int CLIENT_SetDebug( int level );
590 extern int CLIENT_InitThread(void);
591 extern int CLIENT_CloseHandle( int handle );
592 extern int CLIENT_DuplicateHandle( int src_process, int src_handle, int dst_process,
593                                    int dst_handle, DWORD access, BOOL32 inherit, DWORD options );
594 extern int CLIENT_OpenProcess( void *pid, DWORD access, BOOL32 inherit );
595 #endif  /* __WINE_SERVER__ */
596
597 #endif  /* __WINE_SERVER_H */