2 // Copyright (c) Microsoft. All rights reserved.
3 // Licensed under the MIT license. See LICENSE file in the project root for full license information.
10 This file includes parts which are Copyright (c) 1982-1986 Regents
11 of the University of California. All rights reserved. The
12 Berkeley Software License Agreement specifies the terms and
13 conditions for redistribution.
22 Rotor Platform Adaptation Layer (PAL) header file. This file
23 defines all types and API calls required by the Rotor port of
24 the Microsoft Common Language Runtime.
26 Defines which control the behavior of this include file:
27 UNICODE - define it to set the Ansi/Unicode neutral names to
28 be the ...W names. Otherwise the neutral names default
30 PAL_IMPLEMENTATION - define it when implementing the PAL. Otherwise
31 leave it undefined when consuming the PAL.
33 Note: some fields in structs have been renamed from the original
34 SDK documentation names, with _PAL_Undefined appended. This leaves
35 the structure layout identical to its Win32 version, but prevents
36 PAL consumers from inadvertently referencing undefined fields.
38 If you want to add a PAL_ wrapper function to a native function in
39 here, you also need to edit palinternal.h and win32pal.h.
52 #if defined (PLATFORM_UNIX)
53 // This macro is used to standardize the wide character string literals between UNIX and Windows.
54 // Unix L"" is UTF32, and on windows it's UTF16. Because of built-in assumptions on the size
55 // of string literals, it's important to match behaviour between Unix and Windows. Unix will be defined
59 // Undefine the QUOTE_MACRO_L helper and redefine it in terms of u.
60 // The reason that we do this is that quote macro is defined in ndp\common\inc,
61 // not inside of coreclr sources.
63 #define QUOTE_MACRO_L(x) QUOTE_MACRO_u(x)
64 #define QUOTE_MACRO_u_HELPER(x) u###x
65 #define QUOTE_MACRO_u(x) QUOTE_MACRO_u_HELPER(x)
69 #include <pal_char16.h>
70 #include <pal_error.h>
71 #include <pal_mstypes.h>
73 /******************* Processor-specific glue *****************************/
77 #if defined(__i686__) && !defined(_M_IX86)
79 #elif defined(__i586__) && !defined(_M_IX86)
81 #elif defined(__i486__) && !defined(_M_IX86)
83 #elif defined(__i386__) && !defined(_M_IX86)
85 #elif defined(__ppc__) && !defined(_M_PPC)
87 #elif defined(_AIX) && defined(_POWER) && !defined(_M_PPC)
89 #elif defined(__sparc__) && !defined(_M_SPARC)
91 #elif defined(__hppa__) && !defined(_M_PARISC)
93 #elif defined(__ia64__) && !defined(_M_IA64)
95 #elif defined(__x86_64__) && !defined(_M_AMD64)
99 #if defined(_M_IX86) && !defined(_X86_)
101 #elif defined(_M_ALPHA) && !defined(_ALPHA_)
103 #elif defined(_M_PPC) && !defined(_PPC_)
105 #elif defined(_M_SPARC) && !defined(_SPARC_)
107 #elif defined(_M_PARISC) && !defined(_PARISC_)
109 #elif defined(_M_MRX000) && !defined(_MIPS_)
111 #elif defined(_M_M68K) && !defined(_68K_)
113 #elif defined(_M_IA64) && !defined(_IA64_)
115 #elif defined(_M_AMD64) && !defined(_AMD64_)
121 /******************* ABI-specific glue *******************************/
123 #if defined(_PPC_) || defined(_PPC64_) || defined(_SPARC_) || defined(_PARISC_) || defined(_IA64_)
128 // Both PowerPC, i386 and x86_64 on Mac OS X use 16-byte alignment.
129 #define STACK_ALIGN_BITS 4
130 #define STACK_ALIGN_REQ (1 << STACK_ALIGN_BITS)
134 #define _MAX_PATH 260 /* max. length of full pathname */
135 #define _MAX_DRIVE 3 /* max. length of drive component */
136 #define _MAX_DIR 256 /* max. length of path component */
137 #define _MAX_FNAME 256 /* max. length of file name component */
138 #define _MAX_EXT 256 /* max. length of extension component */
140 #define MAXSHORT 0x7fff
141 #define MAXLONG 0x7fffffff
143 #define MAXDWORD 0xffffffff
147 // Note that the named locale APIs (eg CompareStringExEx) are recommended.
150 #define LANG_CHINESE 0x04
151 #define LANG_ENGLISH 0x09
152 #define LANG_JAPANESE 0x11
153 #define LANG_KOREAN 0x12
154 #define LANG_THAI 0x1e
156 /******************* Compiler-specific glue *******************************/
160 // Define this if the underlying platform supports true 2-pass EH.
161 // At the same time, this enables running several PAL instances
163 #define FEATURE_PAL_SXS 1
168 #if defined(_MSC_VER) || defined(__llvm__)
169 #define DECLSPEC_ALIGN(x) __declspec(align(x))
171 #define DECLSPEC_ALIGN(x)
174 #define DECLSPEC_NORETURN PAL_NORETURN
177 #define __assume(x) (void)0
178 #define __annotation(x)
183 #if defined(_M_MRX000) || defined(_M_ALPHA) || defined(_M_PPC) || defined(_M_IA64)
184 #define UNALIGNED __unaligned
198 char *a0; /* pointer to first homed integer argument */
199 int offset; /* byte offset of next parameter */
202 #define va_start(list, v) __builtin_va_start(list, v, 1)
209 typedef __builtin_va_list __gnuc_va_list;
210 typedef __builtin_va_list va_list;
211 #define va_start(v,l) __builtin_va_start(v,l)
212 #define va_end __builtin_va_end
213 #define va_arg __builtin_va_arg
218 typedef void * va_list;
220 typedef __builtin_va_list va_list;
223 /* We should consider if the va_arg definition here is actually necessary.
224 Could we use the standard va_arg definition? */
227 #if defined(_SPARC_) || defined(_PARISC_) // ToDo: is this the right thing for PARISC?
228 #define va_start(list, v) (__builtin_next_arg(v), list = (char *) __builtin_saveregs())
229 #define __va_rounded_size(TYPE) \
230 (((sizeof (TYPE) + sizeof (int) - 1) / sizeof (int)) * sizeof (int))
231 #define __record_type_class 12
232 #define __real_type_class 8
233 #define va_arg(pvar,TYPE) \
235 (*({((__builtin_classify_type (*(TYPE*) 0) >= __record_type_class \
236 || (__builtin_classify_type (*(TYPE*) 0) == __real_type_class \
237 && sizeof (TYPE) == 16)) \
238 ? ((pvar) = (char *)(pvar) + __va_rounded_size (TYPE *), \
239 *(TYPE **) (void *) ((char *)(pvar) - __va_rounded_size (TYPE *))) \
240 : __va_rounded_size (TYPE) == 8 \
241 ? ({ union {char __d[sizeof (TYPE)]; int __i[2];} __u; \
242 __u.__i[0] = ((int *) (void *) (pvar))[0]; \
243 __u.__i[1] = ((int *) (void *) (pvar))[1]; \
244 (pvar) = (char *)(pvar) + 8; \
245 (TYPE *) (void *) __u.__d; }) \
246 : ((pvar) = (char *)(pvar) + __va_rounded_size (TYPE), \
247 ((TYPE *) (void *) ((char *)(pvar) - __va_rounded_size (TYPE)))));}))
248 #else // _SPARC_ or _PARISC_
249 // GCC 2.95.3 on non-SPARC
250 #define __va_size(type) (((sizeof(type) + sizeof(int) - 1) / sizeof(int)) * sizeof(int))
251 #define va_start(list, v) ((list) = (va_list) __builtin_next_arg(v))
252 #define va_arg(ap, type) (*(type *)((ap) += __va_size(type), (ap) - __va_size(type)))
253 #endif // _SPARC_ or _PARISC_
254 #else // __GNUC__ == 2
255 #define va_start __builtin_va_start
256 #define va_arg __builtin_va_arg
257 #endif // __GNUC__ == 2
259 #define va_copy __builtin_va_copy
260 #define va_end __builtin_va_end
266 #define PUB __attribute__((visibility("default")))
270 typedef char * va_list;
272 #define _INTSIZEOF(n) ( (sizeof(n) + sizeof(int) - 1) & ~(sizeof(int) - 1) )
277 #define _ADDRESSOF(v) ( &reinterpret_cast<const char &>(v) )
279 #define _ADDRESSOF(v) ( &(v) )
282 #define _crt_va_start(ap,v) ( ap = (va_list)_ADDRESSOF(v) + _INTSIZEOF(v) )
283 #define _crt_va_arg(ap,t) ( *(t *)((ap += _INTSIZEOF(t)) - _INTSIZEOF(t)) )
284 #define _crt_va_end(ap) ( ap = (va_list)0 )
286 #define va_start _crt_va_start
287 #define va_arg _crt_va_arg
288 #define va_end _crt_va_end
292 #define va_start(ap,v) (ap = (va_list) (&(v)) + _INTSIZEOF(v))
293 #define va_arg(ap,t) ( *(t *)((ap += _INTSIZEOF(t)) - _INTSIZEOF(t)) )
298 #define va_copy(dest,src) (dest = src)
302 /******************* PAL-Specific Entrypoints *****************************/
304 #define IsDebuggerPresent PAL_IsDebuggerPresent
309 PAL_IsDebuggerPresent();
311 #define MAXIMUM_SUSPEND_COUNT MAXCHAR
315 #define SCHAR_MIN (-128)
316 #define SCHAR_MAX 127
317 #define UCHAR_MAX 0xff
319 #define SHRT_MIN (-32768)
320 #define SHRT_MAX 32767
321 #define USHRT_MAX 0xffff
323 #define INT_MIN (-2147483647 - 1)
324 #define INT_MAX 2147483647
325 #define UINT_MAX 0xffffffff
327 #define LONG_MIN (-2147483647L - 1)
328 #define LONG_MAX 2147483647L
329 #define ULONG_MAX 0xffffffffUL
331 #define FLT_MAX 3.402823466e+38F
332 #define DBL_MAX 1.7976931348623157e+308
334 /* minimum signed 64 bit value */
335 #define _I64_MIN (I64(-9223372036854775807) - 1)
336 /* maximum signed 64 bit value */
337 #define _I64_MAX I64(9223372036854775807)
338 /* maximum unsigned 64 bit value */
339 #define _UI64_MAX UI64(0xffffffffffffffff)
341 #define _I8_MAX SCHAR_MAX
342 #define _I8_MIN SCHAR_MIN
343 #define _I16_MAX SHRT_MAX
344 #define _I16_MIN SHRT_MIN
345 #define _I32_MAX INT_MAX
346 #define _I32_MIN INT_MIN
347 #define _UI8_MAX UCHAR_MAX
348 #define _UI8_MIN UCHAR_MIN
349 #define _UI16_MAX USHRT_MAX
350 #define _UI16_MIN USHRT_MIN
351 #define _UI32_MAX UINT_MAX
352 #define _UI32_MIN UINT_MIN
355 #if defined(__cplusplus)
358 #define NULL ((void *)0)
362 typedef ULONG64 fpos_t;
364 #if _WIN64 || _MSC_VER >= 1400
365 typedef __int64 time_t;
369 #define _TIME_T_DEFINED
371 #if ENABLE_DOWNLEVEL_FOR_NLS
372 #define MAKELCID(lgid, srtid) ((DWORD)((((DWORD)((WORD )(srtid))) << 16) | \
373 ((DWORD)((WORD )(lgid)))))
374 #define LANGIDFROMLCID(lcid) ((WORD)(lcid))
375 #define SORTIDFROMLCID(lcid) ((WORD)((((DWORD)(lcid)) >> 16) & 0xf))
377 #define LANG_NEUTRAL 0x00
378 #define LANG_INVARIANT 0x7f
379 #define SUBLANG_NEUTRAL 0x00 // language neutral
380 #define SUBLANG_DEFAULT 0x01 // user default
381 #define SORT_DEFAULT 0x0 // sorting default
383 #define MAKELANGID(p, s) ((((WORD )(s)) << 10) | (WORD )(p))
384 #define PRIMARYLANGID(lgid) ((WORD )(lgid) & 0x3ff)
385 #define SUBLANGID(lgid) ((WORD )(lgid) >> 10)
387 #define LANG_USER_DEFAULT (MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT))
388 #define LOCALE_USER_DEFAULT (MAKELCID(LANG_USER_DEFAULT, SORT_DEFAULT))
389 #define LOCALE_NEUTRAL (MAKELCID(MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), SORT_DEFAULT))
390 #define LOCALE_US_ENGLISH (MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT))
391 #define LOCALE_INVARIANT (MAKELCID(MAKELANGID(LANG_INVARIANT, SUBLANG_NEUTRAL), SORT_DEFAULT))
393 #define SUBLANG_ENGLISH_US 0x01
394 #define SUBLANG_CHINESE_TRADITIONAL 0x01 /* Chinese (Traditional) */
396 #endif // ENABLE_DOWNLEVEL_FOR_NLS
399 #define CT_CTYPE1 0x00000001 /* ctype 1 information */
400 #define CT_CTYPE2 0x00000002 /* ctype 2 information */
401 #define CT_CTYPE3 0x00000004 /* ctype 3 information */
402 #define C1_UPPER 0x0001 /* upper case */
403 #define C1_LOWER 0x0002 /* lower case */
404 #define C1_DIGIT 0x0004 /* decimal digits */
405 #define C1_SPACE 0x0008 /* spacing characters */
406 #define C1_PUNCT 0x0010 /* punctuation characters */
407 #define C1_CNTRL 0x0020 /* control characters */
408 #define C1_BLANK 0x0040 /* blank characters */
409 #define C1_XDIGIT 0x0080 /* other digits */
410 #define C1_ALPHA 0x0100 /* any linguistic character */
411 #define C2_LEFTTORIGHT 0x0001 /* left to right */
412 #define C2_RIGHTTOLEFT 0x0002 /* right to left */
413 #define C2_EUROPENUMBER 0x0003 /* European number, digit */
414 #define C2_EUROPESEPARATOR 0x0004 /* European numeric separator */
415 #define C2_EUROPETERMINATOR 0x0005 /* European numeric terminator */
416 #define C2_ARABICNUMBER 0x0006 /* Arabic number */
417 #define C2_COMMONSEPARATOR 0x0007 /* common numeric separator */
418 #define C2_BLOCKSEPARATOR 0x0008 /* block separator */
419 #define C2_SEGMENTSEPARATOR 0x0009 /* segment separator */
420 #define C2_WHITESPACE 0x000A /* white space */
421 #define C2_OTHERNEUTRAL 0x000B /* other neutrals */
422 #define C2_NOTAPPLICABLE 0x0000 /* no implicit directionality */
423 #define C3_NONSPACING 0x0001 /* nonspacing character */
424 #define C3_DIACRITIC 0x0002 /* diacritic mark */
425 #define C3_VOWELMARK 0x0004 /* vowel mark */
426 #define C3_SYMBOL 0x0008 /* symbols */
427 #define C3_KATAKANA 0x0010 /* katakana character */
428 #define C3_HIRAGANA 0x0020 /* hiragana character */
429 #define C3_HALFWIDTH 0x0040 /* half width character */
430 #define C3_FULLWIDTH 0x0080 /* full width character */
431 #define C3_IDEOGRAPH 0x0100 /* ideographic character */
432 #define C3_KASHIDA 0x0200 /* Arabic kashida character */
433 #define C3_LEXICAL 0x0400 /* lexical character */
434 #define C3_ALPHA 0x8000 /* any ling. char (C1_ALPHA) */
435 #define C3_NOTAPPLICABLE 0x0000 /* ctype 3 is not applicable */
437 #define DLL_PROCESS_ATTACH 1
438 #define DLL_THREAD_ATTACH 2
439 #define DLL_THREAD_DETACH 3
440 #define DLL_PROCESS_DETACH 0
442 typedef DWORD (PALAPI *PTHREAD_START_ROUTINE)(LPVOID lpThreadParameter);
443 typedef PTHREAD_START_ROUTINE LPTHREAD_START_ROUTINE;
445 /******************* PAL-Specific Entrypoints *****************************/
452 const char * const argv[]);
457 PAL_InitializeCoreCLR(
458 const char *szExePath,
459 const char *szCoreCLRPath,
466 IN LPTHREAD_START_ROUTINE lpStartAddress,
467 IN LPVOID lpParameter);
470 /// This function shuts down PAL and exits the current process.
479 /// This function shuts down PAL and exits the current process with
480 /// the specified exit code.
485 PAL_TerminateEx(int exitCode);
496 PAL_RegisterLibraryW(
497 IN LPCWSTR lpLibFileName);
502 PAL_UnregisterLibraryW(
503 IN HMODULE hLibModule);
506 #define PAL_RegisterLibrary PAL_RegisterLibraryW
507 #define PAL_UnregisterLibrary PAL_UnregisterLibraryW
513 PAL_GetPALDirectoryW(
514 OUT LPWSTR lpDirectoryName,
515 IN UINT cchDirectoryName);
520 PAL_GetPALDirectoryA(
521 OUT LPSTR lpDirectoryName,
522 IN UINT cchDirectoryName);
525 #define PAL_GetPALDirectory PAL_GetPALDirectoryW
527 #define PAL_GetPALDirectory PAL_GetPALDirectoryA
535 IN OUT LPVOID lpBuffer,
538 // This helper will be used *only* by the CoreCLR to determine
539 // if an address lies inside CoreCLR or not.
541 // This shouldnt be used by any other component that links into the PAL.
545 PAL_IsIPInCoreCLR(IN PVOID address);
552 PAL_CreateExecWatchpoint(
560 PAL_DeleteExecWatchpoint(
571 PAL_PublishDacTableAddress(
579 PAL_GetDacTableAddress(
588 PAL_CleanupDacTableAddress(
595 PAL_RegisterMacEHPort();
598 /******************* winuser.h Entrypoints *******************************/
611 IN LPCSTR lpCurrentChar,
615 #define CharNext CharNextA
616 #define CharNextEx CharNextExA
637 #define wsprintf wsprintfW
639 #define wsprintf wsprintfA
642 #define MB_OK 0x00000000L
643 #define MB_OKCANCEL 0x00000001L
644 #define MB_ABORTRETRYIGNORE 0x00000002L
645 #define MB_YESNO 0x00000004L
646 #define MB_RETRYCANCEL 0x00000005L
648 #define MB_ICONHAND 0x00000010L
649 #define MB_ICONQUESTION 0x00000020L
650 #define MB_ICONEXCLAMATION 0x00000030L
651 #define MB_ICONASTERISK 0x00000040L
653 #define MB_ICONINFORMATION MB_ICONASTERISK
654 #define MB_ICONSTOP MB_ICONHAND
655 #define MB_ICONERROR MB_ICONHAND
657 #define MB_DEFBUTTON1 0x00000000L
658 #define MB_DEFBUTTON2 0x00000100L
659 #define MB_DEFBUTTON3 0x00000200L
661 #define MB_SYSTEMMODAL 0x00001000L
662 #define MB_TASKMODAL 0x00002000L
663 #define MB_SETFOREGROUND 0x00010000L
664 #define MB_TOPMOST 0x00040000L
666 #define MB_NOFOCUS 0x00008000L
667 #define MB_SETFOREGROUND 0x00010000L
668 #define MB_DEFAULT_DESKTOP_ONLY 0x00020000L
670 // Note: this is the NT 4.0 and greater value.
671 #define MB_SERVICE_NOTIFICATION 0x00200000L
673 #define MB_TYPEMASK 0x0000000FL
674 #define MB_ICONMASK 0x000000F0L
675 #define MB_DEFMASK 0x00000F00L
689 IN LPVOID hWnd, // NOTE: diff from winuser.h
691 IN LPCWSTR lpCaption,
695 #define MessageBox MessageBoxW
698 /***************** wincon.h Entrypoints **********************************/
700 #define CTRL_C_EVENT 0
701 #define CTRL_BREAK_EVENT 1
702 #define CTRL_CLOSE_EVENT 2
705 #define CTRL_LOGOFF_EVENT 5
706 #define CTRL_SHUTDOWN_EVENT 6
710 (PALAPI *PHANDLER_ROUTINE)(
717 SetConsoleCtrlHandler(
718 IN PHANDLER_ROUTINE HandlerRoutine,
725 GenerateConsoleCtrlEvent(
726 IN DWORD dwCtrlEvent,
727 IN DWORD dwProcessGroupId
731 //end wincon.h Entrypoints
735 #define _CRTIMP __declspec(dllimport)
738 /******************* winbase.h Entrypoints and defines ************************/
745 typedef struct _SECURITY_ATTRIBUTES {
747 LPVOID lpSecurityDescriptor;
749 } SECURITY_ATTRIBUTES, *PSECURITY_ATTRIBUTES, *LPSECURITY_ATTRIBUTES;
751 #define _SH_DENYWR 0x20 /* deny write mode */
753 #define FILE_READ_DATA ( 0x0001 ) // file & pipe
754 #define FILE_APPEND_DATA ( 0x0004 ) // file
756 #define GENERIC_READ (0x80000000L)
757 #define GENERIC_WRITE (0x40000000L)
759 #define FILE_SHARE_READ 0x00000001
760 #define FILE_SHARE_WRITE 0x00000002
761 #define FILE_SHARE_DELETE 0x00000004
764 #define CREATE_ALWAYS 2
765 #define OPEN_EXISTING 3
766 #define OPEN_ALWAYS 4
767 #define TRUNCATE_EXISTING 5
769 #define FILE_ATTRIBUTE_READONLY 0x00000001
770 #define FILE_ATTRIBUTE_HIDDEN 0x00000002
771 #define FILE_ATTRIBUTE_SYSTEM 0x00000004
772 #define FILE_ATTRIBUTE_DIRECTORY 0x00000010
773 #define FILE_ATTRIBUTE_ARCHIVE 0x00000020
774 #define FILE_ATTRIBUTE_NORMAL 0x00000080
776 #define FILE_FLAG_WRITE_THROUGH 0x80000000
777 #define FILE_FLAG_NO_BUFFERING 0x20000000
778 #define FILE_FLAG_RANDOM_ACCESS 0x10000000
779 #define FILE_FLAG_SEQUENTIAL_SCAN 0x08000000
780 #define FILE_FLAG_BACKUP_SEMANTICS 0x02000000
783 #define FILE_CURRENT 1
786 #define STILL_ACTIVE (0x00000103L)
788 #define INVALID_SET_FILE_POINTER ((DWORD)-1)
794 IN LPCSTR lpFileName,
795 IN DWORD dwDesiredAccess,
796 IN DWORD dwShareMode,
797 IN LPSECURITY_ATTRIBUTES lpSecurityAttributes,
798 IN DWORD dwCreationDisposition,
799 IN DWORD dwFlagsAndAttributes,
800 IN HANDLE hTemplateFile);
806 IN LPCWSTR lpFileName,
807 IN DWORD dwDesiredAccess,
808 IN DWORD dwShareMode,
809 IN LPSECURITY_ATTRIBUTES lpSecurityAttributes,
810 IN DWORD dwCreationDisposition,
811 IN DWORD dwFlagsAndAttributes,
812 IN HANDLE hTemplateFile);
815 #define CreateFile CreateFileW
817 #define CreateFile CreateFileA
825 IN DWORD dwFileOffsetLow,
826 IN DWORD dwFileOffsetHigh,
827 IN DWORD nNumberOfBytesToLockLow,
828 IN DWORD nNumberOfBytesToLockHigh
836 IN DWORD dwFileOffsetLow,
837 IN DWORD dwFileOffsetHigh,
838 IN DWORD nNumberOfBytesToUnlockLow,
839 IN DWORD nNumberOfBytesToUnlockHigh
847 IN LPCSTR lpFileName,
848 IN LPCSTR lpExtension,
849 IN DWORD nBufferLength,
851 OUT LPSTR *lpFilePart
859 IN LPCWSTR lpFileName,
860 IN LPCWSTR lpExtension,
861 IN DWORD nBufferLength,
863 OUT LPWSTR *lpFilePart
866 #define SearchPath SearchPathW
868 #define SearchPath SearchPathA
876 IN LPCSTR lpExistingFileName,
877 IN LPCSTR lpNewFileName,
878 IN BOOL bFailIfExists);
884 IN LPCWSTR lpExistingFileName,
885 IN LPCWSTR lpNewFileName,
886 IN BOOL bFailIfExists);
889 #define CopyFile CopyFileW
891 #define CopyFile CopyFileA
898 IN LPCSTR lpFileName);
904 IN LPCWSTR lpFileName);
907 #define DeleteFile DeleteFileW
909 #define DeleteFile DeleteFileA
917 IN LPCSTR lpExistingFileName,
918 IN LPCSTR lpNewFileName);
924 IN LPCWSTR lpExistingFileName,
925 IN LPCWSTR lpNewFileName);
928 #define MoveFile MoveFileW
930 #define MoveFile MoveFileA
933 #define MOVEFILE_REPLACE_EXISTING 0x00000001
934 #define MOVEFILE_COPY_ALLOWED 0x00000002
940 IN LPCSTR lpExistingFileName,
941 IN LPCSTR lpNewFileName,
948 IN LPCWSTR lpExistingFileName,
949 IN LPCWSTR lpNewFileName,
953 #define MoveFileEx MoveFileExW
955 #define MoveFileEx MoveFileExA
962 IN LPCSTR lpPathName,
963 IN LPSECURITY_ATTRIBUTES lpSecurityAttributes);
969 IN LPCWSTR lpPathName,
970 IN LPSECURITY_ATTRIBUTES lpSecurityAttributes);
973 #define CreateDirectory CreateDirectoryW
975 #define CreateDirectory CreateDirectoryA
982 IN LPCWSTR lpPathName);
988 IN LPCSTR lpPathName);
991 #define RemoveDirectory RemoveDirectoryW
993 #define RemoveDirectory RemoveDirectoryA
996 typedef struct _BY_HANDLE_FILE_INFORMATION {
997 DWORD dwFileAttributes;
998 FILETIME ftCreationTime;
999 FILETIME ftLastAccessTime;
1000 FILETIME ftLastWriteTime;
1001 DWORD dwVolumeSerialNumber;
1002 DWORD nFileSizeHigh;
1004 DWORD nNumberOfLinks;
1005 DWORD nFileIndexHigh;
1006 DWORD nFileIndexLow;
1007 } BY_HANDLE_FILE_INFORMATION, *PBY_HANDLE_FILE_INFORMATION, *LPBY_HANDLE_FILE_INFORMATION;
1009 typedef struct _WIN32_FIND_DATAA {
1010 DWORD dwFileAttributes;
1011 FILETIME ftCreationTime;
1012 FILETIME ftLastAccessTime;
1013 FILETIME ftLastWriteTime;
1014 DWORD nFileSizeHigh;
1018 CHAR cFileName[ MAX_PATH ];
1019 CHAR cAlternateFileName[ 14 ];
1020 } WIN32_FIND_DATAA, *PWIN32_FIND_DATAA, *LPWIN32_FIND_DATAA;
1022 typedef struct _WIN32_FIND_DATAW {
1023 DWORD dwFileAttributes;
1024 FILETIME ftCreationTime;
1025 FILETIME ftLastAccessTime;
1026 FILETIME ftLastWriteTime;
1027 DWORD nFileSizeHigh;
1031 WCHAR cFileName[ MAX_PATH ];
1032 WCHAR cAlternateFileName[ 14 ];
1033 } WIN32_FIND_DATAW, *PWIN32_FIND_DATAW, *LPWIN32_FIND_DATAW;
1036 typedef WIN32_FIND_DATAW WIN32_FIND_DATA;
1037 typedef PWIN32_FIND_DATAW PWIN32_FIND_DATA;
1038 typedef LPWIN32_FIND_DATAW LPWIN32_FIND_DATA;
1040 typedef WIN32_FIND_DATAA WIN32_FIND_DATA;
1041 typedef PWIN32_FIND_DATAA PWIN32_FIND_DATA;
1042 typedef LPWIN32_FIND_DATAA LPWIN32_FIND_DATA;
1049 IN LPCSTR lpFileName,
1050 OUT LPWIN32_FIND_DATAA lpFindFileData);
1056 IN LPCWSTR lpFileName,
1057 OUT LPWIN32_FIND_DATAW lpFindFileData);
1060 #define FindFirstFile FindFirstFileW
1062 #define FindFirstFile FindFirstFileA
1069 IN HANDLE hFindFile,
1070 OUT LPWIN32_FIND_DATAA lpFindFileData);
1076 IN HANDLE hFindFile,
1077 OUT LPWIN32_FIND_DATAW lpFindFileData);
1080 #define FindNextFile FindNextFileW
1082 #define FindNextFile FindNextFileA
1089 IN OUT HANDLE hFindFile);
1095 IN LPCSTR lpFileName);
1101 IN LPCWSTR lpFileName);
1104 #define GetFileAttributes GetFileAttributesW
1106 #define GetFileAttributes GetFileAttributesA
1109 typedef enum _GET_FILEEX_INFO_LEVELS {
1110 GetFileExInfoStandard
1111 } GET_FILEEX_INFO_LEVELS;
1113 typedef struct _WIN32_FILE_ATTRIBUTE_DATA {
1114 DWORD dwFileAttributes;
1115 FILETIME ftCreationTime;
1116 FILETIME ftLastAccessTime;
1117 FILETIME ftLastWriteTime;
1118 DWORD nFileSizeHigh;
1120 } WIN32_FILE_ATTRIBUTE_DATA, *LPWIN32_FILE_ATTRIBUTE_DATA;
1125 GetFileAttributesExW(
1126 IN LPCWSTR lpFileName,
1127 IN GET_FILEEX_INFO_LEVELS fInfoLevelId,
1128 OUT LPVOID lpFileInformation);
1131 #define GetFileAttributesEx GetFileAttributesExW
1138 IN LPCSTR lpFileName,
1139 IN DWORD dwFileAttributes);
1145 IN LPCWSTR lpFileName,
1146 IN DWORD dwFileAttributes);
1149 #define SetFileAttributes SetFileAttributesW
1151 #define SetFileAttributes SetFileAttributesA
1154 typedef LPVOID LPOVERLAPPED; // diff from winbase.h
1161 IN LPCVOID lpBuffer,
1162 IN DWORD nNumberOfBytesToWrite,
1163 OUT LPDWORD lpNumberOfBytesWritten,
1164 IN LPOVERLAPPED lpOverlapped);
1171 OUT LPVOID lpBuffer,
1172 IN DWORD nNumberOfBytesToRead,
1173 OUT LPDWORD lpNumberOfBytesRead,
1174 IN LPOVERLAPPED lpOverlapped);
1176 #define STD_INPUT_HANDLE ((DWORD)-10)
1177 #define STD_OUTPUT_HANDLE ((DWORD)-11)
1178 #define STD_ERROR_HANDLE ((DWORD)-12)
1184 IN DWORD nStdHandle);
1197 IN LONG lDistanceToMove,
1198 IN PLONG lpDistanceToMoveHigh,
1199 IN DWORD dwMoveMethod);
1206 IN LARGE_INTEGER liDistanceToMove,
1207 OUT PLARGE_INTEGER lpNewFilePointer,
1208 IN DWORD dwMoveMethod);
1215 OUT LPDWORD lpFileSizeHigh);
1219 PALAPI GetFileSizeEx(
1221 OUT PLARGE_INTEGER lpFileSize);
1226 GetFileInformationByHandle(
1228 OUT BY_HANDLE_FILE_INFORMATION* lpFileInformation);
1234 IN CONST FILETIME *lpFileTime1,
1235 IN CONST FILETIME *lpFileTime2);
1242 IN CONST FILETIME *lpCreationTime,
1243 IN CONST FILETIME *lpLastAccessTime,
1244 IN CONST FILETIME *lpLastWriteTime);
1251 OUT LPFILETIME lpCreationTime,
1252 OUT LPFILETIME lpLastAccessTime,
1253 OUT LPFILETIME lpLastWriteTime);
1258 FileTimeToLocalFileTime(
1259 IN CONST FILETIME *lpFileTime,
1260 OUT LPFILETIME lpLocalFileTime);
1265 LocalFileTimeToFileTime(
1266 IN CONST FILETIME *lpLocalFileTime,
1267 OUT LPFILETIME lpFileTime);
1273 GetSystemTimeAsFileTime(
1274 OUT LPFILETIME lpSystemTimeAsFileTime);
1276 typedef struct _SYSTEMTIME {
1285 } SYSTEMTIME, *PSYSTEMTIME, *LPSYSTEMTIME;
1291 OUT LPSYSTEMTIME lpSystemTime);
1296 FileTimeToSystemTime(
1297 IN CONST FILETIME *lpFileTime,
1298 OUT LPSYSTEMTIME lpSystemTime);
1303 FileTimeToDosDateTime(
1304 IN CONST FILETIME *lpFileTime,
1305 OUT LPWORD lpFatDate,
1306 OUT LPWORD lpFatTime
1312 DosDateTimeToFileTime(
1315 OUT LPFILETIME lpFileTime
1326 #define FILE_TYPE_UNKNOWN 0x0000
1327 #define FILE_TYPE_DISK 0x0001
1328 #define FILE_TYPE_CHAR 0x0002
1329 #define FILE_TYPE_PIPE 0x0003
1330 #define FILE_TYPE_REMOTE 0x8000
1354 IN LPCSTR lpFileName,
1355 IN DWORD nBufferLength,
1357 OUT LPSTR *lpFilePart);
1363 IN LPCWSTR lpFileName,
1364 IN DWORD nBufferLength,
1365 OUT LPWSTR lpBuffer,
1366 OUT LPWSTR *lpFilePart);
1369 #define GetFullPathName GetFullPathNameW
1371 #define GetFullPathName GetFullPathNameA
1378 IN LPCWSTR lpszShortPath,
1379 OUT LPWSTR lpszLongPath,
1380 IN DWORD cchBuffer);
1383 #define GetLongPathName GetLongPathNameW
1390 IN LPCWSTR lpszLongPath,
1391 OUT LPWSTR lpszShortPath,
1392 IN DWORD cchBuffer);
1395 #define GetShortPathName GetShortPathNameW
1403 IN LPCSTR lpPathName,
1404 IN LPCSTR lpPrefixString,
1406 OUT LPSTR lpTempFileName);
1412 IN LPCWSTR lpPathName,
1413 IN LPCWSTR lpPrefixString,
1415 OUT LPWSTR lpTempFileName);
1418 #define GetTempFileName GetTempFileNameW
1420 #define GetTempFileName GetTempFileNameA
1427 IN DWORD nBufferLength,
1428 OUT LPSTR lpBuffer);
1434 IN DWORD nBufferLength,
1435 OUT LPWSTR lpBuffer);
1438 #define GetTempPath GetTempPathW
1440 #define GetTempPath GetTempPathA
1446 GetCurrentDirectoryA(
1447 IN DWORD nBufferLength,
1448 OUT LPSTR lpBuffer);
1453 GetCurrentDirectoryW(
1454 IN DWORD nBufferLength,
1455 OUT LPWSTR lpBuffer);
1458 #define GetCurrentDirectory GetCurrentDirectoryW
1460 #define GetCurrentDirectory GetCurrentDirectoryA
1466 SetCurrentDirectoryA(
1467 IN LPCSTR lpPathName);
1472 SetCurrentDirectoryW(
1473 IN LPCWSTR lpPathName);
1477 #define SetCurrentDirectory SetCurrentDirectoryW
1479 #define SetCurrentDirectory SetCurrentDirectoryA
1482 // maximum length of the NETBIOS name (not including NULL)
1483 #define MAX_COMPUTERNAME_LENGTH 15
1485 // maximum length of the username (not including NULL)
1492 OUT LPWSTR lpBuffer, // address of name buffer
1493 IN OUT LPDWORD nSize ); // address of size of name buffer
1499 OUT LPWSTR lpBuffer, // address of name buffer
1500 IN OUT LPDWORD nSize); // address of size of name buffer
1503 #define GetUserName GetUserNameW
1504 #define GetComputerName GetComputerNameW
1511 IN LPSECURITY_ATTRIBUTES lpSemaphoreAttributes,
1512 IN LONG lInitialCount,
1513 IN LONG lMaximumCount,
1520 IN LPSECURITY_ATTRIBUTES lpSemaphoreAttributes,
1521 IN LONG lInitialCount,
1522 IN LONG lMaximumCount,
1524 IN /*_Reserved_*/ DWORD dwFlags,
1525 IN DWORD dwDesiredAccess);
1531 IN LPSECURITY_ATTRIBUTES lpSemaphoreAttributes,
1532 IN LONG lInitialCount,
1533 IN LONG lMaximumCount,
1540 IN LPSECURITY_ATTRIBUTES lpSemaphoreAttributes,
1541 IN LONG lInitialCount,
1542 IN LONG lMaximumCount,
1544 IN /*_Reserved_*/ DWORD dwFlags,
1545 IN DWORD dwDesiredAccess);
1548 #define CreateSemaphore CreateSemaphoreW
1549 #define CreateSemaphoreEx CreateSemaphoreExW
1551 #define CreateSemaphore CreateSemaphoreA
1552 #define CreateSemaphoreEx CreateSemaphoreExA
1559 IN HANDLE hSemaphore,
1560 IN LONG lReleaseCount,
1561 OUT LPLONG lpPreviousCount);
1567 IN LPSECURITY_ATTRIBUTES lpEventAttributes,
1568 IN BOOL bManualReset,
1569 IN BOOL bInitialState,
1576 IN LPSECURITY_ATTRIBUTES lpEventAttributes,
1577 IN BOOL bManualReset,
1578 IN BOOL bInitialState,
1582 #define CreateEvent CreateEventW
1584 #define CreateEvent CreateEventA
1603 IN DWORD dwDesiredAccess,
1604 IN BOOL bInheritHandle,
1608 #define OpenEvent OpenEventW
1615 IN LPSECURITY_ATTRIBUTES lpMutexAttributes,
1616 IN BOOL bInitialOwner,
1623 IN LPSECURITY_ATTRIBUTES lpMutexAttributes,
1624 IN BOOL bInitialOwner,
1628 #define CreateMutex CreateMutexW
1630 #define CreateMutex CreateMutexA
1637 IN DWORD dwDesiredAccess,
1638 IN BOOL bInheritHandle,
1645 IN DWORD dwDesiredAccess,
1646 IN BOOL bInheritHandle,
1650 #define OpenMutex OpenMutexW
1652 #define OpenMutex OpenMutexA
1664 GetCurrentProcessId(
1679 // To work around multiply-defined symbols in the Carbon framework.
1680 #define GetCurrentThread PAL_GetCurrentThread
1688 #define STARTF_USESTDHANDLES 0x00000100
1690 typedef struct _STARTUPINFOW {
1692 LPWSTR lpReserved_PAL_Undefined;
1693 LPWSTR lpDesktop_PAL_Undefined;
1694 LPWSTR lpTitle_PAL_Undefined;
1695 DWORD dwX_PAL_Undefined;
1696 DWORD dwY_PAL_Undefined;
1697 DWORD dwXSize_PAL_Undefined;
1698 DWORD dwYSize_PAL_Undefined;
1699 DWORD dwXCountChars_PAL_Undefined;
1700 DWORD dwYCountChars_PAL_Undefined;
1701 DWORD dwFillAttribute_PAL_Undefined;
1703 WORD wShowWindow_PAL_Undefined;
1704 WORD cbReserved2_PAL_Undefined;
1705 LPBYTE lpReserved2_PAL_Undefined;
1709 } STARTUPINFOW, *LPSTARTUPINFOW;
1711 typedef struct _STARTUPINFOA {
1713 LPSTR lpReserved_PAL_Undefined;
1714 LPSTR lpDesktop_PAL_Undefined;
1715 LPSTR lpTitle_PAL_Undefined;
1716 DWORD dwX_PAL_Undefined;
1717 DWORD dwY_PAL_Undefined;
1718 DWORD dwXSize_PAL_Undefined;
1719 DWORD dwYSize_PAL_Undefined;
1720 DWORD dwXCountChars_PAL_Undefined;
1721 DWORD dwYCountChars_PAL_Undefined;
1722 DWORD dwFillAttribute_PAL_Undefined;
1724 WORD wShowWindow_PAL_Undefined;
1725 WORD cbReserved2_PAL_Undefined;
1726 LPBYTE lpReserved2_PAL_Undefined;
1730 } STARTUPINFOA, *LPSTARTUPINFOA;
1733 typedef STARTUPINFOW STARTUPINFO;
1734 typedef LPSTARTUPINFOW LPSTARTUPINFO;
1736 typedef STARTUPINFOA STARTUPINFO;
1737 typedef LPSTARTUPINFOW LPSTARTUPINFO;
1740 #define CREATE_NEW_CONSOLE 0x00000010
1742 #define NORMAL_PRIORITY_CLASS 0x00000020
1744 typedef struct _PROCESS_INFORMATION {
1748 DWORD dwThreadId_PAL_Undefined;
1749 } PROCESS_INFORMATION, *PPROCESS_INFORMATION, *LPPROCESS_INFORMATION;
1755 IN LPCSTR lpApplicationName,
1756 IN LPSTR lpCommandLine,
1757 IN LPSECURITY_ATTRIBUTES lpProcessAttributes,
1758 IN LPSECURITY_ATTRIBUTES lpThreadAttributes,
1759 IN BOOL bInheritHandles,
1760 IN DWORD dwCreationFlags,
1761 IN LPVOID lpEnvironment,
1762 IN LPCSTR lpCurrentDirectory,
1763 IN LPSTARTUPINFOA lpStartupInfo,
1764 OUT LPPROCESS_INFORMATION lpProcessInformation);
1770 IN LPCWSTR lpApplicationName,
1771 IN LPWSTR lpCommandLine,
1772 IN LPSECURITY_ATTRIBUTES lpProcessAttributes,
1773 IN LPSECURITY_ATTRIBUTES lpThreadAttributes,
1774 IN BOOL bInheritHandles,
1775 IN DWORD dwCreationFlags,
1776 IN LPVOID lpEnvironment,
1777 IN LPCWSTR lpCurrentDirectory,
1778 IN LPSTARTUPINFOW lpStartupInfo,
1779 OUT LPPROCESS_INFORMATION lpProcessInformation);
1782 #define CreateProcess CreateProcessW
1784 #define CreateProcess CreateProcessA
1806 IN LPDWORD lpExitCode);
1813 OUT LPFILETIME lpCreationTime,
1814 OUT LPFILETIME lpExitTime,
1815 OUT LPFILETIME lpKernelTime,
1816 OUT LPFILETIME lpUserTime);
1818 #define MAXIMUM_WAIT_OBJECTS 64
1819 #define WAIT_OBJECT_0 0
1820 #define WAIT_ABANDONED 0x00000080
1821 #define WAIT_ABANDONED_0 0x00000080
1822 #define WAIT_TIMEOUT 258
1823 #define WAIT_FAILED ((DWORD)0xFFFFFFFF)
1825 #define INFINITE 0xFFFFFFFF // Infinite timeout
1830 WaitForSingleObject(
1832 IN DWORD dwMilliseconds);
1837 WaitForSingleObjectEx(
1839 IN DWORD dwMilliseconds,
1840 IN BOOL bAlertable);
1845 WaitForMultipleObjects(
1847 IN CONST HANDLE *lpHandles,
1849 IN DWORD dwMilliseconds);
1854 WaitForMultipleObjectsEx(
1856 IN CONST HANDLE *lpHandles,
1858 IN DWORD dwMilliseconds,
1859 IN BOOL bAlertable);
1864 PAL_LocalHandleToRemote(
1870 PAL_RemoteHandleToLocal(
1871 IN RHANDLE hRemote);
1874 #define DUPLICATE_CLOSE_SOURCE 0x00000001
1875 #define DUPLICATE_SAME_ACCESS 0x00000002
1881 IN HANDLE hSourceProcessHandle,
1882 IN HANDLE hSourceHandle,
1883 IN HANDLE hTargetProcessHandle,
1884 OUT LPHANDLE lpTargetHandle,
1885 IN DWORD dwDesiredAccess,
1886 IN BOOL bInheritHandle,
1887 IN DWORD dwOptions);
1893 IN DWORD dwMilliseconds);
1899 IN DWORD dwMilliseconds,
1900 IN BOOL bAlertable);
1908 #define DEBUG_PROCESS 0x00000001
1909 #define DEBUG_ONLY_THIS_PROCESS 0x00000002
1910 #define CREATE_SUSPENDED 0x00000004
1911 #define STACK_SIZE_PARAM_IS_A_RESERVATION 0x00010000
1917 IN LPSECURITY_ATTRIBUTES lpThreadAttributes,
1918 IN DWORD dwStackSize,
1919 IN LPTHREAD_START_ROUTINE lpStartAddress,
1920 IN LPVOID lpParameter,
1921 IN DWORD dwCreationFlags,
1922 OUT LPDWORD lpThreadId);
1929 IN DWORD dwExitCode);
1936 IN LPDWORD lpExitCode);
1950 typedef VOID (PALAPI *PAPCFUNC)(ULONG_PTR dwParam);
1958 IN ULONG_PTR dwData);
1963 // ***********************************************************************************
1965 // NOTE: These context definitions are replicated in ndp/clr/src/debug/inc/DbgTargetContext.h (for the
1966 // purposes manipulating contexts from different platforms during remote debugging). Be sure to keep those
1967 // definitions in sync if you make any changes here.
1969 // ***********************************************************************************
1972 #define SIZE_OF_80387_REGISTERS 80
1974 #define CONTEXT_i386 0x00010000
1975 #define CONTEXT_CONTROL (CONTEXT_i386 | 0x00000001L) // SS:SP, CS:IP, FLAGS, BP
1976 #define CONTEXT_INTEGER (CONTEXT_i386 | 0x00000002L) // AX, BX, CX, DX, SI, DI
1977 #define CONTEXT_SEGMENTS (CONTEXT_i386 | 0x00000004L)
1978 #define CONTEXT_FLOATING_POINT (CONTEXT_i386 | 0x00000008L) // 387 state
1979 #define CONTEXT_DEBUG_REGISTERS (CONTEXT_i386 | 0x00000010L)
1981 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS)
1982 #define CONTEXT_EXTENDED_REGISTERS (CONTEXT_i386 | 0x00000020L)
1983 #define CONTEXT_ALL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS | CONTEXT_FLOATING_POINT | CONTEXT_DEBUG_REGISTERS | CONTEXT_EXTENDED_REGISTERS)
1985 #define MAXIMUM_SUPPORTED_EXTENSION 512
1987 typedef struct _FLOATING_SAVE_AREA {
1992 DWORD ErrorSelector;
1995 BYTE RegisterArea[SIZE_OF_80387_REGISTERS];
1997 } FLOATING_SAVE_AREA;
1999 typedef FLOATING_SAVE_AREA *PFLOATING_SAVE_AREA;
2001 typedef struct _CONTEXT {
2004 ULONG Dr0_PAL_Undefined;
2005 ULONG Dr1_PAL_Undefined;
2006 ULONG Dr2_PAL_Undefined;
2007 ULONG Dr3_PAL_Undefined;
2008 ULONG Dr6_PAL_Undefined;
2009 ULONG Dr7_PAL_Undefined;
2011 FLOATING_SAVE_AREA FloatSave;
2013 ULONG SegGs_PAL_Undefined;
2014 ULONG SegFs_PAL_Undefined;
2015 ULONG SegEs_PAL_Undefined;
2016 ULONG SegDs_PAL_Undefined;
2032 UCHAR ExtendedRegisters[MAXIMUM_SUPPORTED_EXTENSION];
2034 } CONTEXT, *PCONTEXT, *LPCONTEXT;
2036 // To support saving and loading xmm register context we need to know the offset in the ExtendedRegisters
2037 // section at which they are stored. This has been determined experimentally since I have found no
2038 // documentation thus far but it corresponds to the offset we'd expect if a fxsave instruction was used to
2039 // store the regular FP state along with the XMM registers at the start of the extended registers section.
2040 // Technically the offset doesn't really matter if no code in the PAL or runtime knows what the offset should
2041 // be either (as long as we're consistent across GetThreadContext() and SetThreadContext() and we don't
2042 // support any other values in the ExtendedRegisters) but we might as well be as accurate as we can.
2043 #define CONTEXT_EXREG_XMM_OFFSET 160
2045 #elif defined(_PPC_)
2048 // ***********************************************************************************
2050 // NOTE: These context definitions are replicated in ndp/clr/src/debug/inc/DbgTargetContext.h (for the
2051 // purposes manipulating contexts from different platforms during remote debugging). Be sure to keep those
2052 // definitions in sync if you make any changes here.
2054 // ***********************************************************************************
2057 #define CONTEXT_CONTROL 0x00000001L
2058 #define CONTEXT_FLOATING_POINT 0x00000002L
2059 #define CONTEXT_INTEGER 0x00000004L
2061 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER)
2062 #define CONTEXT_ALL CONTEXT_FULL
2064 typedef struct _CONTEXT {
2067 // This section is specified/returned if the ContextFlags word contains
2068 // the flag CONTEXT_FLOATING_POINT.
2071 double Fpr0; // Floating registers 0..31
2103 double Fpscr; // Floating point status/control reg
2106 // This section is specified/returned if the ContextFlags word contains
2107 // the flag CONTEXT_INTEGER.
2110 ULONG Gpr0; // General registers 0..31
2111 ULONG Gpr1; // StackPointer
2143 ULONG Cr; // Condition register
2144 ULONG Xer; // Fixed point exception register
2147 // This section is specified/returned if the ContextFlags word contains
2148 // the flag CONTEXT_CONTROL.
2151 ULONG Msr; // Machine status register
2152 ULONG Iar; // Instruction address register
2153 ULONG Lr; // Link register
2154 ULONG Ctr; // Count register
2157 // The flags values within this flag control the contents of
2158 // a CONTEXT record.
2160 // If the context record is used as an input parameter, then
2161 // for each portion of the context record controlled by a flag
2162 // whose value is set, it is assumed that that portion of the
2163 // context record contains valid context. If the context record
2164 // is being used to modify a thread's context, then only that
2165 // portion of the threads context will be modified.
2167 // If the context record is used as an IN OUT parameter to capture
2168 // the context of a thread, then only those portions of the thread's
2169 // context corresponding to set flags will be returned.
2171 // The context record is never used as an OUT only parameter.
2176 ULONG Fill[3]; // Pad out to multiple of 16 bytes
2179 // This section is specified/returned if CONTEXT_DEBUG_REGISTERS is
2180 // set in ContextFlags. Note that CONTEXT_DEBUG_REGISTERS is NOT
2181 // included in CONTEXT_FULL.
2183 ULONG Dr0; // Breakpoint Register 1
2184 ULONG Dr1; // Breakpoint Register 2
2185 ULONG Dr2; // Breakpoint Register 3
2186 ULONG Dr3; // Breakpoint Register 4
2187 ULONG Dr4; // Breakpoint Register 5
2188 ULONG Dr5; // Breakpoint Register 6
2189 ULONG Dr6; // Debug Status Register
2190 ULONG Dr7; // Debug Control Register
2192 } CONTEXT, *PCONTEXT, *LPCONTEXT;
2194 #elif defined(_SPARC_)
2196 #define CONTEXT_CONTROL 0x00000001L
2197 #define CONTEXT_FLOATING_POINT 0x00000002L
2198 #define CONTEXT_INTEGER 0x00000004L
2200 #define COUNT_FLOATING_REGISTER 32
2201 #define COUNT_DOUBLE_REGISTER 16
2202 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER)
2203 #define CONTEXT_ALL CONTEXT_FULL
2205 typedef struct _CONTEXT {
2207 // This section is specified/returned if the ContextFlags word contains
2208 // the flag CONTEXT_INTEGER.
2246 // This section is specified/returned if the ContextFlags word contains
2247 // the flag CONTEXT_CONTROL.
2249 #if defined(__sparcv9)
2254 ULONG pc; // program counter
2255 ULONG npc; // next address to be executed
2260 // This section is specified/returned if the ContextFlags word contains
2261 // the flag CONTEXT_FLOATING_POINT.
2265 float f[COUNT_FLOATING_REGISTER];
2266 double d[COUNT_DOUBLE_REGISTER];
2269 } CONTEXT, *PCONTEXT, *LPCONTEXT;
2271 #elif defined(_PARISC_)
2273 // ToDo: Get this correct for PARISC architecture
2274 #define CONTEXT_CONTROL 0x00000001L
2275 #define CONTEXT_FLOATING_POINT 0x00000002L
2276 #define CONTEXT_INTEGER 0x00000004L
2278 #define COUNT_FLOATING_REGISTER 32
2279 #define COUNT_DOUBLE_REGISTER 16
2280 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER)
2281 #define CONTEXT_ALL CONTEXT_FULL
2283 typedef struct _CONTEXT {
2285 // This section is specified/returned if the ContextFlags word contains
2286 // the flag CONTEXT_INTEGER.
2324 // This section is specified/returned if the ContextFlags word contains
2325 // the flag CONTEXT_CONTROL.
2328 ULONG pc; // program counter
2329 ULONG npc; // next address to be executed
2334 // This section is specified/returned if the ContextFlags word contains
2335 // the flag CONTEXT_FLOATING_POINT.
2339 float f[COUNT_FLOATING_REGISTER];
2340 double d[COUNT_DOUBLE_REGISTER];
2343 } CONTEXT, *PCONTEXT, *LPCONTEXT;
2345 #elif defined(_IA64_)
2347 // copied from winnt.h
2348 typedef struct _FLOAT128 {
2353 typedef FLOAT128 *PFLOAT128;
2355 // begin_ntddk begin_nthal
2358 // The following flags control the contents of the CONTEXT structure.
2361 #if !defined(RC_INVOKED)
2363 #define CONTEXT_IA64 0x00080000
2365 #define CONTEXT_CONTROL (CONTEXT_IA64 | 0x00000001L)
2366 #define CONTEXT_LOWER_FLOATING_POINT (CONTEXT_IA64 | 0x00000002L)
2367 #define CONTEXT_HIGHER_FLOATING_POINT (CONTEXT_IA64 | 0x00000004L)
2368 #define CONTEXT_INTEGER (CONTEXT_IA64 | 0x00000008L)
2369 #define CONTEXT_DEBUG (CONTEXT_IA64 | 0x00000010L)
2370 #define CONTEXT_IA32_CONTROL (CONTEXT_IA64 | 0x00000020L) // Includes StIPSR
2373 #define CONTEXT_FLOATING_POINT (CONTEXT_LOWER_FLOATING_POINT | CONTEXT_HIGHER_FLOATING_POINT)
2374 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER | CONTEXT_IA32_CONTROL)
2375 #define CONTEXT_ALL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER | CONTEXT_DEBUG | CONTEXT_IA32_CONTROL)
2377 #define CONTEXT_EXCEPTION_ACTIVE 0x8000000
2378 #define CONTEXT_SERVICE_ACTIVE 0x10000000
2379 #define CONTEXT_EXCEPTION_REQUEST 0x40000000
2380 #define CONTEXT_EXCEPTION_REPORTING 0x80000000
2382 #endif // !defined(RC_INVOKED)
2387 // This frame has a several purposes: 1) it is used as an argument to
2388 // NtContinue, 2) it is used to construct a call frame for APC delivery,
2389 // 3) it is used to construct a call frame for exception dispatching
2390 // in user mode, 4) it is used in the user level thread creation
2391 // routines, and 5) it is used to to pass thread state to debuggers.
2393 // N.B. Because this record is used as a call frame, it must be EXACTLY
2394 // a multiple of 16 bytes in length and aligned on a 16-byte boundary.
2397 typedef struct _CONTEXT {
2400 // The flags values within this flag control the contents of
2401 // a CONTEXT record.
2403 // If the context record is used as an input parameter, then
2404 // for each portion of the context record controlled by a flag
2405 // whose value is set, it is assumed that that portion of the
2406 // context record contains valid context. If the context record
2407 // is being used to modify a thread's context, then only that
2408 // portion of the threads context will be modified.
2410 // If the context record is used as an IN OUT parameter to capture
2411 // the context of a thread, then only those portions of the thread's
2412 // context corresponding to set flags will be returned.
2414 // The context record is never used as an OUT only parameter.
2418 DWORD Fill1[3]; // for alignment of following on 16-byte boundary
2421 // This section is specified/returned if the ContextFlags word contains
2422 // the flag CONTEXT_DEBUG.
2424 // N.B. CONTEXT_DEBUG is *not* part of CONTEXT_FULL.
2446 // This section is specified/returned if the ContextFlags word contains
2447 // the flag CONTEXT_LOWER_FLOATING_POINT.
2466 // This section is specified/returned if the ContextFlags word contains
2467 // the flag CONTEXT_HIGHER_FLOATING_POINT.
2594 // This section is specified/returned if the ContextFlags word contains
2595 // the flag CONTEXT_LOWER_FLOATING_POINT | CONTEXT_HIGHER_FLOATING_POINT | CONTEXT_CONTROL.
2598 ULONGLONG StFPSR; // FP status
2601 // This section is specified/returned if the ContextFlags word contains
2602 // the flag CONTEXT_INTEGER.
2604 // N.B. The registers gp, sp, rp are part of the control context
2607 ULONGLONG IntGp; // r1, volatile
2608 ULONGLONG IntT0; // r2-r3, volatile
2610 ULONGLONG IntS0; // r4-r7, preserved
2614 ULONGLONG IntV0; // r8, volatile
2615 ULONGLONG IntT2; // r9-r11, volatile
2618 ULONGLONG IntSp; // stack pointer (r12), special
2619 ULONGLONG IntTeb; // teb (r13), special
2620 ULONGLONG IntT5; // r14-r31, volatile
2639 ULONGLONG IntNats; // Nat bits for r1-r31
2640 // r1-r31 in bits 1 thru 31.
2641 ULONGLONG Preds; // predicates, preserved
2643 ULONGLONG BrRp; // return pointer, b0, preserved
2644 ULONGLONG BrS0; // b1-b5, preserved
2649 ULONGLONG BrT0; // b6-b7, volatile
2653 // This section is specified/returned if the ContextFlags word contains
2654 // the flag CONTEXT_CONTROL.
2657 // Other application registers
2658 ULONGLONG ApUNAT; // User Nat collection register, preserved
2659 ULONGLONG ApLC; // Loop counter register, preserved
2660 ULONGLONG ApEC; // Epilog counter register, preserved
2661 ULONGLONG ApCCV; // CMPXCHG value register, volatile
2662 ULONGLONG ApDCR; // Default control register (TBD)
2664 // Register stack info
2665 ULONGLONG RsPFS; // Previous function state, preserved
2666 ULONGLONG RsBSP; // Backing store pointer, preserved
2667 ULONGLONG RsBSPSTORE;
2668 ULONGLONG RsRSC; // RSE configuration, volatile
2669 ULONGLONG RsRNAT; // RSE Nat collection register, preserved
2671 // Trap Status Information
2672 ULONGLONG StIPSR; // Interruption Processor Status
2673 ULONGLONG StIIP; // Interruption IP
2674 ULONGLONG StIFS; // Interruption Function State
2676 // iA32 related control registers
2677 ULONGLONG StFCR; // copy of Ar21
2678 ULONGLONG Eflag; // Eflag copy of Ar24
2679 ULONGLONG SegCSD; // iA32 CSDescriptor (Ar25)
2680 ULONGLONG SegSSD; // iA32 SSDescriptor (Ar26)
2681 ULONGLONG Cflag; // Cr0+Cr4 copy of Ar27
2682 ULONGLONG StFSR; // x86 FP status (copy of AR28)
2683 ULONGLONG StFIR; // x86 FP status (copy of AR29)
2684 ULONGLONG StFDR; // x86 FP status (copy of AR30)
2686 ULONGLONG UNUSEDPACK; // added to pack StFDR to 16-bytes
2688 } CONTEXT, *PCONTEXT, *LPCONTEXT;
2689 #elif defined(_AMD64_)
2690 // copied from winnt.h
2692 #define CONTEXT_AMD64 0x100000
2694 #define CONTEXT_CONTROL (CONTEXT_AMD64 | 0x1L)
2695 #define CONTEXT_INTEGER (CONTEXT_AMD64 | 0x2L)
2696 #define CONTEXT_SEGMENTS (CONTEXT_AMD64 | 0x4L)
2697 #define CONTEXT_FLOATING_POINT (CONTEXT_AMD64 | 0x8L)
2698 #define CONTEXT_DEBUG_REGISTERS (CONTEXT_AMD64 | 0x10L)
2700 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_FLOATING_POINT)
2702 #define CONTEXT_ALL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS | CONTEXT_FLOATING_POINT | CONTEXT_DEBUG_REGISTERS)
2704 #define CONTEXT_EXCEPTION_ACTIVE 0x8000000
2705 #define CONTEXT_SERVICE_ACTIVE 0x10000000
2706 #define CONTEXT_EXCEPTION_REQUEST 0x40000000
2707 #define CONTEXT_EXCEPTION_REPORTING 0x80000000
2709 typedef struct DECLSPEC_ALIGN(16) _M128A {
2714 typedef struct _XMM_SAVE_AREA32 {
2728 M128A FloatRegisters[8];
2729 M128A XmmRegisters[16];
2731 } XMM_SAVE_AREA32, *PXMM_SAVE_AREA32;
2733 #define LEGACY_SAVE_AREA_LENGTH sizeof(XMM_SAVE_AREA32)
2738 // This frame has a several purposes: 1) it is used as an argument to
2739 // NtContinue, 2) is is used to constuct a call frame for APC delivery,
2740 // and 3) it is used in the user level thread creation routines.
2743 // The flags field within this record controls the contents of a CONTEXT
2746 // If the context record is used as an input parameter, then for each
2747 // portion of the context record controlled by a flag whose value is
2748 // set, it is assumed that that portion of the context record contains
2749 // valid context. If the context record is being used to modify a threads
2750 // context, then only that portion of the threads context is modified.
2752 // If the context record is used as an output parameter to capture the
2753 // context of a thread, then only those portions of the thread's context
2754 // corresponding to set flags will be returned.
2756 // CONTEXT_CONTROL specifies SegSs, Rsp, SegCs, Rip, and EFlags.
2758 // CONTEXT_INTEGER specifies Rax, Rcx, Rdx, Rbx, Rbp, Rsi, Rdi, and R8-R15.
2760 // CONTEXT_SEGMENTS specifies SegDs, SegEs, SegFs, and SegGs.
2762 // CONTEXT_DEBUG_REGISTERS specifies Dr0-Dr3 and Dr6-Dr7.
2764 // CONTEXT_MMX_REGISTERS specifies the floating point and extended registers
2765 // Mm0/St0-Mm7/St7 and Xmm0-Xmm15).
2768 typedef struct DECLSPEC_ALIGN(16) _CONTEXT {
2771 // Register parameter home addresses.
2773 // N.B. These fields are for convience - they could be used to extend the
2774 // context record in the future.
2792 // Segment Registers and processor flags.
2815 // Integer registers.
2842 // Floating point state.
2846 XMM_SAVE_AREA32 FltSave;
2870 // Vector registers.
2873 M128A VectorRegister[26];
2874 DWORD64 VectorControl;
2877 // Special debug control registers.
2880 DWORD64 DebugControl;
2881 DWORD64 LastBranchToRip;
2882 DWORD64 LastBranchFromRip;
2883 DWORD64 LastExceptionToRip;
2884 DWORD64 LastExceptionFromRip;
2885 } CONTEXT, *PCONTEXT, *LPCONTEXT;
2888 // Nonvolatile context pointer record.
2891 typedef struct _KNONVOLATILE_CONTEXT_POINTERS {
2893 PM128A FloatingContext[16];
2915 PDWORD64 IntegerContext[16];
2936 } KNONVOLATILE_CONTEXT_POINTERS, *PKNONVOLATILE_CONTEXT_POINTERS;
2939 #error Unknown architecture for defining CONTEXT.
2948 IN OUT LPCONTEXT lpContext);
2955 IN CONST CONTEXT *lpContext);
2957 #define THREAD_BASE_PRIORITY_LOWRT 15
2958 #define THREAD_BASE_PRIORITY_MAX 2
2959 #define THREAD_BASE_PRIORITY_MIN (-2)
2960 #define THREAD_BASE_PRIORITY_IDLE (-15)
2962 #define THREAD_PRIORITY_LOWEST THREAD_BASE_PRIORITY_MIN
2963 #define THREAD_PRIORITY_BELOW_NORMAL (THREAD_PRIORITY_LOWEST+1)
2964 #define THREAD_PRIORITY_NORMAL 0
2965 #define THREAD_PRIORITY_HIGHEST THREAD_BASE_PRIORITY_MAX
2966 #define THREAD_PRIORITY_ABOVE_NORMAL (THREAD_PRIORITY_HIGHEST-1)
2967 #define THREAD_PRIORITY_ERROR_RETURN (MAXLONG)
2969 #define THREAD_PRIORITY_TIME_CRITICAL THREAD_BASE_PRIORITY_LOWRT
2970 #define THREAD_PRIORITY_IDLE THREAD_BASE_PRIORITY_IDLE
2990 OUT LPFILETIME lpCreationTime,
2991 OUT LPFILETIME lpExitTime,
2992 OUT LPFILETIME lpKernelTime,
2993 OUT LPFILETIME lpUserTime);
2995 #define TLS_OUT_OF_INDEXES ((DWORD)0xFFFFFFFF)
3007 IN DWORD dwTlsIndex);
3013 IN DWORD dwTlsIndex,
3014 IN LPVOID lpTlsValue);
3020 IN DWORD dwTlsIndex);
3030 PAL_GetStackLimit();
3032 #ifdef PLATFORM_UNIX
3034 #if defined(__FreeBSD__) && defined(_X86_)
3035 #define PAL_CS_NATIVE_DATA_SIZE 12
3036 #elif defined(__sun__)
3037 #define PAL_CS_NATIVE_DATA_SIZE 48
3038 #elif defined(__hpux__) && (defined(__hppa__) || defined (__ia64__))
3039 #define PAL_CS_NATIVE_DATA_SIZE 148
3041 #define PAL_CS_NATIVE_DATA_SIZE 100
3042 #elif defined(__APPLE__) && defined(__i386__)
3043 #define PAL_CS_NATIVE_DATA_SIZE 76
3044 #elif defined(__APPLE__) && defined(__x86_64__)
3045 #define PAL_CS_NATIVE_DATA_SIZE 120
3046 #elif defined(__LINUX__) && defined(__x86_64__)
3047 #define PAL_CS_NATIVE_DATA_SIZE 96
3049 #error PAL_CS_NATIVE_DATA_SIZE is not defined for this architecture
3052 #endif // PLATFORM_UNIX
3055 typedef struct _CRITICAL_SECTION {
3058 LONG RecursionCount;
3059 HANDLE OwningThread;
3060 HANDLE LockSemaphore;
3061 ULONG_PTR SpinCount;
3063 #ifdef PLATFORM_UNIX
3065 volatile DWORD dwInitState;
3066 union CSNativeDataStorage
3068 BYTE rgNativeDataStorage[PAL_CS_NATIVE_DATA_SIZE];
3069 VOID * pvAlign; // make sure the storage is machine-pointer-size aligned
3071 #endif // PLATFORM_UNIX
3072 } CRITICAL_SECTION, *PCRITICAL_SECTION, *LPCRITICAL_SECTION;
3074 PALIMPORT VOID PALAPI EnterCriticalSection(IN OUT LPCRITICAL_SECTION lpCriticalSection);
3075 PALIMPORT VOID PALAPI LeaveCriticalSection(IN OUT LPCRITICAL_SECTION lpCriticalSection);
3076 PALIMPORT VOID PALAPI InitializeCriticalSection(OUT LPCRITICAL_SECTION lpCriticalSection);
3077 PALIMPORT VOID PALAPI DeleteCriticalSection(IN OUT LPCRITICAL_SECTION lpCriticalSection);
3078 PALIMPORT BOOL PALAPI TryEnterCriticalSection(IN OUT LPCRITICAL_SECTION lpCriticalSection);
3080 #define SEM_FAILCRITICALERRORS 0x0001
3081 #define SEM_NOOPENFILEERRORBOX 0x8000
3089 #define PAGE_NOACCESS 0x01
3090 #define PAGE_READONLY 0x02
3091 #define PAGE_READWRITE 0x04
3092 #define PAGE_WRITECOPY 0x08
3093 #define PAGE_EXECUTE 0x10
3094 #define PAGE_EXECUTE_READ 0x20
3095 #define PAGE_EXECUTE_READWRITE 0x40
3096 #define PAGE_EXECUTE_WRITECOPY 0x80
3097 #define MEM_COMMIT 0x1000
3098 #define MEM_RESERVE 0x2000
3099 #define MEM_DECOMMIT 0x4000
3100 #define MEM_RELEASE 0x8000
3101 #define MEM_FREE 0x10000
3102 #define MEM_PRIVATE 0x20000
3103 #define MEM_MAPPED 0x40000
3104 #define MEM_TOP_DOWN 0x100000
3105 #define MEM_WRITE_WATCH 0x200000
3112 IN LPSECURITY_ATTRIBUTES lpFileMappingAttributes,
3114 IN DWORD dwMaximumSizeHigh,
3115 IN DWORD dwMaximumSizeLow,
3123 IN LPSECURITY_ATTRIBUTES lpFileMappingAttributes,
3125 IN DWORD dwMaxmimumSizeHigh,
3126 IN DWORD dwMaximumSizeLow,
3130 #define CreateFileMapping CreateFileMappingW
3132 #define CreateFileMapping CreateFileMappingA
3135 #define SECTION_QUERY 0x0001
3136 #define SECTION_MAP_WRITE 0x0002
3137 #define SECTION_MAP_READ 0x0004
3138 #define SECTION_ALL_ACCESS (SECTION_MAP_READ | SECTION_MAP_WRITE) // diff from winnt.h
3140 #define FILE_MAP_WRITE SECTION_MAP_WRITE
3141 #define FILE_MAP_READ SECTION_MAP_READ
3142 #define FILE_MAP_ALL_ACCESS SECTION_ALL_ACCESS
3143 #define FILE_MAP_COPY SECTION_QUERY
3149 IN DWORD dwDesiredAccess,
3150 IN BOOL bInheritHandle,
3157 IN DWORD dwDesiredAccess,
3158 IN BOOL bInheritHandle,
3162 #define OpenFileMapping OpenFileMappingW
3164 #define OpenFileMapping OpenFileMappingA
3171 IN HANDLE hFileMappingObject,
3172 IN DWORD dwDesiredAccess,
3173 IN DWORD dwFileOffsetHigh,
3174 IN DWORD dwFileOffsetLow,
3175 IN SIZE_T dwNumberOfBytesToMap);
3181 IN HANDLE hFileMappingObject,
3182 IN DWORD dwDesiredAccess,
3183 IN DWORD dwFileOffsetHigh,
3184 IN DWORD dwFileOffsetLow,
3185 IN SIZE_T dwNumberOfBytesToMap,
3186 IN LPVOID lpBaseAddress);
3192 IN LPVOID lpBaseAddress,
3193 IN SIZE_T dwNumberOfBytesToFlush);
3199 IN LPCVOID lpBaseAddress);
3205 IN LPCSTR lpLibFileName);
3211 IN LPCWSTR lpLibFileName);
3217 IN LPCSTR lpLibFileName,
3218 IN /*Reserved*/ HANDLE hFile,
3225 IN LPCWSTR lpLibFileName,
3226 IN /*Reserved*/ HANDLE hFile,
3234 Loads a PE file into memory. Properly maps all of the sections in the PE file. Returns a pointer to the
3238 IN hFile - The file to load
3241 A valid base address if successful.
3244 void * PAL_LOADLoadPEFile(HANDLE hFile);
3247 PAL_LOADUnloadPEFile
3249 Unload a PE file that was loaded by PAL_LOADLoadPEFile().
3252 IN ptr - the file pointer returned by PAL_LOADLoadPEFile()
3256 FALSE - failure (incorrect ptr, etc.)
3259 BOOL PAL_LOADUnloadPEFile(void * ptr);
3263 #define LoadLibrary LoadLibraryW
3264 #define LoadLibraryEx LoadLibraryExW
3266 #define LoadLibrary LoadLibraryA
3267 #define LoadLibraryEx LoadLibraryExA
3270 typedef INT_PTR (PALAPI *FARPROC)();
3277 IN LPCSTR lpProcName);
3283 IN OUT HMODULE hLibModule);
3289 FreeLibraryAndExitThread(
3290 IN HMODULE hLibModule,
3291 IN DWORD dwExitCode);
3296 DisableThreadLibraryCalls(
3297 IN HMODULE hLibModule);
3304 OUT LPSTR lpFileName,
3312 OUT LPWSTR lpFileName,
3316 #define GetModuleFileName GetModuleFileNameW
3318 #define GetModuleFileName GetModuleFileNameA
3321 // Get base address of the coreclr module
3324 PAL_GetCoreClrModuleBase();
3330 IN LPVOID lpAddress,
3332 IN DWORD flAllocationType,
3333 IN DWORD flProtect);
3339 IN LPVOID lpAddress,
3341 IN DWORD dwFreeType);
3347 IN LPVOID lpAddress,
3349 IN DWORD flNewProtect,
3350 OUT PDWORD lpflOldProtect);
3352 #if defined(_AMD64_)
3353 typedef struct _MEMORYSTATUSEX {
3356 DWORDLONG ullTotalPhys;
3357 DWORDLONG ullAvailPhys;
3358 DWORDLONG ullTotalPageFile;
3359 DWORDLONG ullAvailPageFile;
3360 DWORDLONG ullTotalVirtual;
3361 DWORDLONG ullAvailVirtual;
3362 DWORDLONG ullAvailExtendedVirtual;
3363 } MEMORYSTATUSEX, *LPMEMORYSTATUSEX;
3368 GlobalMemoryStatusEx(
3369 IN OUT LPMEMORYSTATUSEX lpBuffer);
3373 typedef struct _MEMORY_BASIC_INFORMATION {
3375 PVOID AllocationBase_PAL_Undefined;
3376 DWORD AllocationProtect;
3381 } MEMORY_BASIC_INFORMATION, *PMEMORY_BASIC_INFORMATION;
3387 IN LPCVOID lpAddress,
3388 OUT PMEMORY_BASIC_INFORMATION lpBuffer,
3389 IN SIZE_T dwLength);
3396 IN LPCVOID lpBaseAddress,
3397 OUT LPVOID lpBuffer,
3399 OUT SIZE_T * lpNumberOfBytesRead);
3405 IN PVOID Destination,
3406 IN CONST VOID *Source,
3413 IN PVOID Destination,
3416 #define MoveMemory memmove
3417 #define CopyMemory memcpy
3418 #define FillMemory(Destination,Length,Fill) memset((Destination),(Fill),(Length))
3419 #define ZeroMemory(Destination,Length) memset((Destination),0,(Length))
3428 #define HEAP_ZERO_MEMORY 0x00000008
3436 IN SIZE_T dwInitialSize,
3437 IN SIZE_T dwMaximumSize);
3466 typedef enum _HEAP_INFORMATION_CLASS {
3467 HeapCompatibilityInformation,
3468 HeapEnableTerminationOnCorruption
3469 } HEAP_INFORMATION_CLASS;
3475 IN OPTIONAL HANDLE HeapHandle,
3476 IN HEAP_INFORMATION_CLASS HeapInformationClass,
3477 IN PVOID HeapInformation,
3478 IN SIZE_T HeapInformationLength);
3480 #define LMEM_FIXED 0x0000
3481 #define LMEM_ZEROINIT 0x0040
3482 #define LPTR (LMEM_FIXED | LMEM_ZEROINIT)
3500 FlushInstructionCache(
3502 IN LPCVOID lpBaseAddress,
3505 #if ENABLE_DOWNLEVEL_FOR_NLS
3512 IN DWORD dwInfoType,
3513 IN LPCWSTR lpSrcStr,
3515 OUT LPWORD lpCharType);
3518 #define GetStringTypeEx GetStringTypeExW
3521 #endif // ENABLE_DOWNLEVEL_FOR_NLS
3524 #define NORM_IGNORECASE 0x00000001 // ignore case
3525 #define NORM_IGNOREWIDTH 0x00020000 // ignore width
3527 #define NORM_LINGUISTIC_CASING 0x08000000 // use linguistic rules for casing
3530 #define NORM_IGNORENONSPACE 0x00000002 // ignore nonspacing chars
3531 #define NORM_IGNORESYMBOLS 0x00000004 // ignore symbols
3532 #define NORM_IGNOREKANATYPE 0x00010000 // ignore kanatype
3533 #define SORT_STRINGSORT 0x00001000 // use string sort method
3537 typedef struct nlsversioninfo {
3538 DWORD dwNLSVersionInfoSize;
3540 DWORD dwDefinedVersion;
3541 } NLSVERSIONINFO, *LPNLSVERSIONINFO;
3543 #define CSTR_LESS_THAN 1
3544 #define CSTR_EQUAL 2
3545 #define CSTR_GREATER_THAN 3
3547 #if ENABLE_DOWNLEVEL_FOR_NLS
3555 IN DWORD dwCmpFlags,
3556 IN LPCSTR lpString1,
3558 IN LPCSTR lpString2,
3566 IN DWORD dwCmpFlags,
3567 IN LPCWSTR lpString1,
3569 IN LPCWSTR lpString2,
3572 #endif // ENABLE_DOWNLEVEL_FOR_NLS
3579 IN LPCWSTR lpLocaleName,
3580 IN DWORD dwCmpFlags,
3581 IN LPCWSTR lpString1,
3583 IN LPCWSTR lpString2,
3585 IN LPNLSVERSIONINFO lpVersionInformation,
3586 IN LPVOID lpReserved,
3591 #define CompareString CompareStringW
3594 #define MAX_LEADBYTES 12
3595 #define MAX_DEFAULTCHAR 2
3602 typedef struct _cpinfo {
3604 BYTE DefaultChar[MAX_DEFAULTCHAR];
3605 BYTE LeadByte[MAX_LEADBYTES];
3606 } CPINFO, *LPCPINFO;
3613 OUT LPCPINFO lpCPInfo);
3635 #define MB_PRECOMPOSED 0x00000001
3636 #define MB_ERR_INVALID_CHARS 0x00000008
3641 MultiByteToWideChar(
3644 IN LPCSTR lpMultiByteStr,
3646 OUT LPWSTR lpWideCharStr,
3647 IN int cchWideChar);
3649 #define WC_NO_BEST_FIT_CHARS 0x00000400
3654 WideCharToMultiByte(
3657 IN LPCWSTR lpWideCharStr,
3659 OUT LPSTR lpMultiByteStr,
3661 IN LPCSTR lpDefaultChar,
3662 OUT LPBOOL lpUsedDefaultChar);
3664 #if ENABLE_DOWNLEVEL_FOR_NLS
3669 GetSystemDefaultLangID(
3675 GetUserDefaultLangID(
3690 #endif //ENABLE_DOWNLEVEL_FOR_NLS
3695 // These types are used for the GetLocaleInfo NLS API routine.
3701 // The following LCTypes may be used in combination with any other LCTypes.
3703 // LOCALE_NOUSEROVERRIDE is also used in GetTimeFormat and
3706 // LOCALE_RETURN_NUMBER will return the result from GetLocaleInfo as a
3707 // number instead of a string. This flag is only valid for the LCTypes
3708 // beginning with LOCALE_I.
3710 #define LOCALE_NOUSEROVERRIDE 0x80000000 /* do not use user overrides */
3711 #define LOCALE_RETURN_NUMBER 0x20000000 /* return number instead of string */
3712 #define LOCALE_RETURN_GENITIVE_NAMES 0x10000000 //Flag to return the Genitive forms of month names
3714 #define LOCALE_SLOCALIZEDDISPLAYNAME 0x00000002 // localized name of locale, eg "German (Germany)" in UI language
3715 #define LOCALE_SENGLISHDISPLAYNAME 0x00000072 // Display name (language + country usually) in English, eg "German (Germany)"
3716 #define LOCALE_SNATIVEDISPLAYNAME 0x00000073 // Display name in native locale language, eg "Deutsch (Deutschland)
3718 #define LOCALE_SLOCALIZEDLANGUAGENAME 0x0000006f // Language Display Name for a language, eg "German" in UI language
3719 #define LOCALE_SENGLISHLANGUAGENAME 0x00001001 // English name of language, eg "German"
3720 #define LOCALE_SNATIVELANGUAGENAME 0x00000004 // native name of language, eg "Deutsch"
3722 #define LOCALE_SLOCALIZEDCOUNTRYNAME 0x00000006 // localized name of country, eg "Germany" in UI language
3723 #define LOCALE_SENGLISHCOUNTRYNAME 0x00001002 // English name of country, eg "Germany"
3724 #define LOCALE_SNATIVECOUNTRYNAME 0x00000008 // native name of country, eg "Deutschland"
3727 // The following LCTypes are mutually exclusive in that they may NOT
3728 // be used in combination with each other.
3730 #define LOCALE_ILANGUAGE 0x00000001 /* language id */
3731 #define LOCALE_SLANGUAGE 0x00000002 /* localized name of language */
3732 #define LOCALE_SENGLANGUAGE 0x00001001 /* English name of language */
3733 #define LOCALE_SABBREVLANGNAME 0x00000003 /* abbreviated language name */
3734 #define LOCALE_SNATIVELANGNAME 0x00000004 /* native name of language */
3735 #define LOCALE_ICOUNTRY 0x00000005 /* country code */
3736 #define LOCALE_SCOUNTRY 0x00000006 /* localized name of country */
3738 #define LOCALE_SENGCOUNTRY 0x00001002 /* English name of country */
3739 #define LOCALE_SABBREVCTRYNAME 0x00000007 /* abbreviated country name */
3740 #define LOCALE_SNATIVECTRYNAME 0x00000008 /* native name of country */
3742 #define LOCALE_SLIST 0x0000000C /* list item separator */
3743 #define LOCALE_IMEASURE 0x0000000D /* 0 = metric, 1 = US */
3745 #define LOCALE_SDECIMAL 0x0000000E /* decimal separator */
3746 #define LOCALE_STHOUSAND 0x0000000F /* thousand separator */
3747 #define LOCALE_SGROUPING 0x00000010 /* digit grouping */
3748 #define LOCALE_IDIGITS 0x00000011 /* number of fractional digits */
3749 #define LOCALE_ILZERO 0x00000012 /* leading zeros for decimal */
3750 #define LOCALE_INEGNUMBER 0x00001010 /* negative number mode */
3751 #define LOCALE_SNATIVEDIGITS 0x00000013 /* native ascii 0-9 */
3753 #define LOCALE_SCURRENCY 0x00000014 /* local monetary symbol */
3754 #define LOCALE_SINTLSYMBOL 0x00000015 /* intl monetary symbol */
3755 #define LOCALE_SMONDECIMALSEP 0x00000016 /* monetary decimal separator */
3756 #define LOCALE_SMONTHOUSANDSEP 0x00000017 /* monetary thousand separator */
3757 #define LOCALE_SMONGROUPING 0x00000018 /* monetary grouping */
3758 #define LOCALE_ICURRDIGITS 0x00000019 /* # local monetary digits */
3759 #define LOCALE_IINTLCURRDIGITS 0x0000001A /* # intl monetary digits */
3760 #define LOCALE_ICURRENCY 0x0000001B /* positive currency mode */
3761 #define LOCALE_INEGCURR 0x0000001C /* negative currency mode */
3763 #define LOCALE_SSHORTDATE 0x0000001F /* short date format string */
3764 #define LOCALE_SLONGDATE 0x00000020 /* long date format string */
3765 #define LOCALE_STIMEFORMAT 0x00001003 /* time format string */
3766 #define LOCALE_S1159 0x00000028 /* AM designator */
3767 #define LOCALE_S2359 0x00000029 /* PM designator */
3769 #define LOCALE_ICALENDARTYPE 0x00001009 /* type of calendar specifier */
3770 #define LOCALE_IFIRSTDAYOFWEEK 0x0000100C /* first day of week specifier */
3771 #define LOCALE_IFIRSTWEEKOFYEAR 0x0000100D /* first week of year specifier */
3773 #define LOCALE_SDAYNAME1 0x0000002A /* long name for Monday */
3774 #define LOCALE_SDAYNAME2 0x0000002B /* long name for Tuesday */
3775 #define LOCALE_SDAYNAME3 0x0000002C /* long name for Wednesday */
3776 #define LOCALE_SDAYNAME4 0x0000002D /* long name for Thursday */
3777 #define LOCALE_SDAYNAME5 0x0000002E /* long name for Friday */
3778 #define LOCALE_SDAYNAME6 0x0000002F /* long name for Saturday */
3779 #define LOCALE_SDAYNAME7 0x00000030 /* long name for Sunday */
3780 #define LOCALE_SABBREVDAYNAME1 0x00000031 /* abbreviated name for Monday */
3781 #define LOCALE_SABBREVDAYNAME2 0x00000032 /* abbreviated name for Tuesday */
3782 #define LOCALE_SABBREVDAYNAME3 0x00000033 /* abbreviated name for Wednesday */
3783 #define LOCALE_SABBREVDAYNAME4 0x00000034 /* abbreviated name for Thursday */
3784 #define LOCALE_SABBREVDAYNAME5 0x00000035 /* abbreviated name for Friday */
3785 #define LOCALE_SABBREVDAYNAME6 0x00000036 /* abbreviated name for Saturday */
3786 #define LOCALE_SABBREVDAYNAME7 0x00000037 /* abbreviated name for Sunday */
3787 #define LOCALE_SMONTHNAME1 0x00000038 /* long name for January */
3788 #define LOCALE_SMONTHNAME2 0x00000039 /* long name for February */
3789 #define LOCALE_SMONTHNAME3 0x0000003A /* long name for March */
3790 #define LOCALE_SMONTHNAME4 0x0000003B /* long name for April */
3791 #define LOCALE_SMONTHNAME5 0x0000003C /* long name for May */
3792 #define LOCALE_SMONTHNAME6 0x0000003D /* long name for June */
3793 #define LOCALE_SMONTHNAME7 0x0000003E /* long name for July */
3794 #define LOCALE_SMONTHNAME8 0x0000003F /* long name for August */
3795 #define LOCALE_SMONTHNAME9 0x00000040 /* long name for September */
3796 #define LOCALE_SMONTHNAME10 0x00000041 /* long name for October */
3797 #define LOCALE_SMONTHNAME11 0x00000042 /* long name for November */
3798 #define LOCALE_SMONTHNAME12 0x00000043 /* long name for December */
3799 #define LOCALE_SMONTHNAME13 0x0000100E /* long name for 13th month (if exists) */
3800 #define LOCALE_SABBREVMONTHNAME1 0x00000044 /* abbreviated name for January */
3801 #define LOCALE_SABBREVMONTHNAME2 0x00000045 /* abbreviated name for February */
3802 #define LOCALE_SABBREVMONTHNAME3 0x00000046 /* abbreviated name for March */
3803 #define LOCALE_SABBREVMONTHNAME4 0x00000047 /* abbreviated name for April */
3804 #define LOCALE_SABBREVMONTHNAME5 0x00000048 /* abbreviated name for May */
3805 #define LOCALE_SABBREVMONTHNAME6 0x00000049 /* abbreviated name for June */
3806 #define LOCALE_SABBREVMONTHNAME7 0x0000004A /* abbreviated name for July */
3807 #define LOCALE_SABBREVMONTHNAME8 0x0000004B /* abbreviated name for August */
3808 #define LOCALE_SABBREVMONTHNAME9 0x0000004C /* abbreviated name for September */
3809 #define LOCALE_SABBREVMONTHNAME10 0x0000004D /* abbreviated name for October */
3810 #define LOCALE_SABBREVMONTHNAME11 0x0000004E /* abbreviated name for November */
3811 #define LOCALE_SABBREVMONTHNAME12 0x0000004F /* abbreviated name for December */
3812 #define LOCALE_SABBREVMONTHNAME13 0x0000100F /* abbreviated name for 13th month (if exists) */
3814 #define LOCALE_SPOSITIVESIGN 0x00000050 /* positive sign */
3815 #define LOCALE_SNEGATIVESIGN 0x00000051 /* negative sign */
3817 #define LOCALE_FONTSIGNATURE 0x00000058 /* font signature */
3818 #define LOCALE_SISO639LANGNAME 0x00000059 /* ISO abbreviated language name */
3819 #define LOCALE_SISO3166CTRYNAME 0x0000005A /* ISO abbreviated country name */
3821 #define LOCALE_SENGCURRNAME 0x00001007 /* english name of currency */
3822 #define LOCALE_SNATIVECURRNAME 0x00001008 /* native name of currency */
3823 #define LOCALE_SYEARMONTH 0x00001006 /* year month format string */
3824 #define LOCALE_IDIGITSUBSTITUTION 0x00001014 /* 0 = context, 1 = none, 2 = national */
3826 #define LOCALE_SNAME 0x0000005C /* locale name <language>[-<Script>][-<REGION>[_<sort order>]] */
3827 #define LOCALE_SDURATION 0x0000005d /* time duration format */
3828 #define LOCALE_SKEYBOARDSTOINSTALL 0x0000005e /* (windows only) keyboards to install */
3829 #define LOCALE_SSHORTESTDAYNAME1 0x00000060 /* Shortest day name for Monday */
3830 #define LOCALE_SSHORTESTDAYNAME2 0x00000061 /* Shortest day name for Tuesday */
3831 #define LOCALE_SSHORTESTDAYNAME3 0x00000062 /* Shortest day name for Wednesday */
3832 #define LOCALE_SSHORTESTDAYNAME4 0x00000063 /* Shortest day name for Thursday */
3833 #define LOCALE_SSHORTESTDAYNAME5 0x00000064 /* Shortest day name for Friday */
3834 #define LOCALE_SSHORTESTDAYNAME6 0x00000065 /* Shortest day name for Saturday */
3835 #define LOCALE_SSHORTESTDAYNAME7 0x00000066 /* Shortest day name for Sunday */
3836 #define LOCALE_SISO639LANGNAME2 0x00000067 /* 3 character ISO abbreviated language name */
3837 #define LOCALE_SISO3166CTRYNAME2 0x00000068 /* 3 character ISO country name */
3838 #define LOCALE_SNAN 0x00000069 /* Not a Number */
3839 #define LOCALE_SPOSINFINITY 0x0000006a /* + Infinity */
3840 #define LOCALE_SNEGINFINITY 0x0000006b /* - Infinity */
3841 #define LOCALE_SSCRIPTS 0x0000006c /* Typical scripts in the locale */
3842 #define LOCALE_SPARENT 0x0000006d /* Fallback name for resources */
3843 #define LOCALE_SCONSOLEFALLBACKNAME 0x0000006e /* Fallback name for within the console */
3844 #define LOCALE_SLANGDISPLAYNAME 0x0000006f /* Language Display Name for a language */
3845 #define LOCALE_IREADINGLAYOUT 0x00000070 // Returns one of the following 4 reading layout values:
3846 // 0 - Left to right (eg en-US)
3847 // 1 - Right to left (eg arabic locales)
3848 // 2 - Vertical top to bottom with columns to the left and also left to right (ja-JP locales)
3849 // 3 - Vertical top to bottom with columns proceeding to the right
3850 #define LOCALE_INEUTRAL 0x00000071 // Returns 0 for specific cultures, 1 for neutral cultures.
3851 #define LOCALE_INEGATIVEPERCENT 0x00000074 // Returns 0-11 for the negative percent format
3852 #define LOCALE_IPOSITIVEPERCENT 0x00000075 // Returns 0-3 for the positive percent formatIPOSITIVEPERCENT
3853 #define LOCALE_SPERCENT 0x00000076 // Returns the percent symbol
3854 #define LOCALE_SPERMILLE 0x00000077 // Returns the permille (U+2030) symbol
3855 #define LOCALE_SMONTHDAY 0x00000078 // Returns the preferred month/day format
3856 #define LOCALE_SSHORTTIME 0x00000079 // Returns the preferred short time format (ie: no seconds, just h:mm)
3857 #define LOCALE_SOPENTYPELANGUAGETAG 0x0000007a // Open type language tag, eg: "latn" or "dflt"
3858 #define LOCALE_SSORTLOCALE 0x0000007b // Name of locale to use for sorting/collation/casing behavior.
3860 #define LCMAP_LINGUISTIC_CASING 0x01000000 /* Use linguistic casing */
3862 #define CAL_RETURN_GENITIVE_NAMES LOCALE_RETURN_GENITIVE_NAMES // return genitive forms of month names
3864 #define CAL_SSHORTESTDAYNAME1 0x00000031
3865 #define CAL_SSHORTESTDAYNAME2 0x00000032
3866 #define CAL_SSHORTESTDAYNAME3 0x00000033
3867 #define CAL_SSHORTESTDAYNAME4 0x00000034
3868 #define CAL_SSHORTESTDAYNAME5 0x00000035
3869 #define CAL_SSHORTESTDAYNAME6 0x00000036
3870 #define CAL_SSHORTESTDAYNAME7 0x00000037
3872 #define CAL_SMONTHDAY 0x00000038 // Month/day pattern (reserve for potential inclusion in a future version)
3873 #define CAL_SERASTRING 0x00000004 // era name for IYearOffsetRanges, eg A.D.
3874 #define CAL_SABBREVERASTRING 0x00000039 // Abbreviated era string (eg: AD)
3876 #define CAL_SSHORTDATE 0x00000005 /* short date format string */
3877 #define CAL_SLONGDATE 0x00000006 /* long date format string */
3878 #define CAL_SDAYNAME1 0x00000007 /* native name for Monday */
3879 #define CAL_SDAYNAME2 0x00000008 /* native name for Tuesday */
3880 #define CAL_SDAYNAME3 0x00000009 /* native name for Wednesday */
3881 #define CAL_SDAYNAME4 0x0000000a /* native name for Thursday */
3882 #define CAL_SDAYNAME5 0x0000000b /* native name for Friday */
3883 #define CAL_SDAYNAME6 0x0000000c /* native name for Saturday */
3884 #define CAL_SDAYNAME7 0x0000000d /* native name for Sunday */
3885 #define CAL_SABBREVDAYNAME1 0x0000000e /* abbreviated name for Monday */
3886 #define CAL_SABBREVDAYNAME2 0x0000000f /* abbreviated name for Tuesday */
3887 #define CAL_SABBREVDAYNAME3 0x00000010 /* abbreviated name for Wednesday */
3888 #define CAL_SABBREVDAYNAME4 0x00000011 /* abbreviated name for Thursday */
3889 #define CAL_SABBREVDAYNAME5 0x00000012 /* abbreviated name for Friday */
3890 #define CAL_SABBREVDAYNAME6 0x00000013 /* abbreviated name for Saturday */
3891 #define CAL_SABBREVDAYNAME7 0x00000014 /* abbreviated name for Sunday */
3892 #define CAL_SMONTHNAME1 0x00000015 /* native name for January */
3893 #define CAL_SMONTHNAME2 0x00000016 /* native name for February */
3894 #define CAL_SMONTHNAME3 0x00000017 /* native name for March */
3895 #define CAL_SMONTHNAME4 0x00000018 /* native name for April */
3896 #define CAL_SMONTHNAME5 0x00000019 /* native name for May */
3897 #define CAL_SMONTHNAME6 0x0000001a /* native name for June */
3898 #define CAL_SMONTHNAME7 0x0000001b /* native name for July */
3899 #define CAL_SMONTHNAME8 0x0000001c /* native name for August */
3900 #define CAL_SMONTHNAME9 0x0000001d /* native name for September */
3901 #define CAL_SMONTHNAME10 0x0000001e /* native name for October */
3902 #define CAL_SMONTHNAME11 0x0000001f /* native name for November */
3903 #define CAL_SMONTHNAME12 0x00000020 /* native name for December */
3904 #define CAL_SMONTHNAME13 0x00000021 /* native name for 13th month (if any) */
3905 #define CAL_SABBREVMONTHNAME1 0x00000022 /* abbreviated name for January */
3906 #define CAL_SABBREVMONTHNAME2 0x00000023 /* abbreviated name for February */
3907 #define CAL_SABBREVMONTHNAME3 0x00000024 /* abbreviated name for March */
3908 #define CAL_SABBREVMONTHNAME4 0x00000025 /* abbreviated name for April */
3909 #define CAL_SABBREVMONTHNAME5 0x00000026 /* abbreviated name for May */
3910 #define CAL_SABBREVMONTHNAME6 0x00000027 /* abbreviated name for June */
3911 #define CAL_SABBREVMONTHNAME7 0x00000028 /* abbreviated name for July */
3912 #define CAL_SABBREVMONTHNAME8 0x00000029 /* abbreviated name for August */
3913 #define CAL_SABBREVMONTHNAME9 0x0000002a /* abbreviated name for September */
3914 #define CAL_SABBREVMONTHNAME10 0x0000002b /* abbreviated name for October */
3915 #define CAL_SABBREVMONTHNAME11 0x0000002c /* abbreviated name for November */
3916 #define CAL_SABBREVMONTHNAME12 0x0000002d /* abbreviated name for December */
3917 #define CAL_SABBREVMONTHNAME13 0x0000002e /* abbreviated name for 13th month (if any) */
3918 #define CAL_SYEARMONTH 0x0000002f /* year month format string */
3923 #define LOCALE_SDECIMAL 0x0000000E /* decimal separator */
3924 #define LOCALE_STHOUSAND 0x0000000F /* thousand separator */
3925 #define LOCALE_ILZERO 0x00000012 /* leading zeros for decimal */
3926 #define LOCALE_SCURRENCY 0x00000014 /* local monetary symbol */
3927 #define LOCALE_SMONDECIMALSEP 0x00000016 /* monetary decimal separator */
3928 #define LOCALE_SMONTHOUSANDSEP 0x00000017 /* monetary thousand separator */
3933 #if ENABLE_DOWNLEVEL_FOR_NLS
3941 OUT LPWSTR lpLCData,
3944 #endif // ENABLE_DOWNLEVEL_FOR_NLS
3950 IN LPCWSTR lpLocaleName,
3952 OUT LPWSTR lpLCData,
3959 CompareStringOrdinal(
3960 IN LPCWSTR lpString1,
3962 IN LPCWSTR lpString2,
3964 IN BOOL bIgnoreCase);
3966 typedef struct _nlsversioninfoex {
3967 DWORD dwNLSVersionInfoSize;
3969 DWORD dwDefinedVersion;
3970 DWORD dwEffectiveId;
3971 GUID guidCustomVersion;
3972 } NLSVERSIONINFOEX, *LPNLSVERSIONINFOEX;
3978 IN LPCWSTR lpLocaleName,
3979 IN DWORD dwFindNLSStringFlags,
3980 IN LPCWSTR lpStringSource,
3982 IN LPCWSTR lpStringValue,
3984 OUT LPINT pcchFound,
3985 IN LPNLSVERSIONINFOEX lpVersionInformation,
3986 IN LPVOID lpReserved,
3990 COMPARE_STRING = 0x0001,
3997 IN NLS_FUNCTION Function,
3999 IN LPNLSVERSIONINFOEX lpVersionInfo,
4000 IN LPCWSTR lpString,
4008 IN LPCWSTR lpNameToResolve,
4009 OUT LPWSTR lpLocaleName,
4010 IN int cchLocaleName );
4015 GetThreadPreferredUILanguages(
4017 OUT PULONG pulNumLanguages,
4018 OUT PWSTR pwszLanguagesBuffer,
4019 IN OUT PULONG pcchLanguagesBuffer);
4025 GetSystemDefaultLocaleName(
4026 OUT LPWSTR lpLocaleName,
4027 IN int cchLocaleName);
4030 #define GetLocaleInfo GetLocaleInfoW
4033 #if ENABLE_DOWNLEVEL_FOR_NLS
4045 GetUserDefaultLocaleName(
4046 OUT LPWSTR lpLocaleName,
4047 IN int cchLocaleName);
4052 #define TIME_ZONE_ID_INVALID ((DWORD)0xFFFFFFFF)
4053 #define TIME_ZONE_ID_UNKNOWN 0
4054 #define TIME_ZONE_ID_STANDARD 1
4055 #define TIME_ZONE_ID_DAYLIGHT 2
4058 typedef struct _TIME_ZONE_INFORMATION {
4060 WCHAR StandardName[ 32 ];
4061 SYSTEMTIME StandardDate;
4063 WCHAR DaylightName[ 32 ];
4064 SYSTEMTIME DaylightDate;
4066 } TIME_ZONE_INFORMATION, *PTIME_ZONE_INFORMATION, *LPTIME_ZONE_INFORMATION;
4071 GetTimeZoneInformation(
4072 OUT LPTIME_ZONE_INFORMATION lpTimeZoneInformation);
4077 PAL_GetTimeZoneInformation(
4079 OUT LPTIME_ZONE_INFORMATION lpTimeZoneInformation);
4081 #define LCID_INSTALLED 0x00000001 // installed locale ids
4082 #define LCID_SUPPORTED 0x00000002 // supported locale ids
4084 #define LCID_ALTERNATE_SORTS 0x00000004 // alternate sort locale ids
4087 #if ENABLE_DOWNLEVEL_FOR_NLS
4094 #endif // ENABLE_DOWNLEVEL_FOR_NLS
4097 typedef DWORD CALID;
4098 typedef DWORD CALTYPE;
4100 #define CAL_ITWODIGITYEARMAX 0x00000030 // two digit year max
4101 #define CAL_RETURN_NUMBER 0x20000000 // return number instead of string
4103 #define CAL_GREGORIAN 1 // Gregorian (localized) calendar
4104 #define CAL_GREGORIAN_US 2 // Gregorian (U.S.) calendar
4105 #define CAL_JAPAN 3 // Japanese Emperor Era calendar
4106 #define CAL_TAIWAN 4 // Taiwan Era calendar
4107 #define CAL_KOREA 5 // Korean Tangun Era calendar
4108 #define CAL_HIJRI 6 // Hijri (Arabic Lunar) calendar
4109 #define CAL_THAI 7 // Thai calendar
4110 #define CAL_HEBREW 8 // Hebrew (Lunar) calendar
4111 #define CAL_GREGORIAN_ME_FRENCH 9 // Gregorian Middle East French calendar
4112 #define CAL_GREGORIAN_ARABIC 10 // Gregorian Arabic calendar
4113 #define CAL_GREGORIAN_XLIT_ENGLISH 11 // Gregorian Transliterated English calendar
4114 #define CAL_GREGORIAN_XLIT_FRENCH 12 // Gregorian Transliterated French calendar
4115 #define CAL_JULIAN 13
4117 #if ENABLE_DOWNLEVEL_FOR_NLS
4125 OUT LPWSTR lpCalData,
4127 OUT LPDWORD lpValue);
4130 #define GetCalendarInfo GetCalendarInfoW
4133 #endif // ENABLE_DOWNLEVEL_FOR_NLS
4140 IN LPCWSTR lpLocaleName,
4142 IN LPCWSTR lpReserved,
4144 OUT LPWSTR lpCalData,
4146 OUT LPDWORD lpValue);
4148 #if ENABLE_DOWNLEVEL_FOR_NLS
4149 typedef BOOL (CALLBACK* LOCALE_ENUMPROCW)(LPWSTR);
4155 IN LOCALE_ENUMPROCW lpLocaleEnumProc,
4157 #endif // ENABLE_DOWNLEVEL_FOR_NLS
4159 #define DATE_SHORTDATE 0x00000001 // use short date picture
4160 #define DATE_LONGDATE 0x00000002 // use long date picture
4161 #define DATE_YEARMONTH 0x00000008 // use year month picture
4163 typedef BOOL (CALLBACK* DATEFMT_ENUMPROCEXW)(LPWSTR, CALID);
4165 #if ENABLE_DOWNLEVEL_FOR_NLS
4171 IN DATEFMT_ENUMPROCEXW lpDateFmtEnumProcEx,
4175 #else // ENABLE_DOWNLEVEL_FOR_NLS
4177 typedef BOOL (CALLBACK* DATEFMT_ENUMPROCEXEXW)(LPWSTR, CALID, LPARAM);
4182 EnumDateFormatsExEx(
4183 IN DATEFMT_ENUMPROCEXEXW lpDateFmtEnumProcEx,
4184 IN LPCWSTR lpLocaleName,
4188 #endif // ENABLE_DOWNLEVEL_FOR_NLS
4190 typedef BOOL (CALLBACK* TIMEFMT_ENUMPROCW)(LPWSTR);
4192 #if ENABLE_DOWNLEVEL_FOR_NLS
4198 IN TIMEFMT_ENUMPROCW lpTimeFmtEnumProc,
4202 #else // ENABLE_DOWNLEVEL_FOR_NLS
4204 typedef BOOL (CALLBACK* TIMEFMT_ENUMPROCEXW)(LPWSTR, LPARAM);
4210 IN TIMEFMT_ENUMPROCEXW lpTimeFmtEnumProc,
4211 IN LPCWSTR lpLocaleName,
4215 #endif // ENABLE_DOWNLEVEL_FOR_NLS
4217 #define ENUM_ALL_CALENDARS 0xffffffff // enumerate all calendars
4218 #define CAL_ICALINTVALUE 0x00000001 // calendar type
4219 #define CAL_NOUSEROVERRIDE LOCALE_NOUSEROVERRIDE // do not use user overrides
4220 #define CAL_SCALNAME 0x00000002 // native name of calendar
4222 typedef BOOL (CALLBACK* CALINFO_ENUMPROCEXW)(LPWSTR,CALID);
4224 #if ENABLE_DOWNLEVEL_FOR_NLS
4229 EnumCalendarInfoExW(
4230 IN CALINFO_ENUMPROCEXW lpCalInfoEnumProc,
4233 IN CALTYPE CalType);
4235 #else // ENABLE_DOWNLEVEL_FOR_NLS
4237 typedef BOOL (CALLBACK* CALINFO_ENUMPROCEXEXW)(LPWSTR, CALID, LPWSTR, LPARAM);
4242 EnumCalendarInfoExEx(
4243 IN CALINFO_ENUMPROCEXEXW lpCalInfoEnumProc,
4244 IN LPCWSTR lpLocaleName,
4246 IN LPCWSTR lpReserved,
4250 #endif // ENABLE_DOWNLEVEL_FOR_NLS
4252 #define LCMAP_LOWERCASE 0x00000100
4253 #define LCMAP_UPPERCASE 0x00000200
4255 #if ENABLE_DOWNLEVEL_FOR_NLS
4262 IN DWORD dwMapFlags,
4263 IN LPCWSTR lpSrcStr,
4265 OUT LPWSTR lpDestStr,
4269 #define LCMapString LCMapStringW
4273 #endif // ENABLE_DOWNLEVEL_FOR_NLS
4280 IN LPCWSTR lpLocaleName,
4281 IN DWORD dwMapFlags,
4282 IN LPCWSTR lpSrcStr,
4284 OUT LPWSTR lpDestStr,
4286 IN LPNLSVERSIONINFO lpVersionInformation,
4287 IN LPVOID lpReserved,
4294 IN LPCWSTR lpLocaleName,
4295 IN DWORD dwMapFlags,
4297 OUT WCHAR *destChar,
4298 LPNLSVERSIONINFO lpVersionInformation,
4305 PAL_NormalizeStringExW(
4306 IN LPCWSTR lpLocaleName,
4307 IN DWORD dwMapFlags,
4308 IN LPCWSTR lpSrcStr,
4310 OUT LPWSTR lpDestStr,
4318 IN LPCWSTR lpLocaleName,
4319 IN LPCWSTR lpFormat,
4321 IN BOOL fUseCustomTz,
4322 IN int tzOffsetSeconds,
4323 IN LPSYSTEMTIME lpTime,
4324 OUT LPWSTR lpDestStr,
4331 IN LPCWSTR lpLocaleName,
4332 IN LPCWSTR lpFormat,
4333 IN LPCWSTR lpString,
4334 OUT LPSYSTEMTIME lpTime);
4340 IN LPCWSTR lpLocaleName,
4341 OUT CALID* pCalendar);
4343 #define GEOID_NOT_AVAILABLE -1
4345 // "a number", might represent different types
4346 typedef struct PALNUMBER__* PALNUMBER;
4348 // return NULL on OOM
4349 PALIMPORT PALNUMBER PALAPI PAL_DoubleToNumber(double);
4350 PALIMPORT PALNUMBER PALAPI PAL_Int64ToNumber(INT64);
4351 PALIMPORT PALNUMBER PALAPI PAL_UInt64ToNumber(UINT64);
4352 PALIMPORT PALNUMBER PALAPI PAL_IntToNumber(int);
4353 PALIMPORT PALNUMBER PALAPI PAL_UIntToNumber(unsigned int);
4355 PALIMPORT void PALAPI PAL_ReleaseNumber(PALNUMBER);
4358 // return string length if Buffer is NULL or the result fits in cchBuffer, otherwise -1
4359 PALIMPORT int PALAPI PAL_FormatScientific(LPCWSTR sLocale, LPWSTR pBuffer, SIZE_T cchBuffer, PALNUMBER number, int nMinDigits, int nMaxDigits,
4360 LPCWSTR sExponent, LPCWSTR sNumberDecimal, LPCWSTR sPositive, LPCWSTR sNegative, LPCWSTR sZero);
4362 PALIMPORT int PALAPI PAL_FormatCurrency(LPCWSTR sLocale, LPWSTR pBuffer, SIZE_T cchBuffer, PALNUMBER number, int nMinDigits, int nMaxDigits, int iNegativeFormat, int iPositiveFormat,
4363 int iPrimaryGroup, int iSecondaryGroup, LPCWSTR sCurrencyDecimal, LPCWSTR sCurrencyGroup, LPCWSTR sNegative, LPCWSTR sCurrency, LPCWSTR sZero);
4365 PALIMPORT int PALAPI PAL_FormatPercent(LPCWSTR sLocale, LPWSTR pBuffer, SIZE_T cchBuffer, PALNUMBER number, int nMinDigits, int nMaxDigits,int iNegativeFormat, int iPositiveFormat,
4366 int iPrimaryGroup, int iSecondaryGroup, LPCWSTR sPercentDecimal, LPCWSTR sPercentGroup, LPCWSTR sNegative, LPCWSTR sPercent, LPCWSTR sZero);
4368 PALIMPORT int PALAPI PAL_FormatDecimal(LPCWSTR sLocale, LPWSTR pBuffer, SIZE_T cchBuffer, PALNUMBER number, int nMinDigits, int nMaxDigits, int iNegativeFormat,
4369 int iPrimaryGroup, int iSecondaryGroup, LPCWSTR sDecimal, LPCWSTR sGroup, LPCWSTR sNegative, LPCWSTR sZero);
4372 #define DATE_USE_ALT_CALENDAR 0x00000004
4374 #if ENABLE_DOWNLEVEL_FOR_NLS
4382 IN CONST SYSTEMTIME *lpDate,
4383 IN LPCWSTR lpFormat,
4384 OUT LPWSTR lpDateStr,
4395 IN CONST SYSTEMTIME *lpDate,
4396 IN LPCWSTR lpFormat,
4397 OUT LPWSTR lpDateStr,
4399 IN LPCWSTR lpCalendar);
4402 #endif // ENABLE_DOWNLEVEL_FOR_NLS
4408 IN LPCWSTR lpLocaleName,
4410 IN CONST SYSTEMTIME *lpDate,
4411 IN LPCWSTR lpFormat,
4412 OUT LPWSTR lpDateStr,
4414 LPCWSTR lpCalendar);
4418 #define GetDateFormat GetDateFormatW
4421 #define EXCEPTION_NONCONTINUABLE 0x1
4422 #define EXCEPTION_UNWINDING 0x2
4424 #ifdef FEATURE_PAL_SXS
4426 #define EXCEPTION_EXIT_UNWIND 0x4 // Exit unwind is in progress (not used by PAL SEH)
4427 #define EXCEPTION_NESTED_CALL 0x10 // Nested exception handler call
4428 #define EXCEPTION_TARGET_UNWIND 0x20 // Target unwind in progress
4429 #define EXCEPTION_COLLIDED_UNWIND 0x40 // Collided exception handler call
4430 #define EXCEPTION_SKIP_VEH 0x200
4432 #define EXCEPTION_UNWIND (EXCEPTION_UNWINDING | EXCEPTION_EXIT_UNWIND | \
4433 EXCEPTION_TARGET_UNWIND | EXCEPTION_COLLIDED_UNWIND)
4435 #define IS_DISPATCHING(Flag) ((Flag & EXCEPTION_UNWIND) == 0)
4436 #define IS_UNWINDING(Flag) ((Flag & EXCEPTION_UNWIND) != 0)
4437 #define IS_TARGET_UNWIND(Flag) (Flag & EXCEPTION_TARGET_UNWIND)
4439 #endif // FEATURE_PAL_SXS
4441 #define EXCEPTION_IS_SIGNAL 0x100
4443 #define EXCEPTION_MAXIMUM_PARAMETERS 15
4445 // Index in the ExceptionInformation array where we will keep the reference
4446 // to the native exception that needs to be deleted when dispatching
4447 // exception in managed code.
4448 #define NATIVE_EXCEPTION_ASYNC_SLOT (EXCEPTION_MAXIMUM_PARAMETERS-1)
4450 typedef struct _EXCEPTION_RECORD {
4451 DWORD ExceptionCode;
4452 DWORD ExceptionFlags;
4453 struct _EXCEPTION_RECORD *ExceptionRecord;
4454 PVOID ExceptionAddress;
4455 DWORD NumberParameters;
4456 ULONG_PTR ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS];
4457 } EXCEPTION_RECORD, *PEXCEPTION_RECORD;
4459 typedef struct _EXCEPTION_POINTERS {
4460 PEXCEPTION_RECORD ExceptionRecord;
4461 PCONTEXT ContextRecord;
4462 } EXCEPTION_POINTERS, *PEXCEPTION_POINTERS, *LPEXCEPTION_POINTERS;
4464 #ifdef FEATURE_PAL_SXS
4466 typedef LONG EXCEPTION_DISPOSITION;
4469 ExceptionContinueExecution,
4470 ExceptionContinueSearch,
4471 ExceptionNestedException,
4472 ExceptionCollidedUnwind,
4475 #endif // FEATURE_PAL_SXS
4478 // A function table entry is generated for each frame function.
4480 typedef struct _RUNTIME_FUNCTION {
4484 } RUNTIME_FUNCTION, *PRUNTIME_FUNCTION;
4489 WriteProcessMemory(IN HANDLE hProcess,
4490 IN LPVOID lpBaseAddress,
4491 IN LPCVOID lpBuffer,
4493 OUT SIZE_T * lpNumberOfBytesWritten);
4495 #define STANDARD_RIGHTS_REQUIRED (0x000F0000L)
4496 #define SYNCHRONIZE (0x00100000L)
4497 #define READ_CONTROL (0x00020000L)
4499 #define EVENT_MODIFY_STATE (0x0002)
4500 #define EVENT_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | \
4503 #define MUTANT_QUERY_STATE (0x0001)
4504 #define MUTANT_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | \
4506 #define MUTEX_ALL_ACCESS MUTANT_ALL_ACCESS
4508 #define SEMAPHORE_MODIFY_STATE (0x0002)
4509 #define SEMAPHORE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | \
4512 #define PROCESS_TERMINATE (0x0001)
4513 #define PROCESS_CREATE_THREAD (0x0002)
4514 #define PROCESS_SET_SESSIONID (0x0004)
4515 #define PROCESS_VM_OPERATION (0x0008)
4516 #define PROCESS_VM_READ (0x0010)
4517 #define PROCESS_VM_WRITE (0x0020)
4518 #define PROCESS_DUP_HANDLE (0x0040)
4519 #define PROCESS_CREATE_PROCESS (0x0080)
4520 #define PROCESS_SET_QUOTA (0x0100)
4521 #define PROCESS_SET_INFORMATION (0x0200)
4522 #define PROCESS_QUERY_INFORMATION (0x0400)
4523 #define PROCESS_SUSPEND_RESUME (0x0800)
4524 #define PROCESS_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | \
4531 IN DWORD dwDesiredAccess, /* PROCESS_DUP_HANDLE or PROCESS_ALL_ACCESS */
4532 IN BOOL bInheritHandle,
4533 IN DWORD dwProcessId
4540 IN LPCSTR lpOutputString);
4546 IN LPCWSTR lpOutputStrig);
4549 #define OutputDebugString OutputDebugStringW
4551 #define OutputDebugString OutputDebugStringA
4564 IN OUT LPWSTR lpString1,
4565 IN LPCWSTR lpString2);
4568 #define lstrcat lstrcatW
4575 OUT LPWSTR lpString1,
4576 IN LPCWSTR lpString2);
4579 #define lstrcpy lstrcpyW
4586 IN LPCSTR lpString);
4592 IN LPCWSTR lpString);
4595 #define lstrlen lstrlenW
4597 #define lstrlen lstrlenA
4604 OUT LPWSTR lpString1,
4605 IN LPCWSTR lpString2,
4609 #define lstrcpyn lstrcpynW
4616 GetEnvironmentVariableA(
4624 GetEnvironmentVariableW(
4626 OUT LPWSTR lpBuffer,
4630 #define GetEnvironmentVariable GetEnvironmentVariableW
4632 #define GetEnvironmentVariable GetEnvironmentVariableA
4638 SetEnvironmentVariableA(
4645 SetEnvironmentVariableW(
4647 IN LPCWSTR lpValue);
4650 #define SetEnvironmentVariable SetEnvironmentVariableW
4652 #define SetEnvironmentVariable SetEnvironmentVariableA
4658 GetEnvironmentStringsA(
4664 GetEnvironmentStringsW(
4668 #define GetEnvironmentStrings GetEnvironmentStringsW
4670 #define GetEnvironmentStrings GetEnvironmentStringsA
4676 FreeEnvironmentStringsA(
4682 FreeEnvironmentStringsW(
4686 #define FreeEnvironmentStrings FreeEnvironmentStringsW
4688 #define FreeEnvironmentStrings FreeEnvironmentStringsA
4695 IN OUT HANDLE hObject);
4701 IN DWORD dwExceptionCode,
4702 IN DWORD dwExceptionFlags,
4703 IN DWORD nNumberOfArguments,
4704 IN CONST ULONG_PTR *lpArguments);
4706 #ifdef FEATURE_PAL_SXS
4712 IN PEXCEPTION_POINTERS ExceptionPointers);
4713 #endif // FEATURE_PAL_SXS
4729 QueryPerformanceCounter(
4730 OUT LARGE_INTEGER *lpPerformanceCount
4736 QueryPerformanceFrequency(
4737 OUT LARGE_INTEGER *lpFrequency
4743 QueryThreadCycleTime(
4744 IN HANDLE ThreadHandle,
4745 OUT PULONG64 CycleTime);
4747 #ifndef FEATURE_PAL_SXS
4749 typedef LONG (PALAPI *PTOP_LEVEL_EXCEPTION_FILTER)(
4750 struct _EXCEPTION_POINTERS *ExceptionInfo);
4751 typedef PTOP_LEVEL_EXCEPTION_FILTER LPTOP_LEVEL_EXCEPTION_FILTER;
4754 LPTOP_LEVEL_EXCEPTION_FILTER
4756 SetUnhandledExceptionFilter(
4757 IN LPTOP_LEVEL_EXCEPTION_FILTER lpTopLevelExceptionFilter);
4759 #else // FEATURE_PAL_SXS
4761 typedef EXCEPTION_DISPOSITION (PALAPI *PVECTORED_EXCEPTION_HANDLER)(
4762 struct _EXCEPTION_POINTERS *ExceptionPointers);
4764 #endif // FEATURE_PAL_SXS
4766 // Define BitScanForward64 and BitScanForward
4767 // Per MSDN, BitScanForward64 will search the mask data from LSB to MSB for a set bit.
4768 // If one is found, its bit position is returned in the out PDWORD argument and 1 is returned.
4769 // Otherwise, 0 is returned.
4771 // On GCC, the equivalent function is __builtin_ffsl. It returns 1+index of the least
4772 // significant set bit, or 0 if if mask is zero.
4774 // The same is true for BitScanForward, except that the GCC function is __builtin_ffs.
4780 IN OUT PDWORD Index,
4786 InterlockedIncrement(
4787 IN OUT LONG volatile *lpAddend);
4792 InterlockedDecrement(
4793 IN OUT LONG volatile *lpAddend);
4798 InterlockedExchange(
4799 IN OUT LONG volatile *Target,
4805 InterlockedCompareExchange(
4806 IN OUT LONG volatile *Destination,
4813 InterlockedCompareExchangeAcquire(
4814 IN OUT LONG volatile *Destination,
4821 InterlockedCompareExchangeRelease(
4822 IN OUT LONG volatile *Destination,
4829 InterlockedExchangeAdd(
4830 IN OUT LONG volatile *Addend,
4837 IN OUT LONG volatile *Destination,
4844 IN OUT LONG volatile *Destination,
4851 IN OUT PDWORD Index,
4857 InterlockedIncrement64(
4858 IN OUT LONGLONG volatile *lpAddend);
4863 InterlockedDecrement64(
4864 IN OUT LONGLONG volatile *lpAddend);
4869 InterlockedExchange64(
4870 IN OUT LONGLONG volatile *Target,
4876 InterlockedExchangeAdd64(
4877 IN OUT LONGLONG volatile *Addend,
4883 InterlockedCompareExchange64(
4884 IN OUT LONGLONG volatile *Destination,
4885 IN LONGLONG Exchange,
4886 IN LONGLONG Comperand);
4889 #define InterlockedExchangePointer(Target, Value) \
4890 ((PVOID)InterlockedExchange64((PLONG64)(Target), (LONGLONG)(Value)))
4892 #define InterlockedCompareExchangePointer(Destination, ExChange, Comperand) \
4893 ((PVOID)InterlockedCompareExchange64((PLONG64)(Destination), (LONGLONG)(ExChange), (LONGLONG)(Comperand)))
4895 #define InterlockedExchangePointer(Target, Value) \
4896 ((PVOID)(UINT_PTR)InterlockedExchange((PLONG)(UINT_PTR)(Target), (LONG)(UINT_PTR)(Value)))
4898 #define InterlockedCompareExchangePointer(Destination, ExChange, Comperand) \
4899 ((PVOID)(UINT_PTR)InterlockedCompareExchange((PLONG)(UINT_PTR)(Destination), (LONG)(UINT_PTR)(ExChange), (LONG)(UINT_PTR)(Comperand)))
4917 GetCurrentProcessorNumber();
4919 #define FORMAT_MESSAGE_ALLOCATE_BUFFER 0x00000100
4920 #define FORMAT_MESSAGE_IGNORE_INSERTS 0x00000200
4921 #define FORMAT_MESSAGE_FROM_STRING 0x00000400
4922 #define FORMAT_MESSAGE_FROM_SYSTEM 0x00001000
4923 #define FORMAT_MESSAGE_ARGUMENT_ARRAY 0x00002000
4924 #define FORMAT_MESSAGE_MAX_WIDTH_MASK 0x000000FF
4931 IN LPCVOID lpSource,
4932 IN DWORD dwMessageId,
4933 IN DWORD dwLanguageId,
4936 IN va_list *Arguments);
4939 #define FormatMessage FormatMessageW
4953 IN DWORD dwErrCode);
4962 #define GetCommandLine GetCommandLineW
4969 IN PCONTEXT ContextRecord,
4970 IN PEXCEPTION_RECORD ExceptionRecord
4977 OUT PCONTEXT ContextRecord
4985 IN PVOID lpBaseAddress,
4986 IN SIZE_T dwRegionSize,
4987 OUT PVOID *lpAddresses,
4988 IN OUT PULONG_PTR lpdwCount,
4989 OUT PULONG lpdwGranularity
4996 IN LPVOID lpBaseAddress,
4997 IN SIZE_T dwRegionSize
5003 FlushProcessWriteBuffers();
5005 #define VER_PLATFORM_WIN32_WINDOWS 1
5006 #define VER_PLATFORM_WIN32_NT 2
5007 #define VER_PLATFORM_UNIX 10
5008 #define VER_PLATFORM_MACOSX 11
5010 typedef struct _OSVERSIONINFOA {
5011 DWORD dwOSVersionInfoSize;
5012 DWORD dwMajorVersion;
5013 DWORD dwMinorVersion;
5014 DWORD dwBuildNumber;
5016 CHAR szCSDVersion[ 128 ];
5017 } OSVERSIONINFOA, *POSVERSIONINFOA, *LPOSVERSIONINFOA;
5019 typedef struct _OSVERSIONINFOW {
5020 DWORD dwOSVersionInfoSize;
5021 DWORD dwMajorVersion;
5022 DWORD dwMinorVersion;
5023 DWORD dwBuildNumber;
5025 WCHAR szCSDVersion[ 128 ];
5026 } OSVERSIONINFOW, *POSVERSIONINFOW, *LPOSVERSIONINFOW;
5029 typedef OSVERSIONINFOW OSVERSIONINFO;
5030 typedef POSVERSIONINFOW POSVERSIONINFO;
5031 typedef LPOSVERSIONINFOW LPOSVERSIONINFO;
5033 typedef OSVERSIONINFOA OSVERSIONINFO;
5034 typedef POSVERSIONINFOA POSVERSIONINFO;
5035 typedef LPOSVERSIONINFOA LPOSVERSIONINFO;
5038 typedef struct _OSVERSIONINFOEXA {
5039 DWORD dwOSVersionInfoSize;
5040 DWORD dwMajorVersion;
5041 DWORD dwMinorVersion;
5042 DWORD dwBuildNumber;
5044 CHAR szCSDVersion[ 128 ];
5045 WORD wServicePackMajor;
5046 WORD wServicePackMinor;
5050 } OSVERSIONINFOEXA, *POSVERSIONINFOEXA, *LPOSVERSIONINFOEXA;
5052 typedef struct _OSVERSIONINFOEXW {
5053 DWORD dwOSVersionInfoSize;
5054 DWORD dwMajorVersion;
5055 DWORD dwMinorVersion;
5056 DWORD dwBuildNumber;
5058 WCHAR szCSDVersion[ 128 ];
5059 WORD wServicePackMajor;
5060 WORD wServicePackMinor;
5064 } OSVERSIONINFOEXW, *POSVERSIONINFOEXW, *LPOSVERSIONINFOEXW;
5067 typedef OSVERSIONINFOEXW OSVERSIONINFOEX;
5068 typedef POSVERSIONINFOEXW POSVERSIONINFOEX;
5069 typedef LPOSVERSIONINFOEXW LPOSVERSIONINFOEX;
5071 typedef OSVERSIONINFOEXA OSVERSIONINFOEX;
5072 typedef POSVERSIONINFOEXA POSVERSIONINFOEX;
5073 typedef LPOSVERSIONINFOEXA LPOSVERSIONINFOEX;
5080 IN OUT LPOSVERSIONINFOA lpVersionInformation);
5086 IN OUT LPOSVERSIONINFOW lpVersionInformation);
5089 #define GetVersionEx GetVersionExW
5091 #define GetVersionEx GetVersionExA
5094 #define IMAGE_FILE_MACHINE_I386 0x014c
5095 #define IMAGE_FILE_MACHINE_ARM64 0xAA64 // ARM64 Little-Endian
5097 typedef struct _SYSTEM_INFO {
5098 WORD wProcessorArchitecture_PAL_Undefined;
5099 WORD wReserved_PAL_Undefined; // NOTE: diff from winbase.h - no obsolete dwOemId union
5101 LPVOID lpMinimumApplicationAddress;
5102 LPVOID lpMaximumApplicationAddress;
5103 DWORD_PTR dwActiveProcessorMask_PAL_Undefined;
5104 DWORD dwNumberOfProcessors;
5105 DWORD dwProcessorType_PAL_Undefined;
5106 DWORD dwAllocationGranularity;
5107 WORD wProcessorLevel_PAL_Undefined;
5108 WORD wProcessorRevision_PAL_Undefined;
5109 } SYSTEM_INFO, *LPSYSTEM_INFO;
5115 OUT LPSYSTEM_INFO lpSystemInfo);
5121 LPCWSTR lpDirectoryName,
5122 LPDWORD lpSectorsPerCluster,
5123 LPDWORD lpBytesPerSector,
5124 LPDWORD lpNumberOfFreeClusters,
5125 LPDWORD lpTotalNumberOfClusters);
5128 #define GetDiskFreeSpace GetDiskFreeSpaceW
5135 OUT PHANDLE hReadPipe,
5136 OUT PHANDLE hWritePipe,
5137 IN LPSECURITY_ATTRIBUTES lpPipeAttributes,
5144 DeregisterEventSource (
5151 RegisterEventSourceA (
5152 IN OPTIONAL LPCSTR lpUNCServerName,
5153 IN LPCSTR lpSourceName
5158 RegisterEventSourceW (
5159 IN OPTIONAL LPCWSTR lpUNCServerName,
5160 IN LPCWSTR lpSourceName
5163 #define RegisterEventSource RegisterEventSourceW
5165 #define RegisterEventSource RegisterEventSourceA
5169 // The types of events that can be logged.
5171 #define EVENTLOG_SUCCESS 0x0000
5172 #define EVENTLOG_ERROR_TYPE 0x0001
5173 #define EVENTLOG_WARNING_TYPE 0x0002
5174 #define EVENTLOG_INFORMATION_TYPE 0x0004
5175 #define EVENTLOG_AUDIT_SUCCESS 0x0008
5176 #define EVENTLOG_AUDIT_FAILURE 0x0010
5182 IN HANDLE hEventLog,
5186 IN OPTIONAL PSID lpUserSid,
5187 IN WORD wNumStrings,
5188 IN DWORD dwDataSize,
5189 IN OPTIONAL LPCSTR *lpStrings,
5190 IN OPTIONAL LPVOID lpRawData
5196 IN HANDLE hEventLog,
5200 IN OPTIONAL PSID lpUserSid,
5201 IN WORD wNumStrings,
5202 IN DWORD dwDataSize,
5203 IN OPTIONAL LPCWSTR *lpStrings,
5204 IN OPTIONAL LPVOID lpRawData
5207 #define ReportEvent ReportEventW
5209 #define ReportEvent ReportEventA
5213 /******************* C Runtime Entrypoints *******************************/
5215 #ifdef PLATFORM_UNIX
5216 /* Some C runtime functions needs to be reimplemented by the PAL.
5217 To avoid name collisions, those functions have been renamed using
5219 #define exit PAL_exit
5220 #define atexit PAL_atexit
5221 #define printf PAL_printf
5222 #define vprintf PAL_vprintf
5223 #define wprintf PAL_wprintf
5224 #define sprintf PAL_sprintf
5225 #define swprintf PAL_swprintf
5226 #define sscanf PAL_sscanf
5227 #define wcsspn PAL_wcsspn
5228 #define wcstod PAL_wcstod
5229 #define wcstol PAL_wcstol
5230 #define wcstoul PAL_wcstoul
5231 #define wcscat PAL_wcscat
5232 #define wcscpy PAL_wcscpy
5233 #define wcslen PAL_wcslen
5234 #define wcsncmp PAL_wcsncmp
5235 #define wcschr PAL_wcschr
5236 #define wcsrchr PAL_wcsrchr
5237 #define swscanf PAL_swscanf
5238 #define wcspbrk PAL_wcspbrk
5239 #define wcsstr PAL_wcsstr
5240 #define wcscmp PAL_wcscmp
5241 #define wcsncat PAL_wcsncat
5242 #define wcsncpy PAL_wcsncpy
5243 #define wcstok PAL_wcstok
5244 #define wcscspn PAL_wcscspn
5245 #define iswalpha PAL_iswalpha
5246 #define iswdigit PAL_iswdigit
5247 #define iswprint PAL_iswprint
5248 #define iswspace PAL_iswspace
5249 #define iswupper PAL_iswupper
5250 #define iswxdigit PAL_iswxdigit
5251 #define towlower PAL_towlower
5252 #define towupper PAL_towupper
5253 #define vsprintf PAL_vsprintf
5254 #define vswprintf PAL_vswprintf
5255 #define realloc PAL_realloc
5256 #define fopen PAL_fopen
5257 #define strtok PAL_strtok
5258 #define strtoul PAL_strtoul
5259 #define fprintf PAL_fprintf
5260 #define fwprintf PAL_fwprintf
5261 #define vfprintf PAL_vfprintf
5262 #define vfwprintf PAL_vfwprintf
5263 #define ctime PAL_ctime
5264 #define localtime PAL_localtime
5265 #define mktime PAL_mktime
5266 #define rand PAL_rand
5267 #define getenv PAL_getenv
5268 #define fgets PAL_fgets
5269 #define fgetws PAL_fgetws
5270 #define fputc PAL_fputc
5271 #define putchar PAL_putchar
5272 #define qsort PAL_qsort
5273 #define bsearch PAL_bsearch
5274 #define ferror PAL_ferror
5275 #define fread PAL_fread
5276 #define fwrite PAL_fwrite
5277 #define feof PAL_feof
5278 #define ftell PAL_ftell
5279 #define fclose PAL_fclose
5280 #define setbuf PAL_setbuf
5281 #define fflush PAL_fflush
5282 #define fputs PAL_fputs
5283 #define fseek PAL_fseek
5284 #define fgetpos PAL_fgetpos
5285 #define fsetpos PAL_fsetpos
5286 #define getc PAL_getc
5287 #define fgetc PAL_getc // not a typo
5288 #define ungetc PAL_ungetc
5289 #define setvbuf PAL_setvbuf
5290 #define atol PAL_atol
5291 #define acos PAL_acos
5292 #define asin PAL_asin
5293 #define atan2 PAL_atan2
5295 #define labs PAL_labs
5297 #define log10 PAL_log10
5299 #define malloc PAL_malloc
5300 #define free PAL_free
5301 #define mkstemp PAL_mkstemp
5302 #define rename PAL_rename
5303 #define unlink PAL_unlink
5304 /* Note the TWO underscores. */
5305 #define _vsnprintf PAL__vsnprintf
5306 #define _vsnwprintf PAL__wvsnprintf
5307 #define _strdup PAL__strdup
5308 #define _getcwd PAL__getcwd
5309 #define _open PAL__open
5310 #define _close PAL__close
5311 #define _wcstoui64 PAL__wcstoui64
5312 #define _flushall PAL__flushall
5315 #define _mm_getcsr PAL__mm_getcsr
5316 #define _mm_setcsr PAL__mm_setcsr
5319 #endif /* PLATFORM_UNIX */
5321 #ifndef _CONST_RETURN
5323 #define _CONST_RETURN const
5324 #define _CRT_CONST_CORRECT_OVERLOADS
5326 #define _CONST_RETURN
5330 /* For backwards compatibility */
5331 #define _WConst_return _CONST_RETURN
5335 typedef int errno_t;
5342 PALIMPORT div_t div(int numer, int denom);
5344 PALIMPORT void * __cdecl memcpy(void *, const void *, size_t);
5345 PALIMPORT errno_t __cdecl memcpy_s(void *, size_t, const void *, size_t);
5346 PALIMPORT int __cdecl memcmp(const void *, const void *, size_t);
5347 PALIMPORT void * __cdecl memset(void *, int, size_t);
5348 PALIMPORT void * __cdecl memmove(void *, const void *, size_t);
5349 PALIMPORT errno_t __cdecl memmove_s(void *, size_t, const void *, size_t);
5350 PALIMPORT void * __cdecl memchr(const void *, int, size_t);
5352 PALIMPORT size_t __cdecl strlen(const char *);
5353 PALIMPORT int __cdecl strcmp(const char*, const char *);
5354 PALIMPORT int __cdecl strncmp(const char*, const char *, size_t);
5355 PALIMPORT int __cdecl _stricmp(const char *, const char *);
5356 PALIMPORT int __cdecl _strnicmp(const char *, const char *, size_t);
5357 PALIMPORT char * __cdecl strcat(char *, const char *);
5358 PALIMPORT char * __cdecl strncat(char *, const char *, size_t);
5359 PALIMPORT char * __cdecl strcpy(char *, const char *);
5360 PALIMPORT char * __cdecl strncpy(char *, const char *, size_t);
5361 PALIMPORT char * __cdecl strchr(const char *, int);
5362 PALIMPORT char * __cdecl strrchr(const char *, int);
5363 PALIMPORT char * __cdecl strpbrk(const char *, const char *);
5364 PALIMPORT char * __cdecl strstr(const char *, const char *);
5365 PALIMPORT char * __cdecl strtok(char *, const char *);
5366 PALIMPORT size_t __cdecl strspn(const char *, const char *);
5367 PALIMPORT size_t __cdecl strcspn(const char *, const char *);
5368 PALIMPORT int __cdecl sprintf(char *, const char *, ...);
5369 PALIMPORT int __cdecl vsprintf(char *, const char *, va_list);
5370 PALIMPORT int __cdecl _snprintf(char *, size_t, const char *, ...);
5371 PALIMPORT int __cdecl _vsnprintf(char *, size_t, const char *, va_list);
5372 PALIMPORT int __cdecl sscanf(const char *, const char *, ...);
5373 PALIMPORT char * __cdecl _strlwr(char *);
5374 PALIMPORT int __cdecl atoi(const char *);
5375 PALIMPORT LONG __cdecl atol(const char *);
5376 PALIMPORT ULONG __cdecl strtoul(const char *, char **, int);
5377 PALIMPORT double __cdecl atof(const char *);
5378 PALIMPORT char * __cdecl _gcvt_s(char *, int, double, int);
5379 PALIMPORT char * __cdecl _ecvt(double, int, int *, int *);
5380 PALIMPORT double __cdecl strtod(const char *, char **);
5381 PALIMPORT int __cdecl isprint(int);
5382 PALIMPORT int __cdecl isspace(int);
5383 PALIMPORT int __cdecl isalpha(int);
5384 PALIMPORT int __cdecl isalnum(int);
5385 PALIMPORT int __cdecl isdigit(int);
5386 PALIMPORT int __cdecl isxdigit(int);
5387 PALIMPORT int __cdecl isupper(int);
5388 PALIMPORT int __cdecl islower(int);
5389 PALIMPORT int __cdecl __iscsym(int);
5390 PALIMPORT int __cdecl tolower(int);
5391 PALIMPORT int __cdecl toupper(int);
5393 PALIMPORT size_t __cdecl _mbslen(const unsigned char *);
5394 PALIMPORT unsigned char * __cdecl _mbsinc(const unsigned char *);
5395 PALIMPORT unsigned char * __cdecl _mbsninc(const unsigned char *, size_t);
5396 PALIMPORT unsigned char * __cdecl _mbsdec(const unsigned char *, const unsigned char *);
5398 PALIMPORT size_t __cdecl wcslen(const wchar_t *);
5399 PALIMPORT int __cdecl wcscmp(const wchar_t*, const wchar_t*);
5400 PALIMPORT int __cdecl wcsncmp(const wchar_t *, const wchar_t *, size_t);
5401 PALIMPORT int __cdecl _wcsicmp(const wchar_t *, const wchar_t*);
5402 PALIMPORT int __cdecl _wcsnicmp(const wchar_t *, const wchar_t *, size_t);
5403 PALIMPORT wchar_t * __cdecl wcscat(wchar_t *, const wchar_t *);
5404 PALIMPORT wchar_t * __cdecl wcsncat(wchar_t *, const wchar_t *, size_t);
5405 PALIMPORT wchar_t * __cdecl wcscpy(wchar_t *, const wchar_t *);
5406 PALIMPORT wchar_t * __cdecl wcsncpy(wchar_t *, const wchar_t *, size_t);
5407 PALIMPORT const wchar_t * __cdecl wcschr(const wchar_t *, wchar_t);
5408 PALIMPORT const wchar_t * __cdecl wcsrchr(const wchar_t *, wchar_t);
5409 PALIMPORT wchar_t _WConst_return * __cdecl wcspbrk(const wchar_t *, const wchar_t *);
5410 PALIMPORT wchar_t _WConst_return * __cdecl wcsstr(const wchar_t *, const wchar_t *);
5411 PALIMPORT wchar_t * __cdecl wcstok(wchar_t *, const wchar_t *);
5412 PALIMPORT size_t __cdecl wcscspn(const wchar_t *, const wchar_t *);
5413 PALIMPORT int __cdecl swprintf(wchar_t *, const wchar_t *, ...);
5414 PALIMPORT int __cdecl vswprintf(wchar_t *, const wchar_t *, va_list);
5415 PALIMPORT int __cdecl _snwprintf(wchar_t *, size_t, const wchar_t *, ...);
5416 PALIMPORT int __cdecl _vsnwprintf(wchar_t *, size_t, const wchar_t *, va_list);
5417 PALIMPORT int __cdecl swscanf(const wchar_t *, const wchar_t *, ...);
5418 PALIMPORT wchar_t * __cdecl _wcslwr(wchar_t *);
5419 PALIMPORT LONG __cdecl wcstol(const wchar_t *, wchar_t **, int);
5420 PALIMPORT ULONG __cdecl wcstoul(const wchar_t *, wchar_t **, int);
5421 PALIMPORT ULONGLONG _wcstoui64(const wchar_t *, wchar_t **, int);
5422 PALIMPORT wchar_t * __cdecl _itow(int, wchar_t *, int);
5423 PALIMPORT wchar_t * __cdecl _i64tow(__int64, wchar_t *, int);
5424 PALIMPORT wchar_t * __cdecl _ui64tow(unsigned __int64, wchar_t *, int);
5425 PALIMPORT int __cdecl _wtoi(const wchar_t *);
5426 PALIMPORT size_t __cdecl wcsspn (const wchar_t *, const wchar_t *);
5427 PALIMPORT double __cdecl wcstod(const wchar_t *, wchar_t **);
5428 PALIMPORT int __cdecl iswalpha(wchar_t);
5429 PALIMPORT int __cdecl iswprint(wchar_t);
5430 PALIMPORT int __cdecl iswupper(wchar_t);
5431 PALIMPORT int __cdecl iswspace(wchar_t);
5432 PALIMPORT int __cdecl iswdigit(wchar_t);
5433 PALIMPORT int __cdecl iswxdigit(wchar_t);
5434 PALIMPORT wchar_t __cdecl towlower(wchar_t);
5435 PALIMPORT wchar_t __cdecl towupper(wchar_t);
5440 inline wchar_t *wcschr(wchar_t *_S, wchar_t _C)
5441 {return ((wchar_t *)wcschr((const wchar_t *)_S, _C)); }
5442 inline wchar_t *wcsrchr(wchar_t *_S, wchar_t _C)
5443 {return ((wchar_t *)wcsrchr((const wchar_t *)_S, _C)); }
5444 inline wchar_t *wcspbrk(wchar_t *_S, const wchar_t *_P)
5445 {return ((wchar_t *)wcspbrk((const wchar_t *)_S, _P)); }
5446 inline wchar_t *wcsstr(wchar_t *_S, const wchar_t *_P)
5447 {return ((wchar_t *)wcsstr((const wchar_t *)_S, _P)); }
5451 PALIMPORT unsigned int __cdecl _rotl(unsigned int, int);
5452 // On 64 bit unix, make the long an int.
5454 #define _lrotl _rotl
5457 PALIMPORT unsigned int __cdecl _rotr(unsigned int, int);
5458 PALIMPORT int __cdecl abs(int);
5459 PALIMPORT double __cdecl fabs(double);
5460 PALIMPORT LONG __cdecl labs(LONG);
5461 // clang complains if this is declared with __int64
5462 PALIMPORT long long __cdecl llabs(long long);
5464 PALIMPORT double __cdecl sqrt(double);
5465 PALIMPORT double __cdecl log(double);
5466 PALIMPORT double __cdecl log10(double);
5467 PALIMPORT double __cdecl exp(double);
5468 PALIMPORT double __cdecl pow(double, double);
5469 PALIMPORT double __cdecl acos(double);
5470 PALIMPORT double __cdecl asin(double);
5471 PALIMPORT double __cdecl atan(double);
5472 PALIMPORT double __cdecl atan2(double,double);
5473 PALIMPORT double __cdecl cos(double);
5474 PALIMPORT double __cdecl sin(double);
5475 PALIMPORT double __cdecl tan(double);
5476 PALIMPORT double __cdecl cosh(double);
5477 PALIMPORT double __cdecl sinh(double);
5478 PALIMPORT double __cdecl tanh(double);
5479 PALIMPORT double __cdecl fmod(double, double);
5480 PALIMPORT double __cdecl floor(double);
5481 PALIMPORT double __cdecl ceil(double);
5482 PALIMPORT double __cdecl fabs(double);
5483 PALIMPORT double __cdecl modf(double, double *);
5484 PALIMPORT float __cdecl modff(float, float *);
5486 PALIMPORT int __cdecl _finite(double);
5487 PALIMPORT int __cdecl _isnan(double);
5488 PALIMPORT double __cdecl _copysign(double, double);
5492 inline float fabsf(float _X)
5494 return ((float)fabs((double)_X));
5498 inline __int64 abs(__int64 _X) {
5505 PALIMPORT void * __cdecl malloc(size_t);
5506 PALIMPORT void __cdecl free(void *);
5507 PALIMPORT void * __cdecl realloc(void *, size_t);
5508 PALIMPORT char * __cdecl _strdup(const char *);
5510 #if defined(_MSC_VER)
5511 #define alloca _alloca
5512 #elif defined(PLATFORM_UNIX)
5513 #define _alloca alloca
5516 #define _alloca __builtin_alloca
5517 #define alloca __builtin_alloca
5520 #if defined(__GNUC__) && defined(PLATFORM_UNIX)
5521 // we set -fno-builtin on the command line. This requires that if
5522 // we use alloca, with either have to call __builtin_alloca, or
5523 // ensure that the alloca call doesn't happen in code which is
5524 // modifying the stack (such as "memset (alloca(x), y, z)"
5526 #define alloca __builtin_alloca
5529 #define max(a, b) (((a) > (b)) ? (a) : (b))
5530 #define min(a, b) (((a) < (b)) ? (a) : (b))
5532 PALIMPORT PAL_NORETURN void __cdecl exit(int);
5533 int __cdecl atexit(void (__cdecl *function)(void));
5535 PALIMPORT void __cdecl qsort(void *, size_t, size_t, int (__cdecl *)(const void *, const void *));
5536 PALIMPORT void * __cdecl bsearch(const void *, const void *, size_t, size_t,
5537 int (__cdecl *)(const void *, const void *));
5539 PALIMPORT void __cdecl _splitpath(const char *, char *, char *, char *, char *);
5540 PALIMPORT void __cdecl _wsplitpath(const wchar_t *, wchar_t *, wchar_t *, wchar_t *, wchar_t *);
5541 PALIMPORT void __cdecl _makepath(char *, const char *, const char *, const char *, const char *);
5542 PALIMPORT void __cdecl _wmakepath(wchar_t *, const wchar_t *, const wchar_t *, const wchar_t *, const wchar_t *);
5543 PALIMPORT char * __cdecl _fullpath(char *, const char *, size_t);
5545 PALIMPORT void __cdecl _swab(char *, char *, int);
5547 PALIMPORT time_t __cdecl time(time_t *);
5550 int tm_sec; /* seconds after the minute - [0,59] */
5551 int tm_min; /* minutes after the hour - [0,59] */
5552 int tm_hour; /* hours since midnight - [0,23] */
5553 int tm_mday; /* day of the month - [1,31] */
5554 int tm_mon; /* months since January - [0,11] */
5555 int tm_year; /* years since 1900 */
5556 int tm_wday; /* days since Sunday - [0,6] */
5557 int tm_yday; /* days since January 1 - [0,365] */
5558 int tm_isdst; /* daylight savings time flag */
5561 PALIMPORT struct tm * __cdecl localtime(const time_t *);
5562 PALIMPORT time_t __cdecl mktime(struct tm *);
5563 PALIMPORT char * __cdecl ctime(const time_t *);
5565 PALIMPORT int __cdecl _open_osfhandle(INT_PTR, int);
5566 PALIMPORT int __cdecl _close(int);
5568 PALIMPORT int __cdecl _flushall();
5571 typedef struct _FILE FILE;
5577 /* Locale categories */
5579 #define LC_COLLATE 1
5581 #define LC_MONETARY 3
5582 #define LC_NUMERIC 4
5585 #define _IOFBF 0 /* setvbuf should set fully buffered */
5586 #define _IOLBF 1 /* setvbuf should set line buffered */
5587 #define _IONBF 2 /* setvbuf should set unbuffered */
5589 PALIMPORT int __cdecl fclose(FILE *);
5590 PALIMPORT void __cdecl setbuf(FILE *, char*);
5591 PALIMPORT int __cdecl fflush(FILE *);
5592 PALIMPORT size_t __cdecl fwrite(const void *, size_t, size_t, FILE *);
5593 PALIMPORT size_t __cdecl fread(void *, size_t, size_t, FILE *);
5594 PALIMPORT char * __cdecl fgets(char *, int, FILE *);
5595 PALIMPORT wchar_t * __cdecl fgetws(wchar_t *, int, FILE *);
5596 PALIMPORT int __cdecl fputs(const char *, FILE *);
5597 PALIMPORT int __cdecl fputc(int c, FILE *stream);
5598 PALIMPORT int __cdecl putchar(int c);
5599 PALIMPORT int __cdecl fprintf(FILE *, const char *, ...);
5600 PALIMPORT int __cdecl fwprintf(FILE *, const wchar_t *, ...);
5601 PALIMPORT int __cdecl vfprintf(FILE *, const char *, va_list);
5602 PALIMPORT int __cdecl vfwprintf(FILE *, const wchar_t *, va_list);
5603 PALIMPORT int __cdecl _getw(FILE *);
5604 PALIMPORT int __cdecl _putw(int, FILE *);
5605 PALIMPORT int __cdecl fseek(FILE *, LONG, int);
5606 PALIMPORT int __cdecl fgetpos(FILE *, fpos_t *);
5607 PALIMPORT int __cdecl fsetpos(FILE *, const fpos_t *);
5608 PALIMPORT LONG __cdecl ftell(FILE *);
5609 PALIMPORT int __cdecl feof(FILE *);
5610 PALIMPORT int __cdecl ferror(FILE *);
5611 PALIMPORT FILE * __cdecl fopen(const char *, const char *);
5612 PALIMPORT FILE * __cdecl _fdopen(int, const char *);
5613 PALIMPORT FILE * __cdecl _wfopen(const wchar_t *, const wchar_t *);
5614 PALIMPORT FILE * __cdecl _wfsopen(const wchar_t *, const wchar_t *, int);
5615 PALIMPORT int __cdecl getc(FILE *stream);
5616 PALIMPORT int __cdecl fgetc(FILE *stream);
5617 PALIMPORT int __cdecl ungetc(int c, FILE *stream);
5618 PALIMPORT int __cdecl setvbuf(FILE *stream, char *, int, size_t);
5620 /* Maximum value that can be returned by the rand function. */
5622 #define RAND_MAX 0x7fff
5624 PALIMPORT int __cdecl rand(void);
5625 PALIMPORT void __cdecl srand(unsigned int);
5627 PALIMPORT int __cdecl printf(const char *, ...);
5628 PALIMPORT int __cdecl vprintf(const char *, va_list);
5629 PALIMPORT int __cdecl wprintf(const wchar_t*, ...);
5632 #define PAL_get_caller _MSC_VER
5634 #define PAL_get_caller 0
5637 PALIMPORT FILE * __cdecl PAL_get_stdout(int caller);
5638 PALIMPORT FILE * __cdecl PAL_get_stdin(int caller);
5639 PALIMPORT FILE * __cdecl PAL_get_stderr(int caller);
5640 PALIMPORT int * __cdecl PAL_errno(int caller);
5642 #define stdout (PAL_get_stdout(PAL_get_caller))
5643 #define stdin (PAL_get_stdin(PAL_get_caller))
5644 #define stderr (PAL_get_stderr(PAL_get_caller))
5645 #define errno (*PAL_errno(PAL_get_caller))
5647 PALIMPORT char * __cdecl getenv(const char *);
5648 PALIMPORT int __cdecl _putenv(const char *);
5652 /******************* PAL-specific I/O completion port *****************/
5654 typedef struct _PAL_IOCP_CPU_INFORMATION {
5656 FILETIME ftLastRecordedIdleTime;
5657 FILETIME ftLastRecordedCurrentTime;
5659 FILETIME ftLastRecordedKernelTime;
5660 FILETIME ftLastRecordedUserTime;
5661 } PAL_IOCP_CPU_INFORMATION;
5667 IN OUT PAL_IOCP_CPU_INFORMATION *lpPrevCPUInfo);
5669 /****************PAL Perf functions for PInvoke*********************/
5674 PAL_EnableProcessProfile(VOID);
5679 PAL_DisableProcessProfile(VOID);
5684 PAL_IsProcessProfileEnabled(VOID);
5689 PAL_GetCpuTickCount(VOID);
5692 /******************* PAL functions for SIMD extensions *****************/
5695 unsigned int _mm_getcsr(void);
5698 void _mm_setcsr(unsigned int i);
5700 /******************* PAL side-by-side support ************************/
5702 #ifdef FEATURE_PAL_SXS
5704 // Some versions of the PAL support several PALs side-by-side
5705 // in the process. To avoid those PALs interfering with one
5706 // another, they need to be told by clients when they are active
5707 // and when they are not.
5710 // To avoid performance problems incurred by swapping thread
5711 // exception ports every time we leave the PAL, there's also
5712 // the concept of entering/leaving the PAL at its top boundary
5713 // (entering down/leaving up) or at the bottom boundary
5714 // (leaving down/entering up).
5716 typedef enum _PAL_Boundary {
5717 PAL_BoundaryTop, // closer to main()
5718 PAL_BoundaryBottom, // closer to execution
5719 PAL_BoundaryEH, // out-of-band during EH
5721 PAL_BoundaryMax = PAL_BoundaryEH
5724 // This function needs to be called on a thread when it enters
5725 // a region of code that depends on this instance of the PAL
5726 // in the process, and the current thread may or may not be
5727 // known to the PAL. This function can fail (for something else
5728 // than an internal error) if this is the first time that the
5729 // current thread entered this PAL. Note that PAL_Initialize
5730 // implies a call to this function. Does not modify LastError.
5734 PAL_Enter(PAL_Boundary boundary);
5736 // Returns TRUE if we this thread has already entered the PAL,
5737 // returns FALSE if we have not entered the PAL.
5743 // Equivalent to PAL_Enter(PAL_BoundaryTop) and is for stub
5744 // code generation use.
5750 // This function needs to be called on a thread when it enters
5751 // a region of code that depends on this instance of the PAL
5752 // in the process, and the current thread is already known to
5753 // the PAL. Does not modify LastError.
5757 PAL_Reenter(PAL_Boundary boundary);
5759 // This function needs to be called on a thread when it enters
5760 // a region of code that depends on this instance of the PAL
5761 // in the process, and it is unknown whether the current thread
5762 // is already running in the PAL. Returns TRUE if and only if
5763 // the thread was not running in the PAL previously. Does not
5764 // modify LastError.
5768 PAL_ReenterForEH(VOID);
5770 // This function needs to be called on a thread when it leaves
5771 // a region of code that depends on this instance of the PAL
5772 // in the process. Does not modify LastError.
5776 PAL_Leave(PAL_Boundary boundary);
5778 // This function is equivalent to PAL_Leave(PAL_BoundaryBottom)
5779 // and is available to limit the creation of stub code.
5785 // This function is equivalent to PAL_Leave(PAL_BoundaryTop)
5786 // and is available to limit the creation of stub code.
5792 // Returns TRUE if the argument HMODULE denotes the PAL itself.
5796 PAL_IsSelf(IN HMODULE);
5800 // A holder to enter the PAL for a specific region of code.
5801 // Previously, we must have been executing outside the PAL
5802 // (unless fEnter is set to FALSE).
5804 class PAL_EnterHolder
5810 PAL_EnterHolder(BOOL fEnter = TRUE) : m_palError(ERROR_SUCCESS)
5814 m_palError = PAL_Enter(PAL_BoundaryTop);
5815 m_fEntered = m_palError == ERROR_SUCCESS;
5827 PAL_Leave(PAL_BoundaryTop);
5836 void SuppressRelease()
5838 // Used to avoid calling PAL_Leave() when
5839 // another code path will explicitly do so.
5844 class PAL_LeaveHolder
5849 PAL_Leave(PAL_BoundaryBottom);
5854 PAL_Reenter(PAL_BoundaryBottom);
5857 #endif // __cplusplus
5859 #else // FEATURE_PAL_SXS
5861 #define PAL_Enter(boundary) ERROR_SUCCESS
5862 #define PAL_Reenter(boundary)
5863 #define PAL_Leave(boundary)
5866 class PAL_EnterHolder {
5868 // using constructor to suppress the "unused variable" warnings
5871 class PAL_LeaveHolder {
5873 // using constructor to suppress the "unused variable" warnings
5876 #endif // __cplusplus
5878 #endif // FEATURE_PAL_SXS
5882 #include "pal_unwind.h"
5884 // A pretend exception code that we use to stand for external exceptions,
5885 // such as a C++ exception leaking across a P/Invoke boundary into
5886 // COMPlusFrameHandler.
5887 #define EXCEPTION_FOREIGN 0xe0455874 // 0xe0000000 | 'EXT'
5889 // Test whether the argument exceptionObject is an SEH exception. If it is,
5890 // return the associated exception pointers. If it is not, return NULL.
5892 EXCEPTION_POINTERS *
5894 PAL_GetExceptionPointers(struct _Unwind_Exception *exceptionObject);
5896 typedef void (*PFN_PAL_BODY)(void *pvParam);
5898 typedef struct _PAL_DISPATCHER_CONTEXT {
5899 _Unwind_Action actions;
5900 struct _Unwind_Exception *exception_object;
5901 struct _Unwind_Context *context;
5902 } PAL_DISPATCHER_CONTEXT;
5904 typedef EXCEPTION_DISPOSITION (*PFN_PAL_EXCEPTION_FILTER)(
5905 EXCEPTION_POINTERS *ExceptionPointers,
5906 PAL_DISPATCHER_CONTEXT *DispatcherContext,
5911 struct PAL_SEHException
5914 // Note that the following two are actually embedded in this heap-allocated
5915 // instance - in contrast to Win32, where the exception record would usually
5916 // be allocated on the stack. This is needed because foreign cleanup handlers
5917 // partially unwind the stack on the second pass.
5918 EXCEPTION_POINTERS ExceptionPointers;
5919 EXCEPTION_RECORD ExceptionRecord;
5920 CONTEXT ContextRecord;
5922 PAL_SEHException(EXCEPTION_RECORD *pExceptionRecord, CONTEXT *pContextRecord)
5924 ExceptionPointers.ExceptionRecord = &ExceptionRecord;
5925 ExceptionPointers.ContextRecord = &ContextRecord;
5926 ExceptionRecord = *pExceptionRecord;
5927 ContextRecord = *pContextRecord;
5931 #endif // __cplusplus
5933 // Start of a try block for exceptions raised by RaiseException
5934 #define PAL_TRY(__ParamType, __paramDef, __paramRef) \
5936 __ParamType __param = __paramRef; \
5937 auto tryBlock = [](__ParamType __paramDef) \
5940 // Start of an exception handler. If an exception raised by the RaiseException
5941 // occurs in the try block and the disposition is EXCEPTION_EXECUTE_HANDLER,
5942 // the handler code is executed. If the disposition is EXCEPTION_CONTINUE_SEARCH,
5943 // the exception is rethrown. The EXCEPTION_CONTINUE_EXECUTION disposition is
5945 #define PAL_EXCEPT(dispositionExpression) \
5947 const bool isFinally = false; \
5948 auto finallyBlock = []() {}; \
5951 tryBlock(__param); \
5953 catch (PAL_SEHException& ex) \
5955 EXCEPTION_DISPOSITION disposition = dispositionExpression; \
5956 _ASSERTE(disposition != EXCEPTION_CONTINUE_EXECUTION); \
5957 if (disposition == EXCEPTION_CONTINUE_SEARCH) \
5963 // Start of an exception handler. It works the same way as the PAL_EXCEPT except
5964 // that the disposition is obtained by calling the specified filter.
5965 #define PAL_EXCEPT_FILTER(filter) PAL_EXCEPT(filter(&ex.ExceptionPointers, __param))
5967 // Start of a finally block. The finally block is executed both when the try block
5968 // finishes or when an exception is raised using the RaiseException in it.
5969 #define PAL_FINALLY \
5971 const bool isFinally = true; \
5972 auto finallyBlock = [&]() \
5975 // End of an except or a finally block.
5976 #define PAL_ENDTRY \
5982 tryBlock(__param); \
5993 #endif // FEATURE_PAL_SXS
5995 #define PAL_CPP_THROW(type, obj) { throw obj; }
5996 #define PAL_CPP_RETHROW { throw; }
5997 #define PAL_CPP_TRY try {
5998 #define PAL_CPP_CATCH_EXCEPTION(ident) } catch (Exception *ident) { PAL_Reenter(PAL_BoundaryBottom);
5999 #define PAL_CPP_CATCH_EXCEPTION_NOARG } catch (Exception *) { PAL_Reenter(PAL_BoundaryBottom);
6000 #define PAL_CPP_CATCH_DERIVED(type, ident) } catch (type *ident) { PAL_Reenter(PAL_BoundaryBottom);
6001 #define PAL_CPP_CATCH_ALL } catch (...) { PAL_Reenter(PAL_BoundaryBottom);
6002 #define PAL_CPP_ENDTRY }
6005 #pragma warning(disable:4611) // interaction between '_setjmp' and C++ object destruction is non-portable
6008 #ifdef FEATURE_PAL_SXS
6010 #define PAL_TRY_FOR_DLLMAIN(ParamType, paramDef, paramRef, _reason) PAL_TRY(ParamType, paramDef, paramRef)
6012 #else // FEATURE_PAL_SXS
6014 #define PAL_TRY(ParamType, paramDef, paramRef) \
6016 ParamType __param = paramRef; \
6017 ParamType paramDef; paramDef = __param; \
6019 #define PAL_TRY_FOR_DLLMAIN(ParamType, paramDef, paramRef, _reason) \
6021 ParamType __param = paramRef; \
6022 ParamType paramDef; paramDef = __param; \
6024 #define PAL_ENDTRY \
6028 #endif // FEATURE_PAL_SXS
6030 #define EXCEPTION_CONTINUE_SEARCH 0
6031 #define EXCEPTION_EXECUTE_HANDLER 1
6032 #define EXCEPTION_CONTINUE_EXECUTION -1
6034 // Platform-specific library naming
6036 #ifdef PLATFORM_UNIX
6038 #define MAKEDLLNAME_W(name) u"lib" name u".dylib"
6039 #define MAKEDLLNAME_A(name) "lib" name ".dylib"
6041 #define MAKEDLLNAME_W(name) L"lib" name L".a"
6042 #define MAKEDLLNAME_A(name) "lib" name ".a"
6043 #elif defined(__hppa__) || defined(_IA64_)
6044 #define MAKEDLLNAME_W(name) L"lib" name L".sl"
6045 #define MAKEDLLNAME_A(name) "lib" name ".sl"
6047 #define MAKEDLLNAME_W(name) u"lib" name u".so"
6048 #define MAKEDLLNAME_A(name) "lib" name ".so"
6051 #define MAKEDLLNAME_W(name) name L".dll"
6052 #define MAKEDLLNAME_A(name) name ".dll"
6056 #define MAKEDLLNAME(x) MAKEDLLNAME_W(x)
6058 #define MAKEDLLNAME(x) MAKEDLLNAME_A(x)
6061 #define DBG_EXCEPTION_HANDLED ((DWORD )0x00010001L)
6062 #define DBG_CONTINUE ((DWORD )0x00010002L)
6063 #define DBG_EXCEPTION_NOT_HANDLED ((DWORD )0x80010001L)
6065 #define DBG_TERMINATE_THREAD ((DWORD )0x40010003L)
6066 #define DBG_TERMINATE_PROCESS ((DWORD )0x40010004L)
6067 #define DBG_CONTROL_C ((DWORD )0x40010005L)
6068 #define DBG_RIPEXCEPTION ((DWORD )0x40010007L)
6069 #define DBG_CONTROL_BREAK ((DWORD )0x40010008L)
6070 #define DBG_COMMAND_EXCEPTION ((DWORD )0x40010009L)
6072 #define STATUS_USER_APC ((DWORD )0x000000C0L)
6073 #define STATUS_GUARD_PAGE_VIOLATION ((DWORD )0x80000001L)
6074 #define STATUS_DATATYPE_MISALIGNMENT ((DWORD )0x80000002L)
6075 #define STATUS_BREAKPOINT ((DWORD )0x80000003L)
6076 #define STATUS_SINGLE_STEP ((DWORD )0x80000004L)
6077 #define STATUS_LONGJUMP ((DWORD )0x80000026L)
6078 #define STATUS_UNWIND_CONSOLIDATE ((DWORD )0x80000029L)
6079 #define STATUS_ACCESS_VIOLATION ((DWORD )0xC0000005L)
6080 #define STATUS_IN_PAGE_ERROR ((DWORD )0xC0000006L)
6081 #define STATUS_INVALID_HANDLE ((DWORD )0xC0000008L)
6082 #define STATUS_NO_MEMORY ((DWORD )0xC0000017L)
6083 #define STATUS_ILLEGAL_INSTRUCTION ((DWORD )0xC000001DL)
6084 #define STATUS_NONCONTINUABLE_EXCEPTION ((DWORD )0xC0000025L)
6085 #define STATUS_INVALID_DISPOSITION ((DWORD )0xC0000026L)
6086 #define STATUS_ARRAY_BOUNDS_EXCEEDED ((DWORD )0xC000008CL)
6087 #define STATUS_FLOAT_DENORMAL_OPERAND ((DWORD )0xC000008DL)
6088 #define STATUS_FLOAT_DIVIDE_BY_ZERO ((DWORD )0xC000008EL)
6089 #define STATUS_FLOAT_INEXACT_RESULT ((DWORD )0xC000008FL)
6090 #define STATUS_FLOAT_INVALID_OPERATION ((DWORD )0xC0000090L)
6091 #define STATUS_FLOAT_OVERFLOW ((DWORD )0xC0000091L)
6092 #define STATUS_FLOAT_STACK_CHECK ((DWORD )0xC0000092L)
6093 #define STATUS_FLOAT_UNDERFLOW ((DWORD )0xC0000093L)
6094 #define STATUS_INTEGER_DIVIDE_BY_ZERO ((DWORD )0xC0000094L)
6095 #define STATUS_INTEGER_OVERFLOW ((DWORD )0xC0000095L)
6096 #define STATUS_PRIVILEGED_INSTRUCTION ((DWORD )0xC0000096L)
6097 #define STATUS_STACK_OVERFLOW ((DWORD )0xC00000FDL)
6098 #define STATUS_CONTROL_C_EXIT ((DWORD )0xC000013AL)
6100 #define WAIT_IO_COMPLETION STATUS_USER_APC
6102 #define EXCEPTION_ACCESS_VIOLATION STATUS_ACCESS_VIOLATION
6103 #define EXCEPTION_DATATYPE_MISALIGNMENT STATUS_DATATYPE_MISALIGNMENT
6104 #define EXCEPTION_BREAKPOINT STATUS_BREAKPOINT
6105 #define EXCEPTION_SINGLE_STEP STATUS_SINGLE_STEP
6106 #define EXCEPTION_ARRAY_BOUNDS_EXCEEDED STATUS_ARRAY_BOUNDS_EXCEEDED
6107 #define EXCEPTION_FLT_DENORMAL_OPERAND STATUS_FLOAT_DENORMAL_OPERAND
6108 #define EXCEPTION_FLT_DIVIDE_BY_ZERO STATUS_FLOAT_DIVIDE_BY_ZERO
6109 #define EXCEPTION_FLT_INEXACT_RESULT STATUS_FLOAT_INEXACT_RESULT
6110 #define EXCEPTION_FLT_INVALID_OPERATION STATUS_FLOAT_INVALID_OPERATION
6111 #define EXCEPTION_FLT_OVERFLOW STATUS_FLOAT_OVERFLOW
6112 #define EXCEPTION_FLT_STACK_CHECK STATUS_FLOAT_STACK_CHECK
6113 #define EXCEPTION_FLT_UNDERFLOW STATUS_FLOAT_UNDERFLOW
6114 #define EXCEPTION_INT_DIVIDE_BY_ZERO STATUS_INTEGER_DIVIDE_BY_ZERO
6115 #define EXCEPTION_INT_OVERFLOW STATUS_INTEGER_OVERFLOW
6116 #define EXCEPTION_PRIV_INSTRUCTION STATUS_PRIVILEGED_INSTRUCTION
6117 #define EXCEPTION_IN_PAGE_ERROR STATUS_IN_PAGE_ERROR
6118 #define EXCEPTION_ILLEGAL_INSTRUCTION STATUS_ILLEGAL_INSTRUCTION
6119 #define EXCEPTION_NONCONTINUABLE_EXCEPTION STATUS_NONCONTINUABLE_EXCEPTION
6120 #define EXCEPTION_STACK_OVERFLOW STATUS_STACK_OVERFLOW
6121 #define EXCEPTION_INVALID_DISPOSITION STATUS_INVALID_DISPOSITION
6122 #define EXCEPTION_GUARD_PAGE STATUS_GUARD_PAGE_VIOLATION
6123 #define EXCEPTION_INVALID_HANDLE STATUS_INVALID_HANDLE
6125 #define CONTROL_C_EXIT STATUS_CONTROL_C_EXIT
6127 /* These are from the <FCNTL.H> file in windows.
6128 They are needed for _open_osfhandle.*/
6129 #define _O_RDONLY 0x0000
6130 #define _O_APPEND 0x0008
6131 #define _O_TEXT 0x4000
6132 #define _O_BINARY 0x8000