Improved GetRandomRegion().
[wine/wine-kai.git] / include / server.h
blobc1e922689ab94b9b07872d23dc78d6361243acf9
1 /*
2 * Wine server definitions
4 * Copyright (C) 1998 Alexandre Julliard
5 */
7 #ifndef __WINE_SERVER_H
8 #define __WINE_SERVER_H
10 #include <stdlib.h>
11 #include <time.h>
13 /* Request structures */
15 /* Following are the definitions of all the client<->server */
16 /* communication format; if you make any change in this file, */
17 /* you must run tools/make_requests again. */
20 /* These empty macros are used by tools/make_requests */
21 /* to generate the request/reply tracing functions */
22 #define IN /*nothing*/
23 #define OUT /*nothing*/
26 /* Create a new process from the context of the parent */
27 struct new_process_request
29 IN int inherit; /* inherit flag */
30 IN int inherit_all; /* inherit all handles from parent */
31 IN int create_flags; /* creation flags */
32 IN int start_flags; /* flags from startup info */
33 IN int hstdin; /* handle for stdin */
34 IN int hstdout; /* handle for stdout */
35 IN int hstderr; /* handle for stderr */
36 IN int cmd_show; /* main window show mode */
37 IN void* env_ptr; /* pointer to environment (FIXME: hack) */
38 OUT void* pid; /* process id */
39 OUT int handle; /* process handle (in the current process) */
40 IN char cmdline[1]; /* command line */
44 /* Create a new thread from the context of the parent */
45 struct new_thread_request
47 IN void* pid; /* process id for the new thread */
48 IN int suspend; /* new thread should be suspended on creation */
49 IN int inherit; /* inherit flag */
50 OUT void* tid; /* thread id */
51 OUT int handle; /* thread handle (in the current process) */
55 /* Set the server debug level */
56 struct set_debug_request
58 IN int level; /* New debug level */
62 /* Initialize a process; called from the new process context */
63 struct init_process_request
65 OUT int start_flags; /* flags from startup info */
66 OUT int hstdin; /* handle for stdin */
67 OUT int hstdout; /* handle for stdout */
68 OUT int hstderr; /* handle for stderr */
69 OUT int cmd_show; /* main window show mode */
70 OUT void* env_ptr; /* pointer to environment (FIXME: hack) */
71 OUT char cmdline[1]; /* command line */
75 /* Initialize a thread; called from the child after fork()/clone() */
76 struct init_thread_request
78 IN int unix_pid; /* Unix pid of new thread */
79 IN void* teb; /* TEB of new thread (in thread address space) */
80 OUT void* pid; /* process id of the new thread's process */
81 OUT void* tid; /* thread id of the new thread */
85 /* Retrieve the thread buffer file descriptor */
86 /* The reply to this request is the first thing a newly */
87 /* created thread gets (without having to request it) */
88 struct get_thread_buffer_request
90 IN int dummy;
94 /* Terminate a process */
95 struct terminate_process_request
97 IN int handle; /* process handle to terminate */
98 IN int exit_code; /* process exit code */
102 /* Terminate a thread */
103 struct terminate_thread_request
105 IN int handle; /* thread handle to terminate */
106 IN int exit_code; /* thread exit code */
110 /* Retrieve information about a process */
111 struct get_process_info_request
113 IN int handle; /* process handle */
114 OUT void* pid; /* server process id */
115 OUT int exit_code; /* process exit code */
116 OUT int priority; /* priority class */
117 OUT int process_affinity; /* process affinity mask */
118 OUT int system_affinity; /* system affinity mask */
122 /* Set a process informations */
123 struct set_process_info_request
125 IN int handle; /* process handle */
126 IN int mask; /* setting mask (see below) */
127 IN int priority; /* priority class */
128 IN int affinity; /* affinity mask */
130 #define SET_PROCESS_INFO_PRIORITY 0x01
131 #define SET_PROCESS_INFO_AFFINITY 0x02
134 /* Retrieve information about a thread */
135 struct get_thread_info_request
137 IN int handle; /* thread handle */
138 OUT void* tid; /* server thread id */
139 OUT int exit_code; /* thread exit code */
140 OUT int priority; /* thread priority level */
144 /* Set a thread informations */
145 struct set_thread_info_request
147 IN int handle; /* thread handle */
148 IN int mask; /* setting mask (see below) */
149 IN int priority; /* priority class */
150 IN int affinity; /* affinity mask */
152 #define SET_THREAD_INFO_PRIORITY 0x01
153 #define SET_THREAD_INFO_AFFINITY 0x02
156 /* Suspend a thread */
157 struct suspend_thread_request
159 IN int handle; /* thread handle */
160 OUT int count; /* new suspend count */
164 /* Resume a thread */
165 struct resume_thread_request
167 IN int handle; /* thread handle */
168 OUT int count; /* new suspend count */
172 /* Debugger support: freeze / unfreeze */
173 struct debugger_request
175 IN int op; /* operation type */
178 enum debugger_op { DEBUGGER_FREEZE_ALL, DEBUGGER_UNFREEZE_ALL };
181 /* Queue an APC for a thread */
182 struct queue_apc_request
184 IN int handle; /* thread handle */
185 IN void* func; /* function to call */
186 IN void* param; /* param for function to call */
190 /* Get list of APC to call */
191 struct get_apcs_request
193 OUT int count; /* number of apcs */
194 OUT void* apcs[1]; /* async procedures to call */
198 /* Close a handle for the current process */
199 struct close_handle_request
201 IN int handle; /* handle to close */
205 /* Get information about a handle */
206 struct get_handle_info_request
208 IN int handle; /* handle we are interested in */
209 OUT int flags; /* handle flags */
213 /* Set a handle information */
214 struct set_handle_info_request
216 IN int handle; /* handle we are interested in */
217 IN int flags; /* new handle flags */
218 IN int mask; /* mask for flags to set */
222 /* Duplicate a handle */
223 struct dup_handle_request
225 IN int src_process; /* src process handle */
226 IN int src_handle; /* src handle to duplicate */
227 IN int dst_process; /* dst process handle */
228 IN unsigned int access; /* wanted access rights */
229 IN int inherit; /* inherit flag */
230 IN int options; /* duplicate options (see below) */
231 OUT int handle; /* duplicated handle in dst process */
233 #define DUP_HANDLE_CLOSE_SOURCE DUPLICATE_CLOSE_SOURCE
234 #define DUP_HANDLE_SAME_ACCESS DUPLICATE_SAME_ACCESS
235 #define DUP_HANDLE_MAKE_GLOBAL 0x80000000 /* Not a Windows flag */
238 /* Open a handle to a process */
239 struct open_process_request
241 IN void* pid; /* process id to open */
242 IN unsigned int access; /* wanted access rights */
243 IN int inherit; /* inherit flag */
244 OUT int handle; /* handle to the process */
248 /* Wait for handles */
249 struct select_request
251 IN int count; /* handles count */
252 IN int flags; /* wait flags (see below) */
253 IN int timeout; /* timeout in ms */
254 OUT int signaled; /* signaled handle */
255 IN int handles[1]; /* handles to select on */
257 #define SELECT_ALL 1
258 #define SELECT_ALERTABLE 2
259 #define SELECT_TIMEOUT 4
262 /* Create an event */
263 struct create_event_request
265 IN int manual_reset; /* manual reset event */
266 IN int initial_state; /* initial state of the event */
267 IN int inherit; /* inherit flag */
268 OUT int handle; /* handle to the event */
269 IN char name[1]; /* event name */
272 /* Event operation */
273 struct event_op_request
275 IN int handle; /* handle to event */
276 IN int op; /* event operation (see below) */
278 enum event_op { PULSE_EVENT, SET_EVENT, RESET_EVENT };
281 /* Open an event */
282 struct open_event_request
284 IN unsigned int access; /* wanted access rights */
285 IN int inherit; /* inherit flag */
286 OUT int handle; /* handle to the event */
287 IN char name[1]; /* object name */
291 /* Create a mutex */
292 struct create_mutex_request
294 IN int owned; /* initially owned? */
295 IN int inherit; /* inherit flag */
296 OUT int handle; /* handle to the mutex */
297 IN char name[1]; /* mutex name */
301 /* Release a mutex */
302 struct release_mutex_request
304 IN int handle; /* handle to the mutex */
308 /* Open a mutex */
309 struct open_mutex_request
311 IN unsigned int access; /* wanted access rights */
312 IN int inherit; /* inherit flag */
313 OUT int handle; /* handle to the mutex */
314 IN char name[1]; /* object name */
318 /* Create a semaphore */
319 struct create_semaphore_request
321 IN unsigned int initial; /* initial count */
322 IN unsigned int max; /* maximum count */
323 IN int inherit; /* inherit flag */
324 OUT int handle; /* handle to the semaphore */
325 IN char name[1]; /* semaphore name */
329 /* Release a semaphore */
330 struct release_semaphore_request
332 IN int handle; /* handle to the semaphore */
333 IN unsigned int count; /* count to add to semaphore */
334 OUT unsigned int prev_count; /* previous semaphore count */
338 /* Open a semaphore */
339 struct open_semaphore_request
341 IN unsigned int access; /* wanted access rights */
342 IN int inherit; /* inherit flag */
343 OUT int handle; /* handle to the semaphore */
344 IN char name[1]; /* object name */
348 /* Create a file */
349 struct create_file_request
351 IN unsigned int access; /* wanted access rights */
352 IN int inherit; /* inherit flag */
353 IN unsigned int sharing; /* sharing flags */
354 IN int create; /* file create action */
355 IN unsigned int attrs; /* file attributes for creation */
356 OUT int handle; /* handle to the file */
357 IN char name[1]; /* file name */
361 /* Allocate a file handle for a Unix fd */
362 struct alloc_file_handle_request
364 IN unsigned int access; /* wanted access rights */
365 OUT int handle; /* handle to the file */
369 /* Get a Unix fd to read from a file */
370 struct get_read_fd_request
372 IN int handle; /* handle to the file */
376 /* Get a Unix fd to write to a file */
377 struct get_write_fd_request
379 IN int handle; /* handle to the file */
383 /* Set a file current position */
384 struct set_file_pointer_request
386 IN int handle; /* handle to the file */
387 IN int low; /* position low word */
388 IN int high; /* position high word */
389 IN int whence; /* whence to seek */
390 OUT int new_low; /* new position low word */
391 OUT int new_high; /* new position high word */
395 /* Truncate (or extend) a file */
396 struct truncate_file_request
398 IN int handle; /* handle to the file */
402 /* Set a file access and modification times */
403 struct set_file_time_request
405 IN int handle; /* handle to the file */
406 IN time_t access_time; /* last access time */
407 IN time_t write_time; /* last write time */
411 /* Flush a file buffers */
412 struct flush_file_request
414 IN int handle; /* handle to the file */
418 /* Get information about a file */
419 struct get_file_info_request
421 IN int handle; /* handle to the file */
422 OUT int type; /* file type */
423 OUT int attr; /* file attributes */
424 OUT time_t access_time; /* last access time */
425 OUT time_t write_time; /* last write time */
426 OUT int size_high; /* file size */
427 OUT int size_low; /* file size */
428 OUT int links; /* number of links */
429 OUT int index_high; /* unique index */
430 OUT int index_low; /* unique index */
431 OUT unsigned int serial; /* volume serial number */
435 /* Lock a region of a file */
436 struct lock_file_request
438 IN int handle; /* handle to the file */
439 IN unsigned int offset_low; /* offset of start of lock */
440 IN unsigned int offset_high; /* offset of start of lock */
441 IN unsigned int count_low; /* count of bytes to lock */
442 IN unsigned int count_high; /* count of bytes to lock */
446 /* Unlock a region of a file */
447 struct unlock_file_request
449 IN int handle; /* handle to the file */
450 IN unsigned int offset_low; /* offset of start of unlock */
451 IN unsigned int offset_high; /* offset of start of unlock */
452 IN unsigned int count_low; /* count of bytes to unlock */
453 IN unsigned int count_high; /* count of bytes to unlock */
457 /* Create an anonymous pipe */
458 struct create_pipe_request
460 IN int inherit; /* inherit flag */
461 OUT int handle_read; /* handle to the read-side of the pipe */
462 OUT int handle_write; /* handle to the write-side of the pipe */
466 /* Allocate a console for the current process */
467 struct alloc_console_request
469 IN unsigned int access; /* wanted access rights */
470 IN int inherit; /* inherit flag */
471 OUT int handle_in; /* handle to console input */
472 OUT int handle_out; /* handle to console output */
476 /* Free the console of the current process */
477 struct free_console_request
479 IN int dummy;
483 /* Open a handle to the process console */
484 struct open_console_request
486 IN int output; /* input or output? */
487 IN unsigned int access; /* wanted access rights */
488 IN int inherit; /* inherit flag */
489 OUT int handle; /* handle to the console */
493 /* Set a console file descriptor */
494 struct set_console_fd_request
496 IN int handle; /* handle to the console */
497 IN int file_handle; /* handle of file to use as file descriptor */
498 IN int pid; /* pid of xterm (hack) */
502 /* Get a console mode (input or output) */
503 struct get_console_mode_request
505 IN int handle; /* handle to the console */
506 OUT int mode; /* console mode */
510 /* Set a console mode (input or output) */
511 struct set_console_mode_request
513 IN int handle; /* handle to the console */
514 IN int mode; /* console mode */
518 /* Set info about a console (output only) */
519 struct set_console_info_request
521 IN int handle; /* handle to the console */
522 IN int mask; /* setting mask (see below) */
523 IN int cursor_size; /* size of cursor (percentage filled) */
524 IN int cursor_visible;/* cursor visibility flag */
525 IN char title[1]; /* console title */
527 #define SET_CONSOLE_INFO_CURSOR 0x01
528 #define SET_CONSOLE_INFO_TITLE 0x02
530 /* Get info about a console (output only) */
531 struct get_console_info_request
533 IN int handle; /* handle to the console */
534 OUT int cursor_size; /* size of cursor (percentage filled) */
535 OUT int cursor_visible;/* cursor visibility flag */
536 OUT int pid; /* pid of xterm (hack) */
537 OUT char title[1]; /* console title */
541 /* Add input records to a console input queue */
542 struct write_console_input_request
544 IN int handle; /* handle to the console input */
545 IN int count; /* number of input records */
546 OUT int written; /* number of records written */
547 /* INPUT_RECORD records[0]; */ /* input records */
550 /* Fetch input records from a console input queue */
551 struct read_console_input_request
553 IN int handle; /* handle to the console input */
554 IN int count; /* max number of records to retrieve */
555 IN int flush; /* flush the retrieved records from the queue? */
556 OUT int read; /* number of records read */
557 /* INPUT_RECORD records[0]; */ /* input records */
561 /* Create a change notification */
562 struct create_change_notification_request
564 IN int subtree; /* watch all the subtree */
565 IN int filter; /* notification filter */
566 OUT int handle; /* handle to the change notification */
570 /* Create a file mapping */
571 struct create_mapping_request
573 IN int size_high; /* mapping size */
574 IN int size_low; /* mapping size */
575 IN int protect; /* protection flags (see below) */
576 IN int inherit; /* inherit flag */
577 IN int file_handle; /* file handle */
578 OUT int handle; /* handle to the mapping */
579 IN char name[1]; /* object name */
581 /* protection flags */
582 #define VPROT_READ 0x01
583 #define VPROT_WRITE 0x02
584 #define VPROT_EXEC 0x04
585 #define VPROT_WRITECOPY 0x08
586 #define VPROT_GUARD 0x10
587 #define VPROT_NOCACHE 0x20
588 #define VPROT_COMMITTED 0x40
591 /* Open a mapping */
592 struct open_mapping_request
594 IN unsigned int access; /* wanted access rights */
595 IN int inherit; /* inherit flag */
596 OUT int handle; /* handle to the mapping */
597 IN char name[1]; /* object name */
601 /* Get information about a file mapping */
602 struct get_mapping_info_request
604 IN int handle; /* handle to the mapping */
605 OUT int size_high; /* mapping size */
606 OUT int size_low; /* mapping size */
607 OUT int protect; /* protection flags */
611 /* Create a device */
612 struct create_device_request
614 IN unsigned int access; /* wanted access rights */
615 IN int inherit; /* inherit flag */
616 IN int id; /* client private id */
617 OUT int handle; /* handle to the device */
621 /* Create a snapshot */
622 struct create_snapshot_request
624 IN int inherit; /* inherit flag */
625 IN int flags; /* snapshot flags (TH32CS_*) */
626 OUT int handle; /* handle to the snapshot */
630 /* Get the next process from a snapshot */
631 struct next_process_request
633 IN int handle; /* handle to the snapshot */
634 IN int reset; /* reset snapshot position? */
635 OUT void* pid; /* process id */
636 OUT int threads; /* number of threads */
637 OUT int priority; /* process priority */
641 /* Wait for a debug event */
642 struct wait_debug_event_request
644 IN int timeout; /* timeout in ms */
645 OUT int code; /* event code */
646 OUT void* pid; /* process id */
647 OUT void* tid; /* thread id */
648 /* OUT union debug_event_data data; */
652 /* Send a debug event */
653 struct send_debug_event_request
655 IN int code; /* event code */
656 OUT int status; /* event continuation status */
657 /* IN union debug_event_data data; */
661 /* definitions of the event data depending on the event code */
662 struct debug_event_exception
664 int code; /* exception code */
665 int flags; /* exception flags */
666 void *record; /* exception record ptr */
667 void *addr; /* exception address */
668 int nb_params; /* exceptions parameters */
669 int params[15];
670 int first_chance; /* first chance to handle it? */
672 struct debug_event_create_thread
674 int handle; /* handle to the new thread */
675 void *teb; /* thread teb (in debugged process address space) */
676 void *start; /* thread startup routine */
678 struct debug_event_create_process
680 int file; /* handle to the process exe file */
681 int process; /* handle to the new process */
682 int thread; /* handle to the new thread */
683 void *base; /* base of executable image */
684 int dbg_offset; /* offset of debug info in file */
685 int dbg_size; /* size of debug info */
686 void *teb; /* thread teb (in debugged process address space) */
687 void *start; /* thread startup routine */
688 void *name; /* image name (optional) */
689 int unicode; /* is it Unicode? */
691 struct debug_event_exit
693 int exit_code; /* thread or process exit code */
695 struct debug_event_load_dll
697 int handle; /* file handle for the dll */
698 void *base; /* base address of the dll */
699 int dbg_offset; /* offset of debug info in file */
700 int dbg_size; /* size of debug info */
701 void *name; /* image name (optional) */
702 int unicode; /* is it Unicode? */
704 struct debug_event_unload_dll
706 void *base; /* base address of the dll */
708 struct debug_event_output_string
710 void *string; /* string to display (in debugged process address space) */
711 int unicode; /* is it Unicode? */
712 int length; /* string length */
714 struct debug_event_rip_info
716 int error; /* ??? */
717 int type; /* ??? */
719 union debug_event_data
721 struct debug_event_exception exception;
722 struct debug_event_create_thread create_thread;
723 struct debug_event_create_process create_process;
724 struct debug_event_exit exit;
725 struct debug_event_load_dll load_dll;
726 struct debug_event_unload_dll unload_dll;
727 struct debug_event_output_string output_string;
728 struct debug_event_rip_info rip_info;
732 /* Continue a debug event */
733 struct continue_debug_event_request
735 IN void* pid; /* process id to continue */
736 IN void* tid; /* thread id to continue */
737 IN int status; /* continuation status */
741 /* Start debugging an existing process */
742 struct debug_process_request
744 IN void* pid; /* id of the process to debug */
748 /* Everything below this line is generated automatically by tools/make_requests */
749 /* ### make_requests begin ### */
751 enum request
753 REQ_NEW_PROCESS,
754 REQ_NEW_THREAD,
755 REQ_SET_DEBUG,
756 REQ_INIT_PROCESS,
757 REQ_INIT_THREAD,
758 REQ_GET_THREAD_BUFFER,
759 REQ_TERMINATE_PROCESS,
760 REQ_TERMINATE_THREAD,
761 REQ_GET_PROCESS_INFO,
762 REQ_SET_PROCESS_INFO,
763 REQ_GET_THREAD_INFO,
764 REQ_SET_THREAD_INFO,
765 REQ_SUSPEND_THREAD,
766 REQ_RESUME_THREAD,
767 REQ_DEBUGGER,
768 REQ_QUEUE_APC,
769 REQ_GET_APCS,
770 REQ_CLOSE_HANDLE,
771 REQ_GET_HANDLE_INFO,
772 REQ_SET_HANDLE_INFO,
773 REQ_DUP_HANDLE,
774 REQ_OPEN_PROCESS,
775 REQ_SELECT,
776 REQ_CREATE_EVENT,
777 REQ_EVENT_OP,
778 REQ_OPEN_EVENT,
779 REQ_CREATE_MUTEX,
780 REQ_RELEASE_MUTEX,
781 REQ_OPEN_MUTEX,
782 REQ_CREATE_SEMAPHORE,
783 REQ_RELEASE_SEMAPHORE,
784 REQ_OPEN_SEMAPHORE,
785 REQ_CREATE_FILE,
786 REQ_ALLOC_FILE_HANDLE,
787 REQ_GET_READ_FD,
788 REQ_GET_WRITE_FD,
789 REQ_SET_FILE_POINTER,
790 REQ_TRUNCATE_FILE,
791 REQ_SET_FILE_TIME,
792 REQ_FLUSH_FILE,
793 REQ_GET_FILE_INFO,
794 REQ_LOCK_FILE,
795 REQ_UNLOCK_FILE,
796 REQ_CREATE_PIPE,
797 REQ_ALLOC_CONSOLE,
798 REQ_FREE_CONSOLE,
799 REQ_OPEN_CONSOLE,
800 REQ_SET_CONSOLE_FD,
801 REQ_GET_CONSOLE_MODE,
802 REQ_SET_CONSOLE_MODE,
803 REQ_SET_CONSOLE_INFO,
804 REQ_GET_CONSOLE_INFO,
805 REQ_WRITE_CONSOLE_INPUT,
806 REQ_READ_CONSOLE_INPUT,
807 REQ_CREATE_CHANGE_NOTIFICATION,
808 REQ_CREATE_MAPPING,
809 REQ_OPEN_MAPPING,
810 REQ_GET_MAPPING_INFO,
811 REQ_CREATE_DEVICE,
812 REQ_CREATE_SNAPSHOT,
813 REQ_NEXT_PROCESS,
814 REQ_WAIT_DEBUG_EVENT,
815 REQ_SEND_DEBUG_EVENT,
816 REQ_CONTINUE_DEBUG_EVENT,
817 REQ_DEBUG_PROCESS,
818 REQ_NB_REQUESTS
821 /* ### make_requests end ### */
822 /* Everything above this line is generated automatically by tools/make_requests */
825 /* client-side functions */
827 #ifndef __WINE_SERVER__
829 #include "thread.h"
831 /* client communication functions */
833 /* get a pointer to the request buffer */
834 static inline void * WINE_UNUSED get_req_buffer(void)
836 return NtCurrentTeb()->buffer;
839 /* maximum remaining size in the server buffer */
840 static inline int WINE_UNUSED server_remaining( const void *ptr )
842 return (char *)NtCurrentTeb()->buffer + NtCurrentTeb()->buffer_size - (char *)ptr;
845 extern unsigned int server_call( enum request req );
846 extern unsigned int server_call_fd( enum request req, int fd_out, int *fd_in );
847 extern void server_protocol_error( const char *err, ... );
849 extern int CLIENT_InitServer(void);
850 extern int CLIENT_SetDebug( int level );
851 extern int CLIENT_DebuggerRequest( int op );
852 extern int CLIENT_InitThread(void);
853 #endif /* __WINE_SERVER__ */
855 #endif /* __WINE_SERVER_H */