process.h 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  19. */
  20. #ifndef __WINE_SERVER_PROCESS_H
  21. #define __WINE_SERVER_PROCESS_H
  22. #include "object.h"
  23. struct msg_queue;
  24. struct atom_table;
  25. struct handle_table;
  26. struct startup_info;
  27. /* process startup state */
  28. enum startup_state { STARTUP_IN_PROGRESS, STARTUP_DONE, STARTUP_ABORTED };
  29. /* process structures */
  30. struct process_dll
  31. {
  32. struct process_dll *next; /* per-process dll list */
  33. struct process_dll *prev;
  34. struct file *file; /* dll file */
  35. void *base; /* dll base address (in process addr space) */
  36. size_t size; /* dll size */
  37. void *name; /* ptr to ptr to name (in process addr space) */
  38. int dbg_offset; /* debug info offset */
  39. int dbg_size; /* debug info size */
  40. size_t namelen; /* length of dll file name */
  41. WCHAR *filename; /* dll file name */
  42. };
  43. struct process
  44. {
  45. struct object obj; /* object header */
  46. struct process *next; /* system-wide process list */
  47. struct process *prev;
  48. struct process *parent; /* parent process */
  49. struct thread *thread_list; /* head of the thread list */
  50. struct thread *debugger; /* thread debugging this process */
  51. struct handle_table *handles; /* handle entries */
  52. struct fd *msg_fd; /* fd for sendmsg/recvmsg */
  53. process_id_t id; /* id of the process */
  54. process_id_t group_id; /* group id of the process */
  55. int exit_code; /* process exit code */
  56. int running_threads; /* number of threads running in this process */
  57. struct timeval start_time; /* absolute time at process start */
  58. struct timeval end_time; /* absolute time at process end */
  59. int priority; /* priority class */
  60. int affinity; /* process affinity mask */
  61. int suspend; /* global process suspend count */
  62. int create_flags; /* process creation flags */
  63. struct list locks; /* list of file locks owned by the process */
  64. struct list classes; /* window classes owned by the process */
  65. struct console_input*console; /* console input */
  66. enum startup_state startup_state; /* startup state */
  67. struct startup_info *startup_info; /* startup info while init is in progress */
  68. struct event *idle_event; /* event for input idle */
  69. struct msg_queue *queue; /* main message queue */
  70. struct atom_table *atom_table; /* pointer to local atom table */
  71. struct token *token; /* security token associated with this process */
  72. struct process_dll exe; /* main exe file */
  73. void *peb; /* PEB address in client address space */
  74. void *ldt_copy; /* pointer to LDT copy in client addr space */
  75. };
  76. struct process_snapshot
  77. {
  78. struct process *process; /* process ptr */
  79. int count; /* process refcount */
  80. int threads; /* number of threads */
  81. int priority; /* priority class */
  82. int handles; /* number of handles */
  83. };
  84. struct module_snapshot
  85. {
  86. void *base; /* module base addr */
  87. size_t size; /* module size */
  88. size_t namelen; /* length of file name */
  89. WCHAR *filename; /* module file name */
  90. };
  91. /* process functions */
  92. extern unsigned int alloc_ptid( void *ptr );
  93. extern void free_ptid( unsigned int id );
  94. extern void *get_ptid_entry( unsigned int id );
  95. extern struct thread *create_process( int fd );
  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 int process_set_debugger( struct process *process, struct thread *thread );
  99. extern int debugger_detach( struct process* process, struct thread* debugger );
  100. extern int set_process_debug_flag( struct process *process, int flag );
  101. extern void add_process_thread( struct process *process,
  102. struct thread *thread );
  103. extern void remove_process_thread( struct process *process,
  104. struct thread *thread );
  105. extern void suspend_process( struct process *process );
  106. extern void resume_process( struct process *process );
  107. extern void kill_all_processes( struct process *skip, int exit_code );
  108. extern void kill_process( struct process *process, struct thread *skip, int exit_code );
  109. extern void kill_console_processes( struct thread *renderer, int exit_code );
  110. extern void kill_debugged_processes( struct thread *debugger, int exit_code );
  111. extern void detach_debugged_processes( struct thread *debugger );
  112. extern struct process_snapshot *process_snap( int *count );
  113. extern struct module_snapshot *module_snap( struct process *process, int *count );
  114. extern void enum_processes( int (*cb)(struct process*, void*), void *user);
  115. inline static process_id_t get_process_id( struct process *process ) { return process->id; }
  116. inline static int is_process_init_done( struct process *process )
  117. {
  118. return process->startup_state == STARTUP_DONE;
  119. }
  120. #endif /* __WINE_SERVER_PROCESS_H */