Merge pull request #3262 from lindenlab/add_continuations_test
[mono.git] / mono / io-layer / processes.h
1 /*
2  * processes.h:  Process handles
3  *
4  * Author:
5  *      Dick Porter (dick@ximian.com)
6  *
7  * (C) 2002 Ximian, Inc.
8  */
9
10 #ifndef _WAPI_PROCESSES_H_
11 #define _WAPI_PROCESSES_H_
12
13 #ifdef HAVE_UNISTD_H
14 #include <unistd.h>
15 #endif
16 #include <glib.h>
17
18 #include <mono/io-layer/access.h>
19 #include <mono/io-layer/versioninfo.h>
20
21 G_BEGIN_DECLS
22
23 typedef enum {
24         STARTF_USESHOWWINDOW=0x001,
25         STARTF_USESIZE=0x002,
26         STARTF_USEPOSITION=0x004,
27         STARTF_USECOUNTCHARS=0x008,
28         STARTF_USEFILLATTRIBUTE=0x010,
29         STARTF_RUNFULLSCREEN=0x020,
30         STARTF_FORCEONFEEDBACK=0x040,
31         STARTF_FORCEOFFFEEDBACK=0x080,
32         STARTF_USESTDHANDLES=0x100
33 } WapiStartupFlags;
34
35
36 typedef struct _WapiStartupInfo WapiStartupInfo;
37
38 struct _WapiStartupInfo 
39 {
40         guint32 cb;
41         guchar *lpReserved;
42         guchar *lpDesktop;
43         guchar *lpTitle;
44         guint32 dwX;
45         guint32 dwY;
46         guint32 dwXSize;
47         guint32 dwYSize;
48         guint32 dwXCountChars;
49         guint32 dwYCountChars;
50         guint32 dwFillAttribute;
51         WapiStartupFlags dwFlags;
52         guint16 wShowWindow;
53         guint16 cbReserved2;
54         guint8 *lpReserved2;
55         gpointer hStdInput;
56         gpointer hStdOutput;
57         gpointer hStdError;
58 };
59
60 typedef struct _WapiProcessInformation WapiProcessInformation;
61
62 struct _WapiProcessInformation 
63 {
64         gpointer hProcess;
65         gpointer hThread;
66         guint32 dwProcessId;
67         guint32 dwThreadId;
68 };
69
70 typedef enum {
71         SEE_MASK_CLASSNAME      = 0x01,
72         SEE_MASK_CLASSKEY       = 0x03,
73         SEE_MASK_IDLIST         = 0x04,
74         SEE_MASK_INVOKEIDLIST   = 0x0c,
75         SEE_MASK_ICON           = 0x10,
76         SEE_MASK_HOTKEY         = 0x20,
77         SEE_MASK_NOCLOSEPROCESS = 0x40,
78         SEE_MASK_CONNECTNETDRV  = 0x80,
79         SEE_MASK_FLAG_DDEWAIT   = 0x100,
80         SEE_MASK_DOENVSUBST     = 0x200,
81         SEE_MASK_FLAG_NO_UI     = 0x400,
82         SEE_MASK_NO_CONSOLE     = 0x8000,
83         SEE_MASK_UNICODE        = 0x10000,
84         SEE_MASK_HMONITOR       = 0x200000,
85         /*SEE_MASK_FLAG_LOG_USAGE,*/
86         /*SEE_MASK_NOZONECHECKS,*/
87 } WapiShellExecuteInfoFlags;
88
89 typedef enum {
90         SW_HIDE = 0,
91         SW_SHOWNORMAL = 1,
92         SW_SHOWMINIMIZED = 2,
93         SW_MAXIMIZE = 3,
94         SW_SHOWMAXIMIZED = 3,
95         SW_SHOWNOACTIVATE = 4,
96         SW_SHOW = 5,
97         SW_MINIMIZE = 6,
98         SW_SHOWMINNOACTIVE = 7,
99         SW_SHOWNA = 8,
100         SW_RESTORE = 9,
101         SW_SHOWDEFAULT = 10,
102 } WapiShellExecuteShowFlags;
103
104 typedef struct _WapiShellExecuteInfo WapiShellExecuteInfo;
105
106 struct _WapiShellExecuteInfo
107 {
108         guint32 cbSize;
109         gulong fMask;
110         gpointer hwnd;
111         const gunichar2 *lpVerb;
112         const gunichar2 *lpFile;
113         const gunichar2 *lpParameters;
114         const gunichar2 *lpDirectory;
115         gulong nShow;
116         gpointer hInstApp;
117         gpointer lpIDList;
118         const gunichar2 *lpClass;
119         gpointer hkeyClass;
120         guint32 dwHotKey;
121         union 
122         {
123                 gpointer hIcon;
124                 gpointer hMonitor;
125         } u;
126         gpointer hProcess;
127 };
128
129         
130 #define DEBUG_PROCESS 0x00000001
131 #define DEBUG_ONLY_THIS_PROCESS 0x00000002
132 #define CREATE_SUSPENDED 0x00000004
133 #define DETACHED_PROCESS 0x00000008
134 #define CREATE_NEW_CONSOLE 0x00000010
135 #define NORMAL_PRIORITY_CLASS 0x00000020
136 #define IDLE_PRIORITY_CLASS 0x00000040
137 #define HIGH_PRIORITY_CLASS 0x00000080
138 #define REALTIME_PRIORITY_CLASS 0x00000100
139 #define CREATE_NEW_PROCESS_GROUP 0x00000200
140 #define CREATE_UNICODE_ENVIRONMENT 0x00000400
141 #define CREATE_SEPARATE_WOW_VDM 0x00000800
142 #define CREATE_SHARED_WOW_VDM 0x00001000
143 #define CREATE_FORCEDOS 0x00002000
144 #define BELOW_NORMAL_PRIORITY_CLASS 0x00004000
145 #define ABOVE_NORMAL_PRIORITY_CLASS 0x00008000
146 #define CREATE_BREAKAWAY_FROM_JOB 0x01000000
147 #define CREATE_WITH_USERPROFILE 0x02000000
148 #define CREATE_DEFAULT_ERROR_MODE 0x04000000
149 #define CREATE_NO_WINDOW 0x08000000
150
151 #ifdef NEW_STUFF
152 #define CREATE_PRESERVE_CODE_AUTHZ_LEVEL find out the value for this one...
153 #endif
154
155 #define PROCESS_TERMINATE               0x0001
156 #define PROCESS_CREATE_THREAD           0x0002
157 #define PROCESS_SET_SESSIONID           0x0004
158 #define PROCESS_VM_OPERATION            0x0008
159 #define PROCESS_VM_READ                 0x0010
160 #define PROCESS_VM_WRITE                0x0020
161 #define PROCESS_DUP_HANDLE              0x0040
162 #define PROCESS_CREATE_PROCESS          0x0080
163 #define PROCESS_SET_QUOTA               0x0100
164 #define PROCESS_SET_INFORMATION         0x0200
165 #define PROCESS_QUERY_INFORMATION       0x0400
166 #define PROCESS_ALL_ACCESS              (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0xfff)
167
168 extern gboolean ShellExecuteEx (WapiShellExecuteInfo *sei);
169 extern gboolean CreateProcess (const gunichar2 *appname,
170                                const gunichar2 *cmdline,
171                                WapiSecurityAttributes *process_attrs,
172                                WapiSecurityAttributes *thread_attrs,
173                                gboolean inherit_handles, guint32 create_flags,
174                                gpointer environ, const gunichar2 *cwd,
175                                WapiStartupInfo *startup,
176                                WapiProcessInformation *process_info);
177 extern gboolean CreateProcessWithLogonW (const gunichar2 *username,
178                                          const gunichar2 *domain,
179                                          const gunichar2 *password,
180                                          const guint32 logonFlags,
181                                          const gunichar2 *appname,
182                                          const gunichar2 *cmdline,
183                                          guint32 create_flags,
184                                          gpointer environ,
185                                          const gunichar2 *cwd,
186                                          WapiStartupInfo *startup,
187                                          WapiProcessInformation *process_info);
188 #define LOGON_WITH_PROFILE 0x00000001
189 #define LOGON_NETCREDENTIALS_ONLY 0x00000002
190
191 extern gpointer GetCurrentProcess (void);
192 extern guint32 GetProcessId (gpointer handle);
193 extern gboolean CloseProcess (gpointer handle);
194 extern gpointer OpenProcess (guint32 access, gboolean inherit, guint32 pid);
195 extern gboolean GetExitCodeProcess (gpointer process, guint32 *code);
196 extern gboolean GetProcessTimes (gpointer process, WapiFileTime *create_time,
197                                  WapiFileTime *exit_time,
198                                  WapiFileTime *kernel_time,
199                                  WapiFileTime *user_time);
200 extern gboolean EnumProcessModules (gpointer process, gpointer *modules,
201                                     guint32 size, guint32 *needed);
202 extern guint32 GetModuleBaseName (gpointer process, gpointer module,
203                                   gunichar2 *basename, guint32 size);
204 extern guint32 GetModuleFileNameEx (gpointer process, gpointer module,
205                                     gunichar2 *filename, guint32 size);
206 extern gboolean GetModuleInformation (gpointer process, gpointer module,
207                                       WapiModuleInfo *modinfo, guint32 size);
208 extern gboolean GetProcessWorkingSetSize (gpointer process, size_t *min,
209                                           size_t *max);
210 extern gboolean SetProcessWorkingSetSize (gpointer process, size_t min,
211                                           size_t max);
212
213 extern gboolean TerminateProcess (gpointer process, gint32 exitCode);
214
215 extern guint32 GetPriorityClass (gpointer process);
216 extern gboolean SetPriorityClass (gpointer process, guint32  priority_class);
217
218 gchar* wapi_process_get_path (pid_t pid);
219
220 void wapi_process_set_cli_launcher (char *path);
221
222 G_END_DECLS
223
224 #endif /* _WAPI_PROCESSES_H_ */