source: Daodan/MSYS2/mingw32/i686-w64-mingw32/include/processthreadsapi.h@ 1186

Last change on this file since 1186 was 1166, checked in by rossy, 3 years ago

Daodan: Replace MinGW build env with an up-to-date MSYS2 env

File size: 13.5 KB
RevLine 
[1166]1/**
2 * This file is part of the mingw-w64 runtime package.
3 * No warranty is given; refer to the file DISCLAIMER within this package.
4 */
5#ifndef _PROCESSTHREADSAPI_H_
6#define _PROCESSTHREADSAPI_H_
7
8#include <apiset.h>
9#include <apisetcconv.h>
10#include <minwindef.h>
11#include <minwinbase.h>
12
13#ifdef __cplusplus
14extern "C" {
15#endif
16
17#ifndef FLS_OUT_OF_INDEXES
18#define FLS_OUT_OF_INDEXES ((DWORD)0xffffffff)
19#endif
20
21#define TLS_OUT_OF_INDEXES ((DWORD)0xffffffff)
22
23#if WINAPI_FAMILY_PARTITION (WINAPI_PARTITION_DESKTOP) || _WIN32_WINNT >= _WIN32_WINNT_WIN10
24 WINBASEAPI HANDLE WINAPI OpenProcess (DWORD dwDesiredAccess, WINBOOL bInheritHandle, DWORD dwProcessId);
25
26 WINBASEAPI DWORD WINAPI QueueUserAPC (PAPCFUNC pfnAPC, HANDLE hThread, ULONG_PTR dwData);
27 WINBASEAPI WINBOOL WINAPI GetProcessTimes (HANDLE hProcess, LPFILETIME lpCreationTime, LPFILETIME lpExitTime, LPFILETIME lpKernelTime, LPFILETIME lpUserTime);
28 WINBASEAPI DECLSPEC_NORETURN VOID WINAPI ExitProcess (UINT uExitCode);
29 WINBASEAPI WINBOOL WINAPI GetExitCodeProcess (HANDLE hProcess, LPDWORD lpExitCode);
30 WINBASEAPI WINBOOL WINAPI SwitchToThread (VOID);
31 WINBASEAPI HANDLE WINAPI OpenThread (DWORD dwDesiredAccess, WINBOOL bInheritHandle, DWORD dwThreadId);
32 WINBASEAPI WINBOOL WINAPI SetThreadPriorityBoost (HANDLE hThread, WINBOOL bDisablePriorityBoost);
33 WINBASEAPI WINBOOL WINAPI GetThreadPriorityBoost (HANDLE hThread, PBOOL pDisablePriorityBoost);
34 WINADVAPI WINBOOL APIENTRY SetThreadToken (PHANDLE Thread, HANDLE Token);
35 WINADVAPI WINBOOL WINAPI OpenProcessToken (HANDLE ProcessHandle, DWORD DesiredAccess, PHANDLE TokenHandle);
36 WINADVAPI WINBOOL WINAPI OpenThreadToken (HANDLE ThreadHandle, DWORD DesiredAccess, WINBOOL OpenAsSelf, PHANDLE TokenHandle);
37 WINBASEAPI WINBOOL WINAPI SetPriorityClass (HANDLE hProcess, DWORD dwPriorityClass);
38 WINBASEAPI DWORD WINAPI GetPriorityClass (HANDLE hProcess);
39 WINBASEAPI DWORD WINAPI GetProcessId (HANDLE Process);
40 WINBASEAPI DWORD WINAPI GetThreadId (HANDLE Thread);
41 WINBASEAPI WINBOOL WINAPI GetThreadContext (HANDLE hThread, LPCONTEXT lpContext);
42 WINBASEAPI WINBOOL WINAPI FlushInstructionCache (HANDLE hProcess, LPCVOID lpBaseAddress, SIZE_T dwSize);
43 WINBASEAPI WINBOOL WINAPI GetThreadTimes (HANDLE hThread, LPFILETIME lpCreationTime, LPFILETIME lpExitTime, LPFILETIME lpKernelTime, LPFILETIME lpUserTime);
44 WINBASEAPI DWORD WINAPI GetCurrentProcessorNumber (VOID);
45
46#endif
47
48#if WINAPI_FAMILY_PARTITION (WINAPI_PARTITION_APP)
49 WINBASEAPI WINBOOL WINAPI TerminateProcess (HANDLE hProcess, UINT uExitCode);
50
51 typedef struct _STARTUPINFOA {
52 DWORD cb;
53 LPSTR lpReserved;
54 LPSTR lpDesktop;
55 LPSTR lpTitle;
56 DWORD dwX;
57 DWORD dwY;
58 DWORD dwXSize;
59 DWORD dwYSize;
60 DWORD dwXCountChars;
61 DWORD dwYCountChars;
62 DWORD dwFillAttribute;
63 DWORD dwFlags;
64 WORD wShowWindow;
65 WORD cbReserved2;
66 LPBYTE lpReserved2;
67 HANDLE hStdInput;
68 HANDLE hStdOutput;
69 HANDLE hStdError;
70 } STARTUPINFOA, *LPSTARTUPINFOA;
71
72 typedef struct _STARTUPINFOW {
73 DWORD cb;
74 LPWSTR lpReserved;
75 LPWSTR lpDesktop;
76 LPWSTR lpTitle;
77 DWORD dwX;
78 DWORD dwY;
79 DWORD dwXSize;
80 DWORD dwYSize;
81 DWORD dwXCountChars;
82 DWORD dwYCountChars;
83 DWORD dwFillAttribute;
84 DWORD dwFlags;
85 WORD wShowWindow;
86 WORD cbReserved2;
87 LPBYTE lpReserved2;
88 HANDLE hStdInput;
89 HANDLE hStdOutput;
90 HANDLE hStdError;
91 } STARTUPINFOW, *LPSTARTUPINFOW;
92
93 __MINGW_TYPEDEF_AW(STARTUPINFO)
94 __MINGW_TYPEDEF_AW(LPSTARTUPINFO)
95
96 typedef struct _PROCESS_INFORMATION {
97 HANDLE hProcess;
98 HANDLE hThread;
99 DWORD dwProcessId;
100 DWORD dwThreadId;
101 } PROCESS_INFORMATION, *PPROCESS_INFORMATION, *LPPROCESS_INFORMATION;
102
103 typedef enum _PROCESS_INFORMATION_CLASS {
104 ProcessMemoryPriority,
105 ProcessMemoryExhaustionInfo,
106 ProcessAppMemoryInfo,
107 ProcessInPrivateInfo,
108 ProcessPowerThrottling,
109 ProcessReservedValue1,
110 ProcessTelemetryCoverageInfo,
111 ProcessProtectionLevelInfo,
112 ProcessLeapSecondInfo,
113 ProcessMachineTypeInfo,
114 ProcessInformationClassMax
115 } PROCESS_INFORMATION_CLASS;
116
117 typedef struct _APP_MEMORY_INFORMATION {
118 ULONG64 AvailableCommit;
119 ULONG64 PrivateCommitUsage;
120 ULONG64 PeakPrivateCommitUsage;
121 ULONG64 TotalCommitUsage;
122 } APP_MEMORY_INFORMATION, *PAPP_MEMORY_INFORMATION;
123
124 typedef enum _MACHINE_ATTRIBUTES {
125 UserEnabled = 0x00000001,
126 KernelEnabled = 0x00000002,
127 Wow64Container = 0x00000004
128 } MACHINE_ATTRIBUTES;
129#ifndef __WIDL__
130DEFINE_ENUM_FLAG_OPERATORS(MACHINE_ATTRIBUTES);
131#endif
132
133 typedef struct _PROCESS_MACHINE_INFORMATION {
134 USHORT ProcessMachine;
135 USHORT Res0;
136 MACHINE_ATTRIBUTES MachineAttributes;
137 } PROCESS_MACHINE_INFORMATION;
138
139#define PME_CURRENT_VERSION 1
140
141 typedef enum _PROCESS_MEMORY_EXHAUSTION_TYPE {
142 PMETypeFailFastOnCommitFailure,
143 PMETypeMax
144 } PROCESS_MEMORY_EXHAUSTION_TYPE, *PPROCESS_MEMORY_EXHAUSTION_TYPE;
145
146#define PME_FAILFAST_ON_COMMIT_FAIL_DISABLE 0x0
147#define PME_FAILFAST_ON_COMMIT_FAIL_ENABLE 0x1
148
149 typedef struct _PROCESS_MEMORY_EXHAUSTION_INFO {
150 USHORT Version;
151 USHORT Reserved;
152 PROCESS_MEMORY_EXHAUSTION_TYPE Type;
153 ULONG_PTR Value;
154 } PROCESS_MEMORY_EXHAUSTION_INFO, *PPROCESS_MEMORY_EXHAUSTION_INFO;
155
156#define PROCESS_POWER_THROTTLING_CURRENT_VERSION 1
157
158#define PROCESS_POWER_THROTTLING_EXECUTION_SPEED 0x1
159#define PROCESS_POWER_THROTTLING_IGNORE_TIMER_RESOLUTION 0x4
160
161#define PROCESS_POWER_THROTTLING_VALID_FLAGS (PROCESS_POWER_THROTTLING_EXECUTION_SPEED | PROCESS_POWER_THROTTLING_IGNORE_TIMER_RESOLUTION)
162
163 typedef struct _PROCESS_POWER_THROTTLING_STATE {
164 ULONG Version;
165 ULONG ControlMask;
166 ULONG StateMask;
167 } PROCESS_POWER_THROTTLING_STATE, *PPROCESS_POWER_THROTTLING_STATE;
168
169 typedef struct PROCESS_PROTECTION_LEVEL_INFORMATION {
170 DWORD ProtectionLevel;
171 } PROCESS_PROTECTION_LEVEL_INFORMATION;
172
173#define PROCESS_LEAP_SECOND_INFO_FLAG_ENABLE_SIXTY_SECOND 0x1
174#define PROCESS_LEAP_SECOND_INFO_VALID_FLAGS PROCESS_LEAP_SECOND_INFO_FLAG_ENABLE_SIXTY_SECOND
175
176 typedef struct _PROCESS_LEAP_SECOND_INFO {
177 ULONG Flags;
178 ULONG Reserved;
179 } PROCESS_LEAP_SECOND_INFO, *PPROCESS_LEAP_SECOND_INFO;
180
181#if _WIN32_WINNT >= 0x0602
182 WINBASEAPI WINBOOL WINAPI GetProcessInformation (HANDLE hProcess, PROCESS_INFORMATION_CLASS ProcessInformationClass, LPVOID ProcessInformation, DWORD ProcessInformationSize);
183 WINBASEAPI WINBOOL WINAPI SetProcessInformation (HANDLE hProcess, PROCESS_INFORMATION_CLASS ProcessInformationClass, LPVOID ProcessInformation, DWORD ProcessInformationSize);
184#endif
185
186#endif /* WINAPI_PARTITION_APP */
187
188#if WINAPI_FAMILY_PARTITION (WINAPI_PARTITION_DESKTOP)
189
190 typedef struct _PROC_THREAD_ATTRIBUTE_LIST *PPROC_THREAD_ATTRIBUTE_LIST, *LPPROC_THREAD_ATTRIBUTE_LIST;
191
192 WINBASEAPI HANDLE WINAPI CreateRemoteThread (HANDLE hProcess, LPSECURITY_ATTRIBUTES lpThreadAttributes, SIZE_T dwStackSize, LPTHREAD_START_ROUTINE lpStartAddress, LPVOID lpParameter, DWORD dwCreationFlags, LPDWORD lpThreadId);
193 WINBASEAPI WINBOOL WINAPI TerminateThread (HANDLE hThread, DWORD dwExitCode);
194 WINBASEAPI WINBOOL WINAPI SetProcessShutdownParameters (DWORD dwLevel, DWORD dwFlags);
195 WINBASEAPI DWORD WINAPI GetProcessVersion (DWORD ProcessId);
196 WINBASEAPI VOID WINAPI GetStartupInfoW (LPSTARTUPINFOW lpStartupInfo);
197 WINBASEAPI WINBOOL WINAPI SetThreadStackGuarantee (PULONG StackSizeInBytes);
198 WINBASEAPI WINBOOL WINAPI ProcessIdToSessionId (DWORD dwProcessId, DWORD *pSessionId);
199 WINBASEAPI HANDLE WINAPI CreateRemoteThreadEx (HANDLE hProcess, LPSECURITY_ATTRIBUTES lpThreadAttributes, SIZE_T dwStackSize, LPTHREAD_START_ROUTINE lpStartAddress, LPVOID lpParameter, DWORD dwCreationFlags, LPPROC_THREAD_ATTRIBUTE_LIST lpAttributeList, LPDWORD lpThreadId);
200 WINBASEAPI WINBOOL WINAPI SetThreadContext (HANDLE hThread, CONST CONTEXT *lpContext);
201 WINBASEAPI WINBOOL WINAPI GetProcessHandleCount (HANDLE hProcess, PDWORD pdwHandleCount);
202
203#ifdef UNICODE
204#define GetStartupInfo GetStartupInfoW
205#endif
206
207#ifndef _APISET_EXPORTS_FILTER
208 WINADVAPI WINBOOL WINAPI CreateProcessAsUserW (HANDLE hToken, LPCWSTR lpApplicationName, LPWSTR lpCommandLine, LPSECURITY_ATTRIBUTES lpProcessAttributes, LPSECURITY_ATTRIBUTES lpThreadAttributes, WINBOOL bInheritHandles, DWORD dwCreationFlags, LPVOID lpEnvironment, LPCWSTR lpCurrentDirectory, LPSTARTUPINFOW lpStartupInfo, LPPROCESS_INFORMATION lpProcessInformation);
209
210#ifdef UNICODE
211#define CreateProcessAsUser CreateProcessAsUserW
212#endif
213#endif
214
215#if _WIN32_WINNT >= 0x0600
216#define PROCESS_AFFINITY_ENABLE_AUTO_UPDATE __MSABI_LONG(0x1U)
217#define PROC_THREAD_ATTRIBUTE_REPLACE_VALUE 0x00000001
218
219 WINBASEAPI DWORD WINAPI GetProcessIdOfThread (HANDLE Thread);
220 WINBASEAPI WINBOOL WINAPI InitializeProcThreadAttributeList (LPPROC_THREAD_ATTRIBUTE_LIST lpAttributeList, DWORD dwAttributeCount, DWORD dwFlags, PSIZE_T lpSize);
221 WINBASEAPI VOID WINAPI DeleteProcThreadAttributeList (LPPROC_THREAD_ATTRIBUTE_LIST lpAttributeList);
222 WINBASEAPI WINBOOL WINAPI SetProcessAffinityUpdateMode (HANDLE hProcess, DWORD dwFlags);
223 WINBASEAPI WINBOOL WINAPI QueryProcessAffinityUpdateMode (HANDLE hProcess, LPDWORD lpdwFlags);
224 WINBASEAPI WINBOOL WINAPI UpdateProcThreadAttribute (LPPROC_THREAD_ATTRIBUTE_LIST lpAttributeList, DWORD dwFlags, DWORD_PTR Attribute, PVOID lpValue, SIZE_T cbSize, PVOID lpPreviousValue, PSIZE_T lpReturnSize);
225#endif
226#if _WIN32_WINNT >= 0x0602
227 WINBASEAPI WINBOOL WINAPI SetProcessMitigationPolicy (PROCESS_MITIGATION_POLICY MitigationPolicy, PVOID lpBuffer, SIZE_T dwLength);
228
229 FORCEINLINE HANDLE GetCurrentProcessToken (VOID)
230 {
231 return (HANDLE)(LONG_PTR) (-4);
232 }
233 FORCEINLINE HANDLE GetCurrentThreadToken (VOID)
234 {
235 return (HANDLE)(LONG_PTR) (-5);
236 }
237 FORCEINLINE HANDLE GetCurrentThreadEffectiveToken (VOID)
238 {
239 return (HANDLE)(LONG_PTR) (-6);
240 }
241
242 typedef struct _MEMORY_PRIORITY_INFORMATION {
243 ULONG MemoryPriority;
244 } MEMORY_PRIORITY_INFORMATION, *PMEMORY_PRIORITY_INFORMATION;
245#endif
246
247#define MEMORY_PRIORITY_VERY_LOW 1
248#define MEMORY_PRIORITY_LOW 2
249#define MEMORY_PRIORITY_MEDIUM 3
250#define MEMORY_PRIORITY_BELOW_NORMAL 4
251#define MEMORY_PRIORITY_NORMAL 5
252
253#endif
254
255#if WINAPI_FAMILY_PARTITION (WINAPI_PARTITION_APP)
256#ifndef _APISET_EXPORTS_FILTER
257 WINBASEAPI WINBOOL WINAPI CreateProcessA (LPCSTR lpApplicationName, LPSTR lpCommandLine, LPSECURITY_ATTRIBUTES lpProcessAttributes, LPSECURITY_ATTRIBUTES lpThreadAttributes, WINBOOL bInheritHandles, DWORD dwCreationFlags, LPVOID lpEnvironment, LPCSTR lpCurrentDirectory, LPSTARTUPINFOA lpStartupInfo, LPPROCESS_INFORMATION lpProcessInformation);
258 WINBASEAPI WINBOOL WINAPI CreateProcessW (LPCWSTR lpApplicationName, LPWSTR lpCommandLine, LPSECURITY_ATTRIBUTES lpProcessAttributes, LPSECURITY_ATTRIBUTES lpThreadAttributes, WINBOOL bInheritHandles, DWORD dwCreationFlags, LPVOID lpEnvironment, LPCWSTR lpCurrentDirectory, LPSTARTUPINFOW lpStartupInfo, LPPROCESS_INFORMATION lpProcessInformation);
259#define CreateProcess __MINGW_NAME_AW(CreateProcess)
260
261 #if _WIN32_WINNT >= 0x0601
262 WINBASEAPI WINBOOL WINAPI GetThreadIdealProcessorEx (HANDLE hThread, PPROCESSOR_NUMBER lpIdealProcessor);
263 WINBASEAPI VOID WINAPI GetCurrentProcessorNumberEx (PPROCESSOR_NUMBER ProcNumber);
264#endif
265#if _WIN32_WINNT >= 0x0602
266 WINBASEAPI VOID WINAPI GetCurrentThreadStackLimits (PULONG_PTR LowLimit, PULONG_PTR HighLimit);
267 WINBASEAPI WINBOOL WINAPI GetProcessMitigationPolicy (HANDLE hProcess, PROCESS_MITIGATION_POLICY MitigationPolicy, PVOID lpBuffer, SIZE_T dwLength);
268#endif
269#endif
270
271 WINBASEAPI HANDLE WINAPI GetCurrentProcess (VOID);
272 WINBASEAPI DWORD WINAPI GetCurrentProcessId (VOID);
273 WINBASEAPI HANDLE WINAPI GetCurrentThread (VOID);
274 WINBASEAPI DWORD WINAPI GetCurrentThreadId (VOID);
275 WINBOOL WINAPI IsProcessorFeaturePresent (DWORD ProcessorFeature);
276#if _WIN32_WINNT >= 0x0600
277 WINBASEAPI VOID WINAPI FlushProcessWriteBuffers (VOID);
278#endif
279 WINBASEAPI HANDLE WINAPI CreateThread (LPSECURITY_ATTRIBUTES lpThreadAttributes, SIZE_T dwStackSize, LPTHREAD_START_ROUTINE lpStartAddress, LPVOID lpParameter, DWORD dwCreationFlags, LPDWORD lpThreadId);
280 WINBASEAPI WINBOOL WINAPI SetThreadPriority (HANDLE hThread, int nPriority);
281 WINBASEAPI int WINAPI GetThreadPriority (HANDLE hThread);
282 WINBASEAPI DECLSPEC_NORETURN VOID WINAPI ExitThread (DWORD dwExitCode);
283 WINBASEAPI WINBOOL WINAPI GetExitCodeThread (HANDLE hThread, LPDWORD lpExitCode);
284#if _WIN32_WINNT >= 0x0A00
285 WINBASEAPI DWORD WINAPI QueueUserAPC (PAPCFUNC pfnAPC, HANDLE hThread, ULONG_PTR dwData);
286 WINBASEAPI WINBOOL WINAPI SwitchToThread (VOID);
287#endif
288 WINBASEAPI DWORD WINAPI SuspendThread (HANDLE hThread);
289 WINBASEAPI DWORD WINAPI ResumeThread (HANDLE hThread);
290 WINBASEAPI DWORD WINAPI TlsAlloc (VOID);
291 WINBASEAPI LPVOID WINAPI TlsGetValue (DWORD dwTlsIndex);
292 WINBASEAPI WINBOOL WINAPI TlsSetValue (DWORD dwTlsIndex, LPVOID lpTlsValue);
293 WINBASEAPI WINBOOL WINAPI TlsFree (DWORD dwTlsIndex);
294#if _WIN32_WINNT >= 0x0601
295 WINBASEAPI WINBOOL WINAPI SetThreadIdealProcessorEx (HANDLE hThread, PPROCESSOR_NUMBER lpIdealProcessor, PPROCESSOR_NUMBER lpPreviousIdealProcessor);
296#endif
297#if NTDDI_VERSION >= NTDDI_WIN10_VB
298 WINBASEAPI WINBOOL WINAPI SetProcessDynamicEHContinuationTargets (HANDLE Process, USHORT NumberOfTargets, PPROCESS_DYNAMIC_EH_CONTINUATION_TARGET Targets);
299#endif
300#if NTDDI_VERSION >= NTDDI_WIN10_MN
301 typedef enum _QUEUE_USER_APC_FLAGS {
302 QUEUE_USER_APC_FLAGS_NONE = 0x0,
303 QUEUE_USER_APC_FLAGS_SPECIAL_USER_APC = 0x1
304 } QUEUE_USER_APC_FLAGS;
305 WINBASEAPI WINBOOL WINAPI QueueUserAPC2 (PAPCFUNC ApcRoutine, HANDLE Thread, ULONG_PTR Data, QUEUE_USER_APC_FLAGS Flags);
306#endif
307#if NTDDI_VERSION >= NTDDI_WIN10_FE
308 WINBASEAPI WINBOOL WINAPI SetProcessDynamicEnforcedCetCompatibleRanges (HANDLE Process, USHORT NumberOfRanges, PPROCESS_DYNAMIC_ENFORCED_ADDRESS_RANGE Ranges);
309#endif
310
311#endif
312
313#ifdef __cplusplus
314}
315#endif
316#endif
Note: See TracBrowser for help on using the repository browser.