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