1 /**
2  * Windows API header module
3  *
4  * Translated from MinGW API for MS-Windows 3.10
5  *
6  * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
7  * Source: $(DRUNTIMESRC core/sys/windows/_winbase.d)
8  */
9 module core.sys.windows.winbase;
10 version (Windows):
11 
12 version (ANSI) {} else version = Unicode;
13 pragma(lib, "kernel32");
14 
15 /**
16 Translation Notes:
17 The following macros are obsolete, and have no effect.
18 
19 LockSegment(w), MakeProcInstance(p, i), UnlockResource(h), UnlockSegment(w)
20 FreeModule(m), FreeProcInstance(p), GetFreeSpace(w), DefineHandleTable(w)
21 SetSwapAreaSize(w), LimitEmsPages(n), Yield()
22 
23 // These are not required for DMD.
24 
25 //FIXME:
26 // #ifndef UNDER_CE
27     int WinMain(HINSTANCE, HINSTANCE, LPSTR, int);
28 #else
29     int WinMain(HINSTANCE, HINSTANCE, LPWSTR, int);
30 #endif
31 int wWinMain(HINSTANCE, HINSTANCE, LPWSTR, int);
32 
33 */
34 
35 import core.sys.windows.windef, core.sys.windows.winver;
36 import core.sys.windows.basetyps, core.sys.windows.w32api, core.sys.windows.winnt;
37 
38 // FIXME:
39 //alias void va_list;
40 import core.stdc.stdarg : va_list;
41 import core.stdc.string : memset, memcpy, memmove;
42 
43 
44 // COMMPROP structure, used by GetCommProperties()
45 // -----------------------------------------------
46 
47 // Communications provider type
48 enum : DWORD {
49     PST_UNSPECIFIED,
50     PST_RS232,
51     PST_PARALLELPORT,
52     PST_RS422,
53     PST_RS423,
54     PST_RS449,
55     PST_MODEM,      // =      6
56     PST_FAX            = 0x0021,
57     PST_SCANNER        = 0x0022,
58     PST_NETWORK_BRIDGE = 0x0100,
59     PST_LAT            = 0x0101,
60     PST_TCPIP_TELNET   = 0x0102,
61     PST_X25            = 0x0103
62 }
63 
64 // Max baud rate
65 enum : DWORD {
66     BAUD_075    = 0x00000001,
67     BAUD_110    = 0x00000002,
68     BAUD_134_5  = 0x00000004,
69     BAUD_150    = 0x00000008,
70     BAUD_300    = 0x00000010,
71     BAUD_600    = 0x00000020,
72     BAUD_1200   = 0x00000040,
73     BAUD_1800   = 0x00000080,
74     BAUD_2400   = 0x00000100,
75     BAUD_4800   = 0x00000200,
76     BAUD_7200   = 0x00000400,
77     BAUD_9600   = 0x00000800,
78     BAUD_14400  = 0x00001000,
79     BAUD_19200  = 0x00002000,
80     BAUD_38400  = 0x00004000,
81     BAUD_56K    = 0x00008000,
82     BAUD_128K   = 0x00010000,
83     BAUD_115200 = 0x00020000,
84     BAUD_57600  = 0x00040000,
85     BAUD_USER   = 0x10000000
86 }
87 
88 // Comm capabilities
89 enum : DWORD {
90     PCF_DTRDSR        = 0x0001,
91     PCF_RTSCTS        = 0x0002,
92     PCF_RLSD          = 0x0004,
93     PCF_PARITY_CHECK  = 0x0008,
94     PCF_XONXOFF       = 0x0010,
95     PCF_SETXCHAR      = 0x0020,
96     PCF_TOTALTIMEOUTS = 0x0040,
97     PCF_INTTIMEOUTS   = 0x0080,
98     PCF_SPECIALCHARS  = 0x0100,
99     PCF_16BITMODE     = 0x0200
100 }
101 
102 enum  : DWORD {
103     SP_PARITY       = 1,
104     SP_BAUD         = 2,
105     SP_DATABITS     = 4,
106     SP_STOPBITS     = 8,
107     SP_HANDSHAKING  = 16,
108     SP_PARITY_CHECK = 32,
109     SP_RLSD         = 64
110 }
111 
112 enum : DWORD {
113     DATABITS_5   = 1,
114     DATABITS_6   = 2,
115     DATABITS_7   = 4,
116     DATABITS_8   = 8,
117     DATABITS_16  = 16,
118     DATABITS_16X = 32
119 }
120 
121 enum : WORD {
122     STOPBITS_10  = 0x0001,
123     STOPBITS_15  = 0x0002,
124     STOPBITS_20  = 0x0004,
125     PARITY_NONE  = 0x0100,
126     PARITY_ODD   = 0x0200,
127     PARITY_EVEN  = 0x0400,
128     PARITY_MARK  = 0x0800,
129     PARITY_SPACE = 0x1000
130 }
131 
132 // used by dwServiceMask
133 enum SP_SERIALCOMM = 1;
134 
135 struct COMMPROP {
136     WORD  wPacketLength;
137     WORD  wPacketVersion;
138     DWORD dwServiceMask;
139     DWORD dwReserved1;
140     DWORD dwMaxTxQueue;
141     DWORD dwMaxRxQueue;
142     DWORD dwMaxBaud;
143     DWORD dwProvSubType;
144     DWORD dwProvCapabilities;
145     DWORD dwSettableParams;
146     DWORD dwSettableBaud;
147     WORD  wSettableData;
148     WORD  wSettableStopParity;
149     DWORD dwCurrentTxQueue;
150     DWORD dwCurrentRxQueue;
151     DWORD dwProvSpec1;
152     DWORD dwProvSpec2;
153     WCHAR _wcProvChar = 0;
154 
155     WCHAR* wcProvChar() return { return &_wcProvChar; }
156 }
157 alias COMMPROP* LPCOMMPROP;
158 
159 // ----------
160 
161 // for DEBUG_EVENT
162 enum : DWORD {
163     EXCEPTION_DEBUG_EVENT = 1,
164     CREATE_THREAD_DEBUG_EVENT,
165     CREATE_PROCESS_DEBUG_EVENT,
166     EXIT_THREAD_DEBUG_EVENT,
167     EXIT_PROCESS_DEBUG_EVENT,
168     LOAD_DLL_DEBUG_EVENT,
169     UNLOAD_DLL_DEBUG_EVENT,
170     OUTPUT_DEBUG_STRING_EVENT,
171     RIP_EVENT
172 }
173 
174 enum HFILE HFILE_ERROR = cast(HFILE) (-1);
175 
176 // for SetFilePointer()
177 enum : DWORD {
178     FILE_BEGIN   = 0,
179     FILE_CURRENT = 1,
180     FILE_END     = 2
181 }
182 enum DWORD INVALID_SET_FILE_POINTER = -1;
183 
184 
185 // for OpenFile()
186 deprecated enum : UINT {
187     OF_READ             = 0,
188     OF_WRITE            = 0x0001,
189     OF_READWRITE        = 0x0002,
190     OF_SHARE_COMPAT     = 0,
191     OF_SHARE_EXCLUSIVE  = 0x0010,
192     OF_SHARE_DENY_WRITE = 0x0020,
193     OF_SHARE_DENY_READ  = 0x0030,
194     OF_SHARE_DENY_NONE  = 0x0040,
195     OF_PARSE            = 0x0100,
196     OF_DELETE           = 0x0200,
197     OF_VERIFY           = 0x0400,
198     OF_CANCEL           = 0x0800,
199     OF_CREATE           = 0x1000,
200     OF_PROMPT           = 0x2000,
201     OF_EXIST            = 0x4000,
202     OF_REOPEN           = 0x8000
203 }
204 
205 enum : DWORD {
206     NMPWAIT_NOWAIT           =  1,
207     NMPWAIT_WAIT_FOREVER     = -1,
208     NMPWAIT_USE_DEFAULT_WAIT =  0
209 }
210 
211 // for ClearCommError()
212 enum DWORD
213     CE_RXOVER   = 0x0001,
214     CE_OVERRUN  = 0x0002,
215     CE_RXPARITY = 0x0004,
216     CE_FRAME    = 0x0008,
217     CE_BREAK    = 0x0010,
218     CE_TXFULL   = 0x0100,
219     CE_PTO      = 0x0200,
220     CE_IOE      = 0x0400,
221     CE_DNS      = 0x0800,
222     CE_OOP      = 0x1000,
223     CE_MODE     = 0x8000;
224 
225 // for CopyProgressRoutine callback.
226 enum : DWORD {
227     PROGRESS_CONTINUE = 0,
228     PROGRESS_CANCEL   = 1,
229     PROGRESS_STOP     = 2,
230     PROGRESS_QUIET    = 3
231 }
232 
233 enum : DWORD {
234     CALLBACK_CHUNK_FINISHED = 0,
235     CALLBACK_STREAM_SWITCH  = 1
236 }
237 
238 // CopyFileEx()
239 enum : DWORD {
240     COPY_FILE_FAIL_IF_EXISTS = 1,
241     COPY_FILE_RESTARTABLE    = 2
242 }
243 
244 enum : DWORD {
245     FILE_MAP_COPY       = 1,
246     FILE_MAP_WRITE      = 2,
247     FILE_MAP_READ       = 4,
248     FILE_MAP_ALL_ACCESS = 0x000F001F
249 }
250 
251 enum : DWORD {
252     MUTEX_ALL_ACCESS       = 0x001f0001,
253     MUTEX_MODIFY_STATE     = 0x00000001,
254     SEMAPHORE_ALL_ACCESS   = 0x001f0003,
255     SEMAPHORE_MODIFY_STATE = 0x00000002,
256     EVENT_ALL_ACCESS       = 0x001f0003,
257     EVENT_MODIFY_STATE     = 0x00000002
258 }
259 
260 // CreateNamedPipe()
261 enum : DWORD {
262     PIPE_ACCESS_INBOUND  = 1,
263     PIPE_ACCESS_OUTBOUND = 2,
264     PIPE_ACCESS_DUPLEX   = 3
265 }
266 
267 enum DWORD
268     PIPE_TYPE_BYTE        = 0,
269     PIPE_TYPE_MESSAGE     = 4,
270     PIPE_READMODE_BYTE    = 0,
271     PIPE_READMODE_MESSAGE = 2,
272     PIPE_WAIT             = 0,
273     PIPE_NOWAIT           = 1;
274 
275 // GetNamedPipeInfo()
276 enum DWORD
277     PIPE_CLIENT_END  = 0,
278     PIPE_SERVER_END  = 1;
279 
280 enum DWORD PIPE_UNLIMITED_INSTANCES = 255;
281 
282 // dwCreationFlags for CreateProcess() and CreateProcessAsUser()
283 enum : DWORD {
284     DEBUG_PROCESS               = 0x00000001,
285     DEBUG_ONLY_THIS_PROCESS     = 0x00000002,
286     CREATE_SUSPENDED            = 0x00000004,
287     DETACHED_PROCESS            = 0x00000008,
288     CREATE_NEW_CONSOLE          = 0x00000010,
289     NORMAL_PRIORITY_CLASS       = 0x00000020,
290     IDLE_PRIORITY_CLASS         = 0x00000040,
291     HIGH_PRIORITY_CLASS         = 0x00000080,
292     REALTIME_PRIORITY_CLASS     = 0x00000100,
293     CREATE_NEW_PROCESS_GROUP    = 0x00000200,
294     CREATE_UNICODE_ENVIRONMENT  = 0x00000400,
295     CREATE_SEPARATE_WOW_VDM     = 0x00000800,
296     CREATE_SHARED_WOW_VDM       = 0x00001000,
297     CREATE_FORCEDOS             = 0x00002000,
298     BELOW_NORMAL_PRIORITY_CLASS = 0x00004000,
299     ABOVE_NORMAL_PRIORITY_CLASS = 0x00008000,
300     CREATE_BREAKAWAY_FROM_JOB   = 0x01000000,
301     CREATE_WITH_USERPROFILE     = 0x02000000,
302     CREATE_DEFAULT_ERROR_MODE   = 0x04000000,
303     CREATE_NO_WINDOW            = 0x08000000,
304     PROFILE_USER                = 0x10000000,
305     PROFILE_KERNEL              = 0x20000000,
306     PROFILE_SERVER              = 0x40000000
307 }
308 
309 enum DWORD CONSOLE_TEXTMODE_BUFFER = 1;
310 
311 // CreateFile()
312 enum : DWORD {
313     CREATE_NEW = 1,
314     CREATE_ALWAYS,
315     OPEN_EXISTING,
316     OPEN_ALWAYS,
317     TRUNCATE_EXISTING
318 }
319 
320 // CreateFile()
321 enum DWORD
322     FILE_FLAG_WRITE_THROUGH      = 0x80000000,
323     FILE_FLAG_OVERLAPPED         = 0x40000000,
324     FILE_FLAG_NO_BUFFERING       = 0x20000000,
325     FILE_FLAG_RANDOM_ACCESS      = 0x10000000,
326     FILE_FLAG_SEQUENTIAL_SCAN    = 0x08000000,
327     FILE_FLAG_DELETE_ON_CLOSE    = 0x04000000,
328     FILE_FLAG_BACKUP_SEMANTICS   = 0x02000000,
329     FILE_FLAG_POSIX_SEMANTICS    = 0x01000000,
330     FILE_FLAG_OPEN_REPARSE_POINT = 0x00200000,
331     FILE_FLAG_OPEN_NO_RECALL     = 0x00100000;
332 
333 static if (_WIN32_WINNT >= 0x500) {
334 enum DWORD FILE_FLAG_FIRST_PIPE_INSTANCE = 0x00080000;
335 }
336 
337 // for CreateFile()
338 enum DWORD
339     SECURITY_ANONYMOUS        = SECURITY_IMPERSONATION_LEVEL.SecurityAnonymous<<16,
340     SECURITY_IDENTIFICATION   = SECURITY_IMPERSONATION_LEVEL.SecurityIdentification<<16,
341     SECURITY_IMPERSONATION    = SECURITY_IMPERSONATION_LEVEL.SecurityImpersonation<<16,
342     SECURITY_DELEGATION       = SECURITY_IMPERSONATION_LEVEL.SecurityDelegation<<16,
343     SECURITY_CONTEXT_TRACKING = 0x00040000,
344     SECURITY_EFFECTIVE_ONLY   = 0x00080000,
345     SECURITY_SQOS_PRESENT     = 0x00100000,
346     SECURITY_VALID_SQOS_FLAGS = 0x001F0000;
347 
348 
349 // Thread exit code
350 enum DWORD STILL_ACTIVE = 0x103;
351 
352 /*  ??? The only documentation of this seems to be about Windows CE and to
353  *  state what _doesn't_ support it.
354  */
355 enum DWORD FIND_FIRST_EX_CASE_SENSITIVE = 1;
356 
357 // GetBinaryType()
358 enum : DWORD {
359     SCS_32BIT_BINARY = 0,
360     SCS_DOS_BINARY,
361     SCS_WOW_BINARY,
362     SCS_PIF_BINARY,
363     SCS_POSIX_BINARY,
364     SCS_OS216_BINARY
365 }
366 
367 enum size_t
368     MAX_COMPUTERNAME_LENGTH = 15,
369     HW_PROFILE_GUIDLEN      = 39,
370     MAX_PROFILE_LEN         = 80;
371 
372 // HW_PROFILE_INFO
373 enum DWORD
374     DOCKINFO_UNDOCKED      = 1,
375     DOCKINFO_DOCKED        = 2,
376     DOCKINFO_USER_SUPPLIED = 4,
377     DOCKINFO_USER_UNDOCKED = DOCKINFO_USER_SUPPLIED | DOCKINFO_UNDOCKED,
378     DOCKINFO_USER_DOCKED   = DOCKINFO_USER_SUPPLIED | DOCKINFO_DOCKED;
379 
380 // DriveType(), RealDriveType()
381 enum : int {
382     DRIVE_UNKNOWN = 0,
383     DRIVE_NO_ROOT_DIR,
384     DRIVE_REMOVABLE,
385     DRIVE_FIXED,
386     DRIVE_REMOTE,
387     DRIVE_CDROM,
388     DRIVE_RAMDISK
389 }
390 
391 // GetFileType()
392 enum : DWORD {
393     FILE_TYPE_UNKNOWN = 0,
394     FILE_TYPE_DISK,
395     FILE_TYPE_CHAR,
396     FILE_TYPE_PIPE,
397     FILE_TYPE_REMOTE = 0x8000
398 }
399 
400 // Get/SetHandleInformation()
401 enum DWORD
402     HANDLE_FLAG_INHERIT            = 0x01,
403     HANDLE_FLAG_PROTECT_FROM_CLOSE = 0x02;
404 
405 enum : DWORD {
406     STD_INPUT_HANDLE  = 0xFFFFFFF6,
407     STD_OUTPUT_HANDLE = 0xFFFFFFF5,
408     STD_ERROR_HANDLE  = 0xFFFFFFF4
409 }
410 
411 enum HANDLE INVALID_HANDLE_VALUE = cast(HANDLE) (-1);
412 
413 enum : DWORD {
414     GET_TAPE_MEDIA_INFORMATION = 0,
415     GET_TAPE_DRIVE_INFORMATION = 1
416 }
417 
418 enum : DWORD {
419     SET_TAPE_MEDIA_INFORMATION = 0,
420     SET_TAPE_DRIVE_INFORMATION = 1
421 }
422 
423 // SetThreadPriority()/GetThreadPriority()
424 enum : int {
425     THREAD_PRIORITY_IDLE          = -15,
426     THREAD_PRIORITY_LOWEST        =  -2,
427     THREAD_PRIORITY_BELOW_NORMAL  =  -1,
428     THREAD_PRIORITY_NORMAL        =   0,
429     THREAD_PRIORITY_ABOVE_NORMAL  =   1,
430     THREAD_PRIORITY_HIGHEST       =   2,
431     THREAD_PRIORITY_TIME_CRITICAL =  15,
432     THREAD_PRIORITY_ERROR_RETURN  = 2147483647
433 }
434 
435 enum : DWORD {
436     TIME_ZONE_ID_UNKNOWN,
437     TIME_ZONE_ID_STANDARD,
438     TIME_ZONE_ID_DAYLIGHT,
439     TIME_ZONE_ID_INVALID = 0xFFFFFFFF
440 }
441 
442 enum DWORD
443     FS_CASE_SENSITIVE         =     1,
444     FS_CASE_IS_PRESERVED      =     2,
445     FS_UNICODE_STORED_ON_DISK =     4,
446     FS_PERSISTENT_ACLS        =     8,
447     FS_FILE_COMPRESSION       =    16,
448     FS_VOL_IS_COMPRESSED      = 32768;
449 
450 // Flags for GlobalAlloc
451 enum UINT
452     GMEM_FIXED       = 0,
453     GMEM_MOVEABLE    = 0x0002,
454     GMEM_ZEROINIT    = 0x0040,
455     GPTR             = 0x0040,
456     GHND             = 0x0042,
457     GMEM_MODIFY      = 0x0080,  // used only for GlobalRealloc
458     GMEM_VALID_FLAGS = 0x7F72;
459 
460 /+  // Obselete flags (Win16 only)
461     GMEM_NOCOMPACT=16;
462     GMEM_NODISCARD=32;
463     GMEM_DISCARDABLE=256;
464     GMEM_NOT_BANKED=4096;
465     GMEM_LOWER=4096;
466     GMEM_SHARE=8192;
467     GMEM_DDESHARE=8192;
468 
469     GMEM_LOCKCOUNT=255;
470 
471 // for GlobalFlags()
472     GMEM_DISCARDED      = 16384;
473     GMEM_INVALID_HANDLE = 32768;
474 
475     GMEM_NOTIFY         = 16384;
476 +/
477 
478 enum UINT
479     LMEM_FIXED          = 0,
480     LMEM_MOVEABLE       = 0x0002,
481     LMEM_NONZEROLPTR    = 0,
482     NONZEROLPTR         = 0,
483     LMEM_NONZEROLHND    = 0x0002,
484     NONZEROLHND         = 0x0002,
485     LMEM_DISCARDABLE    = 0x0F00,
486     LMEM_NOCOMPACT      = 0x0010,
487     LMEM_NODISCARD      = 0x0020,
488     LMEM_ZEROINIT       = 0x0040,
489     LPTR                = 0x0040,
490     LHND                = 0x0042,
491     LMEM_MODIFY         = 0x0080,
492     LMEM_LOCKCOUNT      = 0x00FF,
493     LMEM_DISCARDED      = 0x4000,
494     LMEM_INVALID_HANDLE = 0x8000;
495 
496 
497 
498 // used in EXCEPTION_RECORD
499 enum : DWORD {
500     STATUS_WAIT_0                      = 0,
501     STATUS_ABANDONED_WAIT_0            = 0x00000080,
502     STATUS_USER_APC                    = 0x000000C0,
503     STATUS_TIMEOUT                     = 0x00000102,
504     STATUS_PENDING                     = 0x00000103,
505 
506     STATUS_SEGMENT_NOTIFICATION        = 0x40000005,
507     STATUS_GUARD_PAGE_VIOLATION        = 0x80000001,
508     STATUS_DATATYPE_MISALIGNMENT       = 0x80000002,
509     STATUS_BREAKPOINT                  = 0x80000003,
510     STATUS_SINGLE_STEP                 = 0x80000004,
511 
512     STATUS_ACCESS_VIOLATION            = 0xC0000005,
513     STATUS_IN_PAGE_ERROR               = 0xC0000006,
514     STATUS_INVALID_HANDLE              = 0xC0000008,
515 
516     STATUS_NO_MEMORY                   = 0xC0000017,
517     STATUS_ILLEGAL_INSTRUCTION         = 0xC000001D,
518     STATUS_NONCONTINUABLE_EXCEPTION    = 0xC0000025,
519     STATUS_INVALID_DISPOSITION         = 0xC0000026,
520     STATUS_ARRAY_BOUNDS_EXCEEDED       = 0xC000008C,
521     STATUS_FLOAT_DENORMAL_OPERAND      = 0xC000008D,
522     STATUS_FLOAT_DIVIDE_BY_ZERO        = 0xC000008E,
523     STATUS_FLOAT_INEXACT_RESULT        = 0xC000008F,
524     STATUS_FLOAT_INVALID_OPERATION     = 0xC0000090,
525     STATUS_FLOAT_OVERFLOW              = 0xC0000091,
526     STATUS_FLOAT_STACK_CHECK           = 0xC0000092,
527     STATUS_FLOAT_UNDERFLOW             = 0xC0000093,
528     STATUS_INTEGER_DIVIDE_BY_ZERO      = 0xC0000094,
529     STATUS_INTEGER_OVERFLOW            = 0xC0000095,
530     STATUS_PRIVILEGED_INSTRUCTION      = 0xC0000096,
531     STATUS_STACK_OVERFLOW              = 0xC00000FD,
532     STATUS_CONTROL_C_EXIT              = 0xC000013A,
533     STATUS_DLL_INIT_FAILED             = 0xC0000142,
534     STATUS_DLL_INIT_FAILED_LOGOFF      = 0xC000026B,
535 
536     CONTROL_C_EXIT                     = STATUS_CONTROL_C_EXIT,
537 
538     EXCEPTION_ACCESS_VIOLATION         = STATUS_ACCESS_VIOLATION,
539     EXCEPTION_DATATYPE_MISALIGNMENT    = STATUS_DATATYPE_MISALIGNMENT,
540     EXCEPTION_BREAKPOINT               = STATUS_BREAKPOINT,
541     EXCEPTION_SINGLE_STEP              = STATUS_SINGLE_STEP,
542     EXCEPTION_ARRAY_BOUNDS_EXCEEDED    = STATUS_ARRAY_BOUNDS_EXCEEDED,
543     EXCEPTION_FLT_DENORMAL_OPERAND     = STATUS_FLOAT_DENORMAL_OPERAND,
544     EXCEPTION_FLT_DIVIDE_BY_ZERO       = STATUS_FLOAT_DIVIDE_BY_ZERO,
545     EXCEPTION_FLT_INEXACT_RESULT       = STATUS_FLOAT_INEXACT_RESULT,
546     EXCEPTION_FLT_INVALID_OPERATION    = STATUS_FLOAT_INVALID_OPERATION,
547     EXCEPTION_FLT_OVERFLOW             = STATUS_FLOAT_OVERFLOW,
548     EXCEPTION_FLT_STACK_CHECK          = STATUS_FLOAT_STACK_CHECK,
549     EXCEPTION_FLT_UNDERFLOW            = STATUS_FLOAT_UNDERFLOW,
550     EXCEPTION_INT_DIVIDE_BY_ZERO       = STATUS_INTEGER_DIVIDE_BY_ZERO,
551     EXCEPTION_INT_OVERFLOW             = STATUS_INTEGER_OVERFLOW,
552     EXCEPTION_PRIV_INSTRUCTION         = STATUS_PRIVILEGED_INSTRUCTION,
553     EXCEPTION_IN_PAGE_ERROR            = STATUS_IN_PAGE_ERROR,
554     EXCEPTION_ILLEGAL_INSTRUCTION      = STATUS_ILLEGAL_INSTRUCTION,
555     EXCEPTION_NONCONTINUABLE_EXCEPTION = STATUS_NONCONTINUABLE_EXCEPTION,
556     EXCEPTION_STACK_OVERFLOW           = STATUS_STACK_OVERFLOW,
557     EXCEPTION_INVALID_DISPOSITION      = STATUS_INVALID_DISPOSITION,
558     EXCEPTION_GUARD_PAGE               = STATUS_GUARD_PAGE_VIOLATION,
559     EXCEPTION_INVALID_HANDLE           = STATUS_INVALID_HANDLE
560 }
561 
562 // for PROCESS_HEAP_ENTRY
563 enum WORD
564     PROCESS_HEAP_REGION            =  1,
565     PROCESS_HEAP_UNCOMMITTED_RANGE =  2,
566     PROCESS_HEAP_ENTRY_BUSY        =  4,
567     PROCESS_HEAP_ENTRY_MOVEABLE    = 16,
568     PROCESS_HEAP_ENTRY_DDESHARE    = 32;
569 
570 // for LoadLibraryEx()
571 enum DWORD
572     DONT_RESOLVE_DLL_REFERENCES   = 0x01, // not for WinME and earlier
573     LOAD_LIBRARY_AS_DATAFILE      = 0x02,
574     LOAD_WITH_ALTERED_SEARCH_PATH = 0x08,
575     LOAD_IGNORE_CODE_AUTHZ_LEVEL  = 0x10; // only for XP and later
576 
577 // for LockFile()
578 enum DWORD
579     LOCKFILE_FAIL_IMMEDIATELY = 1,
580     LOCKFILE_EXCLUSIVE_LOCK   = 2;
581 
582 enum MAXIMUM_WAIT_OBJECTS  = 64;
583 enum MAXIMUM_SUSPEND_COUNT = 0x7F;
584 
585 enum WAIT_OBJECT_0    = 0;
586 enum WAIT_ABANDONED_0 = 128;
587 
588 //const WAIT_TIMEOUT=258;  // also in winerror.h
589 
590 enum : DWORD {
591     WAIT_IO_COMPLETION = 0x000000C0,
592     WAIT_ABANDONED     = 0x00000080,
593     WAIT_FAILED        = 0xFFFFFFFF
594 }
595 
596 // PurgeComm()
597 enum DWORD
598     PURGE_TXABORT = 1,
599     PURGE_RXABORT = 2,
600     PURGE_TXCLEAR = 4,
601     PURGE_RXCLEAR = 8;
602 
603 // ReadEventLog()
604 enum DWORD
605     EVENTLOG_SEQUENTIAL_READ = 1,
606     EVENTLOG_SEEK_READ       = 2,
607     EVENTLOG_FORWARDS_READ   = 4,
608     EVENTLOG_BACKWARDS_READ  = 8;
609 
610 // ReportEvent()
611 enum : WORD {
612     EVENTLOG_SUCCESS          = 0,
613     EVENTLOG_ERROR_TYPE       = 1,
614     EVENTLOG_WARNING_TYPE     = 2,
615     EVENTLOG_INFORMATION_TYPE = 4,
616     EVENTLOG_AUDIT_SUCCESS    = 8,
617     EVENTLOG_AUDIT_FAILURE    = 16
618 }
619 
620 // FormatMessage()
621 enum DWORD
622     FORMAT_MESSAGE_ALLOCATE_BUFFER = 0x0100,
623     FORMAT_MESSAGE_IGNORE_INSERTS  = 0x0200,
624     FORMAT_MESSAGE_FROM_STRING     = 0x0400,
625     FORMAT_MESSAGE_FROM_HMODULE    = 0x0800,
626     FORMAT_MESSAGE_FROM_SYSTEM     = 0x1000,
627     FORMAT_MESSAGE_ARGUMENT_ARRAY  = 0x2000;
628 
629 enum DWORD FORMAT_MESSAGE_MAX_WIDTH_MASK = 255;
630 
631 // also in ddk/ntapi.h
632 // To restore default error mode, call SetErrorMode(0)
633 enum {
634     SEM_FAILCRITICALERRORS     = 0x0001,
635     SEM_NOGPFAULTERRORBOX      = 0x0002,
636     SEM_NOALIGNMENTFAULTEXCEPT = 0x0004,
637     SEM_NOOPENFILEERRORBOX     = 0x8000
638 }
639 // end ntapi.h
640 
641 enum {
642     SLE_ERROR = 1,
643     SLE_MINORERROR,
644     SLE_WARNING
645 }
646 
647 enum SHUTDOWN_NORETRY = 1;
648 
649 // Return type for exception filters.
650 enum : LONG {
651     EXCEPTION_EXECUTE_HANDLER    =  1,
652     EXCEPTION_CONTINUE_EXECUTION = -1,
653     EXCEPTION_CONTINUE_SEARCH    =  0
654 }
655 
656 enum  : ATOM {
657     MAXINTATOM   = 0xC000,
658     INVALID_ATOM = 0
659 }
660 
661 enum IGNORE   = 0;
662 enum INFINITE = 0xFFFFFFFF;
663 
664 // EscapeCommFunction()
665 enum {
666     SETXOFF    = 1,
667     SETXON,
668     SETRTS,
669     CLRRTS,
670     SETDTR,
671     CLRDTR, // = 6
672     SETBREAK   = 8,
673     CLRBREAK   = 9
674 }
675 
676 
677 // for SetCommMask()
678 enum DWORD
679     EV_RXCHAR   = 0x0001,
680     EV_RXFLAG   = 0x0002,
681     EV_TXEMPTY  = 0x0004,
682     EV_CTS      = 0x0008,
683     EV_DSR      = 0x0010,
684     EV_RLSD     = 0x0020,
685     EV_BREAK    = 0x0040,
686     EV_ERR      = 0x0080,
687     EV_RING     = 0x0100,
688     EV_PERR     = 0x0200,
689     EV_RX80FULL = 0x0400,
690     EV_EVENT1   = 0x0800,
691     EV_EVENT2   = 0x1000;
692 
693 // GetCommModemStatus()
694 enum DWORD
695     MS_CTS_ON  = 0x0010,
696     MS_DSR_ON  = 0x0020,
697     MS_RING_ON = 0x0040,
698     MS_RLSD_ON = 0x0080;
699 
700 
701 // DCB
702 enum : BYTE {
703     NOPARITY = 0,
704     ODDPARITY,
705     EVENPARITY,
706     MARKPARITY,
707     SPACEPARITY
708 }
709 // DCB
710 enum : BYTE {
711     ONESTOPBIT = 0,
712     ONE5STOPBITS,
713     TWOSTOPBITS
714 }
715 // DCB
716 enum : DWORD {
717     CBR_110    =    110,
718     CBR_300    =    300,
719     CBR_600    =    600,
720     CBR_1200   =   1200,
721     CBR_2400   =   2400,
722     CBR_4800   =   4800,
723     CBR_9600   =   9600,
724     CBR_14400  =  14400,
725     CBR_19200  =  19200,
726     CBR_38400  =  38400,
727     CBR_56000  =  56000,
728     CBR_57600  =  57600,
729     CBR_115200 = 115200,
730     CBR_128000 = 128000,
731     CBR_256000 = 256000
732 }
733 // DCB, 2-bit bitfield
734 enum {
735     DTR_CONTROL_DISABLE = 0,
736     DTR_CONTROL_ENABLE,
737     DTR_CONTROL_HANDSHAKE
738 }
739 
740 // DCB, 2-bit bitfield
741 enum {
742     RTS_CONTROL_DISABLE = 0,
743     RTS_CONTROL_ENABLE,
744     RTS_CONTROL_HANDSHAKE,
745     RTS_CONTROL_TOGGLE,
746 }
747 
748 // WIN32_STREAM_ID
749 enum : DWORD {
750     BACKUP_INVALID = 0,
751     BACKUP_DATA,
752     BACKUP_EA_DATA,
753     BACKUP_SECURITY_DATA,
754     BACKUP_ALTERNATE_DATA,
755     BACKUP_LINK,
756     BACKUP_PROPERTY_DATA,
757     BACKUP_OBJECT_ID,
758     BACKUP_REPARSE_DATA,
759     BACKUP_SPARSE_BLOCK
760 }
761 
762 // WIN32_STREAM_ID
763 enum : DWORD {
764     STREAM_NORMAL_ATTRIBUTE    = 0,
765     STREAM_MODIFIED_WHEN_READ  = 1,
766     STREAM_CONTAINS_SECURITY   = 2,
767     STREAM_CONTAINS_PROPERTIES = 4
768 }
769 
770 // STARTUPINFO
771 enum DWORD
772     STARTF_USESHOWWINDOW    = 0x0001,
773     STARTF_USESIZE          = 0x0002,
774     STARTF_USEPOSITION      = 0x0004,
775     STARTF_USECOUNTCHARS    = 0x0008,
776     STARTF_USEFILLATTRIBUTE = 0x0010,
777     STARTF_RUNFULLSCREEN    = 0x0020,
778     STARTF_FORCEONFEEDBACK  = 0x0040,
779     STARTF_FORCEOFFFEEDBACK = 0x0080,
780     STARTF_USESTDHANDLES    = 0x0100,
781     STARTF_USEHOTKEY        = 0x0200;
782 
783 // ???
784 enum {
785     TC_NORMAL  = 0,
786     TC_HARDERR = 1,
787     TC_GP_TRAP = 2,
788     TC_SIGNAL  = 3
789 }
790 
791 /+ These seem to be Windows CE-specific
792 enum {
793     AC_LINE_OFFLINE      = 0,
794     AC_LINE_ONLINE       = 1,
795     AC_LINE_BACKUP_POWER = 2,
796     AC_LINE_UNKNOWN      = 255
797 }
798 
799 enum {
800     BATTERY_FLAG_HIGH          = 1,
801     BATTERY_FLAG_LOW           = 2,
802     BATTERY_FLAG_CRITICAL      = 4,
803     BATTERY_FLAG_CHARGING      = 8,
804     BATTERY_FLAG_NO_BATTERY    = 128,
805     BATTERY_FLAG_UNKNOWN       = 255,
806     BATTERY_PERCENTAGE_UNKNOWN = 255,
807     BATTERY_LIFE_UNKNOWN       = 0xFFFFFFFF
808 }
809 +/
810 
811 // ???
812 enum HINSTANCE_ERROR = 32;
813 
814 // returned from GetFileSize()
815 enum DWORD INVALID_FILE_SIZE = 0xFFFFFFFF;
816 
817 enum DWORD TLS_OUT_OF_INDEXES = 0xFFFFFFFF;
818 
819 // GetWriteWatch()
820 enum DWORD WRITE_WATCH_FLAG_RESET = 1;
821 
822 // for LogonUser()
823 enum : DWORD {
824     LOGON32_LOGON_INTERACTIVE = 2,
825     LOGON32_LOGON_NETWORK     = 3,
826     LOGON32_LOGON_BATCH       = 4,
827     LOGON32_LOGON_SERVICE     = 5,
828     LOGON32_LOGON_UNLOCK      = 7
829 }
830 
831 // for LogonUser()
832 enum : DWORD {
833     LOGON32_PROVIDER_DEFAULT,
834     LOGON32_PROVIDER_WINNT35,
835     LOGON32_PROVIDER_WINNT40,
836     LOGON32_PROVIDER_WINNT50
837 }
838 
839 // for MoveFileEx()
840 enum DWORD
841     MOVEFILE_REPLACE_EXISTING   = 1,
842     MOVEFILE_COPY_ALLOWED       = 2,
843     MOVEFILE_DELAY_UNTIL_REBOOT = 4,
844     MOVEFILE_WRITE_THROUGH      = 8;
845 
846 // DefineDosDevice()
847 enum DWORD
848     DDD_RAW_TARGET_PATH       = 1,
849     DDD_REMOVE_DEFINITION     = 2,
850     DDD_EXACT_MATCH_ON_REMOVE = 4;
851 
852 static if (_WIN32_WINNT >= 0x500) {
853     enum : DWORD {
854         LOGON32_LOGON_NETWORK_CLEARTEXT = 8,
855         LOGON32_LOGON_NEW_CREDENTIALS   = 9
856     }
857 
858     // ReplaceFile()
859 enum DWORD
860         REPLACEFILE_WRITE_THROUGH       = 1,
861         REPLACEFILE_IGNORE_MERGE_ERRORS = 2;
862 }
863 
864 static if (_WIN32_WINNT >= 0x501) {
865 enum DWORD
866         GET_MODULE_HANDLE_EX_FLAG_PIN                = 1,
867         GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT = 2,
868         GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS       = 4;
869 
870     // for ACTCTX
871 enum DWORD
872         ACTCTX_FLAG_PROCESSOR_ARCHITECTURE_VALID = 0x01,
873         ACTCTX_FLAG_LANGID_VALID                 = 0x02,
874         ACTCTX_FLAG_ASSEMBLY_DIRECTORY_VALID     = 0x04,
875         ACTCTX_FLAG_RESOURCE_NAME_VALID          = 0x08,
876         ACTCTX_FLAG_SET_PROCESS_DEFAULT          = 0x10,
877         ACTCTX_FLAG_APPLICATION_NAME_VALID       = 0x20,
878         ACTCTX_FLAG_HMODULE_VALID                = 0x80;
879 
880     // DeactivateActCtx()
881 enum DWORD DEACTIVATE_ACTCTX_FLAG_FORCE_EARLY_DEACTIVATION = 1;
882     // FindActCtxSectionString()
883 enum DWORD FIND_ACTCTX_SECTION_KEY_RETURN_HACTCTX          = 1;
884     // QueryActCtxW()
885 enum DWORD
886         QUERY_ACTCTX_FLAG_USE_ACTIVE_ACTCTX             = 0x04,
887         QUERY_ACTCTX_FLAG_ACTCTX_IS_HMODULE             = 0x08,
888         QUERY_ACTCTX_FLAG_ACTCTX_IS_ADDRESS             = 0x10;
889 
890     enum {
891         LOGON_WITH_PROFILE        = 1,
892         LOGON_NETCREDENTIALS_ONLY
893     }
894 }
895 
896 // ----
897 
898 struct FILETIME {
899     DWORD dwLowDateTime;
900     DWORD dwHighDateTime;
901 }
902 alias FILETIME* PFILETIME, LPFILETIME;
903 
904 struct BY_HANDLE_FILE_INFORMATION {
905     DWORD    dwFileAttributes;
906     FILETIME ftCreationTime;
907     FILETIME ftLastAccessTime;
908     FILETIME ftLastWriteTime;
909     DWORD    dwVolumeSerialNumber;
910     DWORD    nFileSizeHigh;
911     DWORD    nFileSizeLow;
912     DWORD    nNumberOfLinks;
913     DWORD    nFileIndexHigh;
914     DWORD    nFileIndexLow;
915 }
916 alias BY_HANDLE_FILE_INFORMATION* LPBY_HANDLE_FILE_INFORMATION;
917 
918 struct DCB {
919     DWORD DCBlength = DCB.sizeof;
920     DWORD BaudRate;
921 /+
922     DWORD fBinary:1;              // Binary Mode (skip EOF check)
923     DWORD fParity:1;              // Enable parity checking
924     DWORD fOutxCtsFlow:1;         // CTS handshaking on output
925     DWORD fOutxDsrFlow:1;         // DSR handshaking on output
926     DWORD fDtrControl:2;          // DTR Flow control
927     DWORD fDsrSensitivity:1;      // DSR Sensitivity
928     DWORD fTXContinueOnXoff:1;    // Continue TX when Xoff sent
929     DWORD fOutX:1;                // Enable output X-ON/X-OFF
930     DWORD fInX:1;                 // Enable input X-ON/X-OFF
931     DWORD fErrorChar:1;           // Enable Err Replacement
932     DWORD fNull:1;                // Enable Null stripping
933     DWORD fRtsControl:2;          // Rts Flow control
934     DWORD fAbortOnError:1;        // Abort all reads and writes on Error
935     DWORD fDummy2:17;             // Reserved
936 +/
937     uint _bf;
938     bool fBinary(bool f)           { _bf = (_bf & ~0x0001) | f; return f; }
939     bool fParity(bool f)           { _bf = (_bf & ~0x0002) | (f<<1); return f; }
940     bool fOutxCtsFlow(bool f)      { _bf = (_bf & ~0x0004) | (f<<2); return f; }
941     bool fOutxDsrFlow(bool f)      { _bf = (_bf & ~0x0008) | (f<<3); return f; }
942     byte fDtrControl(byte x)       { _bf = (_bf & ~0x0030) | (x<<4); return cast(byte)(x & 3); }
943     bool fDsrSensitivity(bool f)   { _bf = (_bf & ~0x0040) | (f<<6); return f; }
944     bool fTXContinueOnXoff(bool f) { _bf = (_bf & ~0x0080) | (f<<7); return f; }
945     bool fOutX(bool f)             { _bf = (_bf & ~0x0100) | (f<<8); return f; }
946     bool fInX(bool f)              { _bf = (_bf & ~0x0200) | (f<<9); return f; }
947     bool fErrorChar(bool f)        { _bf = (_bf & ~0x0400) | (f<<10); return f; }
948     bool fNull(bool f)             { _bf = (_bf & ~0x0800) | (f<<11); return f; }
949     byte fRtsControl(byte x)       { _bf = (_bf & ~0x3000) | (x<<12); return cast(byte)(x & 3); }
950     bool fAbortOnError(bool f)     { _bf = (_bf & ~0x4000) | (f<<14); return f; }
951 
952     bool fBinary()           { return cast(bool) (_bf & 1); }
953     bool fParity()           { return cast(bool) (_bf & 2); }
954     bool fOutxCtsFlow()      { return cast(bool) (_bf & 4); }
955     bool fOutxDsrFlow()      { return cast(bool) (_bf & 8); }
956     byte fDtrControl()       { return cast(byte) ((_bf & (32+16))>>4); }
957     bool fDsrSensitivity()   { return cast(bool) (_bf & 64); }
958     bool fTXContinueOnXoff() { return cast(bool) (_bf & 128); }
959     bool fOutX()             { return cast(bool) (_bf & 256); }
960     bool fInX()              { return cast(bool) (_bf & 512); }
961     bool fErrorChar()        { return cast(bool) (_bf & 1024); }
962     bool fNull()             { return cast(bool) (_bf & 2048); }
963     byte fRtsControl()       { return cast(byte) ((_bf & (4096+8192))>>12); }
964     bool fAbortOnError()     { return cast(bool) (_bf & 16384); }
965 
966     WORD wReserved;
967     WORD XonLim;
968     WORD XoffLim;
969     BYTE ByteSize;
970     BYTE Parity;
971     BYTE StopBits;
972     char XonChar = 0;
973     char XoffChar = 0;
974     char ErrorChar = 0;
975     char EofChar = 0;
976     char EvtChar = 0;
977     WORD wReserved1;
978 }
979 alias DCB* LPDCB;
980 
981 struct COMMCONFIG {
982     DWORD dwSize = COMMCONFIG.sizeof;
983     WORD  wVersion;
984     WORD  wReserved;
985     DCB   dcb;
986     DWORD dwProviderSubType;
987     DWORD dwProviderOffset;
988     DWORD dwProviderSize;
989     WCHAR _wcProviderData = 0;
990 
991     WCHAR* wcProviderData() return { return &_wcProviderData; }
992 }
993 alias COMMCONFIG* LPCOMMCONFIG;
994 
995 struct COMMTIMEOUTS {
996     DWORD ReadIntervalTimeout;
997     DWORD ReadTotalTimeoutMultiplier;
998     DWORD ReadTotalTimeoutConstant;
999     DWORD WriteTotalTimeoutMultiplier;
1000     DWORD WriteTotalTimeoutConstant;
1001 }
1002 alias COMMTIMEOUTS* LPCOMMTIMEOUTS;
1003 
1004 struct COMSTAT {
1005 /+
1006     DWORD fCtsHold:1;
1007     DWORD fDsrHold:1;
1008     DWORD fRlsdHold:1;
1009     DWORD fXoffHold:1;
1010     DWORD fXoffSent:1;
1011     DWORD fEof:1;
1012     DWORD fTxim:1;
1013     DWORD fReserved:25;
1014 +/
1015     DWORD _bf;
1016     bool fCtsHold(bool f)  { _bf = (_bf & ~1) | f; return f; }
1017     bool fDsrHold(bool f)  { _bf = (_bf & ~2) | (f<<1); return f; }
1018     bool fRlsdHold(bool f) { _bf = (_bf & ~4) | (f<<2); return f; }
1019     bool fXoffHold(bool f) { _bf = (_bf & ~8) | (f<<3); return f; }
1020     bool fXoffSent(bool f) { _bf = (_bf & ~16) | (f<<4); return f; }
1021     bool fEof(bool f)      { _bf = (_bf & ~32) | (f<<5); return f; }
1022     bool fTxim(bool f)     { _bf = (_bf & ~64) | (f<<6); return f; }
1023 
1024     bool fCtsHold()  { return cast(bool) (_bf & 1); }
1025     bool fDsrHold()  { return cast(bool) (_bf & 2); }
1026     bool fRlsdHold() { return cast(bool) (_bf & 4); }
1027     bool fXoffHold() { return cast(bool) (_bf & 8); }
1028     bool fXoffSent() { return cast(bool) (_bf & 16); }
1029     bool fEof()      { return cast(bool) (_bf & 32); }
1030     bool fTxim()     { return cast(bool) (_bf & 64); }
1031 
1032     DWORD cbInQue;
1033     DWORD cbOutQue;
1034 }
1035 alias COMSTAT* LPCOMSTAT;
1036 
1037 struct CREATE_PROCESS_DEBUG_INFO {
1038     HANDLE hFile;
1039     HANDLE hProcess;
1040     HANDLE hThread;
1041     LPVOID lpBaseOfImage;
1042     DWORD  dwDebugInfoFileOffset;
1043     DWORD  nDebugInfoSize;
1044     LPVOID lpThreadLocalBase;
1045     LPTHREAD_START_ROUTINE lpStartAddress;
1046     LPVOID lpImageName;
1047     WORD   fUnicode;
1048 }
1049 alias CREATE_PROCESS_DEBUG_INFO* LPCREATE_PROCESS_DEBUG_INFO;
1050 
1051 struct CREATE_THREAD_DEBUG_INFO {
1052     HANDLE hThread;
1053     LPVOID lpThreadLocalBase;
1054     LPTHREAD_START_ROUTINE lpStartAddress;
1055 }
1056 alias CREATE_THREAD_DEBUG_INFO* LPCREATE_THREAD_DEBUG_INFO;
1057 
1058 struct EXCEPTION_DEBUG_INFO {
1059     EXCEPTION_RECORD ExceptionRecord;
1060     DWORD            dwFirstChance;
1061 }
1062 alias EXCEPTION_DEBUG_INFO* LPEXCEPTION_DEBUG_INFO;
1063 
1064 struct EXIT_THREAD_DEBUG_INFO {
1065     DWORD dwExitCode;
1066 }
1067 alias EXIT_THREAD_DEBUG_INFO* LPEXIT_THREAD_DEBUG_INFO;
1068 
1069 struct EXIT_PROCESS_DEBUG_INFO {
1070     DWORD dwExitCode;
1071 }
1072 alias EXIT_PROCESS_DEBUG_INFO* LPEXIT_PROCESS_DEBUG_INFO;
1073 
1074 struct LOAD_DLL_DEBUG_INFO {
1075     HANDLE hFile;
1076     LPVOID lpBaseOfDll;
1077     DWORD  dwDebugInfoFileOffset;
1078     DWORD  nDebugInfoSize;
1079     LPVOID lpImageName;
1080     WORD   fUnicode;
1081 }
1082 alias LOAD_DLL_DEBUG_INFO* LPLOAD_DLL_DEBUG_INFO;
1083 
1084 struct UNLOAD_DLL_DEBUG_INFO {
1085     LPVOID lpBaseOfDll;
1086 }
1087 alias UNLOAD_DLL_DEBUG_INFO* LPUNLOAD_DLL_DEBUG_INFO;
1088 
1089 struct OUTPUT_DEBUG_STRING_INFO {
1090     LPSTR lpDebugStringData;
1091     WORD  fUnicode;
1092     WORD  nDebugStringLength;
1093 }
1094 alias OUTPUT_DEBUG_STRING_INFO* LPOUTPUT_DEBUG_STRING_INFO;
1095 
1096 struct RIP_INFO {
1097     DWORD dwError;
1098     DWORD dwType;
1099 }
1100 alias RIP_INFO* LPRIP_INFO;
1101 
1102 struct DEBUG_EVENT {
1103     DWORD dwDebugEventCode;
1104     DWORD dwProcessId;
1105     DWORD dwThreadId;
1106     union {
1107         EXCEPTION_DEBUG_INFO      Exception;
1108         CREATE_THREAD_DEBUG_INFO  CreateThread;
1109         CREATE_PROCESS_DEBUG_INFO CreateProcessInfo;
1110         EXIT_THREAD_DEBUG_INFO    ExitThread;
1111         EXIT_PROCESS_DEBUG_INFO   ExitProcess;
1112         LOAD_DLL_DEBUG_INFO       LoadDll;
1113         UNLOAD_DLL_DEBUG_INFO     UnloadDll;
1114         OUTPUT_DEBUG_STRING_INFO  DebugString;
1115         RIP_INFO                  RipInfo;
1116     }
1117 }
1118 alias DEBUG_EVENT* LPDEBUG_EVENT;
1119 
1120 struct OVERLAPPED {
1121     ULONG_PTR Internal;
1122     ULONG_PTR InternalHigh;
1123     union {
1124         struct {
1125             DWORD     Offset;
1126             DWORD     OffsetHigh;
1127         }
1128         PVOID     Pointer;
1129     }
1130     HANDLE    hEvent;
1131 }
1132 alias OVERLAPPED* POVERLAPPED, LPOVERLAPPED;
1133 
1134 struct STARTUPINFOA {
1135     DWORD  cb = STARTUPINFOA.sizeof;
1136     LPSTR  lpReserved;
1137     LPSTR  lpDesktop;
1138     LPSTR  lpTitle;
1139     DWORD  dwX;
1140     DWORD  dwY;
1141     DWORD  dwXSize;
1142     DWORD  dwYSize;
1143     DWORD  dwXCountChars;
1144     DWORD  dwYCountChars;
1145     DWORD  dwFillAttribute;
1146     DWORD  dwFlags;
1147     WORD   wShowWindow;
1148     WORD   cbReserved2;
1149     PBYTE  lpReserved2;
1150     HANDLE hStdInput;
1151     HANDLE hStdOutput;
1152     HANDLE hStdError;
1153 }
1154 alias STARTUPINFOA* LPSTARTUPINFOA;
1155 
1156 struct STARTUPINFOW {
1157     DWORD  cb = STARTUPINFOW.sizeof;
1158     LPWSTR lpReserved;
1159     LPWSTR lpDesktop;
1160     LPWSTR lpTitle;
1161     DWORD  dwX;
1162     DWORD  dwY;
1163     DWORD  dwXSize;
1164     DWORD  dwYSize;
1165     DWORD  dwXCountChars;
1166     DWORD  dwYCountChars;
1167     DWORD  dwFillAttribute;
1168     DWORD  dwFlags;
1169     WORD   wShowWindow;
1170     WORD   cbReserved2;
1171     PBYTE  lpReserved2;
1172     HANDLE hStdInput;
1173     HANDLE hStdOutput;
1174     HANDLE hStdError;
1175 }
1176 alias STARTUPINFOW STARTUPINFO_W;
1177 alias STARTUPINFOW* LPSTARTUPINFOW, LPSTARTUPINFO_W;
1178 
1179 struct PROCESS_INFORMATION {
1180     HANDLE hProcess;
1181     HANDLE hThread;
1182     DWORD  dwProcessId;
1183     DWORD  dwThreadId;
1184 }
1185 alias PROCESS_INFORMATION* PPROCESS_INFORMATION, LPPROCESS_INFORMATION;
1186 
1187 /*
1188 struct CRITICAL_SECTION_DEBUG {
1189     WORD              Type;
1190     WORD              CreatorBackTraceIndex;
1191     CRITICAL_SECTION* CriticalSection;
1192     LIST_ENTRY        ProcessLocksList;
1193     DWORD             EntryCount;
1194     DWORD             ContentionCount;
1195     DWORD[2]          Spare;
1196 }
1197 alias CRITICAL_SECTION_DEBUG* PCRITICAL_SECTION_DEBUG;
1198 
1199 struct CRITICAL_SECTION {
1200     PCRITICAL_SECTION_DEBUG DebugInfo;
1201     LONG   LockCount;
1202     LONG   RecursionCount;
1203     HANDLE OwningThread;
1204     HANDLE LockSemaphore;
1205     DWORD  SpinCount;
1206 }
1207 alias CRITICAL_SECTION* PCRITICAL_SECTION, LPCRITICAL_SECTION;
1208 */
1209 
1210 alias CRITICAL_SECTION_DEBUG = RTL_CRITICAL_SECTION_DEBUG;
1211 alias CRITICAL_SECTION_DEBUG* PCRITICAL_SECTION_DEBUG;
1212 
1213 alias CRITICAL_SECTION = RTL_CRITICAL_SECTION;
1214 alias CRITICAL_SECTION* PCRITICAL_SECTION, LPCRITICAL_SECTION;
1215 
1216 struct SYSTEMTIME {
1217     WORD wYear;
1218     WORD wMonth;
1219     WORD wDayOfWeek;
1220     WORD wDay;
1221     WORD wHour;
1222     WORD wMinute;
1223     WORD wSecond;
1224     WORD wMilliseconds;
1225 }
1226 alias SYSTEMTIME* LPSYSTEMTIME;
1227 
1228 struct WIN32_FILE_ATTRIBUTE_DATA {
1229     DWORD    dwFileAttributes;
1230     FILETIME ftCreationTime;
1231     FILETIME ftLastAccessTime;
1232     FILETIME ftLastWriteTime;
1233     DWORD    nFileSizeHigh;
1234     DWORD    nFileSizeLow;
1235 }
1236 alias WIN32_FILE_ATTRIBUTE_DATA* LPWIN32_FILE_ATTRIBUTE_DATA;
1237 
1238 struct WIN32_FIND_DATAA {
1239     DWORD          dwFileAttributes;
1240     FILETIME       ftCreationTime;
1241     FILETIME       ftLastAccessTime;
1242     FILETIME       ftLastWriteTime;
1243     DWORD          nFileSizeHigh;
1244     DWORD          nFileSizeLow;
1245 // #ifdef _WIN32_WCE
1246 //  DWORD dwOID;
1247 // #else
1248     DWORD          dwReserved0;
1249     DWORD          dwReserved1;
1250 // #endif
1251     CHAR[MAX_PATH] cFileName = 0;
1252 // #ifndef _WIN32_WCE
1253     CHAR[14]       cAlternateFileName = 0;
1254 // #endif
1255 }
1256 alias WIN32_FIND_DATAA* PWIN32_FIND_DATAA, LPWIN32_FIND_DATAA;
1257 
1258 struct WIN32_FIND_DATAW {
1259     DWORD           dwFileAttributes;
1260     FILETIME        ftCreationTime;
1261     FILETIME        ftLastAccessTime;
1262     FILETIME        ftLastWriteTime;
1263     DWORD           nFileSizeHigh;
1264     DWORD           nFileSizeLow;
1265 // #ifdef _WIN32_WCE
1266 //  DWORD dwOID;
1267 // #else
1268     DWORD           dwReserved0;
1269     DWORD           dwReserved1;
1270 // #endif
1271     WCHAR[MAX_PATH] cFileName = 0;
1272 // #ifndef _WIN32_WCE
1273     WCHAR[14]       cAlternateFileName = 0;
1274 // #endif
1275 }
1276 alias WIN32_FIND_DATAW* PWIN32_FIND_DATAW, LPWIN32_FIND_DATAW;
1277 
1278 struct WIN32_STREAM_ID {
1279     DWORD         dwStreamId;
1280     DWORD         dwStreamAttributes;
1281     LARGE_INTEGER Size;
1282     DWORD         dwStreamNameSize;
1283     WCHAR         _cStreamName = 0;
1284 
1285     WCHAR* cStreamName() return { return &_cStreamName; }
1286 }
1287 alias WIN32_STREAM_ID* LPWIN32_STREAM_ID;
1288 
1289 static if (_WIN32_WINNT >= 0x601) {
1290     enum FINDEX_INFO_LEVELS {
1291         FindExInfoStandard,
1292         FindExInfoBasic,
1293         FindExInfoMaxInfoLevel,
1294     }
1295 } else {
1296     enum FINDEX_INFO_LEVELS {
1297         FindExInfoStandard,
1298         FindExInfoMaxInfoLevel,
1299     }
1300 }
1301 
1302 enum FINDEX_SEARCH_OPS {
1303     FindExSearchNameMatch,
1304     FindExSearchLimitToDirectories,
1305     FindExSearchLimitToDevices,
1306     FindExSearchMaxSearchOp
1307 }
1308 
1309 enum ACL_INFORMATION_CLASS {
1310     AclRevisionInformation = 1,
1311     AclSizeInformation
1312 }
1313 
1314 struct HW_PROFILE_INFOA {
1315     DWORD dwDockInfo;
1316     CHAR[HW_PROFILE_GUIDLEN] szHwProfileGuid = 0;
1317     CHAR[MAX_PROFILE_LEN]    szHwProfileName = 0;
1318 }
1319 alias HW_PROFILE_INFOA* LPHW_PROFILE_INFOA;
1320 
1321 struct HW_PROFILE_INFOW {
1322     DWORD dwDockInfo;
1323     WCHAR[HW_PROFILE_GUIDLEN] szHwProfileGuid = 0;
1324     WCHAR[MAX_PROFILE_LEN]    szHwProfileName = 0;
1325 }
1326 alias HW_PROFILE_INFOW* LPHW_PROFILE_INFOW;
1327 
1328 /*  ??? MSDN documents this only for Windows CE/Mobile, but it's used by
1329  *  GetFileAttributesEx, which is in desktop Windows.
1330  */
1331 enum GET_FILEEX_INFO_LEVELS {
1332     GetFileExInfoStandard,
1333     GetFileExMaxInfoLevel
1334 }
1335 
1336 struct SYSTEM_INFO {
1337     union {
1338         DWORD dwOemId;
1339         struct {
1340             WORD wProcessorArchitecture;
1341             WORD wReserved;
1342         }
1343     }
1344     DWORD dwPageSize;
1345     PVOID lpMinimumApplicationAddress;
1346     PVOID lpMaximumApplicationAddress;
1347     DWORD_PTR dwActiveProcessorMask;
1348     DWORD dwNumberOfProcessors;
1349     DWORD dwProcessorType;
1350     DWORD dwAllocationGranularity;
1351     WORD  wProcessorLevel;
1352     WORD  wProcessorRevision;
1353 }
1354 alias SYSTEM_INFO* LPSYSTEM_INFO;
1355 
1356 static if (_WIN32_WINNT >= 0x500) {
1357     struct SYSTEM_POWER_STATUS {
1358         BYTE ACLineStatus;
1359         BYTE BatteryFlag;
1360         BYTE BatteryLifePercent;
1361         BYTE Reserved1;
1362         DWORD BatteryLifeTime;
1363         DWORD BatteryFullLifeTime;
1364     }
1365     alias SYSTEM_POWER_STATUS* LPSYSTEM_POWER_STATUS;
1366 }
1367 
1368 struct TIME_ZONE_INFORMATION {
1369     LONG       Bias;
1370     WCHAR[32]  StandardName = 0;
1371     SYSTEMTIME StandardDate;
1372     LONG       StandardBias;
1373     WCHAR[32]  DaylightName = 0;
1374     SYSTEMTIME DaylightDate;
1375     LONG       DaylightBias;
1376 }
1377 alias TIME_ZONE_INFORMATION* LPTIME_ZONE_INFORMATION;
1378 
1379 // Does not exist in Windows headers, only MSDN
1380 // documentation (for TIME_ZONE_INFORMATION).
1381 // Provided solely for compatibility with the old
1382 // core.sys.windows.windows
1383 struct REG_TZI_FORMAT {
1384     LONG Bias;
1385     LONG StandardBias;
1386     LONG DaylightBias;
1387     SYSTEMTIME StandardDate;
1388     SYSTEMTIME DaylightDate;
1389 }
1390 
1391 // MSDN documents this, possibly erroneously, as Win2000+.
1392 struct MEMORYSTATUS {
1393     DWORD dwLength;
1394     DWORD dwMemoryLoad;
1395     SIZE_T dwTotalPhys;
1396     SIZE_T dwAvailPhys;
1397     SIZE_T dwTotalPageFile;
1398     SIZE_T dwAvailPageFile;
1399     SIZE_T dwTotalVirtual;
1400     SIZE_T dwAvailVirtual;
1401 }
1402 alias MEMORYSTATUS* LPMEMORYSTATUS;
1403 
1404 static if (_WIN32_WINNT >= 0x500) {
1405     struct MEMORYSTATUSEX {
1406         DWORD     dwLength;
1407         DWORD     dwMemoryLoad;
1408         DWORDLONG ullTotalPhys;
1409         DWORDLONG ullAvailPhys;
1410         DWORDLONG ullTotalPageFile;
1411         DWORDLONG ullAvailPageFile;
1412         DWORDLONG ullTotalVirtual;
1413         DWORDLONG ullAvailVirtual;
1414         DWORDLONG ullAvailExtendedVirtual;
1415     }
1416     alias MEMORYSTATUSEX* LPMEMORYSTATUSEX;
1417 }
1418 
1419 struct LDT_ENTRY {
1420     WORD LimitLow;
1421     WORD BaseLow;
1422     struct {
1423         BYTE BaseMid;
1424         BYTE Flags1;
1425         BYTE Flags2;
1426         BYTE BaseHi;
1427 
1428         byte Type(byte f)        { Flags1 = cast(BYTE) ((Flags1 & 0xE0) | f); return cast(byte)(f & 0x1F); }
1429         byte Dpl(byte f)         { Flags1 = cast(BYTE) ((Flags1 & 0x9F) | (f<<5)); return cast(byte)(f & 3); }
1430         bool Pres(bool f)        { Flags1 = cast(BYTE) ((Flags1 & 0x7F) | (f<<7)); return f; }
1431 
1432         byte LimitHi(byte f)     { Flags2 = cast(BYTE) ((Flags2 & 0xF0) | (f&0x0F)); return cast(byte)(f & 0x0F); }
1433         bool Sys(bool f)         { Flags2 = cast(BYTE) ((Flags2 & 0xEF) | (f<<4)); return f; }
1434         // Next bit is reserved
1435         bool Default_Big(bool f) { Flags2 = cast(BYTE) ((Flags2 & 0xBF) | (f<<6)); return f; }
1436         bool Granularity(bool f) { Flags2 = cast(BYTE) ((Flags2 & 0x7F) | (f<<7)); return f; }
1437 
1438         byte Type()        { return cast(byte) (Flags1 & 0x1F); }
1439         byte Dpl()         { return cast(byte) ((Flags1 & 0x60)>>5); }
1440         bool Pres()        { return cast(bool) (Flags1 & 0x80); }
1441 
1442         byte LimitHi()     { return cast(byte) (Flags2 & 0x0F); }
1443         bool Sys()         { return cast(bool) (Flags2 & 0x10); }
1444         bool Default_Big() { return cast(bool) (Flags2 & 0x40); }
1445         bool Granularity() { return cast(bool) (Flags2 & 0x80); }
1446     }
1447 /+
1448     union  HighWord {
1449         struct Bytes {
1450             BYTE BaseMid;
1451             BYTE Flags1;
1452             BYTE Flags2;
1453             BYTE BaseHi;
1454         }
1455     struct Bits {
1456         DWORD BaseMid:8;
1457         DWORD Type:5;
1458         DWORD Dpl:2;
1459         DWORD Pres:1;
1460         DWORD LimitHi:4;
1461         DWORD Sys:1;
1462         DWORD Reserved_0:1;
1463         DWORD Default_Big:1;
1464         DWORD Granularity:1;
1465         DWORD BaseHi:8;
1466     }
1467     }
1468 +/
1469 }
1470 alias LDT_ENTRY* PLDT_ENTRY, LPLDT_ENTRY;
1471 
1472 /*  As with the other memory management functions and structures, MSDN's
1473  *  Windows version info shall be taken with a cup of salt.
1474  */
1475 struct PROCESS_HEAP_ENTRY {
1476     PVOID lpData;
1477     DWORD cbData;
1478     BYTE  cbOverhead;
1479     BYTE  iRegionIndex;
1480     WORD  wFlags;
1481     union {
1482         struct _Block {
1483             HANDLE   hMem;
1484             DWORD[3] dwReserved;
1485         }
1486         _Block Block;
1487         struct _Region {
1488             DWORD    dwCommittedSize;
1489             DWORD    dwUnCommittedSize;
1490             LPVOID   lpFirstBlock;
1491             LPVOID   lpLastBlock;
1492         }
1493         _Region Region;
1494     }
1495 }
1496 alias PROCESS_HEAP_ENTRY* LPPROCESS_HEAP_ENTRY;
1497 
1498 struct OFSTRUCT {
1499     BYTE      cBytes = OFSTRUCT.sizeof;
1500     BYTE      fFixedDisk;
1501     WORD      nErrCode;
1502     WORD      Reserved1;
1503     WORD      Reserved2;
1504     CHAR[128] szPathName = 0; // const OFS_MAXPATHNAME = 128;
1505 }
1506 alias OFSTRUCT* LPOFSTRUCT, POFSTRUCT;
1507 
1508 /*  ??? MSDN documents this only for Windows CE, but it's used by
1509  *  ImageGetCertificateData, which is in desktop Windows.
1510  */
1511 struct WIN_CERTIFICATE {
1512     DWORD dwLength;
1513     WORD  wRevision;
1514     WORD  wCertificateType;
1515     BYTE  _bCertificate;
1516 
1517     BYTE* bCertificate() return { return &_bCertificate; }
1518 }
1519 alias WIN_CERTIFICATE* LPWIN_CERTIFICATE;
1520 
1521 static if (_WIN32_WINNT >= 0x500) {
1522     enum COMPUTER_NAME_FORMAT {
1523         ComputerNameNetBIOS,
1524         ComputerNameDnsHostname,
1525         ComputerNameDnsDomain,
1526         ComputerNameDnsFullyQualified,
1527         ComputerNamePhysicalNetBIOS,
1528         ComputerNamePhysicalDnsHostname,
1529         ComputerNamePhysicalDnsDomain,
1530         ComputerNamePhysicalDnsFullyQualified,
1531         ComputerNameMax
1532     }
1533 }
1534 
1535 static if (_WIN32_WINNT >= 0x501) {
1536     struct ACTCTXA {
1537         ULONG cbSize = this.sizeof;
1538         DWORD dwFlags;
1539         LPCSTR lpSource;
1540         USHORT wProcessorArchitecture;
1541         LANGID wLangId;
1542         LPCSTR lpAssemblyDirectory;
1543         LPCSTR lpResourceName;
1544         LPCSTR lpApplicationName;
1545         HMODULE hModule;
1546     }
1547     alias ACTCTXA*        PACTCTXA;
1548     alias const(ACTCTXA)* PCACTCTXA;
1549 
1550     struct ACTCTXW {
1551         ULONG cbSize = this.sizeof;
1552         DWORD dwFlags;
1553         LPCWSTR lpSource;
1554         USHORT wProcessorArchitecture;
1555         LANGID wLangId;
1556         LPCWSTR lpAssemblyDirectory;
1557         LPCWSTR lpResourceName;
1558         LPCWSTR lpApplicationName;
1559         HMODULE hModule;
1560     }
1561     alias ACTCTXW*        PACTCTXW;
1562     alias const(ACTCTXW)* PCACTCTXW;
1563 
1564     struct ACTCTX_SECTION_KEYED_DATA {
1565         ULONG cbSize = this.sizeof;
1566         ULONG ulDataFormatVersion;
1567         PVOID lpData;
1568         ULONG ulLength;
1569         PVOID lpSectionGlobalData;
1570         ULONG ulSectionGlobalDataLength;
1571         PVOID lpSectionBase;
1572         ULONG ulSectionTotalLength;
1573         HANDLE hActCtx;
1574         HANDLE ulAssemblyRosterIndex;
1575     }
1576     alias ACTCTX_SECTION_KEYED_DATA*        PACTCTX_SECTION_KEYED_DATA;
1577     alias const(ACTCTX_SECTION_KEYED_DATA)* PCACTCTX_SECTION_KEYED_DATA;
1578 
1579     enum MEMORY_RESOURCE_NOTIFICATION_TYPE {
1580         LowMemoryResourceNotification,
1581         HighMemoryResourceNotification
1582     }
1583 
1584 } // (_WIN32_WINNT >= 0x501)
1585 
1586 static if (_WIN32_WINNT >= 0x410) {
1587     /*  apparently used only by SetThreadExecutionState (Win2000+)
1588      *  and DDK functions (version compatibility not established)
1589      */
1590     alias DWORD EXECUTION_STATE;
1591 }
1592 
1593 // CreateSymbolicLink
1594 static if (_WIN32_WINNT >= 0x600) {
1595     enum {
1596         SYMBOLIC_LINK_FLAG_DIRECTORY = 0x1,
1597         SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE = 0x2
1598     }
1599 }
1600 
1601 // Callbacks
1602 extern (Windows) {
1603     alias DWORD function(LPVOID) LPTHREAD_START_ROUTINE;
1604     alias DWORD function(LARGE_INTEGER, LARGE_INTEGER, LARGE_INTEGER, LARGE_INTEGER,
1605         DWORD, DWORD, HANDLE, HANDLE, LPVOID)  LPPROGRESS_ROUTINE;
1606     alias void function(PVOID) LPFIBER_START_ROUTINE;
1607 
1608     alias BOOL function(HMODULE, LPCSTR, LPCSTR, WORD, LONG_PTR) ENUMRESLANGPROCA;
1609     alias BOOL function(HMODULE, LPCWSTR, LPCWSTR, WORD, LONG_PTR) ENUMRESLANGPROCW;
1610     alias BOOL function(HMODULE, LPCSTR, LPSTR, LONG_PTR) ENUMRESNAMEPROCA;
1611     alias BOOL function(HMODULE, LPCWSTR, LPWSTR, LONG_PTR) ENUMRESNAMEPROCW;
1612     alias BOOL function(HMODULE, LPSTR, LONG_PTR) ENUMRESTYPEPROCA;
1613     alias BOOL function(HMODULE, LPWSTR, LONG_PTR) ENUMRESTYPEPROCW;
1614     alias void function(DWORD, DWORD, LPOVERLAPPED) LPOVERLAPPED_COMPLETION_ROUTINE;
1615     alias LONG function(LPEXCEPTION_POINTERS) PTOP_LEVEL_EXCEPTION_FILTER;
1616     alias PTOP_LEVEL_EXCEPTION_FILTER LPTOP_LEVEL_EXCEPTION_FILTER;
1617 
1618     alias void function(ULONG_PTR) PAPCFUNC;
1619     alias void function(PVOID, DWORD, DWORD) PTIMERAPCROUTINE;
1620 
1621     static if (_WIN32_WINNT >= 0x500) {
1622         alias void function(PVOID, BOOLEAN) WAITORTIMERCALLBACK;
1623     }
1624 }
1625 
1626 LPTSTR MAKEINTATOM()(ushort i) {
1627     return cast(LPTSTR) cast(size_t) i;
1628 }
1629 
1630 extern (Windows) nothrow @nogc {
1631     // The following Win16 functions are obselete in Win32.
1632     int _hread(HFILE, LPVOID, int);
1633     int _hwrite(HFILE, LPCSTR, int);
1634     HFILE _lclose(HFILE);
1635     HFILE _lcreat(LPCSTR, int);
1636     LONG _llseek(HFILE, LONG, int);
1637     HFILE _lopen(LPCSTR, int);
1638     UINT _lread(HFILE, LPVOID, UINT);
1639     UINT _lwrite(HFILE, LPCSTR, UINT);
1640     SIZE_T GlobalCompact(DWORD);
1641     VOID GlobalFix(HGLOBAL);
1642 
1643     // MSDN contradicts itself on GlobalFlags:
1644     // "This function is provided only for compatibility with 16-bit versions of Windows."
1645     // but also requires Windows 2000 or above
1646     UINT GlobalFlags(HGLOBAL);
1647     VOID GlobalUnfix(HGLOBAL);
1648     BOOL GlobalUnWire(HGLOBAL);
1649     PVOID GlobalWire(HGLOBAL);
1650     SIZE_T LocalCompact(UINT);
1651     UINT LocalFlags(HLOCAL);
1652     SIZE_T LocalShrink(HLOCAL, UINT);
1653 
1654     /+
1655     //--------------------------------------
1656     // These functions are problematic
1657 
1658     version (UseNtoSKernel) {}else {
1659         /* CAREFUL: These are exported from ntoskrnl.exe and declared in winddk.h
1660            as __fastcall functions, but are  exported from kernel32.dll as __stdcall */
1661         static if (_WIN32_WINNT >= 0x501) {
1662          VOID InitializeSListHead(PSLIST_HEADER);
1663         }
1664         LONG InterlockedCompareExchange(LPLONG, LONG, LONG);
1665         // PVOID WINAPI InterlockedCompareExchangePointer(PVOID*, PVOID, PVOID);
1666         (PVOID)InterlockedCompareExchange((LPLONG)(d)    (PVOID)InterlockedCompareExchange((LPLONG)(d), (LONG)(e), (LONG)(c))
1667         LONG InterlockedDecrement(LPLONG);
1668         LONG InterlockedExchange(LPLONG, LONG);
1669         // PVOID WINAPI InterlockedExchangePointer(PVOID*, PVOID);
1670         (PVOID)InterlockedExchange((LPLONG)((PVOID)InterlockedExchange((LPLONG)(t), (LONG)(v))
1671         LONG InterlockedExchangeAdd(LPLONG, LONG);
1672 
1673         static if (_WIN32_WINNT >= 0x501) {
1674         PSLIST_ENTRY InterlockedFlushSList(PSLIST_HEADER);
1675         }
1676         LONG InterlockedIncrement(LPLONG);
1677         static if (_WIN32_WINNT >= 0x501) {
1678         PSLIST_ENTRY InterlockedPopEntrySList(PSLIST_HEADER);
1679         PSLIST_ENTRY InterlockedPushEntrySList(PSLIST_HEADER, PSLIST_ENTRY);
1680         }
1681     } // #endif //  __USE_NTOSKRNL__
1682     //--------------------------------------
1683     +/
1684 
1685     LONG InterlockedIncrement(LPLONG lpAddend);
1686     LONG InterlockedDecrement(LPLONG lpAddend);
1687     LONG InterlockedExchange(LPLONG Target, LONG Value);
1688     LONG InterlockedExchangeAdd(LPLONG Addend, LONG Value);
1689     LONG InterlockedCompareExchange(LONG *Destination, LONG Exchange, LONG Comperand);
1690 
1691     ATOM AddAtomA(LPCSTR);
1692     ATOM AddAtomW(LPCWSTR);
1693     BOOL AreFileApisANSI();
1694     BOOL Beep(DWORD, DWORD);
1695     HANDLE BeginUpdateResourceA(LPCSTR, BOOL);
1696     HANDLE BeginUpdateResourceW(LPCWSTR, BOOL);
1697     BOOL BuildCommDCBA(LPCSTR, LPDCB);
1698     BOOL BuildCommDCBW(LPCWSTR, LPDCB);
1699     BOOL BuildCommDCBAndTimeoutsA(LPCSTR, LPDCB, LPCOMMTIMEOUTS);
1700     BOOL BuildCommDCBAndTimeoutsW(LPCWSTR, LPDCB, LPCOMMTIMEOUTS);
1701     BOOL CallNamedPipeA(LPCSTR, PVOID, DWORD, PVOID, DWORD, PDWORD, DWORD);
1702     BOOL CallNamedPipeW(LPCWSTR, PVOID, DWORD, PVOID, DWORD, PDWORD, DWORD);
1703     BOOL CancelDeviceWakeupRequest(HANDLE);
1704     BOOL CheckTokenMembership(HANDLE, PSID, PBOOL);
1705     BOOL ClearCommBreak(HANDLE);
1706     BOOL ClearCommError(HANDLE, PDWORD, LPCOMSTAT);
1707     BOOL CloseHandle(HANDLE) @trusted;
1708     BOOL CommConfigDialogA(LPCSTR, HWND, LPCOMMCONFIG);
1709     BOOL CommConfigDialogW(LPCWSTR, HWND, LPCOMMCONFIG);
1710     LONG CompareFileTime(const(FILETIME)*, const(FILETIME)*);
1711     BOOL ContinueDebugEvent(DWORD, DWORD, DWORD);
1712     BOOL CopyFileA(LPCSTR, LPCSTR, BOOL);
1713     BOOL CopyFileW(LPCWSTR, LPCWSTR, BOOL);
1714     BOOL CopyFileExA(LPCSTR, LPCSTR, LPPROGRESS_ROUTINE, LPVOID, LPBOOL, DWORD);
1715     BOOL CopyFileExW(LPCWSTR, LPCWSTR, LPPROGRESS_ROUTINE, LPVOID, LPBOOL, DWORD);
1716 
1717     alias RtlMoveMemory = memmove;
1718     alias RtlCopyMemory = memcpy;
1719     pragma(inline, true) void RtlFillMemory(PVOID Destination, SIZE_T Length, BYTE Fill) { memset(Destination, Fill, Length); }
1720     pragma(inline, true) void RtlZeroMemory(PVOID Destination, SIZE_T Length) { memset(Destination, 0, Length); }
1721     alias MoveMemory = RtlMoveMemory;
1722     alias CopyMemory = RtlCopyMemory;
1723     alias FillMemory = RtlFillMemory;
1724     alias ZeroMemory = RtlZeroMemory;
1725 
1726     BOOL CreateDirectoryA(LPCSTR, LPSECURITY_ATTRIBUTES);
1727     BOOL CreateDirectoryW(LPCWSTR, LPSECURITY_ATTRIBUTES);
1728     BOOL CreateDirectoryExA(LPCSTR, LPCSTR, LPSECURITY_ATTRIBUTES);
1729     BOOL CreateDirectoryExW(LPCWSTR, LPCWSTR, LPSECURITY_ATTRIBUTES);
1730     HANDLE CreateEventA(LPSECURITY_ATTRIBUTES, BOOL, BOOL, LPCSTR);
1731     HANDLE CreateEventW(LPSECURITY_ATTRIBUTES, BOOL, BOOL, LPCWSTR);
1732     HANDLE CreateFileA(LPCSTR, DWORD, DWORD, LPSECURITY_ATTRIBUTES, DWORD, DWORD, HANDLE);
1733     HANDLE CreateFileW(LPCWSTR, DWORD, DWORD, LPSECURITY_ATTRIBUTES, DWORD, DWORD, HANDLE);
1734     HANDLE CreateIoCompletionPort(HANDLE, HANDLE, ULONG_PTR, DWORD);
1735     HANDLE CreateMailslotA(LPCSTR, DWORD, DWORD, LPSECURITY_ATTRIBUTES);
1736     HANDLE CreateMailslotW(LPCWSTR, DWORD, DWORD, LPSECURITY_ATTRIBUTES);
1737     HANDLE CreateMutexA(LPSECURITY_ATTRIBUTES, BOOL, LPCSTR);
1738     HANDLE CreateMutexW(LPSECURITY_ATTRIBUTES, BOOL, LPCWSTR);
1739     BOOL CreatePipe(PHANDLE, PHANDLE, LPSECURITY_ATTRIBUTES, DWORD);
1740     BOOL CreateProcessA(LPCSTR, LPSTR, LPSECURITY_ATTRIBUTES, LPSECURITY_ATTRIBUTES, BOOL, DWORD, PVOID, LPCSTR, LPSTARTUPINFOA, LPPROCESS_INFORMATION);
1741     BOOL CreateProcessW(LPCWSTR, LPWSTR, LPSECURITY_ATTRIBUTES, LPSECURITY_ATTRIBUTES, BOOL, DWORD, PVOID, LPCWSTR, LPSTARTUPINFOW, LPPROCESS_INFORMATION);
1742     HANDLE CreateSemaphoreA(LPSECURITY_ATTRIBUTES, LONG, LONG, LPCSTR) @trusted;
1743     HANDLE CreateSemaphoreW(LPSECURITY_ATTRIBUTES, LONG, LONG, LPCWSTR) @trusted;
1744     HANDLE CreateThread(LPSECURITY_ATTRIBUTES, SIZE_T, LPTHREAD_START_ROUTINE, PVOID, DWORD, PDWORD);
1745     BOOL DebugActiveProcess(DWORD);
1746     void DebugBreak();
1747     ATOM DeleteAtom(ATOM);
1748     void DeleteCriticalSection(PCRITICAL_SECTION);
1749     BOOL DeleteFileA(LPCSTR);
1750     BOOL DeleteFileW(LPCWSTR);
1751     BOOL DisableThreadLibraryCalls(HMODULE);
1752     BOOL DosDateTimeToFileTime(WORD, WORD, LPFILETIME);
1753     BOOL DuplicateHandle(HANDLE, HANDLE, HANDLE, PHANDLE, DWORD, BOOL, DWORD);
1754     BOOL EndUpdateResourceA(HANDLE, BOOL);
1755     BOOL EndUpdateResourceW(HANDLE, BOOL);
1756     void EnterCriticalSection(LPCRITICAL_SECTION);
1757     void EnterCriticalSection(shared(CRITICAL_SECTION)*);
1758     BOOL EnumResourceLanguagesA(HMODULE, LPCSTR, LPCSTR, ENUMRESLANGPROC, LONG_PTR);
1759     BOOL EnumResourceLanguagesW(HMODULE, LPCWSTR, LPCWSTR, ENUMRESLANGPROC, LONG_PTR);
1760     BOOL EnumResourceNamesA(HMODULE, LPCSTR, ENUMRESNAMEPROC, LONG_PTR);
1761     BOOL EnumResourceNamesW(HMODULE, LPCWSTR, ENUMRESNAMEPROC, LONG_PTR);
1762     BOOL EnumResourceTypesA(HMODULE, ENUMRESTYPEPROC, LONG_PTR);
1763     BOOL EnumResourceTypesW(HMODULE, ENUMRESTYPEPROC, LONG_PTR);
1764     BOOL EscapeCommFunction(HANDLE, DWORD);
1765     void ExitProcess(UINT); // Never returns
1766     void ExitThread(DWORD); // Never returns
1767     DWORD ExpandEnvironmentStringsA(LPCSTR, LPSTR, DWORD);
1768     DWORD ExpandEnvironmentStringsW(LPCWSTR, LPWSTR, DWORD);
1769     void FatalAppExitA(UINT, LPCSTR);
1770     void FatalAppExitW(UINT, LPCWSTR);
1771     void FatalExit(int);
1772     BOOL FileTimeToDosDateTime(const(FILETIME)*, LPWORD, LPWORD);
1773     BOOL FileTimeToLocalFileTime(const(FILETIME)*, LPFILETIME);
1774     BOOL FileTimeToSystemTime(const(FILETIME)*, LPSYSTEMTIME);
1775     ATOM FindAtomA(LPCSTR);
1776     ATOM FindAtomW(LPCWSTR);
1777     BOOL FindClose(HANDLE);
1778     BOOL FindCloseChangeNotification(HANDLE);
1779     HANDLE FindFirstChangeNotificationA(LPCSTR, BOOL, DWORD);
1780     HANDLE FindFirstChangeNotificationW(LPCWSTR, BOOL, DWORD);
1781     HANDLE FindFirstFileA(LPCSTR, LPWIN32_FIND_DATAA);
1782     HANDLE FindFirstFileW(LPCWSTR, LPWIN32_FIND_DATAW);
1783     BOOL FindNextChangeNotification(HANDLE);
1784     BOOL FindNextFileA(HANDLE, LPWIN32_FIND_DATAA);
1785     BOOL FindNextFileW(HANDLE, LPWIN32_FIND_DATAW);
1786     HRSRC FindResourceA(HMODULE, LPCSTR, LPCSTR);
1787     HRSRC FindResourceW(HINSTANCE, LPCWSTR, LPCWSTR);
1788     HRSRC FindResourceExA(HINSTANCE, LPCSTR, LPCSTR, WORD);
1789     HRSRC FindResourceExW(HINSTANCE, LPCWSTR, LPCWSTR, WORD);
1790     BOOL FlushFileBuffers(HANDLE);
1791     BOOL FlushInstructionCache(HANDLE, PCVOID, SIZE_T);
1792     DWORD FormatMessageA(DWORD, PCVOID, DWORD, DWORD, LPSTR, DWORD, va_list*);
1793     DWORD FormatMessageW(DWORD, PCVOID, DWORD, DWORD, LPWSTR, DWORD, va_list*);
1794     BOOL FreeEnvironmentStringsA(LPSTR);
1795     BOOL FreeEnvironmentStringsW(LPWSTR);
1796     BOOL FreeLibrary(HMODULE);
1797     void FreeLibraryAndExitThread(HMODULE, DWORD); // never returns
1798     BOOL FreeResource(HGLOBAL);
1799     UINT GetAtomNameA(ATOM, LPSTR, int);
1800     UINT GetAtomNameW(ATOM, LPWSTR, int);
1801     LPSTR GetCommandLineA();
1802     LPWSTR GetCommandLineW();
1803     BOOL GetCommConfig(HANDLE, LPCOMMCONFIG, PDWORD);
1804     BOOL GetCommMask(HANDLE, PDWORD);
1805     BOOL GetCommModemStatus(HANDLE, PDWORD);
1806     BOOL GetCommProperties(HANDLE, LPCOMMPROP);
1807     BOOL GetCommState(HANDLE, LPDCB);
1808     BOOL GetCommTimeouts(HANDLE, LPCOMMTIMEOUTS);
1809     BOOL GetComputerNameA(LPSTR, PDWORD);
1810     BOOL GetComputerNameW(LPWSTR, PDWORD);
1811     DWORD GetCurrentDirectoryA(DWORD, LPSTR);
1812     DWORD GetCurrentDirectoryW(DWORD, LPWSTR);
1813     HANDLE GetCurrentProcess();
1814     DWORD GetCurrentProcessId();
1815     HANDLE GetCurrentThread();
1816 /* In MinGW:
1817 #ifdef _WIN32_WCE
1818 extern DWORD GetCurrentThreadId(void);
1819 #else
1820 WINBASEAPI DWORD WINAPI GetCurrentThreadId(void);
1821 #endif
1822 */
1823     DWORD GetCurrentThreadId();
1824 
1825     alias GetTickCount GetCurrentTime;
1826 
1827     BOOL GetDefaultCommConfigA(LPCSTR, LPCOMMCONFIG, PDWORD);
1828     BOOL GetDefaultCommConfigW(LPCWSTR, LPCOMMCONFIG, PDWORD);
1829     BOOL GetDiskFreeSpaceA(LPCSTR, PDWORD, PDWORD, PDWORD, PDWORD);
1830     BOOL GetDiskFreeSpaceW(LPCWSTR, PDWORD, PDWORD, PDWORD, PDWORD);
1831     BOOL GetDiskFreeSpaceExA(LPCSTR, PULARGE_INTEGER, PULARGE_INTEGER, PULARGE_INTEGER);
1832     BOOL GetDiskFreeSpaceExW(LPCWSTR, PULARGE_INTEGER, PULARGE_INTEGER, PULARGE_INTEGER);
1833     UINT GetDriveTypeA(LPCSTR);
1834     UINT GetDriveTypeW(LPCWSTR);
1835     LPSTR GetEnvironmentStringsA();
1836     LPWSTR GetEnvironmentStringsW();
1837     DWORD GetEnvironmentVariableA(LPCSTR, LPSTR, DWORD);
1838     DWORD GetEnvironmentVariableW(LPCWSTR, LPWSTR, DWORD);
1839     BOOL GetExitCodeProcess(HANDLE, PDWORD);
1840     BOOL GetExitCodeThread(HANDLE, PDWORD);
1841     DWORD GetFileAttributesA(LPCSTR);
1842     DWORD GetFileAttributesW(LPCWSTR);
1843     BOOL GetFileInformationByHandle(HANDLE, LPBY_HANDLE_FILE_INFORMATION);
1844     DWORD GetFileSize(HANDLE, PDWORD);
1845     BOOL GetFileTime(HANDLE, LPFILETIME, LPFILETIME, LPFILETIME);
1846     DWORD GetFileType(HANDLE);
1847     DWORD GetFullPathNameA(LPCSTR, DWORD, LPSTR, LPSTR*);
1848     DWORD GetFullPathNameW(LPCWSTR, DWORD, LPWSTR, LPWSTR*);
1849     DWORD GetLastError() @trusted;
1850     void GetLocalTime(LPSYSTEMTIME);
1851     DWORD GetLogicalDrives();
1852     DWORD GetLogicalDriveStringsA(DWORD, LPSTR);
1853     DWORD GetLogicalDriveStringsW(DWORD, LPWSTR);
1854     BOOL GetMailslotInfo(HANDLE, PDWORD, PDWORD, PDWORD, PDWORD);
1855     DWORD GetModuleFileNameA(HINSTANCE, LPSTR, DWORD);
1856     DWORD GetModuleFileNameW(HINSTANCE, LPWSTR, DWORD);
1857     HMODULE GetModuleHandleA(LPCSTR);
1858     HMODULE GetModuleHandleW(LPCWSTR);
1859     BOOL GetNamedPipeHandleStateA(HANDLE, PDWORD, PDWORD, PDWORD, PDWORD, LPSTR, DWORD);
1860     BOOL GetNamedPipeHandleStateW(HANDLE, PDWORD, PDWORD, PDWORD, PDWORD, LPWSTR, DWORD);
1861     BOOL GetNamedPipeInfo(HANDLE, PDWORD, PDWORD, PDWORD, PDWORD);
1862     BOOL GetOverlappedResult(HANDLE, LPOVERLAPPED, PDWORD, BOOL);
1863     DWORD GetPriorityClass(HANDLE);
1864     UINT GetPrivateProfileIntA(LPCSTR, LPCSTR, INT, LPCSTR);
1865     UINT GetPrivateProfileIntW(LPCWSTR, LPCWSTR, INT, LPCWSTR);
1866     DWORD GetPrivateProfileSectionA(LPCSTR, LPSTR, DWORD, LPCSTR);
1867     DWORD GetPrivateProfileSectionW(LPCWSTR, LPWSTR, DWORD, LPCWSTR);
1868     DWORD GetPrivateProfileSectionNamesA(LPSTR, DWORD, LPCSTR);
1869     DWORD GetPrivateProfileSectionNamesW(LPWSTR, DWORD, LPCWSTR);
1870     DWORD GetPrivateProfileStringA(LPCSTR, LPCSTR, LPCSTR, LPSTR, DWORD, LPCSTR);
1871     DWORD GetPrivateProfileStringW(LPCWSTR, LPCWSTR, LPCWSTR, LPWSTR, DWORD, LPCWSTR);
1872     BOOL GetPrivateProfileStructA(LPCSTR, LPCSTR, LPVOID, UINT, LPCSTR);
1873     BOOL GetPrivateProfileStructW(LPCWSTR, LPCWSTR, LPVOID, UINT, LPCWSTR);
1874     FARPROC GetProcAddress(HMODULE, LPCSTR); // 1st param wrongly HINSTANCE in MinGW
1875     BOOL GetProcessAffinityMask(HANDLE, PDWORD_PTR, PDWORD_PTR);
1876     DWORD GetProcessVersion(DWORD);
1877     UINT GetProfileIntA(LPCSTR, LPCSTR, INT);
1878     UINT GetProfileIntW(LPCWSTR, LPCWSTR, INT);
1879     DWORD GetProfileSectionA(LPCSTR, LPSTR, DWORD);
1880     DWORD GetProfileSectionW(LPCWSTR, LPWSTR, DWORD);
1881     DWORD GetProfileStringA(LPCSTR, LPCSTR, LPCSTR, LPSTR, DWORD);
1882     DWORD GetProfileStringW(LPCWSTR, LPCWSTR, LPCWSTR, LPWSTR, DWORD);
1883     DWORD GetShortPathNameA(LPCSTR, LPSTR, DWORD);
1884     DWORD GetShortPathNameW(LPCWSTR, LPWSTR, DWORD);
1885     VOID GetStartupInfoA(LPSTARTUPINFOA);
1886     VOID GetStartupInfoW(LPSTARTUPINFOW);
1887     HANDLE GetStdHandle(DWORD);
1888     UINT GetSystemDirectoryA(LPSTR, UINT);
1889     UINT GetSystemDirectoryW(LPWSTR, UINT);
1890     VOID GetSystemInfo(LPSYSTEM_INFO);
1891     VOID GetSystemTime(LPSYSTEMTIME);
1892     BOOL GetSystemTimeAdjustment(PDWORD, PDWORD, PBOOL);
1893     void GetSystemTimeAsFileTime(LPFILETIME);
1894     UINT GetTempFileNameA(LPCSTR, LPCSTR, UINT, LPSTR);
1895     UINT GetTempFileNameW(LPCWSTR, LPCWSTR, UINT, LPWSTR);
1896     DWORD GetTempPathA(DWORD, LPSTR);
1897     DWORD GetTempPathW(DWORD, LPWSTR);
1898     BOOL GetThreadContext(HANDLE, LPCONTEXT);
1899     int GetThreadPriority(HANDLE);
1900     BOOL GetThreadSelectorEntry(HANDLE, DWORD, LPLDT_ENTRY);
1901     DWORD GetTickCount();
1902     DWORD GetTimeZoneInformation(LPTIME_ZONE_INFORMATION);
1903     BOOL GetUserNameA (LPSTR, PDWORD);
1904     BOOL GetUserNameW(LPWSTR, PDWORD);
1905     DWORD GetVersion();
1906     BOOL GetVersionExA(LPOSVERSIONINFOA);
1907     BOOL GetVersionExW(LPOSVERSIONINFOW);
1908     BOOL GetVolumeInformationA(LPCSTR, LPSTR, DWORD, PDWORD, PDWORD, PDWORD, LPSTR, DWORD);
1909     BOOL GetVolumeInformationW(LPCWSTR, LPWSTR, DWORD, PDWORD, PDWORD, PDWORD, LPWSTR, DWORD);
1910     UINT GetWindowsDirectoryA(LPSTR, UINT);
1911     UINT GetWindowsDirectoryW(LPWSTR, UINT);
1912     DWORD GetWindowThreadProcessId(HWND, PDWORD);
1913     ATOM GlobalAddAtomA(LPCSTR);
1914     ATOM GlobalAddAtomW(LPCWSTR);
1915     ATOM GlobalDeleteAtom(ATOM);
1916     ATOM GlobalFindAtomA(LPCSTR);
1917     ATOM GlobalFindAtomW(LPCWSTR);
1918     UINT GlobalGetAtomNameA(ATOM, LPSTR, int);
1919     UINT GlobalGetAtomNameW(ATOM, LPWSTR, int);
1920 
1921     bool HasOverlappedIoCompleted(LPOVERLAPPED lpOverlapped) {
1922         return lpOverlapped.Internal != STATUS_PENDING;
1923     }
1924 
1925     BOOL InitAtomTable(DWORD);
1926     VOID InitializeCriticalSection(LPCRITICAL_SECTION) @trusted;
1927     /*  ??? The next two are allegedly obsolete and "supported only for
1928      *  backward compatibility with the 16-bit Windows API".  Yet the
1929      *  replacements IsBadReadPtr and IsBadWritePtr are apparently Win2000+
1930      *  only.  Where's the mistake?
1931      */
1932     BOOL IsBadHugeReadPtr(PCVOID, UINT_PTR);
1933     BOOL IsBadHugeWritePtr(PVOID, UINT_PTR);
1934     BOOL IsBadReadPtr(PCVOID, UINT_PTR);
1935     BOOL IsBadStringPtrA(LPCSTR, UINT_PTR);
1936     BOOL IsBadStringPtrW(LPCWSTR, UINT_PTR);
1937     BOOL IsBadWritePtr(PVOID, UINT_PTR);
1938     void LeaveCriticalSection(LPCRITICAL_SECTION);
1939     void LeaveCriticalSection(shared(CRITICAL_SECTION)*);
1940     HINSTANCE LoadLibraryA(LPCSTR);
1941     HINSTANCE LoadLibraryW(LPCWSTR);
1942     HINSTANCE LoadLibraryExA(LPCSTR, HANDLE, DWORD);
1943     HINSTANCE LoadLibraryExW(LPCWSTR, HANDLE, DWORD);
1944     DWORD LoadModule(LPCSTR, PVOID);
1945     HGLOBAL LoadResource(HINSTANCE, HRSRC);
1946     BOOL LocalFileTimeToFileTime(const(FILETIME)*, LPFILETIME);
1947     BOOL LockFile(HANDLE, DWORD, DWORD, DWORD, DWORD);
1948     PVOID LockResource(HGLOBAL);
1949 
1950     LPSTR lstrcatA(LPSTR, LPCSTR);
1951     LPWSTR lstrcatW(LPWSTR, LPCWSTR);
1952     int lstrcmpA(LPCSTR, LPCSTR);
1953     int lstrcmpiA(LPCSTR, LPCSTR);
1954     int lstrcmpiW(LPCWSTR, LPCWSTR);
1955     int lstrcmpW(LPCWSTR, LPCWSTR);
1956     LPSTR lstrcpyA(LPSTR, LPCSTR);
1957     LPSTR lstrcpynA(LPSTR, LPCSTR, int);
1958     LPWSTR lstrcpynW(LPWSTR, LPCWSTR, int);
1959     LPWSTR lstrcpyW(LPWSTR, LPCWSTR);
1960     int lstrlenA(LPCSTR);
1961     int lstrlenW(LPCWSTR);
1962 
1963     BOOL MoveFileA(LPCSTR, LPCSTR);
1964     BOOL MoveFileW(LPCWSTR, LPCWSTR);
1965     int MulDiv(int, int, int);
1966     HANDLE OpenEventA(DWORD, BOOL, LPCSTR);
1967     HANDLE OpenEventW(DWORD, BOOL, LPCWSTR);
1968     deprecated HFILE OpenFile(LPCSTR, LPOFSTRUCT, UINT);
1969     HANDLE OpenMutexA(DWORD, BOOL, LPCSTR);
1970     HANDLE OpenMutexW(DWORD, BOOL, LPCWSTR);
1971     HANDLE OpenProcess(DWORD, BOOL, DWORD);
1972     HANDLE OpenSemaphoreA(DWORD, BOOL, LPCSTR);
1973     HANDLE OpenSemaphoreW(DWORD, BOOL, LPCWSTR);
1974     void OutputDebugStringA(LPCSTR);
1975     void OutputDebugStringW(LPCWSTR);
1976     BOOL PeekNamedPipe(HANDLE, PVOID, DWORD, PDWORD, PDWORD, PDWORD);
1977     BOOL PulseEvent(HANDLE);
1978     BOOL PurgeComm(HANDLE, DWORD);
1979     BOOL QueryPerformanceCounter(PLARGE_INTEGER);
1980     BOOL QueryPerformanceFrequency(PLARGE_INTEGER);
1981     DWORD QueueUserAPC(PAPCFUNC, HANDLE, ULONG_PTR);
1982     void RaiseException(DWORD, DWORD, DWORD, const(ULONG_PTR)*);
1983     BOOL ReadFile(HANDLE, PVOID, DWORD, PDWORD, LPOVERLAPPED);
1984     BOOL ReadFileEx(HANDLE, PVOID, DWORD, LPOVERLAPPED, LPOVERLAPPED_COMPLETION_ROUTINE);
1985     BOOL ReadProcessMemory(HANDLE, PCVOID, PVOID, SIZE_T, SIZE_T*);
1986     BOOL ReleaseMutex(HANDLE);
1987     BOOL ReleaseSemaphore(HANDLE, LONG, LPLONG);
1988     BOOL RemoveDirectoryA(LPCSTR);
1989     BOOL RemoveDirectoryW(LPCWSTR);
1990 /* In MinGW:
1991 #ifdef _WIN32_WCE
1992 extern BOOL ResetEvent(HANDLE);
1993 #else
1994 WINBASEAPI BOOL WINAPI ResetEvent(HANDLE);
1995 #endif
1996 */
1997     BOOL ResetEvent(HANDLE);
1998     DWORD ResumeThread(HANDLE);
1999     DWORD SearchPathA(LPCSTR, LPCSTR, LPCSTR, DWORD, LPSTR, LPSTR*);
2000     DWORD SearchPathW(LPCWSTR, LPCWSTR, LPCWSTR, DWORD, LPWSTR, LPWSTR*);
2001     BOOL SetCommBreak(HANDLE);
2002     BOOL SetCommConfig(HANDLE, LPCOMMCONFIG, DWORD);
2003     BOOL SetCommMask(HANDLE, DWORD);
2004     BOOL SetCommState(HANDLE, LPDCB);
2005     BOOL SetCommTimeouts(HANDLE, LPCOMMTIMEOUTS);
2006     BOOL SetComputerNameA(LPCSTR);
2007     BOOL SetComputerNameW(LPCWSTR);
2008     BOOL SetCurrentDirectoryA(LPCSTR);
2009     BOOL SetCurrentDirectoryW(LPCWSTR);
2010     BOOL SetDefaultCommConfigA(LPCSTR, LPCOMMCONFIG, DWORD);
2011     BOOL SetDefaultCommConfigW(LPCWSTR, LPCOMMCONFIG, DWORD);
2012     BOOL SetEndOfFile(HANDLE);
2013     BOOL SetEnvironmentVariableA(LPCSTR, LPCSTR);
2014     BOOL SetEnvironmentVariableW(LPCWSTR, LPCWSTR);
2015     UINT SetErrorMode(UINT);
2016 /* In MinGW:
2017 #ifdef _WIN32_WCE
2018 extern BOOL SetEvent(HANDLE);
2019 #else
2020 WINBASEAPI BOOL WINAPI SetEvent(HANDLE);
2021 #endif
2022 */
2023     BOOL SetEvent(HANDLE);
2024     VOID SetFileApisToANSI();
2025     VOID SetFileApisToOEM();
2026     BOOL SetFileAttributesA(LPCSTR, DWORD);
2027     BOOL SetFileAttributesW(LPCWSTR, DWORD);
2028     DWORD SetFilePointer(HANDLE, LONG, PLONG, DWORD);
2029     BOOL SetFileTime(HANDLE, const(FILETIME)*, const(FILETIME)*, const(FILETIME)*);
2030     deprecated UINT SetHandleCount(UINT);
2031     void SetLastError(DWORD);
2032     void SetLastErrorEx(DWORD, DWORD);
2033     BOOL SetLocalTime(const(SYSTEMTIME)*);
2034     BOOL SetMailslotInfo(HANDLE, DWORD);
2035     BOOL SetNamedPipeHandleState(HANDLE, PDWORD, PDWORD, PDWORD);
2036     BOOL SetPriorityClass(HANDLE, DWORD);
2037     BOOL SetStdHandle(DWORD, HANDLE);
2038     BOOL SetSystemTime(const(SYSTEMTIME)*);
2039     DWORD_PTR SetThreadAffinityMask(HANDLE, DWORD_PTR);
2040     BOOL SetThreadContext(HANDLE, const(CONTEXT)*);
2041     BOOL SetThreadPriority(HANDLE, int);
2042     BOOL SetTimeZoneInformation(const(TIME_ZONE_INFORMATION)*);
2043     LPTOP_LEVEL_EXCEPTION_FILTER SetUnhandledExceptionFilter(LPTOP_LEVEL_EXCEPTION_FILTER);
2044     BOOL SetupComm(HANDLE, DWORD, DWORD);
2045     BOOL SetVolumeLabelA(LPCSTR, LPCSTR);
2046     BOOL SetVolumeLabelW(LPCWSTR, LPCWSTR);
2047 
2048     DWORD SizeofResource(HINSTANCE, HRSRC);
2049     void Sleep(DWORD);
2050     DWORD SleepEx(DWORD, BOOL);
2051     DWORD SuspendThread(HANDLE);
2052     BOOL SystemTimeToFileTime(const(SYSTEMTIME)*, LPFILETIME);
2053     BOOL TerminateProcess(HANDLE, UINT);
2054     BOOL TerminateThread(HANDLE, DWORD);
2055     DWORD TlsAlloc();
2056     BOOL TlsFree(DWORD);
2057     PVOID TlsGetValue(DWORD);
2058     BOOL TlsSetValue(DWORD, PVOID);
2059     BOOL TransactNamedPipe(HANDLE, PVOID, DWORD, PVOID, DWORD, PDWORD, LPOVERLAPPED);
2060     BOOL TransmitCommChar(HANDLE, char);
2061     LONG UnhandledExceptionFilter(LPEXCEPTION_POINTERS);
2062     BOOL UnlockFile(HANDLE, DWORD, DWORD, DWORD, DWORD);
2063     BOOL WaitCommEvent(HANDLE, PDWORD, LPOVERLAPPED);
2064     BOOL WaitForDebugEvent(LPDEBUG_EVENT, DWORD);
2065     DWORD WaitForMultipleObjects(DWORD, const(HANDLE)*, BOOL, DWORD);
2066     DWORD WaitForMultipleObjectsEx(DWORD, const(HANDLE)*, BOOL, DWORD, BOOL);
2067     DWORD WaitForSingleObject(HANDLE, DWORD);
2068     DWORD WaitForSingleObjectEx(HANDLE, DWORD, BOOL);
2069     BOOL WaitNamedPipeA(LPCSTR, DWORD);
2070     BOOL WaitNamedPipeW(LPCWSTR, DWORD);
2071     // undocumented on MSDN
2072     BOOL WinLoadTrustProvider(GUID*);
2073     BOOL WriteFile(HANDLE, PCVOID, DWORD, PDWORD, LPOVERLAPPED);
2074     BOOL WriteFileEx(HANDLE, PCVOID, DWORD, LPOVERLAPPED, LPOVERLAPPED_COMPLETION_ROUTINE);
2075     BOOL WritePrivateProfileSectionA(LPCSTR, LPCSTR, LPCSTR);
2076     BOOL WritePrivateProfileSectionW(LPCWSTR, LPCWSTR, LPCWSTR);
2077     BOOL WritePrivateProfileStringA(LPCSTR, LPCSTR, LPCSTR, LPCSTR);
2078     BOOL WritePrivateProfileStringW(LPCWSTR, LPCWSTR, LPCWSTR, LPCWSTR);
2079     BOOL WritePrivateProfileStructA(LPCSTR, LPCSTR, LPVOID, UINT, LPCSTR);
2080     BOOL WritePrivateProfileStructW(LPCWSTR, LPCWSTR, LPVOID, UINT, LPCWSTR);
2081     BOOL WriteProcessMemory(HANDLE, LPVOID, LPCVOID, SIZE_T, SIZE_T*);
2082     BOOL WriteProfileSectionA(LPCSTR, LPCSTR);
2083     BOOL WriteProfileSectionW(LPCWSTR, LPCWSTR);
2084     BOOL WriteProfileStringA(LPCSTR, LPCSTR, LPCSTR);
2085     BOOL WriteProfileStringW(LPCWSTR, LPCWSTR, LPCWSTR);
2086 
2087     /*  Memory allocation functions.
2088      *  MSDN documents these erroneously as Win2000+; thus it is uncertain what
2089      *  version compatibility they really have.
2090      */
2091     HGLOBAL GlobalAlloc(UINT, SIZE_T);
2092     HGLOBAL GlobalDiscard(HGLOBAL);
2093     HGLOBAL GlobalFree(HGLOBAL);
2094     HGLOBAL GlobalHandle(PCVOID);
2095     LPVOID GlobalLock(HGLOBAL);
2096     VOID GlobalMemoryStatus(LPMEMORYSTATUS);
2097     HGLOBAL GlobalReAlloc(HGLOBAL, SIZE_T, UINT);
2098     SIZE_T GlobalSize(HGLOBAL);
2099     BOOL GlobalUnlock(HGLOBAL);
2100     PVOID HeapAlloc(HANDLE, DWORD, SIZE_T);
2101     SIZE_T HeapCompact(HANDLE, DWORD);
2102     HANDLE HeapCreate(DWORD, SIZE_T, SIZE_T);
2103     BOOL HeapDestroy(HANDLE);
2104     BOOL HeapFree(HANDLE, DWORD, PVOID);
2105     BOOL HeapLock(HANDLE);
2106     PVOID HeapReAlloc(HANDLE, DWORD, PVOID, SIZE_T);
2107     SIZE_T HeapSize(HANDLE, DWORD, PCVOID);
2108     BOOL HeapUnlock(HANDLE);
2109     BOOL HeapValidate(HANDLE, DWORD, PCVOID);
2110     BOOL HeapWalk(HANDLE, LPPROCESS_HEAP_ENTRY);
2111     HLOCAL LocalAlloc(UINT, SIZE_T);
2112     HLOCAL LocalDiscard(HLOCAL);
2113     HLOCAL LocalFree(HLOCAL);
2114     HLOCAL LocalHandle(LPCVOID);
2115     PVOID LocalLock(HLOCAL);
2116     HLOCAL LocalReAlloc(HLOCAL, SIZE_T, UINT);
2117     SIZE_T LocalSize(HLOCAL);
2118     BOOL LocalUnlock(HLOCAL);
2119     PVOID VirtualAlloc(PVOID, SIZE_T, DWORD, DWORD);
2120     PVOID VirtualAllocEx(HANDLE, PVOID, SIZE_T, DWORD, DWORD);
2121     BOOL VirtualFree(PVOID, SIZE_T, DWORD);
2122     BOOL VirtualFreeEx(HANDLE, PVOID, SIZE_T, DWORD);
2123     BOOL VirtualLock(PVOID, SIZE_T);
2124     BOOL VirtualProtect(PVOID, SIZE_T, DWORD, PDWORD);
2125     BOOL VirtualProtectEx(HANDLE, PVOID, SIZE_T, DWORD, PDWORD);
2126     SIZE_T VirtualQuery(LPCVOID, PMEMORY_BASIC_INFORMATION, SIZE_T);
2127     SIZE_T VirtualQueryEx(HANDLE, LPCVOID, PMEMORY_BASIC_INFORMATION, SIZE_T);
2128     BOOL VirtualUnlock(PVOID, SIZE_T);
2129 // not in MinGW 4.0 - ???
2130     static if (_WIN32_WINNT >= 0x600) {
2131         BOOL CancelIoEx(HANDLE, LPOVERLAPPED);
2132     }
2133 
2134     BOOL CancelIo(HANDLE);
2135     BOOL CancelWaitableTimer(HANDLE);
2136     PVOID ConvertThreadToFiber(PVOID);
2137     LPVOID CreateFiber(SIZE_T, LPFIBER_START_ROUTINE, LPVOID);
2138     HANDLE CreateWaitableTimerA(LPSECURITY_ATTRIBUTES, BOOL, LPCSTR);
2139     HANDLE CreateWaitableTimerW(LPSECURITY_ATTRIBUTES, BOOL, LPCWSTR);
2140     void DeleteFiber(PVOID);
2141     BOOL GetFileAttributesExA(LPCSTR, GET_FILEEX_INFO_LEVELS, PVOID);
2142     BOOL GetFileAttributesExW(LPCWSTR, GET_FILEEX_INFO_LEVELS, PVOID);
2143     DWORD GetLongPathNameA(LPCSTR, LPSTR, DWORD);
2144     DWORD GetLongPathNameW(LPCWSTR, LPWSTR, DWORD);
2145     BOOL InitializeCriticalSectionAndSpinCount(LPCRITICAL_SECTION, DWORD);
2146     BOOL IsDebuggerPresent();
2147     HANDLE OpenWaitableTimerA(DWORD, BOOL, LPCSTR);
2148     HANDLE OpenWaitableTimerW(DWORD, BOOL, LPCWSTR);
2149     DWORD QueryDosDeviceA(LPCSTR, LPSTR, DWORD);
2150     DWORD QueryDosDeviceW(LPCWSTR, LPWSTR, DWORD);
2151     BOOL SetWaitableTimer(HANDLE, const(LARGE_INTEGER)*, LONG, PTIMERAPCROUTINE, PVOID, BOOL);
2152     void SwitchToFiber(PVOID);
2153 
2154     static if (_WIN32_WINNT >= 0x500) {
2155         HANDLE OpenThread(DWORD, BOOL, DWORD);
2156     }
2157 
2158     BOOL AccessCheck(PSECURITY_DESCRIPTOR, HANDLE, DWORD, PGENERIC_MAPPING, PPRIVILEGE_SET, PDWORD, PDWORD, PBOOL);
2159     BOOL AccessCheckAndAuditAlarmA(LPCSTR, LPVOID, LPSTR, LPSTR, PSECURITY_DESCRIPTOR, DWORD, PGENERIC_MAPPING, BOOL, PDWORD, PBOOL, PBOOL);
2160     BOOL AccessCheckAndAuditAlarmW(LPCWSTR, LPVOID, LPWSTR, LPWSTR, PSECURITY_DESCRIPTOR, DWORD, PGENERIC_MAPPING, BOOL, PDWORD, PBOOL, PBOOL);
2161     BOOL AddAccessAllowedAce(PACL, DWORD, DWORD, PSID);
2162     BOOL AddAccessDeniedAce(PACL, DWORD, DWORD, PSID);
2163     BOOL AddAce(PACL, DWORD, DWORD, PVOID, DWORD);
2164     BOOL AddAuditAccessAce(PACL, DWORD, DWORD, PSID, BOOL, BOOL);
2165     BOOL AdjustTokenGroups(HANDLE, BOOL, PTOKEN_GROUPS, DWORD, PTOKEN_GROUPS, PDWORD);
2166     BOOL AdjustTokenPrivileges(HANDLE, BOOL, PTOKEN_PRIVILEGES, DWORD, PTOKEN_PRIVILEGES, PDWORD);
2167     BOOL AllocateAndInitializeSid(PSID_IDENTIFIER_AUTHORITY, BYTE, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, PSID*);
2168     BOOL AllocateLocallyUniqueId(PLUID);
2169     BOOL AreAllAccessesGranted(DWORD, DWORD);
2170     BOOL AreAnyAccessesGranted(DWORD, DWORD);
2171     BOOL BackupEventLogA(HANDLE, LPCSTR);
2172     BOOL BackupEventLogW(HANDLE, LPCWSTR);
2173     BOOL BackupRead(HANDLE, LPBYTE, DWORD, LPDWORD, BOOL, BOOL, LPVOID*);
2174     BOOL BackupSeek(HANDLE, DWORD, DWORD, LPDWORD, LPDWORD, LPVOID*);
2175     BOOL BackupWrite(HANDLE, LPBYTE, DWORD, LPDWORD, BOOL, BOOL, LPVOID*);
2176     BOOL ClearEventLogA(HANDLE, LPCSTR);
2177     BOOL ClearEventLogW(HANDLE, LPCWSTR);
2178     BOOL CloseEventLog(HANDLE);
2179     BOOL ConnectNamedPipe(HANDLE, LPOVERLAPPED);
2180     BOOL CopySid(DWORD, PSID, PSID);
2181     HANDLE CreateNamedPipeA(LPCSTR, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, LPSECURITY_ATTRIBUTES);
2182     HANDLE CreateNamedPipeW(LPCWSTR, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, LPSECURITY_ATTRIBUTES);
2183     BOOL CreatePrivateObjectSecurity(PSECURITY_DESCRIPTOR, PSECURITY_DESCRIPTOR, PSECURITY_DESCRIPTOR*, BOOL, HANDLE, PGENERIC_MAPPING);
2184     BOOL CreateProcessAsUserA(HANDLE, LPCSTR, LPSTR, LPSECURITY_ATTRIBUTES, LPSECURITY_ATTRIBUTES, BOOL, DWORD, PVOID, LPCSTR, LPSTARTUPINFOA, LPPROCESS_INFORMATION);
2185     BOOL CreateProcessAsUserW(HANDLE, LPCWSTR, LPWSTR, LPSECURITY_ATTRIBUTES, LPSECURITY_ATTRIBUTES, BOOL, DWORD, PVOID, LPCWSTR, LPSTARTUPINFOW, LPPROCESS_INFORMATION);
2186     HANDLE CreateRemoteThread(HANDLE, LPSECURITY_ATTRIBUTES, SIZE_T, LPTHREAD_START_ROUTINE, LPVOID, DWORD, LPDWORD);
2187     DWORD CreateTapePartition(HANDLE, DWORD, DWORD, DWORD);
2188     BOOL DefineDosDeviceA(DWORD, LPCSTR, LPCSTR);
2189     BOOL DefineDosDeviceW(DWORD, LPCWSTR, LPCWSTR);
2190     BOOL DeleteAce(PACL, DWORD);
2191     BOOL DeregisterEventSource(HANDLE);
2192     BOOL DestroyPrivateObjectSecurity(PSECURITY_DESCRIPTOR*);
2193     BOOL DeviceIoControl(HANDLE, DWORD, PVOID, DWORD, PVOID, DWORD, PDWORD, POVERLAPPED);
2194     BOOL DisconnectNamedPipe(HANDLE);
2195     BOOL DuplicateToken(HANDLE, SECURITY_IMPERSONATION_LEVEL, PHANDLE);
2196     BOOL DuplicateTokenEx(HANDLE, DWORD, LPSECURITY_ATTRIBUTES, SECURITY_IMPERSONATION_LEVEL, TOKEN_TYPE, PHANDLE);
2197     BOOL EqualPrefixSid(PSID, PSID);
2198     BOOL EqualSid(PSID, PSID);
2199     DWORD EraseTape(HANDLE, DWORD, BOOL);
2200     HANDLE FindFirstFileExA(LPCSTR, FINDEX_INFO_LEVELS, PVOID, FINDEX_SEARCH_OPS, PVOID, DWORD);
2201     HANDLE FindFirstFileExW(LPCWSTR, FINDEX_INFO_LEVELS, PVOID, FINDEX_SEARCH_OPS, PVOID, DWORD);
2202     BOOL FindFirstFreeAce(PACL, PVOID*);
2203     PVOID FreeSid(PSID);
2204     BOOL GetAce(PACL, DWORD, LPVOID*);
2205     BOOL GetAclInformation(PACL, PVOID, DWORD, ACL_INFORMATION_CLASS);
2206     BOOL GetBinaryTypeA(LPCSTR, PDWORD);
2207     BOOL GetBinaryTypeW(LPCWSTR, PDWORD);
2208     DWORD GetCompressedFileSizeA(LPCSTR, PDWORD);
2209     DWORD GetCompressedFileSizeW(LPCWSTR, PDWORD);
2210     BOOL GetCurrentHwProfileA(LPHW_PROFILE_INFOA);
2211     BOOL GetCurrentHwProfileW(LPHW_PROFILE_INFOW);
2212     BOOL GetFileSecurityA(LPCSTR, SECURITY_INFORMATION, PSECURITY_DESCRIPTOR, DWORD, PDWORD);
2213     BOOL GetFileSecurityW(LPCWSTR, SECURITY_INFORMATION, PSECURITY_DESCRIPTOR, DWORD, PDWORD);
2214     BOOL GetHandleInformation(HANDLE, PDWORD);
2215     BOOL GetKernelObjectSecurity(HANDLE, SECURITY_INFORMATION, PSECURITY_DESCRIPTOR, DWORD, PDWORD);
2216     DWORD GetLengthSid(PSID);
2217     BOOL GetNumberOfEventLogRecords(HANDLE, PDWORD);
2218     BOOL GetOldestEventLogRecord(HANDLE, PDWORD);
2219     BOOL GetPrivateObjectSecurity(PSECURITY_DESCRIPTOR, SECURITY_INFORMATION, PSECURITY_DESCRIPTOR, DWORD, PDWORD);
2220     BOOL GetProcessPriorityBoost(HANDLE, PBOOL);
2221     BOOL GetProcessShutdownParameters(PDWORD, PDWORD);
2222     BOOL GetProcessTimes(HANDLE, LPFILETIME, LPFILETIME, LPFILETIME, LPFILETIME);
2223     HWINSTA GetProcessWindowStation();
2224     BOOL GetProcessWorkingSetSize(HANDLE, PSIZE_T, PSIZE_T);
2225     BOOL GetQueuedCompletionStatus(HANDLE, PDWORD, PULONG_PTR, LPOVERLAPPED*, DWORD);
2226     BOOL GetSecurityDescriptorControl(PSECURITY_DESCRIPTOR, PSECURITY_DESCRIPTOR_CONTROL, PDWORD);
2227     BOOL GetSecurityDescriptorDacl(PSECURITY_DESCRIPTOR, LPBOOL, PACL*, LPBOOL);
2228     BOOL GetSecurityDescriptorGroup(PSECURITY_DESCRIPTOR, PSID*, LPBOOL);
2229     DWORD GetSecurityDescriptorLength(PSECURITY_DESCRIPTOR);
2230     BOOL GetSecurityDescriptorOwner(PSECURITY_DESCRIPTOR, PSID*, LPBOOL);
2231     BOOL GetSecurityDescriptorSacl(PSECURITY_DESCRIPTOR, LPBOOL, PACL*, LPBOOL);
2232     PSID_IDENTIFIER_AUTHORITY GetSidIdentifierAuthority(PSID);
2233     DWORD GetSidLengthRequired(UCHAR);
2234     PDWORD GetSidSubAuthority(PSID, DWORD);
2235     PUCHAR GetSidSubAuthorityCount(PSID);
2236     DWORD GetTapeParameters(HANDLE, DWORD, PDWORD, PVOID);
2237     DWORD GetTapePosition(HANDLE, DWORD, PDWORD, PDWORD, PDWORD);
2238     DWORD GetTapeStatus(HANDLE);
2239     BOOL GetThreadPriorityBoost(HANDLE, PBOOL);
2240     BOOL GetThreadTimes(HANDLE, LPFILETIME, LPFILETIME, LPFILETIME, LPFILETIME);
2241     BOOL GetTokenInformation(HANDLE, TOKEN_INFORMATION_CLASS, PVOID, DWORD, PDWORD);
2242     BOOL ImpersonateLoggedOnUser(HANDLE);
2243     BOOL ImpersonateNamedPipeClient(HANDLE);
2244     BOOL ImpersonateSelf(SECURITY_IMPERSONATION_LEVEL);
2245     BOOL InitializeAcl(PACL, DWORD, DWORD);
2246     DWORD SetCriticalSectionSpinCount(LPCRITICAL_SECTION, DWORD);
2247     BOOL InitializeSecurityDescriptor(PSECURITY_DESCRIPTOR, DWORD);
2248     BOOL InitializeSid(PSID, PSID_IDENTIFIER_AUTHORITY, BYTE);
2249     BOOL IsProcessorFeaturePresent(DWORD);
2250     BOOL IsTextUnicode(PCVOID, int, LPINT);
2251     BOOL IsValidAcl(PACL);
2252     BOOL IsValidSecurityDescriptor(PSECURITY_DESCRIPTOR);
2253     BOOL IsValidSid(PSID);
2254     BOOL CreateWellKnownSid(WELL_KNOWN_SID_TYPE, PSID, PSID, PDWORD);
2255     BOOL LockFileEx(HANDLE, DWORD, DWORD, DWORD, DWORD, LPOVERLAPPED);
2256     BOOL LogonUserA(LPSTR, LPSTR, LPSTR, DWORD, DWORD, PHANDLE);
2257     BOOL LogonUserW(LPWSTR, LPWSTR, LPWSTR, DWORD, DWORD, PHANDLE);
2258     BOOL LookupAccountNameA(LPCSTR, LPCSTR, PSID, PDWORD, LPSTR, PDWORD, PSID_NAME_USE);
2259     BOOL LookupAccountNameW(LPCWSTR, LPCWSTR, PSID, PDWORD, LPWSTR, PDWORD, PSID_NAME_USE);
2260     BOOL LookupAccountSidA(LPCSTR, PSID, LPSTR, PDWORD, LPSTR, PDWORD, PSID_NAME_USE);
2261     BOOL LookupAccountSidW(LPCWSTR, PSID, LPWSTR, PDWORD, LPWSTR, PDWORD, PSID_NAME_USE);
2262     BOOL LookupPrivilegeDisplayNameA(LPCSTR, LPCSTR, LPSTR, PDWORD, PDWORD);
2263     BOOL LookupPrivilegeDisplayNameW(LPCWSTR, LPCWSTR, LPWSTR, PDWORD, PDWORD);
2264     BOOL LookupPrivilegeNameA(LPCSTR, PLUID, LPSTR, PDWORD);
2265     BOOL LookupPrivilegeNameW(LPCWSTR, PLUID, LPWSTR, PDWORD);
2266     BOOL LookupPrivilegeValueA(LPCSTR, LPCSTR, PLUID);
2267     BOOL LookupPrivilegeValueW(LPCWSTR, LPCWSTR, PLUID);
2268     BOOL MakeAbsoluteSD(PSECURITY_DESCRIPTOR, PSECURITY_DESCRIPTOR, PDWORD, PACL, PDWORD, PACL, PDWORD, PSID, PDWORD, PSID, PDWORD);
2269     BOOL MakeSelfRelativeSD(PSECURITY_DESCRIPTOR, PSECURITY_DESCRIPTOR, PDWORD);
2270     VOID MapGenericMask(PDWORD, PGENERIC_MAPPING);
2271     BOOL MoveFileExA(LPCSTR, LPCSTR, DWORD);
2272     BOOL MoveFileExW(LPCWSTR, LPCWSTR, DWORD);
2273     BOOL NotifyChangeEventLog(HANDLE, HANDLE);
2274     BOOL ObjectCloseAuditAlarmA(LPCSTR, PVOID, BOOL);
2275     BOOL ObjectCloseAuditAlarmW(LPCWSTR, PVOID, BOOL);
2276     BOOL ObjectDeleteAuditAlarmA(LPCSTR, PVOID, BOOL);
2277     BOOL ObjectDeleteAuditAlarmW(LPCWSTR, PVOID, BOOL);
2278     BOOL ObjectOpenAuditAlarmA(LPCSTR, PVOID, LPSTR, LPSTR, PSECURITY_DESCRIPTOR, HANDLE, DWORD, DWORD, PPRIVILEGE_SET, BOOL, BOOL, PBOOL);
2279     BOOL ObjectOpenAuditAlarmW(LPCWSTR, PVOID, LPWSTR, LPWSTR, PSECURITY_DESCRIPTOR, HANDLE, DWORD, DWORD, PPRIVILEGE_SET, BOOL, BOOL, PBOOL);
2280     BOOL ObjectPrivilegeAuditAlarmA(LPCSTR, PVOID, HANDLE, DWORD, PPRIVILEGE_SET, BOOL);
2281     BOOL ObjectPrivilegeAuditAlarmW(LPCWSTR, PVOID, HANDLE, DWORD, PPRIVILEGE_SET, BOOL);
2282     HANDLE OpenBackupEventLogA(LPCSTR, LPCSTR);
2283     HANDLE OpenBackupEventLogW(LPCWSTR, LPCWSTR);
2284     HANDLE OpenEventLogA(LPCSTR, LPCSTR);
2285     HANDLE OpenEventLogW(LPCWSTR, LPCWSTR);
2286     BOOL OpenProcessToken(HANDLE, DWORD, PHANDLE);
2287     BOOL OpenThreadToken(HANDLE, DWORD, BOOL, PHANDLE);
2288     BOOL PostQueuedCompletionStatus(HANDLE, DWORD, ULONG_PTR, LPOVERLAPPED);
2289     DWORD PrepareTape(HANDLE, DWORD, BOOL);
2290     BOOL PrivilegeCheck(HANDLE, PPRIVILEGE_SET, PBOOL);
2291     BOOL PrivilegedServiceAuditAlarmA(LPCSTR, LPCSTR, HANDLE, PPRIVILEGE_SET, BOOL);
2292     BOOL PrivilegedServiceAuditAlarmW(LPCWSTR, LPCWSTR, HANDLE, PPRIVILEGE_SET, BOOL);
2293     BOOL ReadDirectoryChangesW(HANDLE, PVOID, DWORD, BOOL, DWORD, PDWORD, LPOVERLAPPED, LPOVERLAPPED_COMPLETION_ROUTINE);
2294     BOOL ReadEventLogA(HANDLE, DWORD, DWORD, PVOID, DWORD, DWORD*, DWORD*);
2295     BOOL ReadEventLogW(HANDLE, DWORD, DWORD, PVOID, DWORD, DWORD*, DWORD*);
2296     BOOL ReadFileScatter(HANDLE, FILE_SEGMENT_ELEMENT*, DWORD, LPDWORD, LPOVERLAPPED);
2297     HANDLE RegisterEventSourceA (LPCSTR, LPCSTR);
2298     HANDLE RegisterEventSourceW(LPCWSTR, LPCWSTR);
2299     BOOL ReportEventA(HANDLE, WORD, WORD, DWORD, PSID, WORD, DWORD, LPCSTR*, PVOID);
2300     BOOL ReportEventW(HANDLE, WORD, WORD, DWORD, PSID, WORD, DWORD, LPCWSTR*, PVOID);
2301     BOOL RevertToSelf();
2302     BOOL SetAclInformation(PACL, PVOID, DWORD, ACL_INFORMATION_CLASS);
2303     BOOL SetFileSecurityA(LPCSTR, SECURITY_INFORMATION, PSECURITY_DESCRIPTOR);
2304     BOOL SetFileSecurityW(LPCWSTR, SECURITY_INFORMATION, PSECURITY_DESCRIPTOR);
2305     BOOL SetHandleInformation(HANDLE, DWORD, DWORD);
2306     BOOL SetKernelObjectSecurity(HANDLE, SECURITY_INFORMATION, PSECURITY_DESCRIPTOR);
2307     BOOL SetPrivateObjectSecurity(SECURITY_INFORMATION, PSECURITY_DESCRIPTOR, PSECURITY_DESCRIPTOR*, PGENERIC_MAPPING, HANDLE);
2308     BOOL SetProcessAffinityMask(HANDLE, DWORD_PTR);
2309     BOOL SetProcessPriorityBoost(HANDLE, BOOL);
2310     BOOL SetProcessShutdownParameters(DWORD, DWORD);
2311     BOOL SetProcessWorkingSetSize(HANDLE, SIZE_T, SIZE_T);
2312     BOOL SetSecurityDescriptorDacl(PSECURITY_DESCRIPTOR, BOOL, PACL, BOOL);
2313     BOOL SetSecurityDescriptorGroup(PSECURITY_DESCRIPTOR, PSID, BOOL);
2314     BOOL SetSecurityDescriptorOwner(PSECURITY_DESCRIPTOR, PSID, BOOL);
2315     BOOL SetSecurityDescriptorSacl(PSECURITY_DESCRIPTOR, BOOL, PACL, BOOL);
2316     BOOL SetSystemTimeAdjustment(DWORD, BOOL);
2317     DWORD SetTapeParameters(HANDLE, DWORD, PVOID);
2318     DWORD SetTapePosition(HANDLE, DWORD, DWORD, DWORD, DWORD, BOOL);
2319     BOOL SetThreadPriorityBoost(HANDLE, BOOL);
2320     BOOL SetThreadToken(PHANDLE, HANDLE);
2321     BOOL SetTokenInformation(HANDLE, TOKEN_INFORMATION_CLASS, PVOID, DWORD);
2322     DWORD SignalObjectAndWait(HANDLE, HANDLE, DWORD, BOOL);
2323     BOOL SwitchToThread();
2324     BOOL SystemTimeToTzSpecificLocalTime(LPTIME_ZONE_INFORMATION, LPSYSTEMTIME, LPSYSTEMTIME);
2325     BOOL TzSpecificLocalTimeToSystemTime(LPTIME_ZONE_INFORMATION, LPSYSTEMTIME, LPSYSTEMTIME);
2326     BOOL TryEnterCriticalSection(LPCRITICAL_SECTION);
2327     BOOL TryEnterCriticalSection(shared(CRITICAL_SECTION)*);
2328     BOOL UnlockFileEx(HANDLE, DWORD, DWORD, DWORD, LPOVERLAPPED);
2329     BOOL UpdateResourceA(HANDLE, LPCSTR, LPCSTR, WORD, PVOID, DWORD);
2330     BOOL UpdateResourceW(HANDLE, LPCWSTR, LPCWSTR, WORD, PVOID, DWORD);
2331     BOOL WriteFileGather(HANDLE, FILE_SEGMENT_ELEMENT*, DWORD, LPDWORD, LPOVERLAPPED);
2332     DWORD WriteTapemark(HANDLE, DWORD, DWORD, BOOL);
2333 
2334     static if (_WIN32_WINNT >= 0x500) {
2335         BOOL AddAccessAllowedAceEx(PACL, DWORD, DWORD, DWORD, PSID);
2336         BOOL AddAccessDeniedAceEx(PACL, DWORD, DWORD, DWORD, PSID);
2337         PVOID AddVectoredExceptionHandler(ULONG, PVECTORED_EXCEPTION_HANDLER);
2338         BOOL AllocateUserPhysicalPages(HANDLE, PULONG_PTR, PULONG_PTR);
2339         BOOL AssignProcessToJobObject(HANDLE, HANDLE);
2340         BOOL ChangeTimerQueueTimer(HANDLE,HANDLE,ULONG,ULONG);
2341         LPVOID CreateFiberEx(SIZE_T, SIZE_T, DWORD, LPFIBER_START_ROUTINE, LPVOID);
2342         HANDLE CreateFileMappingA(HANDLE, LPSECURITY_ATTRIBUTES, DWORD, DWORD, DWORD, LPCSTR);
2343         HANDLE CreateFileMappingW(HANDLE, LPSECURITY_ATTRIBUTES, DWORD, DWORD, DWORD, LPCWSTR);
2344         BOOL CreateHardLinkA(LPCSTR, LPCSTR, LPSECURITY_ATTRIBUTES);
2345         BOOL CreateHardLinkW(LPCWSTR, LPCWSTR, LPSECURITY_ATTRIBUTES);
2346         HANDLE CreateJobObjectA(LPSECURITY_ATTRIBUTES, LPCSTR);
2347         HANDLE CreateJobObjectW(LPSECURITY_ATTRIBUTES, LPCWSTR);
2348         BOOL CreateProcessWithLogonW(LPCWSTR, LPCWSTR, LPCWSTR, DWORD, LPCWSTR, LPWSTR, DWORD, LPVOID, LPCWSTR, LPSTARTUPINFOW, LPPROCESS_INFORMATION);
2349         HANDLE CreateTimerQueue();
2350         BOOL CreateTimerQueueTimer(PHANDLE, HANDLE, WAITORTIMERCALLBACK, PVOID, DWORD, DWORD, ULONG);
2351         BOOL DeleteTimerQueue(HANDLE);
2352         BOOL DeleteTimerQueueEx(HANDLE, HANDLE);
2353         BOOL DeleteTimerQueueTimer(HANDLE, HANDLE, HANDLE);
2354         BOOL DeleteVolumeMountPointA(LPCSTR);
2355         BOOL DeleteVolumeMountPointW(LPCWSTR);
2356         BOOL DnsHostnameToComputerNameA(LPCSTR, LPSTR, LPDWORD);
2357         BOOL DnsHostnameToComputerNameW(LPCWSTR, LPWSTR, LPDWORD);
2358         BOOL EncryptFileA(LPCSTR);
2359         BOOL EncryptFileW(LPCWSTR);
2360         BOOL FileEncryptionStatusA(LPCSTR, LPDWORD);
2361         BOOL FileEncryptionStatusW(LPCWSTR, LPDWORD);
2362         HANDLE FindFirstVolumeA(LPCSTR, DWORD);
2363         HANDLE FindFirstVolumeMountPointA(LPSTR, LPSTR, DWORD);
2364         HANDLE FindFirstVolumeMountPointW(LPWSTR, LPWSTR, DWORD);
2365         HANDLE FindFirstVolumeW(LPCWSTR, DWORD);
2366         BOOL FindNextVolumeA(HANDLE, LPCSTR, DWORD);
2367         BOOL FindNextVolumeW(HANDLE, LPWSTR, DWORD);
2368         BOOL FindNextVolumeMountPointA(HANDLE, LPSTR, DWORD);
2369         BOOL FindNextVolumeMountPointW(HANDLE, LPWSTR, DWORD);
2370         BOOL FindVolumeClose(HANDLE);
2371         BOOL FindVolumeMountPointClose(HANDLE);
2372         BOOL FlushViewOfFile(PCVOID, SIZE_T);
2373         BOOL FreeUserPhysicalPages(HANDLE, PULONG_PTR, PULONG_PTR);
2374         BOOL GetComputerNameExA(COMPUTER_NAME_FORMAT, LPSTR, LPDWORD);
2375         BOOL GetComputerNameExW(COMPUTER_NAME_FORMAT, LPWSTR, LPDWORD);
2376         BOOL GetFileSizeEx(HANDLE, PLARGE_INTEGER);
2377         BOOL GetModuleHandleExA(DWORD, LPCSTR, HMODULE*);
2378         BOOL GetModuleHandleExW(DWORD, LPCWSTR, HMODULE*);
2379         HANDLE GetProcessHeap();
2380         DWORD GetProcessHeaps(DWORD, PHANDLE);
2381         BOOL GetProcessIoCounters(HANDLE, PIO_COUNTERS);
2382         BOOL GetSystemPowerStatus(LPSYSTEM_POWER_STATUS);
2383         UINT GetSystemWindowsDirectoryA(LPSTR, UINT);
2384         UINT GetSystemWindowsDirectoryW(LPWSTR, UINT);
2385         BOOL GetVolumeNameForVolumeMountPointA(LPCSTR, LPSTR, DWORD);
2386         BOOL GetVolumeNameForVolumeMountPointW(LPCWSTR, LPWSTR, DWORD);
2387         BOOL GetVolumePathNameA(LPCSTR, LPSTR, DWORD);
2388         BOOL GetVolumePathNameW(LPCWSTR, LPWSTR, DWORD);
2389         BOOL GlobalMemoryStatusEx(LPMEMORYSTATUSEX);
2390         BOOL IsBadCodePtr(FARPROC);
2391         BOOL IsSystemResumeAutomatic();
2392         BOOL MapUserPhysicalPages(PVOID, ULONG_PTR, PULONG_PTR);
2393         BOOL MapUserPhysicalPagesScatter(PVOID*, ULONG_PTR, PULONG_PTR);
2394         PVOID MapViewOfFile(HANDLE, DWORD, DWORD, DWORD, SIZE_T);
2395         PVOID MapViewOfFileEx(HANDLE, DWORD, DWORD, DWORD, SIZE_T, PVOID);
2396         HANDLE OpenFileMappingA(DWORD, BOOL, LPCSTR);
2397         HANDLE OpenFileMappingW(DWORD, BOOL, LPCWSTR);
2398         BOOL ProcessIdToSessionId(DWORD, DWORD*);
2399         BOOL QueryInformationJobObject(HANDLE, JOBOBJECTINFOCLASS, LPVOID, DWORD, LPDWORD);
2400         ULONG RemoveVectoredExceptionHandler(PVOID);
2401         BOOL ReplaceFileA(LPCSTR, LPCSTR, LPCSTR, DWORD, LPVOID, LPVOID);
2402         BOOL ReplaceFileW(LPCWSTR, LPCWSTR, LPCWSTR, DWORD, LPVOID, LPVOID);
2403         BOOL SetComputerNameExA(COMPUTER_NAME_FORMAT, LPCSTR);
2404         BOOL SetComputerNameExW(COMPUTER_NAME_FORMAT, LPCWSTR);
2405         BOOL SetFilePointerEx(HANDLE, LARGE_INTEGER, PLARGE_INTEGER, DWORD);
2406         BOOL SetInformationJobObject(HANDLE, JOBOBJECTINFOCLASS, LPVOID, DWORD);
2407         BOOL SetSecurityDescriptorControl(PSECURITY_DESCRIPTOR, SECURITY_DESCRIPTOR_CONTROL, SECURITY_DESCRIPTOR_CONTROL);
2408         BOOL SetSystemPowerState(BOOL, BOOL);
2409         EXECUTION_STATE SetThreadExecutionState(EXECUTION_STATE);
2410         DWORD SetThreadIdealProcessor(HANDLE, DWORD);
2411         BOOL SetVolumeMountPointA(LPCSTR, LPCSTR);
2412         BOOL SetVolumeMountPointW(LPCWSTR, LPCWSTR);
2413         BOOL TerminateJobObject(HANDLE, UINT);
2414         BOOL UnmapViewOfFile(PCVOID);
2415         BOOL UnregisterWait(HANDLE);
2416         BOOL UnregisterWaitEx(HANDLE, HANDLE);
2417         BOOL VerifyVersionInfoA(LPOSVERSIONINFOEXA, DWORD, DWORDLONG);
2418         BOOL VerifyVersionInfoW(LPOSVERSIONINFOEXW, DWORD, DWORDLONG);
2419     }
2420 
2421     static if (_WIN32_WINNT >= 0x501) {
2422         BOOL ActivateActCtx(HANDLE, ULONG_PTR*);
2423         void AddRefActCtx(HANDLE);
2424         BOOL CheckNameLegalDOS8Dot3A(LPCSTR, LPSTR, DWORD, PBOOL, PBOOL);
2425         BOOL CheckNameLegalDOS8Dot3W(LPCWSTR, LPSTR, DWORD, PBOOL, PBOOL);
2426         BOOL CheckRemoteDebuggerPresent(HANDLE, PBOOL);
2427         BOOL ConvertFiberToThread();
2428         HANDLE CreateActCtxA(PCACTCTXA);
2429         HANDLE CreateActCtxW(PCACTCTXW);
2430         HANDLE CreateMemoryResourceNotification(MEMORY_RESOURCE_NOTIFICATION_TYPE);
2431         BOOL DeactivateActCtx(DWORD, ULONG_PTR);
2432         BOOL DebugActiveProcessStop(DWORD);
2433         BOOL DebugBreakProcess(HANDLE);
2434         BOOL DebugSetProcessKillOnExit(BOOL);
2435         BOOL FindActCtxSectionGuid(DWORD, const(GUID)*, ULONG, const(GUID)*,
2436           PACTCTX_SECTION_KEYED_DATA);
2437         BOOL FindActCtxSectionStringA(DWORD, const(GUID)*, ULONG, LPCSTR,
2438           PACTCTX_SECTION_KEYED_DATA);
2439         BOOL FindActCtxSectionStringW(DWORD, const(GUID)*, ULONG, LPCWSTR,
2440           PACTCTX_SECTION_KEYED_DATA);
2441         BOOL GetCurrentActCtx(HANDLE*);
2442         VOID GetNativeSystemInfo(LPSYSTEM_INFO);
2443         BOOL GetProcessHandleCount(HANDLE, PDWORD);
2444         BOOL GetSystemRegistryQuota(PDWORD, PDWORD);
2445         BOOL GetSystemTimes(LPFILETIME, LPFILETIME, LPFILETIME);
2446         UINT GetSystemWow64DirectoryA(LPSTR, UINT);
2447         UINT GetSystemWow64DirectoryW(LPWSTR, UINT);
2448         BOOL GetThreadIOPendingFlag(HANDLE, PBOOL);
2449         BOOL GetVolumePathNamesForVolumeNameA(LPCSTR, LPSTR, DWORD, PDWORD);
2450         BOOL GetVolumePathNamesForVolumeNameW(LPCWSTR, LPWSTR, DWORD, PDWORD);
2451         UINT GetWriteWatch(DWORD, PVOID, SIZE_T, PVOID*, PULONG_PTR, PULONG);
2452         BOOL HeapQueryInformation(HANDLE, HEAP_INFORMATION_CLASS, PVOID, SIZE_T, PSIZE_T);
2453         BOOL HeapSetInformation(HANDLE, HEAP_INFORMATION_CLASS, PVOID, SIZE_T);
2454         BOOL IsProcessInJob(HANDLE, HANDLE, PBOOL);
2455         BOOL IsWow64Process(HANDLE, PBOOL);
2456         BOOL QueryActCtxW(DWORD, HANDLE, PVOID, ULONG, PVOID, SIZE_T, SIZE_T*);
2457         BOOL QueryMemoryResourceNotification(HANDLE, PBOOL);
2458         void ReleaseActCtx(HANDLE);
2459         UINT ResetWriteWatch(LPVOID, SIZE_T);
2460         BOOL SetFileShortNameA(HANDLE, LPCSTR);
2461         BOOL SetFileShortNameW(HANDLE, LPCWSTR);
2462         BOOL SetFileValidData(HANDLE, LONGLONG);
2463         BOOL ZombifyActCtx(HANDLE);
2464     }
2465 
2466     static if (_WIN32_WINNT >= 0x502) {
2467         DWORD GetFirmwareEnvironmentVariableA(LPCSTR, LPCSTR, PVOID, DWORD);
2468         DWORD GetFirmwareEnvironmentVariableW(LPCWSTR, LPCWSTR, PVOID, DWORD);
2469         DWORD GetDllDirectoryA(DWORD, LPSTR);
2470         DWORD GetDllDirectoryW(DWORD, LPWSTR);
2471         DWORD GetThreadId(HANDLE);
2472         DWORD GetProcessId(HANDLE);
2473         HANDLE ReOpenFile(HANDLE, DWORD, DWORD, DWORD);
2474         BOOL SetDllDirectoryA(LPCSTR);
2475         BOOL SetDllDirectoryW(LPCWSTR);
2476         BOOL SetFirmwareEnvironmentVariableA(LPCSTR, LPCSTR, PVOID, DWORD);
2477         BOOL SetFirmwareEnvironmentVariableW(LPCWSTR, LPCWSTR, PVOID, DWORD);
2478     }
2479 
2480     // ???
2481     static if (_WIN32_WINNT >= 0x510) {
2482         VOID RestoreLastError(DWORD);
2483     }
2484 
2485     static if (_WIN32_WINNT >= 0x600) {
2486         BOOL CreateSymbolicLinkA(LPCSTR, LPCSTR, DWORD);
2487         BOOL CreateSymbolicLinkW(LPCWSTR, LPCWSTR, DWORD);
2488     }
2489 }
2490 
2491 // For compatibility with old core.sys.windows.windows:
2492 version (LittleEndian) nothrow @nogc
2493 {
2494     BOOL QueryPerformanceCounter(long* lpPerformanceCount) { return QueryPerformanceCounter(cast(PLARGE_INTEGER)lpPerformanceCount); }
2495     BOOL QueryPerformanceFrequency(long* lpFrequency) { return QueryPerformanceFrequency(cast(PLARGE_INTEGER)lpFrequency); }
2496 }
2497 
2498 mixin DECLARE_AW!("STARTUPINFO");
2499 version (Unicode) {
2500     //alias STARTUPINFOW STARTUPINFO;
2501     alias WIN32_FIND_DATAW WIN32_FIND_DATA;
2502     alias ENUMRESLANGPROCW ENUMRESLANGPROC;
2503     alias ENUMRESNAMEPROCW ENUMRESNAMEPROC;
2504     alias ENUMRESTYPEPROCW ENUMRESTYPEPROC;
2505     alias AddAtomW AddAtom;
2506     alias BeginUpdateResourceW BeginUpdateResource;
2507     alias BuildCommDCBW BuildCommDCB;
2508     alias BuildCommDCBAndTimeoutsW BuildCommDCBAndTimeouts;
2509     alias CallNamedPipeW CallNamedPipe;
2510     alias CommConfigDialogW CommConfigDialog;
2511     alias CopyFileW CopyFile;
2512     alias CopyFileExW CopyFileEx;
2513     alias CreateDirectoryW CreateDirectory;
2514     alias CreateDirectoryExW CreateDirectoryEx;
2515     alias CreateEventW CreateEvent;
2516     alias CreateFileW CreateFile;
2517     alias CreateMailslotW CreateMailslot;
2518     alias CreateMutexW CreateMutex;
2519     alias CreateProcessW CreateProcess;
2520     alias CreateSemaphoreW CreateSemaphore;
2521     alias DeleteFileW DeleteFile;
2522     alias EndUpdateResourceW EndUpdateResource;
2523     alias EnumResourceLanguagesW EnumResourceLanguages;
2524     alias EnumResourceNamesW EnumResourceNames;
2525     alias EnumResourceTypesW EnumResourceTypes;
2526     alias ExpandEnvironmentStringsW ExpandEnvironmentStrings;
2527     alias FatalAppExitW FatalAppExit;
2528     alias FindAtomW FindAtom;
2529     alias FindFirstChangeNotificationW FindFirstChangeNotification;
2530     alias FindFirstFileW FindFirstFile;
2531     alias FindNextFileW FindNextFile;
2532     alias FindResourceW FindResource;
2533     alias FindResourceExW FindResourceEx;
2534     alias FormatMessageW FormatMessage;
2535     alias FreeEnvironmentStringsW FreeEnvironmentStrings;
2536     alias GetAtomNameW GetAtomName;
2537     alias GetCommandLineW GetCommandLine;
2538     alias GetComputerNameW GetComputerName;
2539     alias GetCurrentDirectoryW GetCurrentDirectory;
2540     alias GetDefaultCommConfigW GetDefaultCommConfig;
2541     alias GetDiskFreeSpaceW GetDiskFreeSpace;
2542     alias GetDiskFreeSpaceExW GetDiskFreeSpaceEx;
2543     alias GetDriveTypeW GetDriveType;
2544     alias GetEnvironmentStringsW GetEnvironmentStrings;
2545     alias GetEnvironmentVariableW GetEnvironmentVariable;
2546     alias GetFileAttributesW GetFileAttributes;
2547     alias GetFullPathNameW GetFullPathName;
2548     alias GetLogicalDriveStringsW GetLogicalDriveStrings;
2549     alias GetModuleFileNameW GetModuleFileName;
2550     alias GetModuleHandleW GetModuleHandle;
2551     alias GetNamedPipeHandleStateW GetNamedPipeHandleState;
2552     alias GetPrivateProfileIntW GetPrivateProfileInt;
2553     alias GetPrivateProfileSectionW GetPrivateProfileSection;
2554     alias GetPrivateProfileSectionNamesW GetPrivateProfileSectionNames;
2555     alias GetPrivateProfileStringW GetPrivateProfileString;
2556     alias GetPrivateProfileStructW GetPrivateProfileStruct;
2557     alias GetProfileIntW GetProfileInt;
2558     alias GetProfileSectionW GetProfileSection;
2559     alias GetProfileStringW GetProfileString;
2560     alias GetShortPathNameW GetShortPathName;
2561     alias GetStartupInfoW GetStartupInfo;
2562     alias GetSystemDirectoryW GetSystemDirectory;
2563     alias GetTempFileNameW GetTempFileName;
2564     alias GetTempPathW GetTempPath;
2565     alias GetUserNameW GetUserName;
2566     alias GetVersionExW GetVersionEx;
2567     alias GetVolumeInformationW GetVolumeInformation;
2568     alias GetWindowsDirectoryW GetWindowsDirectory;
2569     alias GlobalAddAtomW GlobalAddAtom;
2570     alias GlobalFindAtomW GlobalFindAtom;
2571     alias GlobalGetAtomNameW GlobalGetAtomName;
2572     alias IsBadStringPtrW IsBadStringPtr;
2573     alias LoadLibraryW LoadLibrary;
2574     alias LoadLibraryExW LoadLibraryEx;
2575     alias lstrcatW lstrcat;
2576     alias lstrcmpW lstrcmp;
2577     alias lstrcmpiW lstrcmpi;
2578     alias lstrcpyW lstrcpy;
2579     alias lstrcpynW lstrcpyn;
2580     alias lstrlenW lstrlen;
2581     alias MoveFileW MoveFile;
2582     alias OpenEventW OpenEvent;
2583     alias OpenMutexW OpenMutex;
2584     alias OpenSemaphoreW OpenSemaphore;
2585     alias OutputDebugStringW OutputDebugString;
2586     alias RemoveDirectoryW RemoveDirectory;
2587     alias SearchPathW SearchPath;
2588     alias SetComputerNameW SetComputerName;
2589     alias SetCurrentDirectoryW SetCurrentDirectory;
2590     alias SetDefaultCommConfigW SetDefaultCommConfig;
2591     alias SetEnvironmentVariableW SetEnvironmentVariable;
2592     alias SetFileAttributesW SetFileAttributes;
2593     alias SetVolumeLabelW SetVolumeLabel;
2594     alias WaitNamedPipeW WaitNamedPipe;
2595     alias WritePrivateProfileSectionW WritePrivateProfileSection;
2596     alias WritePrivateProfileStringW WritePrivateProfileString;
2597     alias WritePrivateProfileStructW WritePrivateProfileStruct;
2598     alias WriteProfileSectionW WriteProfileSection;
2599     alias WriteProfileStringW WriteProfileString;
2600     alias CreateWaitableTimerW CreateWaitableTimer;
2601     alias GetFileAttributesExW GetFileAttributesEx;
2602     alias GetLongPathNameW GetLongPathName;
2603     alias QueryDosDeviceW QueryDosDevice;
2604 
2605     alias HW_PROFILE_INFOW HW_PROFILE_INFO;
2606     alias AccessCheckAndAuditAlarmW AccessCheckAndAuditAlarm;
2607     alias BackupEventLogW BackupEventLog;
2608     alias ClearEventLogW ClearEventLog;
2609     alias CreateNamedPipeW CreateNamedPipe;
2610     alias CreateProcessAsUserW CreateProcessAsUser;
2611     alias DefineDosDeviceW DefineDosDevice;
2612     alias FindFirstFileExW FindFirstFileEx;
2613     alias GetBinaryTypeW GetBinaryType;
2614     alias GetCompressedFileSizeW GetCompressedFileSize;
2615     alias GetFileSecurityW GetFileSecurity;
2616     alias LogonUserW LogonUser;
2617     alias LookupAccountNameW LookupAccountName;
2618     alias LookupAccountSidW LookupAccountSid;
2619     alias LookupPrivilegeDisplayNameW LookupPrivilegeDisplayName;
2620     alias LookupPrivilegeNameW LookupPrivilegeName;
2621     alias LookupPrivilegeValueW LookupPrivilegeValue;
2622     alias MoveFileExW MoveFileEx;
2623     alias ObjectCloseAuditAlarmW ObjectCloseAuditAlarm;
2624     alias ObjectDeleteAuditAlarmW ObjectDeleteAuditAlarm;
2625     alias ObjectOpenAuditAlarmW ObjectOpenAuditAlarm;
2626     alias ObjectPrivilegeAuditAlarmW ObjectPrivilegeAuditAlarm;
2627     alias OpenBackupEventLogW OpenBackupEventLog;
2628     alias OpenEventLogW OpenEventLog;
2629     alias PrivilegedServiceAuditAlarmW PrivilegedServiceAuditAlarm;
2630     alias ReadEventLogW ReadEventLog;
2631     alias RegisterEventSourceW RegisterEventSource;
2632     alias ReportEventW ReportEvent;
2633     alias SetFileSecurityW SetFileSecurity;
2634     alias UpdateResourceW UpdateResource;
2635 
2636     static if (_WIN32_WINNT >= 0x500) {
2637         alias CreateFileMappingW CreateFileMapping;
2638         alias CreateHardLinkW CreateHardLink;
2639         alias CreateJobObjectW CreateJobObject;
2640         alias DeleteVolumeMountPointW DeleteVolumeMountPoint;
2641         alias DnsHostnameToComputerNameW DnsHostnameToComputerName;
2642         alias EncryptFileW EncryptFile;
2643         alias FileEncryptionStatusW FileEncryptionStatus;
2644         alias FindFirstVolumeW FindFirstVolume;
2645         alias FindFirstVolumeMountPointW FindFirstVolumeMountPoint;
2646         alias FindNextVolumeW FindNextVolume;
2647         alias FindNextVolumeMountPointW FindNextVolumeMountPoint;
2648         alias GetModuleHandleExW GetModuleHandleEx;
2649         alias GetSystemWindowsDirectoryW GetSystemWindowsDirectory;
2650         alias GetVolumeNameForVolumeMountPointW GetVolumeNameForVolumeMountPoint;
2651         alias GetVolumePathNameW GetVolumePathName;
2652         alias OpenFileMappingW OpenFileMapping;
2653         alias ReplaceFileW ReplaceFile;
2654         alias SetVolumeMountPointW SetVolumeMountPoint;
2655         alias VerifyVersionInfoW VerifyVersionInfo;
2656     }
2657 
2658     static if (_WIN32_WINNT >= 0x501) {
2659         alias ACTCTXW ACTCTX;
2660         alias CheckNameLegalDOS8Dot3W CheckNameLegalDOS8Dot3;
2661         alias CreateActCtxW CreateActCtx;
2662         alias FindActCtxSectionStringW FindActCtxSectionString;
2663         alias GetSystemWow64DirectoryW GetSystemWow64Directory;
2664         alias GetVolumePathNamesForVolumeNameW GetVolumePathNamesForVolumeName;
2665         alias SetFileShortNameW SetFileShortName;
2666     }
2667 
2668     static if (_WIN32_WINNT >= 0x502) {
2669         alias SetFirmwareEnvironmentVariableW SetFirmwareEnvironmentVariable;
2670         alias SetDllDirectoryW SetDllDirectory;
2671         alias GetDllDirectoryW GetDllDirectory;
2672     }
2673 
2674     static if (_WIN32_WINNT >= 0x600) {
2675         alias CreateSymbolicLinkW CreateSymbolicLink;
2676     }
2677 
2678 } else {
2679     //alias STARTUPINFOA STARTUPINFO;
2680     alias WIN32_FIND_DATAA WIN32_FIND_DATA;
2681     alias ENUMRESLANGPROCW ENUMRESLANGPROC;
2682     alias ENUMRESNAMEPROCW ENUMRESNAMEPROC;
2683     alias ENUMRESTYPEPROCW ENUMRESTYPEPROC;
2684     alias AddAtomA AddAtom;
2685     alias BeginUpdateResourceA BeginUpdateResource;
2686     alias BuildCommDCBA BuildCommDCB;
2687     alias BuildCommDCBAndTimeoutsA BuildCommDCBAndTimeouts;
2688     alias CallNamedPipeA CallNamedPipe;
2689     alias CommConfigDialogA CommConfigDialog;
2690     alias CopyFileA CopyFile;
2691     alias CopyFileExA CopyFileEx;
2692     alias CreateDirectoryA CreateDirectory;
2693     alias CreateDirectoryExA CreateDirectoryEx;
2694     alias CreateEventA CreateEvent;
2695     alias CreateFileA CreateFile;
2696     alias CreateMailslotA CreateMailslot;
2697     alias CreateMutexA CreateMutex;
2698     alias CreateProcessA CreateProcess;
2699     alias CreateSemaphoreA CreateSemaphore;
2700     alias DeleteFileA DeleteFile;
2701     alias EndUpdateResourceA EndUpdateResource;
2702     alias EnumResourceLanguagesA EnumResourceLanguages;
2703     alias EnumResourceNamesA EnumResourceNames;
2704     alias EnumResourceTypesA EnumResourceTypes;
2705     alias ExpandEnvironmentStringsA ExpandEnvironmentStrings;
2706     alias FatalAppExitA FatalAppExit;
2707     alias FindAtomA FindAtom;
2708     alias FindFirstChangeNotificationA FindFirstChangeNotification;
2709     alias FindFirstFileA FindFirstFile;
2710     alias FindNextFileA FindNextFile;
2711     alias FindResourceA FindResource;
2712     alias FindResourceExA FindResourceEx;
2713     alias FormatMessageA FormatMessage;
2714     alias FreeEnvironmentStringsA FreeEnvironmentStrings;
2715     alias GetAtomNameA GetAtomName;
2716     alias GetCommandLineA GetCommandLine;
2717     alias GetComputerNameA GetComputerName;
2718     alias GetCurrentDirectoryA GetCurrentDirectory;
2719     alias GetDefaultCommConfigA GetDefaultCommConfig;
2720     alias GetDiskFreeSpaceA GetDiskFreeSpace;
2721     alias GetDiskFreeSpaceExA GetDiskFreeSpaceEx;
2722     alias GetDriveTypeA GetDriveType;
2723     alias GetEnvironmentStringsA GetEnvironmentStrings;
2724     alias GetEnvironmentVariableA GetEnvironmentVariable;
2725     alias GetFileAttributesA GetFileAttributes;
2726     alias GetFullPathNameA GetFullPathName;
2727     alias GetLogicalDriveStringsA GetLogicalDriveStrings;
2728     alias GetNamedPipeHandleStateA GetNamedPipeHandleState;
2729     alias GetModuleHandleA GetModuleHandle;
2730     alias GetModuleFileNameA GetModuleFileName;
2731     alias GetPrivateProfileIntA GetPrivateProfileInt;
2732     alias GetPrivateProfileSectionA GetPrivateProfileSection;
2733     alias GetPrivateProfileSectionNamesA GetPrivateProfileSectionNames;
2734     alias GetPrivateProfileStringA GetPrivateProfileString;
2735     alias GetPrivateProfileStructA GetPrivateProfileStruct;
2736     alias GetProfileIntA GetProfileInt;
2737     alias GetProfileSectionA GetProfileSection;
2738     alias GetProfileStringA GetProfileString;
2739     alias GetShortPathNameA GetShortPathName;
2740     alias GetStartupInfoA GetStartupInfo;
2741     alias GetSystemDirectoryA GetSystemDirectory;
2742     alias GetTempFileNameA GetTempFileName;
2743     alias GetTempPathA GetTempPath;
2744     alias GetUserNameA GetUserName;
2745     alias GetVersionExA GetVersionEx;
2746     alias GetVolumeInformationA GetVolumeInformation;
2747     alias GetWindowsDirectoryA GetWindowsDirectory;
2748     alias GlobalAddAtomA GlobalAddAtom;
2749     alias GlobalFindAtomA GlobalFindAtom;
2750     alias GlobalGetAtomNameA GlobalGetAtomName;
2751     alias IsBadStringPtrA IsBadStringPtr;
2752     alias LoadLibraryA LoadLibrary;
2753     alias LoadLibraryExA LoadLibraryEx;
2754     alias lstrcatA lstrcat;
2755     alias lstrcmpA lstrcmp;
2756     alias lstrcmpiA lstrcmpi;
2757     alias lstrcpyA lstrcpy;
2758     alias lstrcpynA lstrcpyn;
2759     alias lstrlenA lstrlen;
2760     alias MoveFileA MoveFile;
2761     alias OpenEventA OpenEvent;
2762     alias OpenMutexA OpenMutex;
2763     alias OpenSemaphoreA OpenSemaphore;
2764     alias OutputDebugStringA OutputDebugString;
2765     alias RemoveDirectoryA RemoveDirectory;
2766     alias SearchPathA SearchPath;
2767     alias SetComputerNameA SetComputerName;
2768     alias SetCurrentDirectoryA SetCurrentDirectory;
2769     alias SetDefaultCommConfigA SetDefaultCommConfig;
2770     alias SetEnvironmentVariableA SetEnvironmentVariable;
2771     alias SetFileAttributesA SetFileAttributes;
2772     alias SetVolumeLabelA SetVolumeLabel;
2773     alias WaitNamedPipeA WaitNamedPipe;
2774     alias WritePrivateProfileSectionA WritePrivateProfileSection;
2775     alias WritePrivateProfileStringA WritePrivateProfileString;
2776     alias WritePrivateProfileStructA WritePrivateProfileStruct;
2777     alias WriteProfileSectionA WriteProfileSection;
2778     alias WriteProfileStringA WriteProfileString;
2779     alias CreateWaitableTimerA CreateWaitableTimer;
2780     alias GetFileAttributesExA GetFileAttributesEx;
2781     alias GetLongPathNameA GetLongPathName;
2782     alias QueryDosDeviceA QueryDosDevice;
2783 
2784     alias HW_PROFILE_INFOA HW_PROFILE_INFO;
2785     alias AccessCheckAndAuditAlarmA AccessCheckAndAuditAlarm;
2786     alias BackupEventLogA BackupEventLog;
2787     alias ClearEventLogA ClearEventLog;
2788     alias CreateNamedPipeA CreateNamedPipe;
2789     alias CreateProcessAsUserA CreateProcessAsUser;
2790     alias DefineDosDeviceA DefineDosDevice;
2791     alias FindFirstFileExA FindFirstFileEx;
2792     alias GetBinaryTypeA GetBinaryType;
2793     alias GetCompressedFileSizeA GetCompressedFileSize;
2794     alias GetFileSecurityA GetFileSecurity;
2795     alias LogonUserA LogonUser;
2796     alias LookupAccountNameA LookupAccountName;
2797     alias LookupAccountSidA LookupAccountSid;
2798     alias LookupPrivilegeDisplayNameA LookupPrivilegeDisplayName;
2799     alias LookupPrivilegeNameA LookupPrivilegeName;
2800     alias LookupPrivilegeValueA LookupPrivilegeValue;
2801     alias MoveFileExA MoveFileEx;
2802     alias ObjectCloseAuditAlarmA ObjectCloseAuditAlarm;
2803     alias ObjectDeleteAuditAlarmA ObjectDeleteAuditAlarm;
2804     alias ObjectOpenAuditAlarmA ObjectOpenAuditAlarm;
2805     alias ObjectPrivilegeAuditAlarmA ObjectPrivilegeAuditAlarm;
2806     alias OpenBackupEventLogA OpenBackupEventLog;
2807     alias OpenEventLogA OpenEventLog;
2808     alias PrivilegedServiceAuditAlarmA PrivilegedServiceAuditAlarm;
2809     alias ReadEventLogA ReadEventLog;
2810     alias RegisterEventSourceA RegisterEventSource;
2811     alias ReportEventA ReportEvent;
2812     alias SetFileSecurityA SetFileSecurity;
2813     alias UpdateResourceA UpdateResource;
2814 
2815     static if (_WIN32_WINNT >= 0x500) {
2816         alias CreateFileMappingA CreateFileMapping;
2817         alias CreateHardLinkA CreateHardLink;
2818         alias CreateJobObjectA CreateJobObject;
2819         alias DeleteVolumeMountPointA DeleteVolumeMountPoint;
2820         alias DnsHostnameToComputerNameA DnsHostnameToComputerName;
2821         alias EncryptFileA EncryptFile;
2822         alias FileEncryptionStatusA FileEncryptionStatus;
2823         alias FindFirstVolumeA FindFirstVolume;
2824         alias FindFirstVolumeMountPointA FindFirstVolumeMountPoint;
2825         alias FindNextVolumeA FindNextVolume;
2826         alias FindNextVolumeMountPointA FindNextVolumeMountPoint;
2827         alias GetModuleHandleExA GetModuleHandleEx;
2828         alias GetSystemWindowsDirectoryA GetSystemWindowsDirectory;
2829         alias GetVolumeNameForVolumeMountPointA GetVolumeNameForVolumeMountPoint;
2830         alias GetVolumePathNameA GetVolumePathName;
2831         alias OpenFileMappingA OpenFileMapping;
2832         alias ReplaceFileA ReplaceFile;
2833         alias SetVolumeMountPointA SetVolumeMountPoint;
2834         alias VerifyVersionInfoA VerifyVersionInfo;
2835     }
2836 
2837     static if (_WIN32_WINNT >= 0x501) {
2838         alias ACTCTXA ACTCTX;
2839         alias CheckNameLegalDOS8Dot3A CheckNameLegalDOS8Dot3;
2840         alias CreateActCtxA CreateActCtx;
2841         alias FindActCtxSectionStringA FindActCtxSectionString;
2842         alias GetSystemWow64DirectoryA GetSystemWow64Directory;
2843         alias GetVolumePathNamesForVolumeNameA GetVolumePathNamesForVolumeName;
2844         alias SetFileShortNameA SetFileShortName;
2845     }
2846 
2847     static if (_WIN32_WINNT >= 0x502) {
2848         alias GetDllDirectoryA GetDllDirectory;
2849         alias SetDllDirectoryA SetDllDirectory;
2850         alias SetFirmwareEnvironmentVariableA SetFirmwareEnvironmentVariable;
2851     }
2852 
2853     static if (_WIN32_WINNT >= 0x600) {
2854         alias CreateSymbolicLinkA CreateSymbolicLink;
2855     }
2856 }
2857 
2858 alias STARTUPINFO* LPSTARTUPINFO;
2859 alias WIN32_FIND_DATA* LPWIN32_FIND_DATA;
2860 
2861 alias HW_PROFILE_INFO* LPHW_PROFILE_INFO;
2862 
2863 static if (_WIN32_WINNT >= 0x501) {
2864     alias ACTCTX* PACTCTX, PCACTCTX;
2865 }