]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/winapi/include/boost/detail/winapi/process.hpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / winapi / include / boost / detail / winapi / process.hpp
1 // process.hpp --------------------------------------------------------------//
2
3 // Copyright 2016 Klemens D. Morgenstern
4 // Copyright 2016 Andrey Semashev
5
6 // Distributed under the Boost Software License, Version 1.0.
7 // See http://www.boost.org/LICENSE_1_0.txt
8
9 #ifndef BOOST_DETAIL_WINAPI_PROCESS_HPP_
10 #define BOOST_DETAIL_WINAPI_PROCESS_HPP_
11
12 #include <boost/detail/winapi/config.hpp>
13 #include <boost/detail/winapi/basic_types.hpp>
14 #include <boost/detail/winapi/access_rights.hpp>
15 #include <boost/detail/winapi/get_current_process.hpp>
16 #include <boost/detail/winapi/get_current_process_id.hpp>
17 #include <boost/predef/platform.h>
18
19 #ifdef BOOST_HAS_PRAGMA_ONCE
20 #pragma once
21 #endif
22
23 #if BOOST_PLAT_WINDOWS_DESKTOP
24
25 #if !defined( BOOST_USE_WINDOWS_H )
26 extern "C" {
27
28 struct _PROCESS_INFORMATION;
29 #if !defined( BOOST_NO_ANSI_APIS )
30 struct _STARTUPINFOA;
31 #endif
32 struct _STARTUPINFOW;
33
34 #if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6
35 struct _PROC_THREAD_ATTRIBUTE_LIST;
36 #if !defined( BOOST_NO_ANSI_APIS )
37 struct _STARTUPINFOEXA;
38 #endif
39 struct _STARTUPINFOEXW;
40 #endif
41
42 BOOST_SYMBOL_IMPORT BOOST_NORETURN boost::detail::winapi::VOID_ WINAPI
43 ExitProcess(boost::detail::winapi::UINT_ uExitCode);
44
45 BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI TerminateProcess(
46 boost::detail::winapi::HANDLE_ hProcess,
47 boost::detail::winapi::UINT_ uExitCode);
48
49 BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI GetExitCodeProcess(
50 boost::detail::winapi::HANDLE_ hProcess,
51 boost::detail::winapi::LPDWORD_ lpExitCode);
52
53 #if !defined( BOOST_NO_ANSI_APIS )
54 BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI CreateProcessA(
55 boost::detail::winapi::LPCSTR_ lpApplicationName,
56 boost::detail::winapi::LPSTR_ lpCommandLine,
57 ::_SECURITY_ATTRIBUTES* lpProcessAttributes,
58 ::_SECURITY_ATTRIBUTES* lpThreadAttributes,
59 boost::detail::winapi::INT_ bInheritHandles,
60 boost::detail::winapi::DWORD_ dwCreationFlags,
61 boost::detail::winapi::LPVOID_ lpEnvironment,
62 boost::detail::winapi::LPCSTR_ lpCurrentDirectory,
63 ::_STARTUPINFOA* lpStartupInfo,
64 ::_PROCESS_INFORMATION* lpProcessInformation);
65 #endif
66
67 BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI CreateProcessW(
68 boost::detail::winapi::LPCWSTR_ lpApplicationName,
69 boost::detail::winapi::LPWSTR_ lpCommandLine,
70 ::_SECURITY_ATTRIBUTES* lpProcessAttributes,
71 ::_SECURITY_ATTRIBUTES* lpThreadAttributes,
72 boost::detail::winapi::INT_ bInheritHandles,
73 boost::detail::winapi::DWORD_ dwCreationFlags,
74 boost::detail::winapi::LPVOID_ lpEnvironment,
75 boost::detail::winapi::LPCWSTR_ lpCurrentDirectory,
76 ::_STARTUPINFOW* lpStartupInfo,
77 ::_PROCESS_INFORMATION* lpProcessInformation);
78
79 BOOST_SYMBOL_IMPORT boost::detail::winapi::HANDLE_ WINAPI OpenProcess(
80 boost::detail::winapi::DWORD_ dwDesiredAccess,
81 boost::detail::winapi::BOOL_ bInheritHandle,
82 boost::detail::winapi::DWORD_ dwProcessId);
83
84 } // extern "C"
85 #endif //defined BOOST_WINDOWS_H
86
87 namespace boost {
88 namespace detail {
89 namespace winapi {
90
91 #if defined( BOOST_USE_WINDOWS_H )
92
93 const DWORD_ DEBUG_PROCESS_ = DEBUG_PROCESS;
94 const DWORD_ DEBUG_ONLY_THIS_PROCESS_ = DEBUG_ONLY_THIS_PROCESS;
95 const DWORD_ CREATE_SUSPENDED_ = CREATE_SUSPENDED;
96 const DWORD_ DETACHED_PROCESS_ = DETACHED_PROCESS;
97 const DWORD_ CREATE_NEW_CONSOLE_ = CREATE_NEW_CONSOLE;
98 const DWORD_ CREATE_NEW_PROCESS_GROUP_ = CREATE_NEW_PROCESS_GROUP;
99 const DWORD_ CREATE_UNICODE_ENVIRONMENT_ = CREATE_UNICODE_ENVIRONMENT;
100 const DWORD_ CREATE_SEPARATE_WOW_VDM_ = CREATE_SEPARATE_WOW_VDM;
101 const DWORD_ CREATE_SHARED_WOW_VDM_ = CREATE_SHARED_WOW_VDM;
102 const DWORD_ CREATE_FORCEDOS_ = CREATE_FORCEDOS;
103 const DWORD_ CREATE_BREAKAWAY_FROM_JOB_ = CREATE_BREAKAWAY_FROM_JOB;
104 const DWORD_ CREATE_DEFAULT_ERROR_MODE_ = CREATE_DEFAULT_ERROR_MODE;
105 const DWORD_ CREATE_NO_WINDOW_ = CREATE_NO_WINDOW;
106
107 // Undocumented
108 const DWORD_ PROFILE_USER_ = PROFILE_USER;
109 const DWORD_ PROFILE_KERNEL_ = PROFILE_KERNEL;
110 const DWORD_ PROFILE_SERVER_ = PROFILE_SERVER;
111
112 #if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6
113 const DWORD_ CREATE_PROTECTED_PROCESS_ = CREATE_PROTECTED_PROCESS;
114 const DWORD_ EXTENDED_STARTUPINFO_PRESENT_ = EXTENDED_STARTUPINFO_PRESENT;
115 #endif
116
117 #if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN7
118 const DWORD_ INHERIT_PARENT_AFFINITY_ = INHERIT_PARENT_AFFINITY;
119 #endif
120
121 // Only documented for Windows CE
122 #if defined(UNDER_CE)
123 const DWORD_ INHERIT_CALLER_PRIORITY_ = INHERIT_CALLER_PRIORITY;
124 #endif
125
126 const DWORD_ STARTF_USESHOWWINDOW_ = STARTF_USESHOWWINDOW;
127 const DWORD_ STARTF_USESIZE_ = STARTF_USESIZE;
128 const DWORD_ STARTF_USEPOSITION_ = STARTF_USEPOSITION;
129 const DWORD_ STARTF_USECOUNTCHARS_ = STARTF_USECOUNTCHARS;
130 const DWORD_ STARTF_USEFILLATTRIBUTE_ = STARTF_USEFILLATTRIBUTE;
131 const DWORD_ STARTF_RUNFULLSCREEN_ = STARTF_RUNFULLSCREEN;
132 const DWORD_ STARTF_FORCEONFEEDBACK_ = STARTF_FORCEONFEEDBACK;
133 const DWORD_ STARTF_FORCEOFFFEEDBACK_ = STARTF_FORCEOFFFEEDBACK;
134 const DWORD_ STARTF_USESTDHANDLES_ = STARTF_USESTDHANDLES;
135 const DWORD_ STARTF_USEHOTKEY_ = STARTF_USEHOTKEY;
136
137 #if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN7
138 const DWORD_ STARTF_TITLEISLINKNAME_ = STARTF_TITLEISLINKNAME;
139 const DWORD_ STARTF_TITLEISAPPID_ = STARTF_TITLEISAPPID;
140 const DWORD_ STARTF_PREVENTPINNING_ = STARTF_PREVENTPINNING;
141 #endif
142
143 const DWORD_ PROCESS_TERMINATE_ = PROCESS_TERMINATE;
144 const DWORD_ PROCESS_CREATE_THREAD_ = PROCESS_CREATE_THREAD;
145 const DWORD_ PROCESS_SET_SESSIONID_ = PROCESS_SET_SESSIONID;
146 const DWORD_ PROCESS_VM_OPERATION_ = PROCESS_VM_OPERATION;
147 const DWORD_ PROCESS_VM_READ_ = PROCESS_VM_READ;
148 const DWORD_ PROCESS_VM_WRITE_ = PROCESS_VM_WRITE;
149 const DWORD_ PROCESS_DUP_HANDLE_ = PROCESS_DUP_HANDLE;
150 const DWORD_ PROCESS_CREATE_PROCESS_ = PROCESS_CREATE_PROCESS;
151 const DWORD_ PROCESS_SET_QUOTA_ = PROCESS_SET_QUOTA;
152 const DWORD_ PROCESS_SET_INFORMATION_ = PROCESS_SET_INFORMATION;
153 const DWORD_ PROCESS_QUERY_INFORMATION_ = PROCESS_QUERY_INFORMATION;
154 const DWORD_ PROCESS_SUSPEND_RESUME_ = PROCESS_SUSPEND_RESUME;
155 const DWORD_ PROCESS_ALL_ACCESS_ = PROCESS_ALL_ACCESS;
156
157 #else // defined( BOOST_USE_WINDOWS_H )
158
159 const DWORD_ DEBUG_PROCESS_ = 0x1;
160 const DWORD_ DEBUG_ONLY_THIS_PROCESS_ = 0x2;
161 const DWORD_ CREATE_SUSPENDED_ = 0x4;
162 const DWORD_ DETACHED_PROCESS_ = 0x8;
163 const DWORD_ CREATE_NEW_CONSOLE_ = 0x10;
164 const DWORD_ CREATE_NEW_PROCESS_GROUP_ = 0x200;
165 const DWORD_ CREATE_UNICODE_ENVIRONMENT_ = 0x400;
166 const DWORD_ CREATE_SEPARATE_WOW_VDM_ = 0x800;
167 const DWORD_ CREATE_SHARED_WOW_VDM_ = 0x1000;
168 const DWORD_ CREATE_FORCEDOS_ = 0x2000;
169 const DWORD_ CREATE_BREAKAWAY_FROM_JOB_ = 0x1000000;
170 const DWORD_ CREATE_DEFAULT_ERROR_MODE_ = 0x4000000;
171 const DWORD_ CREATE_NO_WINDOW_ = 0x8000000;
172
173 // Undocumented
174 const DWORD_ PROFILE_USER_ = 0x10000000;
175 const DWORD_ PROFILE_KERNEL_ = 0x20000000;
176 const DWORD_ PROFILE_SERVER_ = 0x40000000;
177
178 #if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6
179 const DWORD_ CREATE_PROTECTED_PROCESS_ = 0x40000;
180 const DWORD_ EXTENDED_STARTUPINFO_PRESENT_ = 0x80000;
181 #endif
182
183 #if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN7
184 const DWORD_ INHERIT_PARENT_AFFINITY_ = 0x10000;
185 #endif
186
187 // Only documented for Windows CE
188 #if defined(UNDER_CE)
189 const DWORD_ INHERIT_CALLER_PRIORITY_ = 0x20000;
190 #endif
191
192 const DWORD_ STARTF_USESHOWWINDOW_ = 0x00000001;
193 const DWORD_ STARTF_USESIZE_ = 0x00000002;
194 const DWORD_ STARTF_USEPOSITION_ = 0x00000004;
195 const DWORD_ STARTF_USECOUNTCHARS_ = 0x00000008;
196 const DWORD_ STARTF_USEFILLATTRIBUTE_ = 0x00000010;
197 const DWORD_ STARTF_RUNFULLSCREEN_ = 0x00000020;
198 const DWORD_ STARTF_FORCEONFEEDBACK_ = 0x00000040;
199 const DWORD_ STARTF_FORCEOFFFEEDBACK_ = 0x00000080;
200 const DWORD_ STARTF_USESTDHANDLES_ = 0x00000100;
201 const DWORD_ STARTF_USEHOTKEY_ = 0x00000200;
202
203 #if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN7
204 const DWORD_ STARTF_TITLEISLINKNAME_ = 0x00000800;
205 const DWORD_ STARTF_TITLEISAPPID_ = 0x00001000;
206 const DWORD_ STARTF_PREVENTPINNING_ = 0x00002000;
207 #endif
208
209 const DWORD_ PROCESS_TERMINATE_ = 0x0001;
210 const DWORD_ PROCESS_CREATE_THREAD_ = 0x0002;
211 const DWORD_ PROCESS_SET_SESSIONID_ = 0x0004;
212 const DWORD_ PROCESS_VM_OPERATION_ = 0x0008;
213 const DWORD_ PROCESS_VM_READ_ = 0x0010;
214 const DWORD_ PROCESS_VM_WRITE_ = 0x0020;
215 const DWORD_ PROCESS_DUP_HANDLE_ = 0x0040;
216 const DWORD_ PROCESS_CREATE_PROCESS_ = 0x0080;
217 const DWORD_ PROCESS_SET_QUOTA_ = 0x0100;
218 const DWORD_ PROCESS_SET_INFORMATION_ = 0x0200;
219 const DWORD_ PROCESS_QUERY_INFORMATION_ = 0x0400;
220 const DWORD_ PROCESS_SUSPEND_RESUME_ = 0x0800;
221 const DWORD_ PROCESS_ALL_ACCESS_ = (STANDARD_RIGHTS_REQUIRED_ | SYNCHRONIZE_ | 0xFFF);
222
223 #endif // defined( BOOST_USE_WINDOWS_H )
224
225 #if defined( BOOST_USE_WINDOWS_H ) && !defined( BOOST_WINAPI_IS_MINGW )
226
227 const DWORD_ CREATE_PRESERVE_CODE_AUTHZ_LEVEL_ = CREATE_PRESERVE_CODE_AUTHZ_LEVEL;
228
229 // Undocumented
230 const DWORD_ CREATE_IGNORE_SYSTEM_DEFAULT_ = CREATE_IGNORE_SYSTEM_DEFAULT;
231
232 #else // defined( BOOST_USE_WINDOWS_H ) && !defined( BOOST_WINAPI_IS_MINGW )
233
234 const DWORD_ CREATE_PRESERVE_CODE_AUTHZ_LEVEL_ = 0x2000000;
235
236 // Undocumented
237 const DWORD_ CREATE_IGNORE_SYSTEM_DEFAULT_ = 0x80000000;
238
239 #endif // defined( BOOST_USE_WINDOWS_H ) && !defined( BOOST_WINAPI_IS_MINGW )
240
241 typedef struct BOOST_DETAIL_WINAPI_MAY_ALIAS _PROCESS_INFORMATION {
242 HANDLE_ hProcess;
243 HANDLE_ hThread;
244 DWORD_ dwProcessId;
245 DWORD_ dwThreadId;
246 } PROCESS_INFORMATION_, *PPROCESS_INFORMATION_, *LPPROCESS_INFORMATION_;
247
248 typedef struct BOOST_DETAIL_WINAPI_MAY_ALIAS _STARTUPINFOA {
249 DWORD_ cb;
250 LPSTR_ lpReserved;
251 LPSTR_ lpDesktop;
252 LPSTR_ lpTitle;
253 DWORD_ dwX;
254 DWORD_ dwY;
255 DWORD_ dwXSize;
256 DWORD_ dwYSize;
257 DWORD_ dwXCountChars;
258 DWORD_ dwYCountChars;
259 DWORD_ dwFillAttribute;
260 DWORD_ dwFlags;
261 WORD_ wShowWindow;
262 WORD_ cbReserved2;
263 LPBYTE_ lpReserved2;
264 HANDLE_ hStdInput;
265 HANDLE_ hStdOutput;
266 HANDLE_ hStdError;
267 } STARTUPINFOA_, *LPSTARTUPINFOA_;
268
269 typedef struct BOOST_DETAIL_WINAPI_MAY_ALIAS _STARTUPINFOW {
270 DWORD_ cb;
271 LPWSTR_ lpReserved;
272 LPWSTR_ lpDesktop;
273 LPWSTR_ lpTitle;
274 DWORD_ dwX;
275 DWORD_ dwY;
276 DWORD_ dwXSize;
277 DWORD_ dwYSize;
278 DWORD_ dwXCountChars;
279 DWORD_ dwYCountChars;
280 DWORD_ dwFillAttribute;
281 DWORD_ dwFlags;
282 WORD_ wShowWindow;
283 WORD_ cbReserved2;
284 LPBYTE_ lpReserved2;
285 HANDLE_ hStdInput;
286 HANDLE_ hStdOutput;
287 HANDLE_ hStdError;
288 } STARTUPINFOW_, *LPSTARTUPINFOW_;
289
290 #if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6
291
292 typedef struct _PROC_THREAD_ATTRIBUTE_LIST PROC_THREAD_ATTRIBUTE_LIST_, *PPROC_THREAD_ATTRIBUTE_LIST_;
293
294 #if !defined(BOOST_NO_ANSI_APIS)
295 typedef struct BOOST_DETAIL_WINAPI_MAY_ALIAS _STARTUPINFOEXA {
296 STARTUPINFOA_ StartupInfo;
297 PPROC_THREAD_ATTRIBUTE_LIST_ lpAttributeList;
298 } STARTUPINFOEXA_, *LPSTARTUPINFOEXA_;
299 #endif //BOOST_NO_ANSI_APIS
300
301 typedef struct BOOST_DETAIL_WINAPI_MAY_ALIAS _STARTUPINFOEXW {
302 STARTUPINFOW_ StartupInfo;
303 PPROC_THREAD_ATTRIBUTE_LIST_ lpAttributeList;
304 } STARTUPINFOEXW_, *LPSTARTUPINFOEXW_;
305
306 #endif // BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6
307
308 using ::GetExitCodeProcess;
309 using ::ExitProcess;
310 using ::TerminateProcess;
311 using ::OpenProcess;
312
313 #if !defined( BOOST_NO_ANSI_APIS )
314 BOOST_FORCEINLINE BOOL_ CreateProcessA(
315 LPCSTR_ lpApplicationName,
316 LPSTR_ lpCommandLine,
317 LPSECURITY_ATTRIBUTES_ lpProcessAttributes,
318 LPSECURITY_ATTRIBUTES_ lpThreadAttributes,
319 INT_ bInheritHandles,
320 DWORD_ dwCreationFlags,
321 LPVOID_ lpEnvironment,
322 LPCSTR_ lpCurrentDirectory,
323 LPSTARTUPINFOA_ lpStartupInfo,
324 LPPROCESS_INFORMATION_ lpProcessInformation)
325 {
326 return ::CreateProcessA(
327 lpApplicationName,
328 lpCommandLine,
329 reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpProcessAttributes),
330 reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpThreadAttributes),
331 bInheritHandles,
332 dwCreationFlags,
333 lpEnvironment,
334 lpCurrentDirectory,
335 reinterpret_cast< ::_STARTUPINFOA* >(lpStartupInfo),
336 reinterpret_cast< ::_PROCESS_INFORMATION* >(lpProcessInformation));
337 }
338
339 BOOST_FORCEINLINE BOOL_ create_process(
340 LPCSTR_ lpApplicationName,
341 LPSTR_ lpCommandLine,
342 LPSECURITY_ATTRIBUTES_ lpProcessAttributes,
343 LPSECURITY_ATTRIBUTES_ lpThreadAttributes,
344 INT_ bInheritHandles,
345 DWORD_ dwCreationFlags,
346 LPVOID_ lpEnvironment,
347 LPCSTR_ lpCurrentDirectory,
348 LPSTARTUPINFOA_ lpStartupInfo,
349 LPPROCESS_INFORMATION_ lpProcessInformation)
350 {
351 return ::CreateProcessA(
352 lpApplicationName,
353 lpCommandLine,
354 reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpProcessAttributes),
355 reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpThreadAttributes),
356 bInheritHandles,
357 dwCreationFlags,
358 lpEnvironment,
359 lpCurrentDirectory,
360 reinterpret_cast< ::_STARTUPINFOA* >(lpStartupInfo),
361 reinterpret_cast< ::_PROCESS_INFORMATION* >(lpProcessInformation));
362 }
363 #endif
364
365 BOOST_FORCEINLINE BOOL_ CreateProcessW(
366 LPCWSTR_ lpApplicationName,
367 LPWSTR_ lpCommandLine,
368 LPSECURITY_ATTRIBUTES_ lpProcessAttributes,
369 LPSECURITY_ATTRIBUTES_ lpThreadAttributes,
370 INT_ bInheritHandles,
371 DWORD_ dwCreationFlags,
372 LPVOID_ lpEnvironment,
373 LPCWSTR_ lpCurrentDirectory,
374 LPSTARTUPINFOW_ lpStartupInfo,
375 LPPROCESS_INFORMATION_ lpProcessInformation)
376 {
377 return ::CreateProcessW(
378 lpApplicationName,
379 lpCommandLine,
380 reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpProcessAttributes),
381 reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpThreadAttributes),
382 bInheritHandles,
383 dwCreationFlags,
384 lpEnvironment,
385 lpCurrentDirectory,
386 reinterpret_cast< ::_STARTUPINFOW* >(lpStartupInfo),
387 reinterpret_cast< ::_PROCESS_INFORMATION* >(lpProcessInformation));
388 }
389
390 BOOST_FORCEINLINE BOOL_ create_process(
391 LPCWSTR_ lpApplicationName,
392 LPWSTR_ lpCommandLine,
393 LPSECURITY_ATTRIBUTES_ lpProcessAttributes,
394 LPSECURITY_ATTRIBUTES_ lpThreadAttributes,
395 INT_ bInheritHandles,
396 DWORD_ dwCreationFlags,
397 LPVOID_ lpEnvironment,
398 LPCWSTR_ lpCurrentDirectory,
399 LPSTARTUPINFOW_ lpStartupInfo,
400 LPPROCESS_INFORMATION_ lpProcessInformation)
401 {
402 return ::CreateProcessW(
403 lpApplicationName,
404 lpCommandLine,
405 reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpProcessAttributes),
406 reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpThreadAttributes),
407 bInheritHandles,
408 dwCreationFlags,
409 lpEnvironment,
410 lpCurrentDirectory,
411 reinterpret_cast< ::_STARTUPINFOW* >(lpStartupInfo),
412 reinterpret_cast< ::_PROCESS_INFORMATION* >(lpProcessInformation));
413 }
414
415 }
416 }
417 }
418
419 #endif // BOOST_PLAT_WINDOWS_DESKTOP
420
421 #endif // BOOST_DETAIL_WINAPI_PROCESS_HPP_