process.hpp 19 KB

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