process.h 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. /*
  2. * Wine server processes
  3. *
  4. * Copyright (C) 1999 Alexandre Julliard
  5. *
  6. * This library is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 2.1 of the License, or (at your option) any later version.
  10. *
  11. * This library is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public
  17. * License along with this library; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  19. */
  20. #ifndef __WINE_SERVER_PROCESS_H
  21. #define __WINE_SERVER_PROCESS_H
  22. #include "object.h"
  23. struct atom_table;
  24. struct handle_table;
  25. struct startup_info;
  26. struct job;
  27. /* process startup state */
  28. enum startup_state { STARTUP_IN_PROGRESS, STARTUP_DONE, STARTUP_ABORTED };
  29. /* process structures */
  30. struct rawinput_device_entry
  31. {
  32. struct list entry;
  33. struct rawinput_device device;
  34. };
  35. struct process
  36. {
  37. struct object obj; /* object header */
  38. struct list entry; /* entry in system-wide process list */
  39. process_id_t parent_id; /* parent process id (at the time of creation) */
  40. struct list thread_list; /* thread list */
  41. struct debug_obj *debug_obj; /* debug object debugging this process */
  42. struct debug_event *debug_event; /* debug event being sent to debugger */
  43. struct handle_table *handles; /* handle entries */
  44. struct fd *msg_fd; /* fd for sendmsg/recvmsg */
  45. process_id_t id; /* id of the process */
  46. process_id_t group_id; /* group id of the process */
  47. unsigned int session_id; /* session id */
  48. struct timeout_user *sigkill_timeout; /* timeout for final SIGKILL */
  49. timeout_t sigkill_delay; /* delay before final SIGKILL */
  50. unsigned short machine; /* client machine type */
  51. int unix_pid; /* Unix pid for final SIGKILL */
  52. int exit_code; /* process exit code */
  53. int running_threads; /* number of threads running in this process */
  54. timeout_t start_time; /* absolute time at process start */
  55. timeout_t end_time; /* absolute time at process end */
  56. affinity_t affinity; /* process affinity mask */
  57. int priority; /* priority class */
  58. int suspend; /* global process suspend count */
  59. unsigned int is_system:1; /* is it a system process? */
  60. unsigned int debug_children:1;/* also debug all child processes */
  61. unsigned int is_terminating:1;/* is process terminating? */
  62. data_size_t imagelen; /* length of image path in bytes */
  63. WCHAR *image; /* main exe image full path */
  64. struct job *job; /* job object associated with this process */
  65. struct list job_entry; /* list entry for job object */
  66. struct list asyncs; /* list of async object owned by the process */
  67. struct list locks; /* list of file locks owned by the process */
  68. struct list classes; /* window classes owned by the process */
  69. struct console *console; /* console input */
  70. enum startup_state startup_state; /* startup state */
  71. struct startup_info *startup_info; /* startup info while init is in progress */
  72. struct event *idle_event; /* event for input idle */
  73. obj_handle_t winstation; /* main handle to process window station */
  74. obj_handle_t desktop; /* handle to desktop to use for new threads */
  75. struct token *token; /* security token associated with this process */
  76. struct list views; /* list of memory views */
  77. client_ptr_t peb; /* PEB address in client address space */
  78. client_ptr_t ldt_copy; /* pointer to LDT copy in client addr space */
  79. struct dir_cache *dir_cache; /* map of client-side directory cache */
  80. unsigned int trace_data; /* opaque data used by the process tracing mechanism */
  81. struct list rawinput_devices;/* list of registered rawinput devices */
  82. const struct rawinput_device *rawinput_mouse; /* rawinput mouse device, if any */
  83. const struct rawinput_device *rawinput_kbd; /* rawinput keyboard device, if any */
  84. struct list kernel_object; /* list of kernel object pointers */
  85. pe_image_info_t image_info; /* main exe image info */
  86. };
  87. /* process functions */
  88. extern unsigned int alloc_ptid( void *ptr );
  89. extern void free_ptid( unsigned int id );
  90. extern void *get_ptid_entry( unsigned int id );
  91. extern struct process *create_process( int fd, struct process *parent, unsigned int flags, const startup_info_t *info,
  92. const struct security_descriptor *sd, const obj_handle_t *handles,
  93. unsigned int handle_count, struct token *token );
  94. extern data_size_t get_process_startup_info_size( struct process *process );
  95. extern struct thread *get_process_first_thread( struct process *process );
  96. extern struct process *get_process_from_id( process_id_t id );
  97. extern struct process *get_process_from_handle( obj_handle_t handle, unsigned int access );
  98. extern struct debug_obj *get_debug_obj( struct process *process, obj_handle_t handle, unsigned int access );
  99. extern int process_set_debugger( struct process *process, struct thread *thread );
  100. extern void debugger_detach( struct process *process, struct debug_obj *debug_obj );
  101. extern int set_process_debug_flag( struct process *process, int flag );
  102. extern void add_process_thread( struct process *process,
  103. struct thread *thread );
  104. extern void remove_process_thread( struct process *process,
  105. struct thread *thread );
  106. extern void suspend_process( struct process *process );
  107. extern void resume_process( struct process *process );
  108. extern void kill_process( struct process *process, int violent_death );
  109. extern void kill_console_processes( struct thread *renderer, int exit_code );
  110. extern void detach_debugged_processes( struct debug_obj *debug_obj, int exit_code );
  111. extern void enum_processes( int (*cb)(struct process*, void*), void *user);
  112. /* console functions */
  113. extern struct thread *console_get_renderer( struct console *console );
  114. /* process tracing mechanism to use */
  115. #ifdef __APPLE__
  116. #define USE_MACH
  117. #elif defined(__sun)
  118. #define USE_PROCFS
  119. #else
  120. #define USE_PTRACE
  121. #endif
  122. extern void init_tracing_mechanism(void);
  123. extern void init_process_tracing( struct process *process );
  124. extern void finish_process_tracing( struct process *process );
  125. extern int read_process_memory( struct process *process, client_ptr_t ptr, data_size_t size, char *dest );
  126. extern int write_process_memory( struct process *process, client_ptr_t ptr, data_size_t size, const char *src );
  127. static inline process_id_t get_process_id( struct process *process ) { return process->id; }
  128. static inline int is_process_init_done( struct process *process )
  129. {
  130. return process->startup_state == STARTUP_DONE;
  131. }
  132. static const unsigned int default_session_id = 1;
  133. #endif /* __WINE_SERVER_PROCESS_H */