• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef _MINWINBASE_
2 #define _MINWINBASE_
3 
4 #ifdef __cplusplus
5 extern "C" {
6 #endif
7 
8 #define MoveMemory RtlMoveMemory
9 #define CopyMemory RtlCopyMemory
10 #define FillMemory RtlFillMemory
11 #define ZeroMemory RtlZeroMemory
12 
13   typedef struct _SECURITY_ATTRIBUTES {
14     DWORD nLength;
15     LPVOID lpSecurityDescriptor;
16     WINBOOL bInheritHandle;
17   } SECURITY_ATTRIBUTES, *PSECURITY_ATTRIBUTES, *LPSECURITY_ATTRIBUTES;
18 
19   typedef struct _OVERLAPPED {
20     ULONG_PTR Internal;
21     ULONG_PTR InternalHigh;
22     __C89_NAMELESS union {
23         struct {
24             DWORD Offset;
25             DWORD OffsetHigh;
26         } DUMMYSTRUCTNAME;
27         PVOID Pointer;
28     } DUMMYUNIONNAME;
29     HANDLE hEvent;
30   } OVERLAPPED, *LPOVERLAPPED;
31 
32   typedef struct _OVERLAPPED_ENTRY {
33     ULONG_PTR lpCompletionKey;
34     LPOVERLAPPED lpOverlapped;
35     ULONG_PTR Internal;
36     DWORD dwNumberOfBytesTransferred;
37   } OVERLAPPED_ENTRY, *LPOVERLAPPED_ENTRY;
38 
39 #ifndef _FILETIME_
40 #define _FILETIME_
41   typedef struct _FILETIME {
42     DWORD dwLowDateTime;
43     DWORD dwHighDateTime;
44   } FILETIME,*PFILETIME,*LPFILETIME;
45 #endif
46 
47 #ifndef _SYSTEMTIME_
48 #define _SYSTEMTIME_
49   typedef struct _SYSTEMTIME {
50     WORD wYear;
51     WORD wMonth;
52     WORD wDayOfWeek;
53     WORD wDay;
54     WORD wHour;
55     WORD wMinute;
56     WORD wSecond;
57     WORD wMilliseconds;
58   } SYSTEMTIME, *PSYSTEMTIME, *LPSYSTEMTIME;
59 #endif
60 
61   typedef struct _WIN32_FIND_DATAA {
62     DWORD dwFileAttributes;
63     FILETIME ftCreationTime;
64     FILETIME ftLastAccessTime;
65     FILETIME ftLastWriteTime;
66     DWORD nFileSizeHigh;
67     DWORD nFileSizeLow;
68     DWORD dwReserved0;
69     DWORD dwReserved1;
70     CHAR cFileName[MAX_PATH];
71     CHAR cAlternateFileName[14];
72 #ifdef _MAC
73     DWORD dwFileType;
74     DWORD dwCreatorType;
75     WORD  wFinderFlags;
76 #endif
77   } WIN32_FIND_DATAA, *PWIN32_FIND_DATAA, *LPWIN32_FIND_DATAA;
78 
79   typedef struct _WIN32_FIND_DATAW {
80     DWORD dwFileAttributes;
81     FILETIME ftCreationTime;
82     FILETIME ftLastAccessTime;
83     FILETIME ftLastWriteTime;
84     DWORD nFileSizeHigh;
85     DWORD nFileSizeLow;
86     DWORD dwReserved0;
87     DWORD dwReserved1;
88     WCHAR cFileName[MAX_PATH];
89     WCHAR cAlternateFileName[14];
90 #ifdef _MAC
91     DWORD dwFileType;
92     DWORD dwCreatorType;
93     WORD  wFinderFlags;
94 #endif
95   } WIN32_FIND_DATAW, *PWIN32_FIND_DATAW, *LPWIN32_FIND_DATAW;
96 
97   __MINGW_TYPEDEF_AW(WIN32_FIND_DATA)
98   __MINGW_TYPEDEF_AW(PWIN32_FIND_DATA)
99   __MINGW_TYPEDEF_AW(LPWIN32_FIND_DATA)
100 
101 #if _WIN32_WINNT >= 0x0400
102   typedef enum _FINDEX_INFO_LEVELS {
103     FindExInfoStandard,
104     FindExInfoBasic,
105     FindExInfoMaxInfoLevel
106   } FINDEX_INFO_LEVELS;
107 
108 #define FIND_FIRST_EX_CASE_SENSITIVE 0x00000001
109 #define FIND_FIRST_EX_LARGE_FETCH 0x00000002
110 #if NTDDI_VERSION >= 0x0A000005
111 #define FIND_FIRST_EX_ON_DISK_ENTRIES_ONLY  0x00000004
112 #endif
113 
114   typedef enum _FINDEX_SEARCH_OPS {
115     FindExSearchNameMatch,
116     FindExSearchLimitToDirectories,
117     FindExSearchLimitToDevices,
118     FindExSearchMaxSearchOp
119   } FINDEX_SEARCH_OPS;
120 #endif
121 
122 #if _WIN32_WINNT >= 0x0400
123 #if NTDDI_VERSION >= 0x0A000004
124   typedef enum _READ_DIRECTORY_NOTIFY_INFORMATION_CLASS {
125     ReadDirectoryNotifyInformation = 1,
126     ReadDirectoryNotifyExtendedInformation = 2
127   } READ_DIRECTORY_NOTIFY_INFORMATION_CLASS, *PREAD_DIRECTORY_NOTIFY_INFORMATION_CLASS;
128 #endif
129 #endif
130 
131   typedef enum _GET_FILEEX_INFO_LEVELS {
132     GetFileExInfoStandard,
133     GetFileExMaxInfoLevel
134   } GET_FILEEX_INFO_LEVELS;
135 
136 #if _WIN32_WINNT >= 0x0600
137   typedef enum _FILE_INFO_BY_HANDLE_CLASS {
138     FileBasicInfo /* is zero? */,
139     FileStandardInfo,
140     FileNameInfo,
141     FileRenameInfo,
142     FileDispositionInfo,
143     FileAllocationInfo,
144     FileEndOfFileInfo,
145     FileStreamInfo,
146     FileCompressionInfo,
147     FileAttributeTagInfo,
148     FileIdBothDirectoryInfo,
149     FileIdBothDirectoryRestartInfo,
150     FileIoPriorityHintInfo,
151     FileRemoteProtocolInfo,
152     FileFullDirectoryInfo,
153     FileFullDirectoryRestartInfo,
154 #if _WIN32_WINNT >= 0x0602
155     FileStorageInfo,
156     FileAlignmentInfo,
157     FileIdInfo,
158     FileIdExtdDirectoryInfo,
159     FileIdExtdDirectoryRestartInfo,
160 #endif
161 #if _WIN32_WINNT >= 0x0A000002
162     FileDispositionInfoEx,
163     FileRenameInfoEx,
164 #endif
165     FileCaseSensitiveInfo,
166     FileNormalizedNameInfo,
167     MaximumFileInfoByHandleClass
168   } FILE_INFO_BY_HANDLE_CLASS, *PFILE_INFO_BY_HANDLE_CLASS;
169 #endif
170 
171   typedef RTL_CRITICAL_SECTION CRITICAL_SECTION;
172   typedef PRTL_CRITICAL_SECTION PCRITICAL_SECTION;
173   typedef PRTL_CRITICAL_SECTION LPCRITICAL_SECTION;
174   typedef RTL_CRITICAL_SECTION_DEBUG CRITICAL_SECTION_DEBUG;
175   typedef PRTL_CRITICAL_SECTION_DEBUG PCRITICAL_SECTION_DEBUG;
176   typedef PRTL_CRITICAL_SECTION_DEBUG LPCRITICAL_SECTION_DEBUG;
177 
178   typedef VOID (WINAPI *LPOVERLAPPED_COMPLETION_ROUTINE) (DWORD dwErrorCode, DWORD dwNumberOfBytesTransfered, LPOVERLAPPED lpOverlapped);
179 
180 #define LOCKFILE_FAIL_IMMEDIATELY 0x1
181 #define LOCKFILE_EXCLUSIVE_LOCK 0x2
182 
183   typedef struct _PROCESS_HEAP_ENTRY {
184     PVOID lpData;
185     DWORD cbData;
186     BYTE cbOverhead;
187     BYTE iRegionIndex;
188     WORD wFlags;
189     __C89_NAMELESS union {
190         struct {
191             HANDLE hMem;
192             DWORD dwReserved[3];
193         } Block;
194         struct {
195             DWORD dwCommittedSize;
196             DWORD dwUnCommittedSize;
197             LPVOID lpFirstBlock;
198             LPVOID lpLastBlock;
199         } Region;
200     } DUMMYUNIONNAME;
201   } PROCESS_HEAP_ENTRY,*LPPROCESS_HEAP_ENTRY,*PPROCESS_HEAP_ENTRY;
202 
203 #define PROCESS_HEAP_REGION 0x1
204 #define PROCESS_HEAP_UNCOMMITTED_RANGE 0x2
205 #define PROCESS_HEAP_ENTRY_BUSY 0x4
206 #define PROCESS_HEAP_SEG_ALLOC 0x8
207 #define PROCESS_HEAP_ENTRY_MOVEABLE 0x10
208 #define PROCESS_HEAP_ENTRY_DDESHARE 0x20
209 
210   typedef struct _REASON_CONTEXT {
211     ULONG Version;
212     DWORD Flags;
213     union {
214         struct {
215             HMODULE LocalizedReasonModule;
216             ULONG LocalizedReasonId;
217             ULONG ReasonStringCount;
218             LPWSTR *ReasonStrings;
219         } Detailed;
220         LPWSTR SimpleReasonString;
221     } Reason;
222   } REASON_CONTEXT, *PREASON_CONTEXT;
223 
224 #define EXCEPTION_DEBUG_EVENT 1
225 #define CREATE_THREAD_DEBUG_EVENT 2
226 #define CREATE_PROCESS_DEBUG_EVENT 3
227 #define EXIT_THREAD_DEBUG_EVENT 4
228 #define EXIT_PROCESS_DEBUG_EVENT 5
229 #define LOAD_DLL_DEBUG_EVENT 6
230 #define UNLOAD_DLL_DEBUG_EVENT 7
231 #define OUTPUT_DEBUG_STRING_EVENT 8
232 #define RIP_EVENT 9
233 
234   typedef DWORD (WINAPI *PTHREAD_START_ROUTINE) (LPVOID lpThreadParameter);
235   typedef PTHREAD_START_ROUTINE LPTHREAD_START_ROUTINE;
236 
237   typedef LPVOID (WINAPI *PENCLAVE_ROUTINE) (LPVOID lpThreadParameter);
238   typedef PENCLAVE_ROUTINE LPENCLAVE_ROUTINE;
239 
240   typedef struct _EXCEPTION_DEBUG_INFO {
241     EXCEPTION_RECORD ExceptionRecord;
242     DWORD dwFirstChance;
243   } EXCEPTION_DEBUG_INFO, *LPEXCEPTION_DEBUG_INFO;
244 
245   typedef struct _CREATE_THREAD_DEBUG_INFO {
246     HANDLE hThread;
247     LPVOID lpThreadLocalBase;
248     LPTHREAD_START_ROUTINE lpStartAddress;
249   } CREATE_THREAD_DEBUG_INFO, *LPCREATE_THREAD_DEBUG_INFO;
250 
251   typedef struct _CREATE_PROCESS_DEBUG_INFO {
252     HANDLE hFile;
253     HANDLE hProcess;
254     HANDLE hThread;
255     LPVOID lpBaseOfImage;
256     DWORD dwDebugInfoFileOffset;
257     DWORD nDebugInfoSize;
258     LPVOID lpThreadLocalBase;
259     LPTHREAD_START_ROUTINE lpStartAddress;
260     LPVOID lpImageName;
261     WORD fUnicode;
262   } CREATE_PROCESS_DEBUG_INFO, *LPCREATE_PROCESS_DEBUG_INFO;
263 
264   typedef struct _EXIT_THREAD_DEBUG_INFO {
265     DWORD dwExitCode;
266   } EXIT_THREAD_DEBUG_INFO, *LPEXIT_THREAD_DEBUG_INFO;
267 
268   typedef struct _EXIT_PROCESS_DEBUG_INFO {
269     DWORD dwExitCode;
270   } EXIT_PROCESS_DEBUG_INFO, *LPEXIT_PROCESS_DEBUG_INFO;
271 
272   typedef struct _LOAD_DLL_DEBUG_INFO {
273     HANDLE hFile;
274     LPVOID lpBaseOfDll;
275     DWORD dwDebugInfoFileOffset;
276     DWORD nDebugInfoSize;
277     LPVOID lpImageName;
278     WORD fUnicode;
279   } LOAD_DLL_DEBUG_INFO, *LPLOAD_DLL_DEBUG_INFO;
280 
281   typedef struct _UNLOAD_DLL_DEBUG_INFO {
282     LPVOID lpBaseOfDll;
283   } UNLOAD_DLL_DEBUG_INFO, *LPUNLOAD_DLL_DEBUG_INFO;
284 
285   typedef struct _OUTPUT_DEBUG_STRING_INFO {
286     LPSTR lpDebugStringData;
287     WORD fUnicode;
288     WORD nDebugStringLength;
289   } OUTPUT_DEBUG_STRING_INFO, *LPOUTPUT_DEBUG_STRING_INFO;
290 
291   typedef struct _RIP_INFO {
292     DWORD dwError;
293     DWORD dwType;
294   } RIP_INFO, *LPRIP_INFO;
295 
296   typedef struct _DEBUG_EVENT {
297     DWORD dwDebugEventCode;
298     DWORD dwProcessId;
299     DWORD dwThreadId;
300     union {
301       EXCEPTION_DEBUG_INFO Exception;
302       CREATE_THREAD_DEBUG_INFO CreateThread;
303       CREATE_PROCESS_DEBUG_INFO CreateProcessInfo;
304       EXIT_THREAD_DEBUG_INFO ExitThread;
305       EXIT_PROCESS_DEBUG_INFO ExitProcess;
306       LOAD_DLL_DEBUG_INFO LoadDll;
307       UNLOAD_DLL_DEBUG_INFO UnloadDll;
308       OUTPUT_DEBUG_STRING_INFO DebugString;
309       RIP_INFO RipInfo;
310     } u;
311   } DEBUG_EVENT, *LPDEBUG_EVENT;
312 
313 #ifndef __WIDL__
314   typedef PCONTEXT LPCONTEXT;
315 #endif
316 
317 #define STILL_ACTIVE STATUS_PENDING
318 #define EXCEPTION_ACCESS_VIOLATION STATUS_ACCESS_VIOLATION
319 #define EXCEPTION_DATATYPE_MISALIGNMENT STATUS_DATATYPE_MISALIGNMENT
320 #define EXCEPTION_BREAKPOINT STATUS_BREAKPOINT
321 #define EXCEPTION_SINGLE_STEP STATUS_SINGLE_STEP
322 #define EXCEPTION_ARRAY_BOUNDS_EXCEEDED STATUS_ARRAY_BOUNDS_EXCEEDED
323 #define EXCEPTION_FLT_DENORMAL_OPERAND STATUS_FLOAT_DENORMAL_OPERAND
324 #define EXCEPTION_FLT_DIVIDE_BY_ZERO STATUS_FLOAT_DIVIDE_BY_ZERO
325 #define EXCEPTION_FLT_INEXACT_RESULT STATUS_FLOAT_INEXACT_RESULT
326 #define EXCEPTION_FLT_INVALID_OPERATION STATUS_FLOAT_INVALID_OPERATION
327 #define EXCEPTION_FLT_OVERFLOW STATUS_FLOAT_OVERFLOW
328 #define EXCEPTION_FLT_STACK_CHECK STATUS_FLOAT_STACK_CHECK
329 #define EXCEPTION_FLT_UNDERFLOW STATUS_FLOAT_UNDERFLOW
330 #define EXCEPTION_INT_DIVIDE_BY_ZERO STATUS_INTEGER_DIVIDE_BY_ZERO
331 #define EXCEPTION_INT_OVERFLOW STATUS_INTEGER_OVERFLOW
332 #define EXCEPTION_PRIV_INSTRUCTION STATUS_PRIVILEGED_INSTRUCTION
333 #define EXCEPTION_IN_PAGE_ERROR STATUS_IN_PAGE_ERROR
334 #define EXCEPTION_ILLEGAL_INSTRUCTION STATUS_ILLEGAL_INSTRUCTION
335 #define EXCEPTION_NONCONTINUABLE_EXCEPTION STATUS_NONCONTINUABLE_EXCEPTION
336 #define EXCEPTION_STACK_OVERFLOW STATUS_STACK_OVERFLOW
337 #define EXCEPTION_INVALID_DISPOSITION STATUS_INVALID_DISPOSITION
338 #define EXCEPTION_GUARD_PAGE STATUS_GUARD_PAGE_VIOLATION
339 #define EXCEPTION_INVALID_HANDLE STATUS_INVALID_HANDLE
340 #define EXCEPTION_POSSIBLE_DEADLOCK STATUS_POSSIBLE_DEADLOCK
341 #define CONTROL_C_EXIT STATUS_CONTROL_C_EXIT
342 
343 #define LMEM_FIXED 0x0
344 #define LMEM_MOVEABLE 0x2
345 #define LMEM_NOCOMPACT 0x10
346 #define LMEM_NODISCARD 0x20
347 #define LMEM_ZEROINIT 0x40
348 #define LMEM_MODIFY 0x80
349 #define LMEM_DISCARDABLE 0xf00
350 #define LMEM_VALID_FLAGS 0xf72
351 #define LMEM_INVALID_HANDLE 0x8000
352 
353 #define LHND (LMEM_MOVEABLE | LMEM_ZEROINIT)
354 #define LPTR (LMEM_FIXED | LMEM_ZEROINIT)
355 
356 #define NONZEROLHND (LMEM_MOVEABLE)
357 #define NONZEROLPTR (LMEM_FIXED)
358 
359 #define LocalDiscard(h) LocalReAlloc ((h), 0, LMEM_MOVEABLE)
360 
361 #define LMEM_DISCARDED 0x4000
362 #define LMEM_LOCKCOUNT 0xff
363 
364 #define NUMA_NO_PREFERRED_NODE ((DWORD) -1)
365 
366 #ifdef __cplusplus
367 }
368 #endif
369 #endif
370