Reactos
at master 375 lines 12 kB view raw
1// 2// process.h 3// 4// Copyright (c) Microsoft Corporation. All rights reserved. 5// 6// This file declares the process control functionality (e.g., the exec and 7// spawn families of functions). 8// 9#pragma once 10#ifndef _INC_PROCESS // include guard for 3rd party interop 11#define _INC_PROCESS 12 13#include <corecrt.h> 14#include <corecrt_startup.h> 15#include <corecrt_wprocess.h> 16 17#pragma warning(push) 18#pragma warning(disable: _UCRT_DISABLED_WARNINGS) 19_UCRT_DISABLE_CLANG_WARNINGS 20 21_CRT_BEGIN_C_HEADER 22 23 24 25// Flag values for the _spawn family of functions 26#define _P_WAIT 0 27#define _P_NOWAIT 1 28#define _OLD_P_OVERLAY 2 29#define _P_NOWAITO 3 30#define _P_DETACH 4 31#define _P_OVERLAY 2 32 33// Action codes for _cwait(). The action code argument to _cwait() is ignored on 34// Win32. The parameter only exists so that we do not break existing code. 35#define _WAIT_CHILD 0 36#define _WAIT_GRANDCHILD 1 37 38 39 40#if _CRT_FUNCTIONS_REQUIRED 41 42 _ACRTIMP __declspec(noreturn) void __cdecl exit(_In_ int _Code); 43 _ACRTIMP __declspec(noreturn) void __cdecl _exit(_In_ int _Code); 44 _ACRTIMP __declspec(noreturn) void __cdecl _Exit(_In_ int _Code); 45 _ACRTIMP __declspec(noreturn) void __cdecl quick_exit(_In_ int _Code); 46 _ACRTIMP __declspec(noreturn) void __cdecl abort(void); 47 48 _DCRTIMP int __cdecl system(_In_opt_z_ char const* _Command); 49 50 _ACRTIMP void __cdecl _cexit(void); 51 _ACRTIMP void __cdecl _c_exit(void); 52 53 typedef void (__stdcall *_tls_callback_type)(void *, unsigned long, void *); 54 _ACRTIMP void __cdecl _register_thread_local_exe_atexit_callback(_In_ _tls_callback_type _Callback); 55 56#endif // _CRT_FUNCTIONS_REQUIRED 57 58// Declare DLL notification (initialization/termination) routines. The preferred 59// method is for the CRT client to define DllMain(), which will automatically be 60// called by the DLL entry point defined by the CRT. If the CRT client wants to 61// define the DLL entry point, the client entry point must call _CRT_INIT on all 62// types of notifications, as the very first thing on attach notifications and as 63// the very last thing on detach notifications. 64#ifdef _DECL_DLLMAIN 65 66 int __stdcall DllMain( 67 _In_ void* _DllHandle, 68 _In_ unsigned long _Reason, 69 _In_opt_ void* _Reserved 70 ); 71 72 int __stdcall _CRT_INIT( 73 _In_ void* _DllHandle, 74 _In_ unsigned long _Reason, 75 _In_opt_ void* _Reserved 76 ); 77 78 extern int (__stdcall* const _pRawDllMain)(void*, unsigned long, void*); 79 80#endif 81 82 83 84typedef void (__cdecl* _beginthread_proc_type )(void*); 85typedef unsigned (__stdcall* _beginthreadex_proc_type)(void*); 86 87_ACRTIMP uintptr_t __cdecl _beginthread( 88 _In_ _beginthread_proc_type _StartAddress, 89 _In_ unsigned _StackSize, 90 _In_opt_ void* _ArgList 91 ); 92 93_ACRTIMP void __cdecl _endthread(void); 94 95_Success_(return != 0) 96_ACRTIMP uintptr_t __cdecl _beginthreadex( 97 _In_opt_ void* _Security, 98 _In_ unsigned _StackSize, 99 _In_ _beginthreadex_proc_type _StartAddress, 100 _In_opt_ void* _ArgList, 101 _In_ unsigned _InitFlag, 102 _Out_opt_ unsigned* _ThrdAddr 103 ); 104 105_ACRTIMP void __cdecl _endthreadex( 106 _In_ unsigned _ReturnCode 107 ); 108 109 110 111#ifdef _CRT_USE_WINAPI_FAMILY_DESKTOP_APP 112 113 _ACRTIMP int __cdecl _getpid(void); 114 115 _DCRTIMP intptr_t __cdecl _cwait( 116 _Out_opt_ int* _TermStat, 117 _In_ intptr_t _ProcHandle, 118 _In_ int _Action 119 ); 120 121 _DCRTIMP intptr_t __cdecl _execl( 122 _In_z_ char const* _FileName, 123 _In_z_ char const* _Arguments, 124 ...); 125 126 _DCRTIMP intptr_t __cdecl _execle( 127 _In_z_ char const* _FileName, 128 _In_z_ char const* _Arguments, 129 ...); 130 131 _DCRTIMP intptr_t __cdecl _execlp( 132 _In_z_ char const* _FileName, 133 _In_z_ char const* _Arguments, 134 ...); 135 136 _DCRTIMP intptr_t __cdecl _execlpe( 137 _In_z_ char const* _FileName, 138 _In_z_ char const* _Arguments, 139 ...); 140 141 _DCRTIMP intptr_t __cdecl _execv( 142 _In_z_ char const* _FileName, 143 _In_z_ char const* const* _Arguments 144 ); 145 146 _DCRTIMP intptr_t __cdecl _execve( 147 _In_z_ char const* _FileName, 148 _In_z_ char const* const* _Arguments, 149 _In_opt_z_ char const* const* _Environment 150 ); 151 152 _DCRTIMP intptr_t __cdecl _execvp( 153 _In_z_ char const* _FileName, 154 _In_z_ char const* const* _Arguments 155 ); 156 157 _DCRTIMP intptr_t __cdecl _execvpe( 158 _In_z_ char const* _FileName, 159 _In_z_ char const* const* _Arguments, 160 _In_opt_z_ char const* const* _Environment 161 ); 162 163 _DCRTIMP intptr_t __cdecl _spawnl( 164 _In_ int _Mode, 165 _In_z_ char const* _FileName, 166 _In_z_ char const* _Arguments, 167 ...); 168 169 _DCRTIMP intptr_t __cdecl _spawnle( 170 _In_ int _Mode, 171 _In_z_ char const* _FileName, 172 _In_z_ char const* _Arguments, 173 ...); 174 175 _DCRTIMP intptr_t __cdecl _spawnlp( 176 _In_ int _Mode, 177 _In_z_ char const* _FileName, 178 _In_z_ char const* _Arguments, 179 ...); 180 181 _DCRTIMP intptr_t __cdecl _spawnlpe( 182 _In_ int _Mode, 183 _In_z_ char const* _FileName, 184 _In_z_ char const* _Arguments, 185 ...); 186 187 _DCRTIMP intptr_t __cdecl _spawnv( 188 _In_ int _Mode, 189 _In_z_ char const* _FileName, 190 _In_z_ char const* const* _Arguments 191 ); 192 193 _DCRTIMP intptr_t __cdecl _spawnve( 194 _In_ int _Mode, 195 _In_z_ char const* _FileName, 196 _In_z_ char const* const* _Arguments, 197 _In_opt_z_ char const* const* _Environment 198 ); 199 200 _DCRTIMP intptr_t __cdecl _spawnvp( 201 _In_ int _Mode, 202 _In_z_ char const* _FileName, 203 _In_z_ char const* const* _Arguments 204 ); 205 206 _DCRTIMP intptr_t __cdecl _spawnvpe( 207 _In_ int _Mode, 208 _In_z_ char const* _FileName, 209 _In_z_ char const* const* _Arguments, 210 _In_opt_z_ char const* const* _Environment 211 ); 212 213 _CRT_OBSOLETE(LoadLibrary) 214 _DCRTIMP intptr_t __cdecl _loaddll( 215 _In_z_ char* _FileName 216 ); 217 218 _CRT_OBSOLETE(FreeLibrary) 219 _DCRTIMP int __cdecl _unloaddll( 220 _In_ intptr_t _Handle 221 ); 222 223 typedef int (__cdecl* _GetDllProcAddrProcType)(void); 224 225 _CRT_OBSOLETE(GetProcAddress) 226 _DCRTIMP _GetDllProcAddrProcType __cdecl _getdllprocaddr( 227 _In_ intptr_t _Handle, 228 _In_opt_z_ char* _ProcedureName, 229 _In_ intptr_t _Ordinal 230 ); 231 232#endif // _CRT_USE_WINAPI_FAMILY_DESKTOP_APP 233 234 235 236#if defined(_CRT_INTERNAL_NONSTDC_NAMES) && _CRT_INTERNAL_NONSTDC_NAMES 237 238 #define P_WAIT _P_WAIT 239 #define P_NOWAIT _P_NOWAIT 240 #define P_OVERLAY _P_OVERLAY 241 #define OLD_P_OVERLAY _OLD_P_OVERLAY 242 #define P_NOWAITO _P_NOWAITO 243 #define P_DETACH _P_DETACH 244 #define WAIT_CHILD _WAIT_CHILD 245 #define WAIT_GRANDCHILD _WAIT_GRANDCHILD 246 247 #ifdef _CRT_USE_WINAPI_FAMILY_DESKTOP_APP 248 249 _CRT_NONSTDC_DEPRECATE(_cwait) 250 _DCRTIMP intptr_t __cdecl cwait( 251 _Out_opt_ int* _TermStat, 252 _In_ intptr_t _ProcHandle, 253 _In_ int _Action 254 ); 255 256 _CRT_NONSTDC_DEPRECATE(_execl) 257 _DCRTIMP intptr_t __cdecl execl( 258 _In_z_ char const* _FileName, 259 _In_z_ char const* _Arguments, 260 ...); 261 262 _CRT_NONSTDC_DEPRECATE(_execle) 263 _DCRTIMP intptr_t __cdecl execle( 264 _In_z_ char const* _FileName, 265 _In_z_ char const* _Arguments, 266 ...); 267 268 _CRT_NONSTDC_DEPRECATE(_execlp) 269 _DCRTIMP intptr_t __cdecl execlp( 270 _In_z_ char const* _FileName, 271 _In_z_ char const* _Arguments, 272 ...); 273 274 _CRT_NONSTDC_DEPRECATE(_execlpe) 275 _DCRTIMP intptr_t __cdecl execlpe( 276 _In_z_ char const* _FileName, 277 _In_z_ char const* _Arguments, 278 ...); 279 280 _CRT_NONSTDC_DEPRECATE(_execv) 281 _DCRTIMP intptr_t __cdecl execv( 282 _In_z_ char const* _FileName, 283 _In_z_ char const* const* _Arguments 284 ); 285 286 _CRT_NONSTDC_DEPRECATE(_execve) 287 _DCRTIMP intptr_t __cdecl execve( 288 _In_z_ char const* _FileName, 289 _In_z_ char const* const* _Arguments, 290 _In_opt_z_ char const* const* _Environment 291 ); 292 293 _CRT_NONSTDC_DEPRECATE(_execvp) 294 _DCRTIMP intptr_t __cdecl execvp( 295 _In_z_ char const* _FileName, 296 _In_z_ char const* const* _Arguments 297 ); 298 299 _CRT_NONSTDC_DEPRECATE(_execvpe) 300 _DCRTIMP intptr_t __cdecl execvpe( 301 _In_z_ char const* _FileName, 302 _In_z_ char const* const* _Arguments, 303 _In_opt_z_ char const* const* _Environment 304 ); 305 306 _CRT_NONSTDC_DEPRECATE(_spawnl) 307 _DCRTIMP intptr_t __cdecl spawnl( 308 _In_ int _Mode, 309 _In_z_ char const* _FileName, 310 _In_z_ char const* _Arguments, 311 ...); 312 313 _CRT_NONSTDC_DEPRECATE(_spawnle) 314 _DCRTIMP intptr_t __cdecl spawnle( 315 _In_ int _Mode, 316 _In_z_ char const* _FileName, 317 _In_z_ char const* _Arguments, 318 ...); 319 320 _CRT_NONSTDC_DEPRECATE(_spawnlp) 321 _DCRTIMP intptr_t __cdecl spawnlp( 322 _In_ int _Mode, 323 _In_z_ char const* _FileName, 324 _In_z_ char const* _Arguments, 325 ...); 326 327 _CRT_NONSTDC_DEPRECATE(_spawnlpe) 328 _DCRTIMP intptr_t __cdecl spawnlpe( 329 _In_ int _Mode, 330 _In_z_ char const* _FileName, 331 _In_z_ char const* _Arguments, 332 ...); 333 334 _CRT_NONSTDC_DEPRECATE(_spawnv) 335 _DCRTIMP intptr_t __cdecl spawnv( 336 _In_ int _Mode, 337 _In_z_ char const* _FileName, 338 _In_z_ char const* const* _Arguments); 339 340 _CRT_NONSTDC_DEPRECATE(_spawnve) 341 _DCRTIMP intptr_t __cdecl spawnve( 342 _In_ int _Mode, 343 _In_z_ char const* _FileName, 344 _In_z_ char const* const* _Arguments, 345 _In_opt_z_ char const* const* _Environment 346 ); 347 348 _CRT_NONSTDC_DEPRECATE(_spawnvp) 349 _DCRTIMP intptr_t __cdecl spawnvp( 350 _In_ int _Mode, 351 _In_z_ char const* _FileName, 352 _In_z_ char const* const* _Arguments 353 ); 354 355 _CRT_NONSTDC_DEPRECATE(_spawnvpe) 356 _DCRTIMP intptr_t __cdecl spawnvpe( 357 _In_ int _Mode, 358 _In_z_ char const* _FileName, 359 _In_z_ char const* const* _Arguments, 360 _In_opt_z_ char const* const* _Environment 361 ); 362 363 _CRT_NONSTDC_DEPRECATE(_getpid) 364 _ACRTIMP int __cdecl getpid(void); 365 366 #endif // _CRT_USE_WINAPI_FAMILY_DESKTOP_APP 367 368#endif // _CRT_INTERNAL_NONSTDC_NAMES 369 370 371 372_CRT_END_C_HEADER 373_UCRT_RESTORE_CLANG_WARNINGS 374#pragma warning(pop) // _UCRT_DISABLED_WARNINGS 375#endif // _INC_PROCESS