1 // Licensed to the .NET Foundation under one or more agreements.
2 // The .NET Foundation licenses this file to you under the MIT license.
3 // See the LICENSE file in the project root for more information.
13 Rotor Platform Adaptation Layer (PAL) header file. This file
14 defines all types and API calls required by the Rotor port of
15 the Microsoft Common Language Runtime.
17 Defines which control the behavior of this include file:
18 UNICODE - define it to set the Ansi/Unicode neutral names to
19 be the ...W names. Otherwise the neutral names default
21 PAL_IMPLEMENTATION - define it when implementing the PAL. Otherwise
22 leave it undefined when consuming the PAL.
24 Note: some fields in structs have been renamed from the original
25 SDK documentation names, with _PAL_Undefined appended. This leaves
26 the structure layout identical to its Win32 version, but prevents
27 PAL consumers from inadvertently referencing undefined fields.
29 If you want to add a PAL_ wrapper function to a native function in
30 here, you also need to edit palinternal.h and win32pal.h.
39 #ifdef PAL_STDCPP_COMPAT
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)
67 #include <pal_char16.h>
68 #include <pal_error.h>
69 #include <pal_mstypes.h>
71 /******************* Processor-specific glue *****************************/
75 #if defined(__i686__) && !defined(_M_IX86)
77 #elif defined(__i586__) && !defined(_M_IX86)
79 #elif defined(__i486__) && !defined(_M_IX86)
81 #elif defined(__i386__) && !defined(_M_IX86)
83 #elif defined(__x86_64__) && !defined(_M_AMD64)
85 #elif defined(__arm__) && !defined(_M_ARM)
87 #elif defined(__aarch64__) && !defined(_M_ARM64)
91 #if defined(_M_IX86) && !defined(_X86_)
93 #elif defined(_M_AMD64) && !defined(_AMD64_)
95 #elif defined(_M_ARM) && !defined(_ARM_)
97 #elif defined(_M_ARM64) && !defined(_ARM64_)
103 /******************* ABI-specific glue *******************************/
106 // Both PowerPC, i386 and x86_64 on Mac OS X use 16-byte alignment.
107 #define STACK_ALIGN_BITS 4
108 #define STACK_ALIGN_REQ (1 << STACK_ALIGN_BITS)
112 #define _MAX_PATH 260
113 #define _MAX_DRIVE 3 /* max. length of drive component */
114 #define _MAX_DIR 256 /* max. length of path component */
115 #define _MAX_FNAME 256 /* max. length of file name component */
116 #define _MAX_EXT 256 /* max. length of extension component */
118 // In some Win32 APIs MAX_PATH is used for file names (even though 256 is the normal file system limit)
119 // use _MAX_PATH_FNAME to indicate these cases
120 #define MAX_PATH_FNAME MAX_PATH
121 #define MAX_LONGPATH 1024 /* max. length of full pathname */
123 #define MAXSHORT 0x7fff
124 #define MAXLONG 0x7fffffff
126 #define MAXDWORD 0xffffffff
130 // Note that the named locale APIs (eg CompareStringExEx) are recommended.
133 #define LANG_CHINESE 0x04
134 #define LANG_ENGLISH 0x09
135 #define LANG_JAPANESE 0x11
136 #define LANG_KOREAN 0x12
137 #define LANG_THAI 0x1e
139 /******************* Compiler-specific glue *******************************/
143 // Define this if the underlying platform supports true 2-pass EH.
144 // At the same time, this enables running several PAL instances
146 #define FEATURE_PAL_SXS 1
150 #if defined(_MSC_VER) || defined(__llvm__)
151 #define DECLSPEC_ALIGN(x) __declspec(align(x))
153 #define DECLSPEC_ALIGN(x)
156 #define DECLSPEC_NORETURN PAL_NORETURN
158 #if !defined(_MSC_VER) || defined(SOURCE_FORMATTING)
159 #define __assume(x) (void)0
160 #define __annotation(x)
167 #define FORCEINLINE inline
169 #define FORCEINLINE __forceinline
173 #ifndef PAL_STDCPP_COMPAT
177 typedef __builtin_va_list va_list;
179 /* We should consider if the va_arg definition here is actually necessary.
180 Could we use the standard va_arg definition? */
182 #define va_start __builtin_va_start
183 #define va_arg __builtin_va_arg
185 #define va_copy __builtin_va_copy
186 #define va_end __builtin_va_end
190 #define PUB __attribute__((visibility("default")))
194 typedef char * va_list;
196 #define _INTSIZEOF(n) ( (sizeof(n) + sizeof(int) - 1) & ~(sizeof(int) - 1) )
201 #define _ADDRESSOF(v) ( &reinterpret_cast<const char &>(v) )
203 #define _ADDRESSOF(v) ( &(v) )
206 #define _crt_va_start(ap,v) ( ap = (va_list)_ADDRESSOF(v) + _INTSIZEOF(v) )
207 #define _crt_va_arg(ap,t) ( *(t *)((ap += _INTSIZEOF(t)) - _INTSIZEOF(t)) )
208 #define _crt_va_end(ap) ( ap = (va_list)0 )
210 #define va_start _crt_va_start
211 #define va_arg _crt_va_arg
212 #define va_end _crt_va_end
216 #define va_start(ap,v) (ap = (va_list) (&(v)) + _INTSIZEOF(v))
217 #define va_arg(ap,t) ( *(t *)((ap += _INTSIZEOF(t)) - _INTSIZEOF(t)) )
222 #define va_copy(dest,src) (dest = src)
226 #endif // !PAL_STDCPP_COMPAT
228 /******************* PAL-Specific Entrypoints *****************************/
230 #define IsDebuggerPresent PAL_IsDebuggerPresent
235 PAL_IsDebuggerPresent(VOID);
237 #define MAXIMUM_SUSPEND_COUNT MAXCHAR
241 #define SCHAR_MIN (-128)
242 #define SCHAR_MAX 127
243 #define UCHAR_MAX 0xff
245 #define SHRT_MIN (-32768)
246 #define SHRT_MAX 32767
247 #define USHRT_MAX 0xffff
249 #define INT_MIN (-2147483647 - 1)
250 #define INT_MAX 2147483647
251 #define UINT_MAX 0xffffffff
253 #define LONG_MIN (-2147483647L - 1)
254 #define LONG_MAX 2147483647L
255 #define ULONG_MAX 0xffffffffUL
257 #define FLT_MAX 3.402823466e+38F
258 #define DBL_MAX 1.7976931348623157e+308
260 /* minimum signed 64 bit value */
261 #define _I64_MIN (I64(-9223372036854775807) - 1)
262 /* maximum signed 64 bit value */
263 #define _I64_MAX I64(9223372036854775807)
264 /* maximum unsigned 64 bit value */
265 #define _UI64_MAX UI64(0xffffffffffffffff)
267 #define _I8_MAX SCHAR_MAX
268 #define _I8_MIN SCHAR_MIN
269 #define _I16_MAX SHRT_MAX
270 #define _I16_MIN SHRT_MIN
271 #define _I32_MAX INT_MAX
272 #define _I32_MIN INT_MIN
273 #define _UI8_MAX UCHAR_MAX
274 #define _UI8_MIN UCHAR_MIN
275 #define _UI16_MAX USHRT_MAX
276 #define _UI16_MIN USHRT_MIN
277 #define _UI32_MAX UINT_MAX
278 #define _UI32_MIN UINT_MIN
280 #ifdef PAL_STDCPP_COMPAT
285 #if defined(__cplusplus)
288 #define NULL ((void *)0)
292 #if defined(PAL_STDCPP_COMPAT) && !defined(__cplusplus)
294 #endif // defined(PAL_STDCPP_COMPAT) && !defined(__cplusplus)
296 #ifndef PAL_STDCPP_COMPAT
298 #if _WIN64 || _MSC_VER >= 1400
299 typedef __int64 time_t;
303 #define _TIME_T_DEFINED
304 #endif // !PAL_STDCPP_COMPAT
306 #if ENABLE_DOWNLEVEL_FOR_NLS
307 #define MAKELCID(lgid, srtid) ((DWORD)((((DWORD)((WORD )(srtid))) << 16) | \
308 ((DWORD)((WORD )(lgid)))))
309 #define LANGIDFROMLCID(lcid) ((WORD)(lcid))
310 #define SORTIDFROMLCID(lcid) ((WORD)((((DWORD)(lcid)) >> 16) & 0xf))
312 #define LANG_NEUTRAL 0x00
313 #define LANG_INVARIANT 0x7f
314 #define SUBLANG_NEUTRAL 0x00 // language neutral
315 #define SUBLANG_DEFAULT 0x01 // user default
316 #define SORT_DEFAULT 0x0 // sorting default
317 #define SUBLANG_SYS_DEFAULT 0x02 // system default
319 #define MAKELANGID(p, s) ((((WORD )(s)) << 10) | (WORD )(p))
320 #define PRIMARYLANGID(lgid) ((WORD )(lgid) & 0x3ff)
321 #define SUBLANGID(lgid) ((WORD )(lgid) >> 10)
323 #define LANG_SYSTEM_DEFAULT (MAKELANGID(LANG_NEUTRAL, SUBLANG_SYS_DEFAULT))
324 #define LANG_USER_DEFAULT (MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT))
325 #define LOCALE_SYSTEM_DEFAULT (MAKELCID(LANG_SYSTEM_DEFAULT, SORT_DEFAULT))
326 #define LOCALE_USER_DEFAULT (MAKELCID(LANG_USER_DEFAULT, SORT_DEFAULT))
327 #define LOCALE_NEUTRAL (MAKELCID(MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), SORT_DEFAULT))
328 #define LOCALE_US_ENGLISH (MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT))
329 #define LOCALE_INVARIANT (MAKELCID(MAKELANGID(LANG_INVARIANT, SUBLANG_NEUTRAL), SORT_DEFAULT))
331 #define SUBLANG_ENGLISH_US 0x01
332 #define SUBLANG_CHINESE_TRADITIONAL 0x01 /* Chinese (Traditional) */
334 #endif // ENABLE_DOWNLEVEL_FOR_NLS
337 #define CT_CTYPE1 0x00000001 /* ctype 1 information */
338 #define CT_CTYPE2 0x00000002 /* ctype 2 information */
339 #define CT_CTYPE3 0x00000004 /* ctype 3 information */
340 #define C1_UPPER 0x0001 /* upper case */
341 #define C1_LOWER 0x0002 /* lower case */
342 #define C1_DIGIT 0x0004 /* decimal digits */
343 #define C1_SPACE 0x0008 /* spacing characters */
344 #define C1_PUNCT 0x0010 /* punctuation characters */
345 #define C1_CNTRL 0x0020 /* control characters */
346 #define C1_BLANK 0x0040 /* blank characters */
347 #define C1_XDIGIT 0x0080 /* other digits */
348 #define C1_ALPHA 0x0100 /* any linguistic character */
349 #define C2_LEFTTORIGHT 0x0001 /* left to right */
350 #define C2_RIGHTTOLEFT 0x0002 /* right to left */
351 #define C2_EUROPENUMBER 0x0003 /* European number, digit */
352 #define C2_EUROPESEPARATOR 0x0004 /* European numeric separator */
353 #define C2_EUROPETERMINATOR 0x0005 /* European numeric terminator */
354 #define C2_ARABICNUMBER 0x0006 /* Arabic number */
355 #define C2_COMMONSEPARATOR 0x0007 /* common numeric separator */
356 #define C2_BLOCKSEPARATOR 0x0008 /* block separator */
357 #define C2_SEGMENTSEPARATOR 0x0009 /* segment separator */
358 #define C2_WHITESPACE 0x000A /* white space */
359 #define C2_OTHERNEUTRAL 0x000B /* other neutrals */
360 #define C2_NOTAPPLICABLE 0x0000 /* no implicit directionality */
361 #define C3_NONSPACING 0x0001 /* nonspacing character */
362 #define C3_DIACRITIC 0x0002 /* diacritic mark */
363 #define C3_VOWELMARK 0x0004 /* vowel mark */
364 #define C3_SYMBOL 0x0008 /* symbols */
365 #define C3_KATAKANA 0x0010 /* katakana character */
366 #define C3_HIRAGANA 0x0020 /* hiragana character */
367 #define C3_HALFWIDTH 0x0040 /* half width character */
368 #define C3_FULLWIDTH 0x0080 /* full width character */
369 #define C3_IDEOGRAPH 0x0100 /* ideographic character */
370 #define C3_KASHIDA 0x0200 /* Arabic kashida character */
371 #define C3_LEXICAL 0x0400 /* lexical character */
372 #define C3_ALPHA 0x8000 /* any ling. char (C1_ALPHA) */
373 #define C3_NOTAPPLICABLE 0x0000 /* ctype 3 is not applicable */
375 #define DLL_PROCESS_ATTACH 1
376 #define DLL_THREAD_ATTACH 2
377 #define DLL_THREAD_DETACH 3
378 #define DLL_PROCESS_DETACH 0
380 #define PAL_INITIALIZE_NONE 0x00
381 #define PAL_INITIALIZE_SYNC_THREAD 0x01
382 #define PAL_INITIALIZE_EXEC_ALLOCATOR 0x02
383 #define PAL_INITIALIZE_STD_HANDLES 0x04
384 #define PAL_INITIALIZE_REGISTER_SIGTERM_HANDLER 0x08
385 #define PAL_INITIALIZE_DEBUGGER_EXCEPTIONS 0x10
387 // PAL_Initialize() flags
388 #define PAL_INITIALIZE (PAL_INITIALIZE_SYNC_THREAD | PAL_INITIALIZE_STD_HANDLES)
390 // PAL_InitializeDLL() flags - don't start any of the helper threads
391 #define PAL_INITIALIZE_DLL PAL_INITIALIZE_NONE
393 // PAL_InitializeCoreCLR() flags
394 #define PAL_INITIALIZE_CORECLR (PAL_INITIALIZE | PAL_INITIALIZE_EXEC_ALLOCATOR | PAL_INITIALIZE_REGISTER_SIGTERM_HANDLER | PAL_INITIALIZE_DEBUGGER_EXCEPTIONS)
396 typedef DWORD (PALAPI *PTHREAD_START_ROUTINE)(LPVOID lpThreadParameter);
397 typedef PTHREAD_START_ROUTINE LPTHREAD_START_ROUTINE;
399 /******************* PAL-Specific Entrypoints *****************************/
406 const char * const argv[]);
411 PAL_InitializeDLL(VOID);
416 PAL_InitializeCoreCLR(
417 const char *szExePath);
423 IN LPTHREAD_START_ROUTINE lpStartAddress,
424 IN LPVOID lpParameter);
427 /// This function shuts down PAL WITHOUT exiting the current process.
436 /// This function shuts down PAL and exits the current process.
445 /// This function shuts down PAL and exits the current process with
446 /// the specified exit code.
454 typedef VOID (*PSHUTDOWN_CALLBACK)(void);
459 PAL_SetShutdownCallback(
460 IN PSHUTDOWN_CALLBACK callback);
462 typedef VOID (*PPAL_STARTUP_CALLBACK)(
470 PAL_RegisterForRuntimeStartup(
471 IN DWORD dwProcessId,
472 IN PPAL_STARTUP_CALLBACK pfnCallback,
474 OUT PVOID *ppUnregisterToken);
479 PAL_UnregisterForRuntimeStartup(
480 IN PVOID pUnregisterToken);
485 PAL_NotifyRuntimeStarted(VOID);
487 static const int MAX_DEBUGGER_TRANSPORT_PIPE_NAME_LENGTH = 64;
492 PAL_GetTransportPipeName(
495 IN const char *suffix);
506 PAL_IgnoreProfileSignal(int signalNum);
512 IN LPCSTR lpLibFileName);
517 PAL_UnregisterModule(
518 IN HINSTANCE hInstance);
523 PAL_GetPALDirectoryW(
524 OUT LPWSTR lpDirectoryName,
525 IN OUT UINT* cchDirectoryName);
527 #define PAL_GetPALDirectory PAL_GetPALDirectoryW
529 #define PAL_GetPALDirectory PAL_GetPALDirectoryA
537 IN OUT LPVOID lpBuffer,
548 /******************* winuser.h Entrypoints *******************************/
560 IN LPCSTR lpCurrentChar,
564 #define CharNext CharNextA
565 #define CharNextEx CharNextExA
569 #define MB_OK 0x00000000L
570 #define MB_OKCANCEL 0x00000001L
571 #define MB_ABORTRETRYIGNORE 0x00000002L
572 #define MB_YESNO 0x00000004L
573 #define MB_RETRYCANCEL 0x00000005L
575 #define MB_ICONHAND 0x00000010L
576 #define MB_ICONQUESTION 0x00000020L
577 #define MB_ICONEXCLAMATION 0x00000030L
578 #define MB_ICONASTERISK 0x00000040L
580 #define MB_ICONINFORMATION MB_ICONASTERISK
581 #define MB_ICONSTOP MB_ICONHAND
582 #define MB_ICONERROR MB_ICONHAND
584 #define MB_DEFBUTTON1 0x00000000L
585 #define MB_DEFBUTTON2 0x00000100L
586 #define MB_DEFBUTTON3 0x00000200L
588 #define MB_SYSTEMMODAL 0x00001000L
589 #define MB_TASKMODAL 0x00002000L
590 #define MB_SETFOREGROUND 0x00010000L
591 #define MB_TOPMOST 0x00040000L
593 #define MB_NOFOCUS 0x00008000L
594 #define MB_SETFOREGROUND 0x00010000L
595 #define MB_DEFAULT_DESKTOP_ONLY 0x00020000L
597 // Note: this is the NT 4.0 and greater value.
598 #define MB_SERVICE_NOTIFICATION 0x00200000L
600 #define MB_TYPEMASK 0x0000000FL
601 #define MB_ICONMASK 0x000000F0L
602 #define MB_DEFMASK 0x00000F00L
617 IN LPVOID hWnd, // NOTE: diff from winuser.h
619 IN LPCWSTR lpCaption,
624 #define MessageBox MessageBoxW
626 #define MessageBox MessageBoxA
629 /***************** wincon.h Entrypoints **********************************/
631 #define CTRL_C_EVENT 0
632 #define CTRL_BREAK_EVENT 1
633 #define CTRL_CLOSE_EVENT 2
636 #define CTRL_LOGOFF_EVENT 5
637 #define CTRL_SHUTDOWN_EVENT 6
641 (PALAPI *PHANDLER_ROUTINE)(
649 GenerateConsoleCtrlEvent(
650 IN DWORD dwCtrlEvent,
651 IN DWORD dwProcessGroupId
655 //end wincon.h Entrypoints
662 #define _CRTIMP __declspec(dllimport)
666 /******************* winbase.h Entrypoints and defines ************************/
673 typedef struct _SECURITY_ATTRIBUTES {
675 LPVOID lpSecurityDescriptor;
677 } SECURITY_ATTRIBUTES, *PSECURITY_ATTRIBUTES, *LPSECURITY_ATTRIBUTES;
679 #define _SH_DENYWR 0x20 /* deny write mode */
681 #define FILE_READ_DATA ( 0x0001 ) // file & pipe
682 #define FILE_APPEND_DATA ( 0x0004 ) // file
684 #define GENERIC_READ (0x80000000L)
685 #define GENERIC_WRITE (0x40000000L)
687 #define FILE_SHARE_READ 0x00000001
688 #define FILE_SHARE_WRITE 0x00000002
689 #define FILE_SHARE_DELETE 0x00000004
692 #define CREATE_ALWAYS 2
693 #define OPEN_EXISTING 3
694 #define OPEN_ALWAYS 4
695 #define TRUNCATE_EXISTING 5
697 #define FILE_ATTRIBUTE_READONLY 0x00000001
698 #define FILE_ATTRIBUTE_HIDDEN 0x00000002
699 #define FILE_ATTRIBUTE_SYSTEM 0x00000004
700 #define FILE_ATTRIBUTE_DIRECTORY 0x00000010
701 #define FILE_ATTRIBUTE_ARCHIVE 0x00000020
702 #define FILE_ATTRIBUTE_DEVICE 0x00000040
703 #define FILE_ATTRIBUTE_NORMAL 0x00000080
705 #define FILE_FLAG_WRITE_THROUGH 0x80000000
706 #define FILE_FLAG_NO_BUFFERING 0x20000000
707 #define FILE_FLAG_RANDOM_ACCESS 0x10000000
708 #define FILE_FLAG_SEQUENTIAL_SCAN 0x08000000
709 #define FILE_FLAG_BACKUP_SEMANTICS 0x02000000
712 #define FILE_CURRENT 1
715 #define STILL_ACTIVE (0x00000103L)
717 #define INVALID_SET_FILE_POINTER ((DWORD)-1)
724 IN LPCWSTR lpFileName,
725 IN DWORD dwDesiredAccess,
726 IN DWORD dwShareMode,
727 IN LPSECURITY_ATTRIBUTES lpSecurityAttributes,
728 IN DWORD dwCreationDisposition,
729 IN DWORD dwFlagsAndAttributes,
730 IN HANDLE hTemplateFile);
733 #define CreateFile CreateFileW
735 #define CreateFile CreateFileA
743 IN DWORD dwFileOffsetLow,
744 IN DWORD dwFileOffsetHigh,
745 IN DWORD nNumberOfBytesToLockLow,
746 IN DWORD nNumberOfBytesToLockHigh
754 IN DWORD dwFileOffsetLow,
755 IN DWORD dwFileOffsetHigh,
756 IN DWORD nNumberOfBytesToUnlockLow,
757 IN DWORD nNumberOfBytesToUnlockHigh
766 IN LPCWSTR lpFileName,
767 IN LPCWSTR lpExtension,
768 IN DWORD nBufferLength,
770 OUT LPWSTR *lpFilePart
773 #define SearchPath SearchPathW
775 #define SearchPath SearchPathA
784 IN LPCWSTR lpExistingFileName,
785 IN LPCWSTR lpNewFileName,
786 IN BOOL bFailIfExists);
789 #define CopyFile CopyFileW
791 #define CopyFile CopyFileA
799 IN LPCWSTR lpFileName);
802 #define DeleteFile DeleteFileW
804 #define DeleteFile DeleteFileA
813 IN LPCWSTR lpExistingFileName,
814 IN LPCWSTR lpNewFileName);
817 #define MoveFile MoveFileW
819 #define MoveFile MoveFileA
822 #define MOVEFILE_REPLACE_EXISTING 0x00000001
823 #define MOVEFILE_COPY_ALLOWED 0x00000002
830 IN LPCWSTR lpExistingFileName,
831 IN LPCWSTR lpNewFileName,
835 #define MoveFileEx MoveFileExW
837 #define MoveFileEx MoveFileExA
844 IN LPCWSTR lpPathName,
845 IN LPSECURITY_ATTRIBUTES lpSecurityAttributes);
848 #define CreateDirectory CreateDirectoryW
850 #define CreateDirectory CreateDirectoryA
857 IN LPCWSTR lpPathName);
860 #define RemoveDirectory RemoveDirectoryW
862 #define RemoveDirectory RemoveDirectoryA
865 typedef struct _BY_HANDLE_FILE_INFORMATION {
866 DWORD dwFileAttributes;
867 FILETIME ftCreationTime;
868 FILETIME ftLastAccessTime;
869 FILETIME ftLastWriteTime;
870 DWORD dwVolumeSerialNumber;
873 DWORD nNumberOfLinks;
874 DWORD nFileIndexHigh;
876 } BY_HANDLE_FILE_INFORMATION, *PBY_HANDLE_FILE_INFORMATION, *LPBY_HANDLE_FILE_INFORMATION;
878 typedef struct _WIN32_FIND_DATAA {
879 DWORD dwFileAttributes;
880 FILETIME ftCreationTime;
881 FILETIME ftLastAccessTime;
882 FILETIME ftLastWriteTime;
887 CHAR cFileName[ MAX_PATH_FNAME ];
888 CHAR cAlternateFileName[ 14 ];
889 } WIN32_FIND_DATAA, *PWIN32_FIND_DATAA, *LPWIN32_FIND_DATAA;
891 typedef struct _WIN32_FIND_DATAW {
892 DWORD dwFileAttributes;
893 FILETIME ftCreationTime;
894 FILETIME ftLastAccessTime;
895 FILETIME ftLastWriteTime;
900 WCHAR cFileName[ MAX_PATH_FNAME ];
901 WCHAR cAlternateFileName[ 14 ];
902 } WIN32_FIND_DATAW, *PWIN32_FIND_DATAW, *LPWIN32_FIND_DATAW;
905 typedef WIN32_FIND_DATAW WIN32_FIND_DATA;
906 typedef PWIN32_FIND_DATAW PWIN32_FIND_DATA;
907 typedef LPWIN32_FIND_DATAW LPWIN32_FIND_DATA;
909 typedef WIN32_FIND_DATAA WIN32_FIND_DATA;
910 typedef PWIN32_FIND_DATAA PWIN32_FIND_DATA;
911 typedef LPWIN32_FIND_DATAA LPWIN32_FIND_DATA;
918 IN LPCWSTR lpFileName,
919 OUT LPWIN32_FIND_DATAW lpFindFileData);
922 #define FindFirstFile FindFirstFileW
924 #define FindFirstFile FindFirstFileA
932 OUT LPWIN32_FIND_DATAW lpFindFileData);
935 #define FindNextFile FindNextFileW
937 #define FindNextFile FindNextFileA
944 IN OUT HANDLE hFindFile);
950 IN LPCWSTR lpFileName);
953 #define GetFileAttributes GetFileAttributesW
955 #define GetFileAttributes GetFileAttributesA
958 typedef enum _GET_FILEEX_INFO_LEVELS {
959 GetFileExInfoStandard
960 } GET_FILEEX_INFO_LEVELS;
962 typedef enum _FINDEX_INFO_LEVELS {
965 FindExInfoMaxInfoLevel
966 } FINDEX_INFO_LEVELS;
968 typedef enum _FINDEX_SEARCH_OPS {
969 FindExSearchNameMatch,
970 FindExSearchLimitToDirectories,
971 FindExSearchLimitToDevices,
972 FindExSearchMaxSearchOp
975 typedef struct _WIN32_FILE_ATTRIBUTE_DATA {
976 DWORD dwFileAttributes;
977 FILETIME ftCreationTime;
978 FILETIME ftLastAccessTime;
979 FILETIME ftLastWriteTime;
982 } WIN32_FILE_ATTRIBUTE_DATA, *LPWIN32_FILE_ATTRIBUTE_DATA;
987 GetFileAttributesExW(
988 IN LPCWSTR lpFileName,
989 IN GET_FILEEX_INFO_LEVELS fInfoLevelId,
990 OUT LPVOID lpFileInformation);
993 #define GetFileAttributesEx GetFileAttributesExW
1000 IN LPCWSTR lpFileName,
1001 IN DWORD dwFileAttributes);
1004 #define SetFileAttributes SetFileAttributesW
1006 #define SetFileAttributes SetFileAttributesA
1009 typedef LPVOID LPOVERLAPPED; // diff from winbase.h
1016 IN LPCVOID lpBuffer,
1017 IN DWORD nNumberOfBytesToWrite,
1018 OUT LPDWORD lpNumberOfBytesWritten,
1019 IN LPOVERLAPPED lpOverlapped);
1026 OUT LPVOID lpBuffer,
1027 IN DWORD nNumberOfBytesToRead,
1028 OUT LPDWORD lpNumberOfBytesRead,
1029 IN LPOVERLAPPED lpOverlapped);
1031 #define STD_INPUT_HANDLE ((DWORD)-10)
1032 #define STD_OUTPUT_HANDLE ((DWORD)-11)
1033 #define STD_ERROR_HANDLE ((DWORD)-12)
1039 IN DWORD nStdHandle);
1052 IN LONG lDistanceToMove,
1053 IN PLONG lpDistanceToMoveHigh,
1054 IN DWORD dwMoveMethod);
1061 IN LARGE_INTEGER liDistanceToMove,
1062 OUT PLARGE_INTEGER lpNewFilePointer,
1063 IN DWORD dwMoveMethod);
1070 OUT LPDWORD lpFileSizeHigh);
1074 PALAPI GetFileSizeEx(
1076 OUT PLARGE_INTEGER lpFileSize);
1081 GetFileInformationByHandle(
1083 OUT BY_HANDLE_FILE_INFORMATION* lpFileInformation);
1089 IN CONST FILETIME *lpFileTime1,
1090 IN CONST FILETIME *lpFileTime2);
1097 IN CONST FILETIME *lpCreationTime,
1098 IN CONST FILETIME *lpLastAccessTime,
1099 IN CONST FILETIME *lpLastWriteTime);
1106 OUT LPFILETIME lpCreationTime,
1107 OUT LPFILETIME lpLastAccessTime,
1108 OUT LPFILETIME lpLastWriteTime);
1113 GetSystemTimeAsFileTime(
1114 OUT LPFILETIME lpSystemTimeAsFileTime);
1116 typedef struct _SYSTEMTIME {
1125 } SYSTEMTIME, *PSYSTEMTIME, *LPSYSTEMTIME;
1131 OUT LPSYSTEMTIME lpSystemTime);
1136 FileTimeToSystemTime(
1137 IN CONST FILETIME *lpFileTime,
1138 OUT LPSYSTEMTIME lpSystemTime);
1143 FileTimeToDosDateTime(
1144 IN CONST FILETIME *lpFileTime,
1145 OUT LPWORD lpFatDate,
1146 OUT LPWORD lpFatTime
1157 #define FILE_TYPE_UNKNOWN 0x0000
1158 #define FILE_TYPE_DISK 0x0001
1159 #define FILE_TYPE_CHAR 0x0002
1160 #define FILE_TYPE_PIPE 0x0003
1161 #define FILE_TYPE_REMOTE 0x8000
1185 IN LPCWSTR lpFileName,
1186 IN DWORD nBufferLength,
1187 OUT LPWSTR lpBuffer,
1188 OUT LPWSTR *lpFilePart);
1191 #define GetFullPathName GetFullPathNameW
1193 #define GetFullPathName GetFullPathNameA
1200 IN LPCWSTR lpszShortPath,
1201 OUT LPWSTR lpszLongPath,
1202 IN DWORD cchBuffer);
1205 #define GetLongPathName GetLongPathNameW
1212 IN LPCWSTR lpszLongPath,
1213 OUT LPWSTR lpszShortPath,
1214 IN DWORD cchBuffer);
1217 #define GetShortPathName GetShortPathNameW
1225 IN LPCWSTR lpPathName,
1226 IN LPCWSTR lpPrefixString,
1228 OUT LPWSTR lpTempFileName);
1231 #define GetTempFileName GetTempFileNameW
1233 #define GetTempFileName GetTempFileNameA
1240 IN DWORD nBufferLength,
1241 OUT LPWSTR lpBuffer);
1244 #define GetTempPath GetTempPathW
1246 #define GetTempPath GetTempPathA
1252 GetCurrentDirectoryW(
1253 IN DWORD nBufferLength,
1254 OUT LPWSTR lpBuffer);
1257 #define GetCurrentDirectory GetCurrentDirectoryW
1259 #define GetCurrentDirectory GetCurrentDirectoryA
1265 SetCurrentDirectoryW(
1266 IN LPCWSTR lpPathName);
1270 #define SetCurrentDirectory SetCurrentDirectoryW
1272 #define SetCurrentDirectory SetCurrentDirectoryA
1275 // maximum length of the NETBIOS name (not including NULL)
1276 #define MAX_COMPUTERNAME_LENGTH 15
1278 // maximum length of the username (not including NULL)
1285 OUT LPWSTR lpBuffer, // address of name buffer
1286 IN OUT LPDWORD nSize ); // address of size of name buffer
1292 OUT LPWSTR lpBuffer, // address of name buffer
1293 IN OUT LPDWORD nSize); // address of size of name buffer
1296 #define GetUserName GetUserNameW
1297 #define GetComputerName GetComputerNameW
1304 IN LPSECURITY_ATTRIBUTES lpSemaphoreAttributes,
1305 IN LONG lInitialCount,
1306 IN LONG lMaximumCount,
1313 IN LPSECURITY_ATTRIBUTES lpSemaphoreAttributes,
1314 IN LONG lInitialCount,
1315 IN LONG lMaximumCount,
1317 IN /*_Reserved_*/ DWORD dwFlags,
1318 IN DWORD dwDesiredAccess);
1324 IN DWORD dwDesiredAccess,
1325 IN BOOL bInheritHandle,
1329 #define CreateSemaphore CreateSemaphoreW
1330 #define CreateSemaphoreEx CreateSemaphoreExW
1332 #define CreateSemaphore CreateSemaphoreA
1333 #define CreateSemaphoreEx CreateSemaphoreExA
1340 IN HANDLE hSemaphore,
1341 IN LONG lReleaseCount,
1342 OUT LPLONG lpPreviousCount);
1348 IN LPSECURITY_ATTRIBUTES lpEventAttributes,
1349 IN BOOL bManualReset,
1350 IN BOOL bInitialState,
1357 IN LPSECURITY_ATTRIBUTES lpEventAttributes,
1360 IN DWORD dwDesiredAccess);
1362 // CreateEventExW: dwFlags
1363 #define CREATE_EVENT_MANUAL_RESET ((DWORD)0x1)
1364 #define CREATE_EVENT_INITIAL_SET ((DWORD)0x2)
1367 #define CreateEvent CreateEventW
1369 #define CreateEvent CreateEventA
1388 IN DWORD dwDesiredAccess,
1389 IN BOOL bInheritHandle,
1393 #define OpenEvent OpenEventW
1400 IN LPSECURITY_ATTRIBUTES lpMutexAttributes,
1401 IN BOOL bInitialOwner,
1408 IN LPSECURITY_ATTRIBUTES lpMutexAttributes,
1411 IN DWORD dwDesiredAccess);
1413 // CreateMutexExW: dwFlags
1414 #define CREATE_MUTEX_INITIAL_OWNER ((DWORD)0x1)
1417 #define CreateMutex CreateMutexW
1419 #define CreateMutex CreateMutexA
1426 IN DWORD dwDesiredAccess,
1427 IN BOOL bInheritHandle,
1432 #define OpenMutex OpenMutexW
1434 #define OpenMutex OpenMutexA
1446 GetCurrentProcessId(
1452 GetCurrentSessionId(
1467 // To work around multiply-defined symbols in the Carbon framework.
1468 #define GetCurrentThread PAL_GetCurrentThread
1476 #define STARTF_USESTDHANDLES 0x00000100
1478 typedef struct _STARTUPINFOW {
1480 LPWSTR lpReserved_PAL_Undefined;
1481 LPWSTR lpDesktop_PAL_Undefined;
1482 LPWSTR lpTitle_PAL_Undefined;
1483 DWORD dwX_PAL_Undefined;
1484 DWORD dwY_PAL_Undefined;
1485 DWORD dwXSize_PAL_Undefined;
1486 DWORD dwYSize_PAL_Undefined;
1487 DWORD dwXCountChars_PAL_Undefined;
1488 DWORD dwYCountChars_PAL_Undefined;
1489 DWORD dwFillAttribute_PAL_Undefined;
1491 WORD wShowWindow_PAL_Undefined;
1492 WORD cbReserved2_PAL_Undefined;
1493 LPBYTE lpReserved2_PAL_Undefined;
1497 } STARTUPINFOW, *LPSTARTUPINFOW;
1499 typedef struct _STARTUPINFOA {
1501 LPSTR lpReserved_PAL_Undefined;
1502 LPSTR lpDesktop_PAL_Undefined;
1503 LPSTR lpTitle_PAL_Undefined;
1504 DWORD dwX_PAL_Undefined;
1505 DWORD dwY_PAL_Undefined;
1506 DWORD dwXSize_PAL_Undefined;
1507 DWORD dwYSize_PAL_Undefined;
1508 DWORD dwXCountChars_PAL_Undefined;
1509 DWORD dwYCountChars_PAL_Undefined;
1510 DWORD dwFillAttribute_PAL_Undefined;
1512 WORD wShowWindow_PAL_Undefined;
1513 WORD cbReserved2_PAL_Undefined;
1514 LPBYTE lpReserved2_PAL_Undefined;
1518 } STARTUPINFOA, *LPSTARTUPINFOA;
1521 typedef STARTUPINFOW STARTUPINFO;
1522 typedef LPSTARTUPINFOW LPSTARTUPINFO;
1524 typedef STARTUPINFOA STARTUPINFO;
1525 typedef LPSTARTUPINFOW LPSTARTUPINFO;
1528 #define CREATE_NEW_CONSOLE 0x00000010
1530 #define NORMAL_PRIORITY_CLASS 0x00000020
1532 typedef struct _PROCESS_INFORMATION {
1536 DWORD dwThreadId_PAL_Undefined;
1537 } PROCESS_INFORMATION, *PPROCESS_INFORMATION, *LPPROCESS_INFORMATION;
1543 IN LPCWSTR lpApplicationName,
1544 IN LPWSTR lpCommandLine,
1545 IN LPSECURITY_ATTRIBUTES lpProcessAttributes,
1546 IN LPSECURITY_ATTRIBUTES lpThreadAttributes,
1547 IN BOOL bInheritHandles,
1548 IN DWORD dwCreationFlags,
1549 IN LPVOID lpEnvironment,
1550 IN LPCWSTR lpCurrentDirectory,
1551 IN LPSTARTUPINFOW lpStartupInfo,
1552 OUT LPPROCESS_INFORMATION lpProcessInformation);
1555 #define CreateProcess CreateProcessW
1557 #define CreateProcess CreateProcessA
1579 IN LPDWORD lpExitCode);
1586 OUT LPFILETIME lpCreationTime,
1587 OUT LPFILETIME lpExitTime,
1588 OUT LPFILETIME lpKernelTime,
1589 OUT LPFILETIME lpUserTime);
1591 #define MAXIMUM_WAIT_OBJECTS 64
1592 #define WAIT_OBJECT_0 0
1593 #define WAIT_ABANDONED 0x00000080
1594 #define WAIT_ABANDONED_0 0x00000080
1595 #define WAIT_TIMEOUT 258
1596 #define WAIT_FAILED ((DWORD)0xFFFFFFFF)
1598 #define INFINITE 0xFFFFFFFF // Infinite timeout
1603 WaitForSingleObject(
1605 IN DWORD dwMilliseconds);
1610 WaitForSingleObjectEx(
1612 IN DWORD dwMilliseconds,
1613 IN BOOL bAlertable);
1618 WaitForMultipleObjects(
1620 IN CONST HANDLE *lpHandles,
1622 IN DWORD dwMilliseconds);
1627 WaitForMultipleObjectsEx(
1629 IN CONST HANDLE *lpHandles,
1631 IN DWORD dwMilliseconds,
1632 IN BOOL bAlertable);
1634 #define DUPLICATE_CLOSE_SOURCE 0x00000001
1635 #define DUPLICATE_SAME_ACCESS 0x00000002
1641 IN HANDLE hSourceProcessHandle,
1642 IN HANDLE hSourceHandle,
1643 IN HANDLE hTargetProcessHandle,
1644 OUT LPHANDLE lpTargetHandle,
1645 IN DWORD dwDesiredAccess,
1646 IN BOOL bInheritHandle,
1647 IN DWORD dwOptions);
1653 IN DWORD dwMilliseconds);
1659 IN DWORD dwMilliseconds,
1660 IN BOOL bAlertable);
1668 #define DEBUG_PROCESS 0x00000001
1669 #define DEBUG_ONLY_THIS_PROCESS 0x00000002
1670 #define CREATE_SUSPENDED 0x00000004
1671 #define STACK_SIZE_PARAM_IS_A_RESERVATION 0x00010000
1677 IN LPSECURITY_ATTRIBUTES lpThreadAttributes,
1678 IN DWORD dwStackSize,
1679 IN LPTHREAD_START_ROUTINE lpStartAddress,
1680 IN LPVOID lpParameter,
1681 IN DWORD dwCreationFlags,
1682 OUT LPDWORD lpThreadId);
1689 IN DWORD dwExitCode);
1696 IN LPDWORD lpExitCode);
1704 typedef VOID (PALAPI *PAPCFUNC)(ULONG_PTR dwParam);
1712 IN ULONG_PTR dwData);
1717 // ***********************************************************************************
1719 // NOTE: These context definitions are replicated in ndp/clr/src/debug/inc/DbgTargetContext.h (for the
1720 // purposes manipulating contexts from different platforms during remote debugging). Be sure to keep those
1721 // definitions in sync if you make any changes here.
1723 // ***********************************************************************************
1726 #define SIZE_OF_80387_REGISTERS 80
1728 #define CONTEXT_i386 0x00010000
1729 #define CONTEXT_CONTROL (CONTEXT_i386 | 0x00000001L) // SS:SP, CS:IP, FLAGS, BP
1730 #define CONTEXT_INTEGER (CONTEXT_i386 | 0x00000002L) // AX, BX, CX, DX, SI, DI
1731 #define CONTEXT_SEGMENTS (CONTEXT_i386 | 0x00000004L)
1732 #define CONTEXT_FLOATING_POINT (CONTEXT_i386 | 0x00000008L) // 387 state
1733 #define CONTEXT_DEBUG_REGISTERS (CONTEXT_i386 | 0x00000010L)
1735 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS)
1736 #define CONTEXT_EXTENDED_REGISTERS (CONTEXT_i386 | 0x00000020L)
1737 #define CONTEXT_ALL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS | CONTEXT_FLOATING_POINT | CONTEXT_DEBUG_REGISTERS | CONTEXT_EXTENDED_REGISTERS)
1739 #define MAXIMUM_SUPPORTED_EXTENSION 512
1741 #define CONTEXT_XSTATE (CONTEXT_i386 | 0x40L)
1743 #define CONTEXT_EXCEPTION_ACTIVE 0x8000000L
1744 #define CONTEXT_SERVICE_ACTIVE 0x10000000L
1745 #define CONTEXT_EXCEPTION_REQUEST 0x40000000L
1746 #define CONTEXT_EXCEPTION_REPORTING 0x80000000L
1749 // This flag is set by the unwinder if it has unwound to a call
1750 // site, and cleared whenever it unwinds through a trap frame.
1751 // It is used by language-specific exception handlers to help
1752 // differentiate exception scopes during dispatching.
1755 #define CONTEXT_UNWOUND_TO_CALL 0x20000000
1757 typedef struct _FLOATING_SAVE_AREA {
1762 DWORD ErrorSelector;
1765 BYTE RegisterArea[SIZE_OF_80387_REGISTERS];
1767 } FLOATING_SAVE_AREA;
1769 typedef FLOATING_SAVE_AREA *PFLOATING_SAVE_AREA;
1771 typedef struct _CONTEXT {
1774 ULONG Dr0_PAL_Undefined;
1775 ULONG Dr1_PAL_Undefined;
1776 ULONG Dr2_PAL_Undefined;
1777 ULONG Dr3_PAL_Undefined;
1778 ULONG Dr6_PAL_Undefined;
1779 ULONG Dr7_PAL_Undefined;
1781 FLOATING_SAVE_AREA FloatSave;
1783 ULONG SegGs_PAL_Undefined;
1784 ULONG SegFs_PAL_Undefined;
1785 ULONG SegEs_PAL_Undefined;
1786 ULONG SegDs_PAL_Undefined;
1802 UCHAR ExtendedRegisters[MAXIMUM_SUPPORTED_EXTENSION];
1803 } CONTEXT, *PCONTEXT, *LPCONTEXT;
1805 // To support saving and loading xmm register context we need to know the offset in the ExtendedRegisters
1806 // section at which they are stored. This has been determined experimentally since I have found no
1807 // documentation thus far but it corresponds to the offset we'd expect if a fxsave instruction was used to
1808 // store the regular FP state along with the XMM registers at the start of the extended registers section.
1809 // Technically the offset doesn't really matter if no code in the PAL or runtime knows what the offset should
1810 // be either (as long as we're consistent across GetThreadContext() and SetThreadContext() and we don't
1811 // support any other values in the ExtendedRegisters) but we might as well be as accurate as we can.
1812 #define CONTEXT_EXREG_XMM_OFFSET 160
1814 typedef struct _KNONVOLATILE_CONTEXT {
1821 } KNONVOLATILE_CONTEXT, *PKNONVOLATILE_CONTEXT;
1823 typedef struct _KNONVOLATILE_CONTEXT_POINTERS {
1825 // The ordering of these fields should be aligned with that
1826 // of corresponding fields in CONTEXT
1828 // (See FillRegDisplay in inc/regdisp.h for details)
1838 } KNONVOLATILE_CONTEXT_POINTERS, *PKNONVOLATILE_CONTEXT_POINTERS;
1840 #elif defined(_AMD64_)
1841 // copied from winnt.h
1843 #define CONTEXT_AMD64 0x100000
1845 #define CONTEXT_CONTROL (CONTEXT_AMD64 | 0x1L)
1846 #define CONTEXT_INTEGER (CONTEXT_AMD64 | 0x2L)
1847 #define CONTEXT_SEGMENTS (CONTEXT_AMD64 | 0x4L)
1848 #define CONTEXT_FLOATING_POINT (CONTEXT_AMD64 | 0x8L)
1849 #define CONTEXT_DEBUG_REGISTERS (CONTEXT_AMD64 | 0x10L)
1851 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_FLOATING_POINT)
1853 #define CONTEXT_ALL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS | CONTEXT_FLOATING_POINT | CONTEXT_DEBUG_REGISTERS)
1855 #define CONTEXT_XSTATE (CONTEXT_AMD64 | 0x40L)
1857 #define CONTEXT_EXCEPTION_ACTIVE 0x8000000
1858 #define CONTEXT_SERVICE_ACTIVE 0x10000000
1859 #define CONTEXT_EXCEPTION_REQUEST 0x40000000
1860 #define CONTEXT_EXCEPTION_REPORTING 0x80000000
1862 typedef struct DECLSPEC_ALIGN(16) _M128A {
1867 typedef struct _XMM_SAVE_AREA32 {
1881 M128A FloatRegisters[8];
1882 M128A XmmRegisters[16];
1884 } XMM_SAVE_AREA32, *PXMM_SAVE_AREA32;
1886 #define LEGACY_SAVE_AREA_LENGTH sizeof(XMM_SAVE_AREA32)
1891 // This frame has a several purposes: 1) it is used as an argument to
1892 // NtContinue, 2) is is used to constuct a call frame for APC delivery,
1893 // and 3) it is used in the user level thread creation routines.
1896 // The flags field within this record controls the contents of a CONTEXT
1899 // If the context record is used as an input parameter, then for each
1900 // portion of the context record controlled by a flag whose value is
1901 // set, it is assumed that that portion of the context record contains
1902 // valid context. If the context record is being used to modify a threads
1903 // context, then only that portion of the threads context is modified.
1905 // If the context record is used as an output parameter to capture the
1906 // context of a thread, then only those portions of the thread's context
1907 // corresponding to set flags will be returned.
1909 // CONTEXT_CONTROL specifies SegSs, Rsp, SegCs, Rip, and EFlags.
1911 // CONTEXT_INTEGER specifies Rax, Rcx, Rdx, Rbx, Rbp, Rsi, Rdi, and R8-R15.
1913 // CONTEXT_SEGMENTS specifies SegDs, SegEs, SegFs, and SegGs.
1915 // CONTEXT_DEBUG_REGISTERS specifies Dr0-Dr3 and Dr6-Dr7.
1917 // CONTEXT_MMX_REGISTERS specifies the floating point and extended registers
1918 // Mm0/St0-Mm7/St7 and Xmm0-Xmm15).
1921 typedef struct DECLSPEC_ALIGN(16) _CONTEXT {
1924 // Register parameter home addresses.
1926 // N.B. These fields are for convience - they could be used to extend the
1927 // context record in the future.
1945 // Segment Registers and processor flags.
1968 // Integer registers.
1995 // Floating point state.
1999 XMM_SAVE_AREA32 FltSave;
2023 // Vector registers.
2026 M128A VectorRegister[26];
2027 DWORD64 VectorControl;
2030 // Special debug control registers.
2033 DWORD64 DebugControl;
2034 DWORD64 LastBranchToRip;
2035 DWORD64 LastBranchFromRip;
2036 DWORD64 LastExceptionToRip;
2037 DWORD64 LastExceptionFromRip;
2038 } CONTEXT, *PCONTEXT, *LPCONTEXT;
2041 // Nonvolatile context pointer record.
2044 typedef struct _KNONVOLATILE_CONTEXT_POINTERS {
2046 PM128A FloatingContext[16];
2068 PDWORD64 IntegerContext[16];
2089 } KNONVOLATILE_CONTEXT_POINTERS, *PKNONVOLATILE_CONTEXT_POINTERS;
2091 #elif defined(_ARM_)
2093 #define CONTEXT_ARM 0x00200000L
2097 #define CONTEXT_CONTROL (CONTEXT_ARM | 0x1L)
2098 #define CONTEXT_INTEGER (CONTEXT_ARM | 0x2L)
2099 #define CONTEXT_FLOATING_POINT (CONTEXT_ARM | 0x4L)
2100 #define CONTEXT_DEBUG_REGISTERS (CONTEXT_ARM | 0x8L)
2102 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_FLOATING_POINT)
2104 #define CONTEXT_ALL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_FLOATING_POINT | CONTEXT_DEBUG_REGISTERS)
2106 #define CONTEXT_EXCEPTION_ACTIVE 0x8000000L
2107 #define CONTEXT_SERVICE_ACTIVE 0x10000000L
2108 #define CONTEXT_EXCEPTION_REQUEST 0x40000000L
2109 #define CONTEXT_EXCEPTION_REPORTING 0x80000000L
2112 // This flag is set by the unwinder if it has unwound to a call
2113 // site, and cleared whenever it unwinds through a trap frame.
2114 // It is used by language-specific exception handlers to help
2115 // differentiate exception scopes during dispatching.
2118 #define CONTEXT_UNWOUND_TO_CALL 0x20000000
2121 // Specify the number of breakpoints and watchpoints that the OS
2122 // will track. Architecturally, ARM supports up to 16. In practice,
2123 // however, almost no one implements more than 4 of each.
2126 #define ARM_MAX_BREAKPOINTS 8
2127 #define ARM_MAX_WATCHPOINTS 1
2129 typedef struct _NEON128 {
2132 } NEON128, *PNEON128;
2137 // This frame has a several purposes: 1) it is used as an argument to
2138 // NtContinue, 2) it is used to constuct a call frame for APC delivery,
2139 // and 3) it is used in the user level thread creation routines.
2142 // The flags field within this record controls the contents of a CONTEXT
2145 // If the context record is used as an input parameter, then for each
2146 // portion of the context record controlled by a flag whose value is
2147 // set, it is assumed that that portion of the context record contains
2148 // valid context. If the context record is being used to modify a threads
2149 // context, then only that portion of the threads context is modified.
2151 // If the context record is used as an output parameter to capture the
2152 // context of a thread, then only those portions of the thread's context
2153 // corresponding to set flags will be returned.
2155 // CONTEXT_CONTROL specifies Sp, Lr, Pc, and Cpsr
2157 // CONTEXT_INTEGER specifies R0-R12
2159 // CONTEXT_FLOATING_POINT specifies Q0-Q15 / D0-D31 / S0-S31
2161 // CONTEXT_DEBUG_REGISTERS specifies up to 16 of DBGBVR, DBGBCR, DBGWVR,
2165 typedef struct DECLSPEC_ALIGN(8) _CONTEXT {
2174 // Integer registers
2192 // Control Registers
2201 // Floating Point/NEON Registers
2216 DWORD Bvr[ARM_MAX_BREAKPOINTS];
2217 DWORD Bcr[ARM_MAX_BREAKPOINTS];
2218 DWORD Wvr[ARM_MAX_WATCHPOINTS];
2219 DWORD Wcr[ARM_MAX_WATCHPOINTS];
2223 } CONTEXT, *PCONTEXT, *LPCONTEXT;
2226 // Nonvolatile context pointer record.
2229 typedef struct _KNONVOLATILE_CONTEXT_POINTERS {
2250 } KNONVOLATILE_CONTEXT_POINTERS, *PKNONVOLATILE_CONTEXT_POINTERS;
2252 typedef struct _IMAGE_ARM_RUNTIME_FUNCTION_ENTRY {
2259 DWORD FunctionLength : 11;
2266 DWORD StackAdjust : 10;
2269 } IMAGE_ARM_RUNTIME_FUNCTION_ENTRY, * PIMAGE_ARM_RUNTIME_FUNCTION_ENTRY;
2271 #elif defined(_ARM64_)
2273 #define CONTEXT_ARM64 0x00400000L
2275 #define CONTEXT_CONTROL (CONTEXT_ARM64 | 0x1L)
2276 #define CONTEXT_INTEGER (CONTEXT_ARM64 | 0x2L)
2277 #define CONTEXT_FLOATING_POINT (CONTEXT_ARM64 | 0x4L)
2278 #define CONTEXT_DEBUG_REGISTERS (CONTEXT_ARM64 | 0x8L)
2280 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_FLOATING_POINT)
2282 #define CONTEXT_ALL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_FLOATING_POINT | CONTEXT_DEBUG_REGISTERS)
2284 #define CONTEXT_EXCEPTION_ACTIVE 0x8000000L
2285 #define CONTEXT_SERVICE_ACTIVE 0x10000000L
2286 #define CONTEXT_EXCEPTION_REQUEST 0x40000000L
2287 #define CONTEXT_EXCEPTION_REPORTING 0x80000000L
2290 // This flag is set by the unwinder if it has unwound to a call
2291 // site, and cleared whenever it unwinds through a trap frame.
2292 // It is used by language-specific exception handlers to help
2293 // differentiate exception scopes during dispatching.
2296 #define CONTEXT_UNWOUND_TO_CALL 0x20000000
2299 // Define initial Cpsr/Fpscr value
2302 #define INITIAL_CPSR 0x10
2303 #define INITIAL_FPSCR 0
2308 // Specify the number of breakpoints and watchpoints that the OS
2309 // will track. Architecturally, ARM64 supports up to 16. In practice,
2310 // however, almost no one implements more than 4 of each.
2313 #define ARM64_MAX_BREAKPOINTS 8
2314 #define ARM64_MAX_WATCHPOINTS 2
2319 // This frame has a several purposes: 1) it is used as an argument to
2320 // NtContinue, 2) it is used to constuct a call frame for APC delivery,
2321 // and 3) it is used in the user level thread creation routines.
2324 // The flags field within this record controls the contents of a CONTEXT
2327 // If the context record is used as an input parameter, then for each
2328 // portion of the context record controlled by a flag whose value is
2329 // set, it is assumed that that portion of the context record contains
2330 // valid context. If the context record is being used to modify a threads
2331 // context, then only that portion of the threads context is modified.
2333 // If the context record is used as an output parameter to capture the
2334 // context of a thread, then only those portions of the thread's context
2335 // corresponding to set flags will be returned.
2337 // CONTEXT_CONTROL specifies Sp, Lr, Pc, and Cpsr
2339 // CONTEXT_INTEGER specifies R0-R12
2341 // CONTEXT_FLOATING_POINT specifies Q0-Q15 / D0-D31 / S0-S31
2343 // CONTEXT_DEBUG_REGISTERS specifies up to 16 of DBGBVR, DBGBCR, DBGWVR,
2347 typedef struct _NEON128 {
2350 } NEON128, *PNEON128;
2352 typedef struct DECLSPEC_ALIGN(16) _CONTEXT {
2358 /* +0x000 */ DWORD ContextFlags;
2361 // Integer registers
2364 /* +0x004 */ DWORD Cpsr; // NZVF + DAIF + CurrentEL + SPSel
2365 /* +0x008 */ union {
2399 /* +0x0f0 */ DWORD64 Fp;
2400 /* +0x0f8 */ DWORD64 Lr;
2401 /* +0x100 */ DWORD64 Sp;
2402 /* +0x108 */ DWORD64 Pc;
2405 // Floating Point/NEON Registers
2408 /* +0x110 */ NEON128 V[32];
2409 /* +0x310 */ DWORD Fpcr;
2410 /* +0x314 */ DWORD Fpsr;
2416 /* +0x318 */ DWORD Bcr[ARM64_MAX_BREAKPOINTS];
2417 /* +0x338 */ DWORD64 Bvr[ARM64_MAX_BREAKPOINTS];
2418 /* +0x378 */ DWORD Wcr[ARM64_MAX_WATCHPOINTS];
2419 /* +0x380 */ DWORD64 Wvr[ARM64_MAX_WATCHPOINTS];
2422 } CONTEXT, *PCONTEXT, *LPCONTEXT;
2425 // Nonvolatile context pointer record.
2428 typedef struct _KNONVOLATILE_CONTEXT_POINTERS {
2452 } KNONVOLATILE_CONTEXT_POINTERS, *PKNONVOLATILE_CONTEXT_POINTERS;
2455 #error Unknown architecture for defining CONTEXT.
2464 IN OUT LPCONTEXT lpContext);
2471 IN CONST CONTEXT *lpContext);
2473 #define THREAD_BASE_PRIORITY_LOWRT 15
2474 #define THREAD_BASE_PRIORITY_MAX 2
2475 #define THREAD_BASE_PRIORITY_MIN (-2)
2476 #define THREAD_BASE_PRIORITY_IDLE (-15)
2478 #define THREAD_PRIORITY_LOWEST THREAD_BASE_PRIORITY_MIN
2479 #define THREAD_PRIORITY_BELOW_NORMAL (THREAD_PRIORITY_LOWEST+1)
2480 #define THREAD_PRIORITY_NORMAL 0
2481 #define THREAD_PRIORITY_HIGHEST THREAD_BASE_PRIORITY_MAX
2482 #define THREAD_PRIORITY_ABOVE_NORMAL (THREAD_PRIORITY_HIGHEST-1)
2483 #define THREAD_PRIORITY_ERROR_RETURN (MAXLONG)
2485 #define THREAD_PRIORITY_TIME_CRITICAL THREAD_BASE_PRIORITY_LOWRT
2486 #define THREAD_PRIORITY_IDLE THREAD_BASE_PRIORITY_IDLE
2506 OUT LPFILETIME lpCreationTime,
2507 OUT LPFILETIME lpExitTime,
2508 OUT LPFILETIME lpKernelTime,
2509 OUT LPFILETIME lpUserTime);
2511 #define TLS_OUT_OF_INDEXES ((DWORD)0xFFFFFFFF)
2523 IN DWORD dwTlsIndex);
2529 IN DWORD dwTlsIndex,
2530 IN LPVOID lpTlsValue);
2536 IN DWORD dwTlsIndex);
2541 PAL_GetStackBase(VOID);
2546 PAL_GetStackLimit(VOID);
2551 PAL_GetLogicalCpuCountFromOS(VOID);
2556 PAL_GetRestrictedPhysicalMemoryLimit(VOID);
2561 PAL_GetWorkingSetSize(size_t* val);
2566 PAL_GetCpuLimit(UINT* val);
2571 PAL_GetLogicalProcessorCacheSizeFromOS(VOID);
2573 typedef BOOL(*UnwindReadMemoryCallback)(PVOID address, PVOID buffer, SIZE_T size);
2575 PALIMPORT BOOL PALAPI PAL_VirtualUnwind(CONTEXT *context, KNONVOLATILE_CONTEXT_POINTERS *contextPointers);
2577 PALIMPORT BOOL PALAPI PAL_VirtualUnwindOutOfProc(CONTEXT *context, KNONVOLATILE_CONTEXT_POINTERS *contextPointers, SIZE_T baseAddress, UnwindReadMemoryCallback readMemoryCallback);
2579 #define GetLogicalProcessorCacheSizeFromOS PAL_GetLogicalProcessorCacheSizeFromOS
2581 /* PAL_CS_NATIVE_DATA_SIZE is defined as sizeof(PAL_CRITICAL_SECTION_NATIVE_DATA) */
2583 #if defined(__APPLE__) && defined(__i386__)
2584 #define PAL_CS_NATIVE_DATA_SIZE 76
2585 #elif defined(__APPLE__) && defined(__x86_64__)
2586 #define PAL_CS_NATIVE_DATA_SIZE 120
2587 #elif defined(__FreeBSD__) && defined(_X86_)
2588 #define PAL_CS_NATIVE_DATA_SIZE 12
2589 #elif defined(__FreeBSD__) && defined(__x86_64__)
2590 #define PAL_CS_NATIVE_DATA_SIZE 24
2591 #elif defined(__linux__) && defined(_ARM_)
2592 #define PAL_CS_NATIVE_DATA_SIZE 80
2593 #elif defined(__linux__) && defined(_ARM64_)
2594 #define PAL_CS_NATIVE_DATA_SIZE 116
2595 #elif defined(__linux__) && defined(__i386__)
2596 #define PAL_CS_NATIVE_DATA_SIZE 76
2597 #elif defined(__linux__) && defined(__x86_64__)
2598 #define PAL_CS_NATIVE_DATA_SIZE 96
2599 #elif defined(__NetBSD__) && defined(__amd64__)
2600 #define PAL_CS_NATIVE_DATA_SIZE 96
2601 #elif defined(__NetBSD__) && defined(__earm__)
2602 #define PAL_CS_NATIVE_DATA_SIZE 56
2603 #elif defined(__NetBSD__) && defined(__i386__)
2604 #define PAL_CS_NATIVE_DATA_SIZE 56
2607 #error PAL_CS_NATIVE_DATA_SIZE is not defined for this architecture
2611 typedef struct _CRITICAL_SECTION {
2614 LONG RecursionCount;
2615 HANDLE OwningThread;
2616 HANDLE LockSemaphore;
2617 ULONG_PTR SpinCount;
2620 volatile DWORD dwInitState;
2621 union CSNativeDataStorage
2623 BYTE rgNativeDataStorage[PAL_CS_NATIVE_DATA_SIZE];
2624 VOID * pvAlign; // make sure the storage is machine-pointer-size aligned
2626 } CRITICAL_SECTION, *PCRITICAL_SECTION, *LPCRITICAL_SECTION;
2628 PALIMPORT VOID PALAPI EnterCriticalSection(IN OUT LPCRITICAL_SECTION lpCriticalSection);
2629 PALIMPORT VOID PALAPI LeaveCriticalSection(IN OUT LPCRITICAL_SECTION lpCriticalSection);
2630 PALIMPORT VOID PALAPI InitializeCriticalSection(OUT LPCRITICAL_SECTION lpCriticalSection);
2631 PALIMPORT BOOL PALAPI InitializeCriticalSectionEx(LPCRITICAL_SECTION lpCriticalSection, DWORD dwSpinCount, DWORD Flags);
2632 PALIMPORT VOID PALAPI DeleteCriticalSection(IN OUT LPCRITICAL_SECTION lpCriticalSection);
2633 PALIMPORT BOOL PALAPI TryEnterCriticalSection(IN OUT LPCRITICAL_SECTION lpCriticalSection);
2635 #define SEM_FAILCRITICALERRORS 0x0001
2636 #define SEM_NOOPENFILEERRORBOX 0x8000
2644 #define PAGE_NOACCESS 0x01
2645 #define PAGE_READONLY 0x02
2646 #define PAGE_READWRITE 0x04
2647 #define PAGE_WRITECOPY 0x08
2648 #define PAGE_EXECUTE 0x10
2649 #define PAGE_EXECUTE_READ 0x20
2650 #define PAGE_EXECUTE_READWRITE 0x40
2651 #define PAGE_EXECUTE_WRITECOPY 0x80
2652 #define MEM_COMMIT 0x1000
2653 #define MEM_RESERVE 0x2000
2654 #define MEM_DECOMMIT 0x4000
2655 #define MEM_RELEASE 0x8000
2656 #define MEM_RESET 0x80000
2657 #define MEM_FREE 0x10000
2658 #define MEM_PRIVATE 0x20000
2659 #define MEM_MAPPED 0x40000
2660 #define MEM_TOP_DOWN 0x100000
2661 #define MEM_WRITE_WATCH 0x200000
2662 #define MEM_RESERVE_EXECUTABLE 0x40000000 // reserve memory using executable memory allocator
2669 IN LPSECURITY_ATTRIBUTES lpFileMappingAttributes,
2671 IN DWORD dwMaxmimumSizeHigh,
2672 IN DWORD dwMaximumSizeLow,
2676 #define CreateFileMapping CreateFileMappingW
2678 #define CreateFileMapping CreateFileMappingA
2681 #define SECTION_QUERY 0x0001
2682 #define SECTION_MAP_WRITE 0x0002
2683 #define SECTION_MAP_READ 0x0004
2684 #define SECTION_ALL_ACCESS (SECTION_MAP_READ | SECTION_MAP_WRITE) // diff from winnt.h
2686 #define FILE_MAP_WRITE SECTION_MAP_WRITE
2687 #define FILE_MAP_READ SECTION_MAP_READ
2688 #define FILE_MAP_ALL_ACCESS SECTION_ALL_ACCESS
2689 #define FILE_MAP_COPY SECTION_QUERY
2695 IN DWORD dwDesiredAccess,
2696 IN BOOL bInheritHandle,
2700 #define OpenFileMapping OpenFileMappingW
2702 #define OpenFileMapping OpenFileMappingA
2709 IN HANDLE hFileMappingObject,
2710 IN DWORD dwDesiredAccess,
2711 IN DWORD dwFileOffsetHigh,
2712 IN DWORD dwFileOffsetLow,
2713 IN SIZE_T dwNumberOfBytesToMap);
2719 IN HANDLE hFileMappingObject,
2720 IN DWORD dwDesiredAccess,
2721 IN DWORD dwFileOffsetHigh,
2722 IN DWORD dwFileOffsetLow,
2723 IN SIZE_T dwNumberOfBytesToMap,
2724 IN LPVOID lpBaseAddress);
2730 IN LPVOID lpBaseAddress,
2731 IN SIZE_T dwNumberOfBytesToFlush);
2737 IN LPCVOID lpBaseAddress);
2744 IN LPCWSTR lpLibFileName);
2750 IN LPCWSTR lpLibFileName,
2751 IN /*Reserved*/ HANDLE hFile,
2757 PAL_LoadLibraryDirect(
2758 IN LPCWSTR lpLibFileName);
2763 PAL_RegisterLibraryDirect(
2765 IN LPCWSTR lpLibFileName);
2772 Loads a PE file into memory. Properly maps all of the sections in the PE file. Returns a pointer to the
2776 IN hFile - The file to load
2779 A valid base address if successful.
2784 PAL_LOADLoadPEFile(HANDLE hFile);
2787 PAL_LOADUnloadPEFile
2789 Unload a PE file that was loaded by PAL_LOADLoadPEFile().
2792 IN ptr - the file pointer returned by PAL_LOADLoadPEFile()
2796 FALSE - failure (incorrect ptr, etc.)
2800 PAL_LOADUnloadPEFile(void * ptr);
2803 #define LoadLibrary LoadLibraryW
2804 #define LoadLibraryEx LoadLibraryExW
2806 #define LoadLibrary LoadLibraryA
2807 #define LoadLibraryEx LoadLibraryExA
2810 typedef INT_PTR (PALAPI *FARPROC)();
2817 IN LPCSTR lpProcName);
2823 IN OUT HMODULE hLibModule);
2829 FreeLibraryAndExitThread(
2830 IN HMODULE hLibModule,
2831 IN DWORD dwExitCode);
2836 DisableThreadLibraryCalls(
2837 IN HMODULE hLibModule);
2844 OUT LPWSTR lpFileName,
2848 #define GetModuleFileName GetModuleFileNameW
2850 #define GetModuleFileName GetModuleFileNameA
2856 GetModuleFileNameExW(
2859 OUT LPWSTR lpFilename,
2864 #define GetModuleFileNameEx GetModuleFileNameExW
2867 // Get base address of the module containing a given symbol
2870 PAL_GetSymbolModuleBase(void *symbol);
2875 PAL_VirtualReserveFromExecutableMemoryAllocatorWithinRange(
2876 IN LPCVOID lpBeginAddress,
2877 IN LPCVOID lpEndAddress,
2884 IN LPVOID lpAddress,
2886 IN DWORD flAllocationType,
2887 IN DWORD flProtect);
2893 IN LPVOID lpAddress,
2895 IN DWORD dwFreeType);
2901 IN LPVOID lpAddress,
2903 IN DWORD flNewProtect,
2904 OUT PDWORD lpflOldProtect);
2906 typedef struct _MEMORYSTATUSEX {
2909 DWORDLONG ullTotalPhys;
2910 DWORDLONG ullAvailPhys;
2911 DWORDLONG ullTotalPageFile;
2912 DWORDLONG ullAvailPageFile;
2913 DWORDLONG ullTotalVirtual;
2914 DWORDLONG ullAvailVirtual;
2915 DWORDLONG ullAvailExtendedVirtual;
2916 } MEMORYSTATUSEX, *LPMEMORYSTATUSEX;
2921 GlobalMemoryStatusEx(
2922 IN OUT LPMEMORYSTATUSEX lpBuffer);
2924 typedef struct _MEMORY_BASIC_INFORMATION {
2926 PVOID AllocationBase_PAL_Undefined;
2927 DWORD AllocationProtect;
2932 } MEMORY_BASIC_INFORMATION, *PMEMORY_BASIC_INFORMATION;
2938 IN LPCVOID lpAddress,
2939 OUT PMEMORY_BASIC_INFORMATION lpBuffer,
2940 IN SIZE_T dwLength);
2946 IN PVOID Destination,
2947 IN CONST VOID *Source,
2954 IN PVOID Destination,
2957 #define MoveMemory memmove
2958 #define CopyMemory memcpy
2959 #define FillMemory(Destination,Length,Fill) memset((Destination),(Fill),(Length))
2960 #define ZeroMemory(Destination,Length) memset((Destination),0,(Length))
2969 #define HEAP_ZERO_MEMORY 0x00000008
2976 IN SIZE_T dwInitialSize,
2977 IN SIZE_T dwMaximumSize);
3005 typedef enum _HEAP_INFORMATION_CLASS {
3006 HeapCompatibilityInformation,
3007 HeapEnableTerminationOnCorruption
3008 } HEAP_INFORMATION_CLASS;
3014 IN OPTIONAL HANDLE HeapHandle,
3015 IN HEAP_INFORMATION_CLASS HeapInformationClass,
3016 IN PVOID HeapInformation,
3017 IN SIZE_T HeapInformationLength);
3019 #define LMEM_FIXED 0x0000
3020 #define LMEM_MOVEABLE 0x0002
3021 #define LMEM_ZEROINIT 0x0040
3022 #define LPTR (LMEM_FIXED | LMEM_ZEROINIT)
3048 FlushInstructionCache(
3050 IN LPCVOID lpBaseAddress,
3053 #if ENABLE_DOWNLEVEL_FOR_NLS
3060 IN DWORD dwInfoType,
3061 IN LPCWSTR lpSrcStr,
3063 OUT LPWORD lpCharType);
3066 #define GetStringTypeEx GetStringTypeExW
3069 #endif // ENABLE_DOWNLEVEL_FOR_NLS
3072 #define NORM_IGNORECASE 0x00000001 // ignore case
3073 #define NORM_IGNOREWIDTH 0x00020000 // ignore width
3075 #define NORM_LINGUISTIC_CASING 0x08000000 // use linguistic rules for casing
3078 #define NORM_IGNORENONSPACE 0x00000002 // ignore nonspacing chars
3079 #define NORM_IGNORESYMBOLS 0x00000004 // ignore symbols
3080 #define NORM_IGNOREKANATYPE 0x00010000 // ignore kanatype
3081 #define SORT_STRINGSORT 0x00001000 // use string sort method
3085 typedef struct nlsversioninfo {
3086 DWORD dwNLSVersionInfoSize;
3088 DWORD dwDefinedVersion;
3089 } NLSVERSIONINFO, *LPNLSVERSIONINFO;
3091 #define CSTR_LESS_THAN 1
3092 #define CSTR_EQUAL 2
3093 #define CSTR_GREATER_THAN 3
3095 #if ENABLE_DOWNLEVEL_FOR_NLS
3103 IN DWORD dwCmpFlags,
3104 IN LPCWSTR lpString1,
3106 IN LPCWSTR lpString2,
3109 #endif // ENABLE_DOWNLEVEL_FOR_NLS
3116 IN LPCWSTR lpLocaleName,
3117 IN DWORD dwCmpFlags,
3118 IN LPCWSTR lpString1,
3120 IN LPCWSTR lpString2,
3122 IN LPNLSVERSIONINFO lpVersionInformation,
3123 IN LPVOID lpReserved,
3128 #define CompareString CompareStringW
3131 #define MAX_LEADBYTES 12
3132 #define MAX_DEFAULTCHAR 2
3139 typedef struct _cpinfo {
3141 BYTE DefaultChar[MAX_DEFAULTCHAR];
3142 BYTE LeadByte[MAX_LEADBYTES];
3143 } CPINFO, *LPCPINFO;
3150 OUT LPCPINFO lpCPInfo);
3172 #define MB_PRECOMPOSED 0x00000001
3173 #define MB_ERR_INVALID_CHARS 0x00000008
3178 MultiByteToWideChar(
3181 IN LPCSTR lpMultiByteStr,
3183 OUT LPWSTR lpWideCharStr,
3184 IN int cchWideChar);
3186 #define WC_NO_BEST_FIT_CHARS 0x00000400
3191 WideCharToMultiByte(
3194 IN LPCWSTR lpWideCharStr,
3196 OUT LPSTR lpMultiByteStr,
3198 IN LPCSTR lpDefaultChar,
3199 OUT LPBOOL lpUsedDefaultChar);
3201 #if ENABLE_DOWNLEVEL_FOR_NLS
3206 GetSystemDefaultLangID(
3212 GetUserDefaultLangID(
3227 #endif //ENABLE_DOWNLEVEL_FOR_NLS
3232 // These types are used for the GetLocaleInfo NLS API routine.
3238 // The following LCTypes may be used in combination with any other LCTypes.
3240 // LOCALE_NOUSEROVERRIDE is also used in GetTimeFormat and
3243 // LOCALE_RETURN_NUMBER will return the result from GetLocaleInfo as a
3244 // number instead of a string. This flag is only valid for the LCTypes
3245 // beginning with LOCALE_I.
3247 #define LOCALE_NOUSEROVERRIDE 0x80000000 /* do not use user overrides */
3248 #define LOCALE_RETURN_NUMBER 0x20000000 /* return number instead of string */
3249 #define LOCALE_RETURN_GENITIVE_NAMES 0x10000000 //Flag to return the Genitive forms of month names
3251 #define LOCALE_SLOCALIZEDDISPLAYNAME 0x00000002 // localized name of locale, eg "German (Germany)" in UI language
3252 #define LOCALE_SENGLISHDISPLAYNAME 0x00000072 // Display name (language + country usually) in English, eg "German (Germany)"
3253 #define LOCALE_SNATIVEDISPLAYNAME 0x00000073 // Display name in native locale language, eg "Deutsch (Deutschland)
3255 #define LOCALE_SLOCALIZEDLANGUAGENAME 0x0000006f // Language Display Name for a language, eg "German" in UI language
3256 #define LOCALE_SENGLISHLANGUAGENAME 0x00001001 // English name of language, eg "German"
3257 #define LOCALE_SNATIVELANGUAGENAME 0x00000004 // native name of language, eg "Deutsch"
3259 #define LOCALE_SLOCALIZEDCOUNTRYNAME 0x00000006 // localized name of country, eg "Germany" in UI language
3260 #define LOCALE_SENGLISHCOUNTRYNAME 0x00001002 // English name of country, eg "Germany"
3261 #define LOCALE_SNATIVECOUNTRYNAME 0x00000008 // native name of country, eg "Deutschland"
3264 // The following LCTypes are mutually exclusive in that they may NOT
3265 // be used in combination with each other.
3267 #define LOCALE_ILANGUAGE 0x00000001 /* language id */
3268 #define LOCALE_SLANGUAGE 0x00000002 /* localized name of language */
3269 #define LOCALE_SENGLANGUAGE 0x00001001 /* English name of language */
3270 #define LOCALE_SABBREVLANGNAME 0x00000003 /* abbreviated language name */
3271 #define LOCALE_SNATIVELANGNAME 0x00000004 /* native name of language */
3272 #define LOCALE_ICOUNTRY 0x00000005 /* country code */
3273 #define LOCALE_SCOUNTRY 0x00000006 /* localized name of country */
3275 #define LOCALE_SENGCOUNTRY 0x00001002 /* English name of country */
3276 #define LOCALE_SABBREVCTRYNAME 0x00000007 /* abbreviated country name */
3277 #define LOCALE_SNATIVECTRYNAME 0x00000008 /* native name of country */
3279 #define LOCALE_SLIST 0x0000000C /* list item separator */
3280 #define LOCALE_IMEASURE 0x0000000D /* 0 = metric, 1 = US */
3282 #define LOCALE_SDECIMAL 0x0000000E /* decimal separator */
3283 #define LOCALE_STHOUSAND 0x0000000F /* thousand separator */
3284 #define LOCALE_SGROUPING 0x00000010 /* digit grouping */
3285 #define LOCALE_IDIGITS 0x00000011 /* number of fractional digits */
3286 #define LOCALE_ILZERO 0x00000012 /* leading zeros for decimal */
3287 #define LOCALE_INEGNUMBER 0x00001010 /* negative number mode */
3288 #define LOCALE_SNATIVEDIGITS 0x00000013 /* native ascii 0-9 */
3290 #define LOCALE_SCURRENCY 0x00000014 /* local monetary symbol */
3291 #define LOCALE_SINTLSYMBOL 0x00000015 /* intl monetary symbol */
3292 #define LOCALE_SMONDECIMALSEP 0x00000016 /* monetary decimal separator */
3293 #define LOCALE_SMONTHOUSANDSEP 0x00000017 /* monetary thousand separator */
3294 #define LOCALE_SMONGROUPING 0x00000018 /* monetary grouping */
3295 #define LOCALE_ICURRDIGITS 0x00000019 /* # local monetary digits */
3296 #define LOCALE_IINTLCURRDIGITS 0x0000001A /* # intl monetary digits */
3297 #define LOCALE_ICURRENCY 0x0000001B /* positive currency mode */
3298 #define LOCALE_INEGCURR 0x0000001C /* negative currency mode */
3300 #define LOCALE_SSHORTDATE 0x0000001F /* short date format string */
3301 #define LOCALE_SLONGDATE 0x00000020 /* long date format string */
3302 #define LOCALE_STIMEFORMAT 0x00001003 /* time format string */
3303 #define LOCALE_S1159 0x00000028 /* AM designator */
3304 #define LOCALE_S2359 0x00000029 /* PM designator */
3306 #define LOCALE_ICALENDARTYPE 0x00001009 /* type of calendar specifier */
3307 #define LOCALE_IFIRSTDAYOFWEEK 0x0000100C /* first day of week specifier */
3308 #define LOCALE_IFIRSTWEEKOFYEAR 0x0000100D /* first week of year specifier */
3310 #define LOCALE_SDAYNAME1 0x0000002A /* long name for Monday */
3311 #define LOCALE_SDAYNAME2 0x0000002B /* long name for Tuesday */
3312 #define LOCALE_SDAYNAME3 0x0000002C /* long name for Wednesday */
3313 #define LOCALE_SDAYNAME4 0x0000002D /* long name for Thursday */
3314 #define LOCALE_SDAYNAME5 0x0000002E /* long name for Friday */
3315 #define LOCALE_SDAYNAME6 0x0000002F /* long name for Saturday */
3316 #define LOCALE_SDAYNAME7 0x00000030 /* long name for Sunday */
3317 #define LOCALE_SABBREVDAYNAME1 0x00000031 /* abbreviated name for Monday */
3318 #define LOCALE_SABBREVDAYNAME2 0x00000032 /* abbreviated name for Tuesday */
3319 #define LOCALE_SABBREVDAYNAME3 0x00000033 /* abbreviated name for Wednesday */
3320 #define LOCALE_SABBREVDAYNAME4 0x00000034 /* abbreviated name for Thursday */
3321 #define LOCALE_SABBREVDAYNAME5 0x00000035 /* abbreviated name for Friday */
3322 #define LOCALE_SABBREVDAYNAME6 0x00000036 /* abbreviated name for Saturday */
3323 #define LOCALE_SABBREVDAYNAME7 0x00000037 /* abbreviated name for Sunday */
3324 #define LOCALE_SMONTHNAME1 0x00000038 /* long name for January */
3325 #define LOCALE_SMONTHNAME2 0x00000039 /* long name for February */
3326 #define LOCALE_SMONTHNAME3 0x0000003A /* long name for March */
3327 #define LOCALE_SMONTHNAME4 0x0000003B /* long name for April */
3328 #define LOCALE_SMONTHNAME5 0x0000003C /* long name for May */
3329 #define LOCALE_SMONTHNAME6 0x0000003D /* long name for June */
3330 #define LOCALE_SMONTHNAME7 0x0000003E /* long name for July */
3331 #define LOCALE_SMONTHNAME8 0x0000003F /* long name for August */
3332 #define LOCALE_SMONTHNAME9 0x00000040 /* long name for September */
3333 #define LOCALE_SMONTHNAME10 0x00000041 /* long name for October */
3334 #define LOCALE_SMONTHNAME11 0x00000042 /* long name for November */
3335 #define LOCALE_SMONTHNAME12 0x00000043 /* long name for December */
3336 #define LOCALE_SMONTHNAME13 0x0000100E /* long name for 13th month (if exists) */
3337 #define LOCALE_SABBREVMONTHNAME1 0x00000044 /* abbreviated name for January */
3338 #define LOCALE_SABBREVMONTHNAME2 0x00000045 /* abbreviated name for February */
3339 #define LOCALE_SABBREVMONTHNAME3 0x00000046 /* abbreviated name for March */
3340 #define LOCALE_SABBREVMONTHNAME4 0x00000047 /* abbreviated name for April */
3341 #define LOCALE_SABBREVMONTHNAME5 0x00000048 /* abbreviated name for May */
3342 #define LOCALE_SABBREVMONTHNAME6 0x00000049 /* abbreviated name for June */
3343 #define LOCALE_SABBREVMONTHNAME7 0x0000004A /* abbreviated name for July */
3344 #define LOCALE_SABBREVMONTHNAME8 0x0000004B /* abbreviated name for August */
3345 #define LOCALE_SABBREVMONTHNAME9 0x0000004C /* abbreviated name for September */
3346 #define LOCALE_SABBREVMONTHNAME10 0x0000004D /* abbreviated name for October */
3347 #define LOCALE_SABBREVMONTHNAME11 0x0000004E /* abbreviated name for November */
3348 #define LOCALE_SABBREVMONTHNAME12 0x0000004F /* abbreviated name for December */
3349 #define LOCALE_SABBREVMONTHNAME13 0x0000100F /* abbreviated name for 13th month (if exists) */
3351 #define LOCALE_SPOSITIVESIGN 0x00000050 /* positive sign */
3352 #define LOCALE_SNEGATIVESIGN 0x00000051 /* negative sign */
3354 #define LOCALE_FONTSIGNATURE 0x00000058 /* font signature */
3355 #define LOCALE_SISO639LANGNAME 0x00000059 /* ISO abbreviated language name */
3356 #define LOCALE_SISO3166CTRYNAME 0x0000005A /* ISO abbreviated country name */
3358 #define LOCALE_SENGCURRNAME 0x00001007 /* english name of currency */
3359 #define LOCALE_SNATIVECURRNAME 0x00001008 /* native name of currency */
3360 #define LOCALE_SYEARMONTH 0x00001006 /* year month format string */
3361 #define LOCALE_IDIGITSUBSTITUTION 0x00001014 /* 0 = context, 1 = none, 2 = national */
3363 #define LOCALE_SNAME 0x0000005C /* locale name <language>[-<Script>][-<REGION>[_<sort order>]] */
3364 #define LOCALE_SDURATION 0x0000005d /* time duration format */
3365 #define LOCALE_SKEYBOARDSTOINSTALL 0x0000005e /* (windows only) keyboards to install */
3366 #define LOCALE_SSHORTESTDAYNAME1 0x00000060 /* Shortest day name for Monday */
3367 #define LOCALE_SSHORTESTDAYNAME2 0x00000061 /* Shortest day name for Tuesday */
3368 #define LOCALE_SSHORTESTDAYNAME3 0x00000062 /* Shortest day name for Wednesday */
3369 #define LOCALE_SSHORTESTDAYNAME4 0x00000063 /* Shortest day name for Thursday */
3370 #define LOCALE_SSHORTESTDAYNAME5 0x00000064 /* Shortest day name for Friday */
3371 #define LOCALE_SSHORTESTDAYNAME6 0x00000065 /* Shortest day name for Saturday */
3372 #define LOCALE_SSHORTESTDAYNAME7 0x00000066 /* Shortest day name for Sunday */
3373 #define LOCALE_SISO639LANGNAME2 0x00000067 /* 3 character ISO abbreviated language name */
3374 #define LOCALE_SISO3166CTRYNAME2 0x00000068 /* 3 character ISO country name */
3375 #define LOCALE_SNAN 0x00000069 /* Not a Number */
3376 #define LOCALE_SPOSINFINITY 0x0000006a /* + Infinity */
3377 #define LOCALE_SNEGINFINITY 0x0000006b /* - Infinity */
3378 #define LOCALE_SSCRIPTS 0x0000006c /* Typical scripts in the locale */
3379 #define LOCALE_SPARENT 0x0000006d /* Fallback name for resources */
3380 #define LOCALE_SCONSOLEFALLBACKNAME 0x0000006e /* Fallback name for within the console */
3381 #define LOCALE_SLANGDISPLAYNAME 0x0000006f /* Language Display Name for a language */
3382 #define LOCALE_IREADINGLAYOUT 0x00000070 // Returns one of the following 4 reading layout values:
3383 // 0 - Left to right (eg en-US)
3384 // 1 - Right to left (eg arabic locales)
3385 // 2 - Vertical top to bottom with columns to the left and also left to right (ja-JP locales)
3386 // 3 - Vertical top to bottom with columns proceeding to the right
3387 #define LOCALE_INEUTRAL 0x00000071 // Returns 0 for specific cultures, 1 for neutral cultures.
3388 #define LOCALE_INEGATIVEPERCENT 0x00000074 // Returns 0-11 for the negative percent format
3389 #define LOCALE_IPOSITIVEPERCENT 0x00000075 // Returns 0-3 for the positive percent formatIPOSITIVEPERCENT
3390 #define LOCALE_SPERCENT 0x00000076 // Returns the percent symbol
3391 #define LOCALE_SPERMILLE 0x00000077 // Returns the permille (U+2030) symbol
3392 #define LOCALE_SMONTHDAY 0x00000078 // Returns the preferred month/day format
3393 #define LOCALE_SSHORTTIME 0x00000079 // Returns the preferred short time format (ie: no seconds, just h:mm)
3394 #define LOCALE_SOPENTYPELANGUAGETAG 0x0000007a // Open type language tag, eg: "latn" or "dflt"
3395 #define LOCALE_SSORTLOCALE 0x0000007b // Name of locale to use for sorting/collation/casing behavior.
3397 #define LCMAP_LINGUISTIC_CASING 0x01000000 /* Use linguistic casing */
3399 #define CAL_RETURN_GENITIVE_NAMES LOCALE_RETURN_GENITIVE_NAMES // return genitive forms of month names
3401 #define CAL_SSHORTESTDAYNAME1 0x00000031
3402 #define CAL_SSHORTESTDAYNAME2 0x00000032
3403 #define CAL_SSHORTESTDAYNAME3 0x00000033
3404 #define CAL_SSHORTESTDAYNAME4 0x00000034
3405 #define CAL_SSHORTESTDAYNAME5 0x00000035
3406 #define CAL_SSHORTESTDAYNAME6 0x00000036
3407 #define CAL_SSHORTESTDAYNAME7 0x00000037
3409 #define CAL_SMONTHDAY 0x00000038 // Month/day pattern (reserve for potential inclusion in a future version)
3410 #define CAL_SERASTRING 0x00000004 // era name for IYearOffsetRanges, eg A.D.
3411 #define CAL_SABBREVERASTRING 0x00000039 // Abbreviated era string (eg: AD)
3413 #define CAL_SSHORTDATE 0x00000005 /* short date format string */
3414 #define CAL_SLONGDATE 0x00000006 /* long date format string */
3415 #define CAL_SDAYNAME1 0x00000007 /* native name for Monday */
3416 #define CAL_SDAYNAME2 0x00000008 /* native name for Tuesday */
3417 #define CAL_SDAYNAME3 0x00000009 /* native name for Wednesday */
3418 #define CAL_SDAYNAME4 0x0000000a /* native name for Thursday */
3419 #define CAL_SDAYNAME5 0x0000000b /* native name for Friday */
3420 #define CAL_SDAYNAME6 0x0000000c /* native name for Saturday */
3421 #define CAL_SDAYNAME7 0x0000000d /* native name for Sunday */
3422 #define CAL_SABBREVDAYNAME1 0x0000000e /* abbreviated name for Monday */
3423 #define CAL_SABBREVDAYNAME2 0x0000000f /* abbreviated name for Tuesday */
3424 #define CAL_SABBREVDAYNAME3 0x00000010 /* abbreviated name for Wednesday */
3425 #define CAL_SABBREVDAYNAME4 0x00000011 /* abbreviated name for Thursday */
3426 #define CAL_SABBREVDAYNAME5 0x00000012 /* abbreviated name for Friday */
3427 #define CAL_SABBREVDAYNAME6 0x00000013 /* abbreviated name for Saturday */
3428 #define CAL_SABBREVDAYNAME7 0x00000014 /* abbreviated name for Sunday */
3429 #define CAL_SMONTHNAME1 0x00000015 /* native name for January */
3430 #define CAL_SMONTHNAME2 0x00000016 /* native name for February */
3431 #define CAL_SMONTHNAME3 0x00000017 /* native name for March */
3432 #define CAL_SMONTHNAME4 0x00000018 /* native name for April */
3433 #define CAL_SMONTHNAME5 0x00000019 /* native name for May */
3434 #define CAL_SMONTHNAME6 0x0000001a /* native name for June */
3435 #define CAL_SMONTHNAME7 0x0000001b /* native name for July */
3436 #define CAL_SMONTHNAME8 0x0000001c /* native name for August */
3437 #define CAL_SMONTHNAME9 0x0000001d /* native name for September */
3438 #define CAL_SMONTHNAME10 0x0000001e /* native name for October */
3439 #define CAL_SMONTHNAME11 0x0000001f /* native name for November */
3440 #define CAL_SMONTHNAME12 0x00000020 /* native name for December */
3441 #define CAL_SMONTHNAME13 0x00000021 /* native name for 13th month (if any) */
3442 #define CAL_SABBREVMONTHNAME1 0x00000022 /* abbreviated name for January */
3443 #define CAL_SABBREVMONTHNAME2 0x00000023 /* abbreviated name for February */
3444 #define CAL_SABBREVMONTHNAME3 0x00000024 /* abbreviated name for March */
3445 #define CAL_SABBREVMONTHNAME4 0x00000025 /* abbreviated name for April */
3446 #define CAL_SABBREVMONTHNAME5 0x00000026 /* abbreviated name for May */
3447 #define CAL_SABBREVMONTHNAME6 0x00000027 /* abbreviated name for June */
3448 #define CAL_SABBREVMONTHNAME7 0x00000028 /* abbreviated name for July */
3449 #define CAL_SABBREVMONTHNAME8 0x00000029 /* abbreviated name for August */
3450 #define CAL_SABBREVMONTHNAME9 0x0000002a /* abbreviated name for September */
3451 #define CAL_SABBREVMONTHNAME10 0x0000002b /* abbreviated name for October */
3452 #define CAL_SABBREVMONTHNAME11 0x0000002c /* abbreviated name for November */
3453 #define CAL_SABBREVMONTHNAME12 0x0000002d /* abbreviated name for December */
3454 #define CAL_SABBREVMONTHNAME13 0x0000002e /* abbreviated name for 13th month (if any) */
3455 #define CAL_SYEARMONTH 0x0000002f /* year month format string */
3460 #define LOCALE_SDECIMAL 0x0000000E /* decimal separator */
3461 #define LOCALE_STHOUSAND 0x0000000F /* thousand separator */
3462 #define LOCALE_ILZERO 0x00000012 /* leading zeros for decimal */
3463 #define LOCALE_SCURRENCY 0x00000014 /* local monetary symbol */
3464 #define LOCALE_SMONDECIMALSEP 0x00000016 /* monetary decimal separator */
3465 #define LOCALE_SMONTHOUSANDSEP 0x00000017 /* monetary thousand separator */
3470 #if ENABLE_DOWNLEVEL_FOR_NLS
3478 OUT LPWSTR lpLCData,
3481 #endif // ENABLE_DOWNLEVEL_FOR_NLS
3487 IN LPCWSTR lpLocaleName,
3489 OUT LPWSTR lpLCData,
3496 CompareStringOrdinal(
3497 IN LPCWSTR lpString1,
3499 IN LPCWSTR lpString2,
3501 IN BOOL bIgnoreCase);
3503 typedef struct _nlsversioninfoex {
3504 DWORD dwNLSVersionInfoSize;
3506 DWORD dwDefinedVersion;
3507 DWORD dwEffectiveId;
3508 GUID guidCustomVersion;
3509 } NLSVERSIONINFOEX, *LPNLSVERSIONINFOEX;
3515 IN LPCWSTR lpLocaleName,
3516 IN DWORD dwFindNLSStringFlags,
3517 IN LPCWSTR lpStringSource,
3519 IN LPCWSTR lpStringValue,
3521 OUT LPINT pcchFound,
3522 IN LPNLSVERSIONINFOEX lpVersionInformation,
3523 IN LPVOID lpReserved,
3527 COMPARE_STRING = 0x0001,
3534 IN NLS_FUNCTION Function,
3536 IN LPNLSVERSIONINFOEX lpVersionInfo,
3537 IN LPCWSTR lpString,
3545 IN LPCWSTR lpNameToResolve,
3546 OUT LPWSTR lpLocaleName,
3547 IN int cchLocaleName );
3552 GetThreadPreferredUILanguages(
3554 OUT PULONG pulNumLanguages,
3555 OUT PWSTR pwszLanguagesBuffer,
3556 IN OUT PULONG pcchLanguagesBuffer);
3562 GetSystemDefaultLocaleName(
3563 OUT LPWSTR lpLocaleName,
3564 IN int cchLocaleName);
3567 #define GetLocaleInfo GetLocaleInfoW
3570 #if ENABLE_DOWNLEVEL_FOR_NLS
3582 GetUserDefaultLocaleName(
3583 OUT LPWSTR lpLocaleName,
3584 IN int cchLocaleName);
3587 #define LCID_INSTALLED 0x00000001 // installed locale ids
3588 #define LCID_SUPPORTED 0x00000002 // supported locale ids
3590 #define LCID_ALTERNATE_SORTS 0x00000004 // alternate sort locale ids
3593 #if ENABLE_DOWNLEVEL_FOR_NLS
3600 #endif // ENABLE_DOWNLEVEL_FOR_NLS
3603 typedef DWORD CALID;
3604 typedef DWORD CALTYPE;
3606 #define CAL_ITWODIGITYEARMAX 0x00000030 // two digit year max
3607 #define CAL_RETURN_NUMBER 0x20000000 // return number instead of string
3609 #define CAL_GREGORIAN 1 // Gregorian (localized) calendar
3610 #define CAL_GREGORIAN_US 2 // Gregorian (U.S.) calendar
3611 #define CAL_JAPAN 3 // Japanese Emperor Era calendar
3612 #define CAL_TAIWAN 4 // Taiwan Era calendar
3613 #define CAL_KOREA 5 // Korean Tangun Era calendar
3614 #define CAL_HIJRI 6 // Hijri (Arabic Lunar) calendar
3615 #define CAL_THAI 7 // Thai calendar
3616 #define CAL_HEBREW 8 // Hebrew (Lunar) calendar
3617 #define CAL_GREGORIAN_ME_FRENCH 9 // Gregorian Middle East French calendar
3618 #define CAL_GREGORIAN_ARABIC 10 // Gregorian Arabic calendar
3619 #define CAL_GREGORIAN_XLIT_ENGLISH 11 // Gregorian Transliterated English calendar
3620 #define CAL_GREGORIAN_XLIT_FRENCH 12 // Gregorian Transliterated French calendar
3621 #define CAL_JULIAN 13
3623 #if ENABLE_DOWNLEVEL_FOR_NLS
3631 OUT LPWSTR lpCalData,
3633 OUT LPDWORD lpValue);
3636 #define GetCalendarInfo GetCalendarInfoW
3639 #endif // ENABLE_DOWNLEVEL_FOR_NLS
3646 IN LPCWSTR lpLocaleName,
3648 IN LPCWSTR lpReserved,
3650 OUT LPWSTR lpCalData,
3652 OUT LPDWORD lpValue);
3654 #if ENABLE_DOWNLEVEL_FOR_NLS
3655 typedef BOOL (CALLBACK* LOCALE_ENUMPROCW)(LPWSTR);
3661 IN LOCALE_ENUMPROCW lpLocaleEnumProc,
3663 #endif // ENABLE_DOWNLEVEL_FOR_NLS
3665 #define DATE_SHORTDATE 0x00000001 // use short date picture
3666 #define DATE_LONGDATE 0x00000002 // use long date picture
3667 #define DATE_YEARMONTH 0x00000008 // use year month picture
3669 typedef BOOL (CALLBACK* DATEFMT_ENUMPROCEXW)(LPWSTR, CALID);
3671 #if ENABLE_DOWNLEVEL_FOR_NLS
3677 IN DATEFMT_ENUMPROCEXW lpDateFmtEnumProcEx,
3681 #else // ENABLE_DOWNLEVEL_FOR_NLS
3683 typedef BOOL (CALLBACK* DATEFMT_ENUMPROCEXEXW)(LPWSTR, CALID, LPARAM);
3688 EnumDateFormatsExEx(
3689 IN DATEFMT_ENUMPROCEXEXW lpDateFmtEnumProcEx,
3690 IN LPCWSTR lpLocaleName,
3694 #endif // ENABLE_DOWNLEVEL_FOR_NLS
3696 typedef BOOL (CALLBACK* TIMEFMT_ENUMPROCW)(LPWSTR);
3698 #if ENABLE_DOWNLEVEL_FOR_NLS
3704 IN TIMEFMT_ENUMPROCW lpTimeFmtEnumProc,
3708 #else // ENABLE_DOWNLEVEL_FOR_NLS
3710 typedef BOOL (CALLBACK* TIMEFMT_ENUMPROCEXW)(LPWSTR, LPARAM);
3716 IN TIMEFMT_ENUMPROCEXW lpTimeFmtEnumProc,
3717 IN LPCWSTR lpLocaleName,
3721 #endif // ENABLE_DOWNLEVEL_FOR_NLS
3723 #define ENUM_ALL_CALENDARS 0xffffffff // enumerate all calendars
3724 #define CAL_ICALINTVALUE 0x00000001 // calendar type
3725 #define CAL_NOUSEROVERRIDE LOCALE_NOUSEROVERRIDE // do not use user overrides
3726 #define CAL_SCALNAME 0x00000002 // native name of calendar
3728 typedef BOOL (CALLBACK* CALINFO_ENUMPROCEXW)(LPWSTR,CALID);
3730 #if ENABLE_DOWNLEVEL_FOR_NLS
3735 EnumCalendarInfoExW(
3736 IN CALINFO_ENUMPROCEXW lpCalInfoEnumProc,
3739 IN CALTYPE CalType);
3741 #else // ENABLE_DOWNLEVEL_FOR_NLS
3743 typedef BOOL (CALLBACK* CALINFO_ENUMPROCEXEXW)(LPWSTR, CALID, LPWSTR, LPARAM);
3748 EnumCalendarInfoExEx(
3749 IN CALINFO_ENUMPROCEXEXW lpCalInfoEnumProc,
3750 IN LPCWSTR lpLocaleName,
3752 IN LPCWSTR lpReserved,
3756 #endif // ENABLE_DOWNLEVEL_FOR_NLS
3758 #define LCMAP_LOWERCASE 0x00000100
3759 #define LCMAP_UPPERCASE 0x00000200
3761 #if ENABLE_DOWNLEVEL_FOR_NLS
3768 IN DWORD dwMapFlags,
3769 IN LPCWSTR lpSrcStr,
3771 OUT LPWSTR lpDestStr,
3775 #define LCMapString LCMapStringW
3779 #endif // ENABLE_DOWNLEVEL_FOR_NLS
3786 IN LPCWSTR lpLocaleName,
3787 IN DWORD dwMapFlags,
3788 IN LPCWSTR lpSrcStr,
3790 OUT LPWSTR lpDestStr,
3792 IN LPNLSVERSIONINFO lpVersionInformation,
3793 IN LPVOID lpReserved,
3800 IN LPCWSTR lpLocaleName,
3801 IN DWORD dwMapFlags,
3803 OUT WCHAR *destChar,
3804 LPNLSVERSIONINFO lpVersionInformation,
3811 PAL_NormalizeStringExW(
3812 IN LPCWSTR lpLocaleName,
3813 IN DWORD dwMapFlags,
3814 IN LPCWSTR lpSrcStr,
3816 OUT LPWSTR lpDestStr,
3823 IN LPCWSTR lpLocaleName,
3824 IN LPCWSTR lpFormat,
3825 IN LPCWSTR lpString,
3826 OUT LPSYSTEMTIME lpTime);
3832 IN LPCWSTR lpLocaleName,
3833 OUT CALID* pCalendar);
3835 #define GEOID_NOT_AVAILABLE -1
3837 #define DATE_USE_ALT_CALENDAR 0x00000004
3839 #if ENABLE_DOWNLEVEL_FOR_NLS
3847 IN CONST SYSTEMTIME *lpDate,
3848 IN LPCWSTR lpFormat,
3849 OUT LPWSTR lpDateStr,
3860 IN CONST SYSTEMTIME *lpDate,
3861 IN LPCWSTR lpFormat,
3862 OUT LPWSTR lpDateStr,
3864 IN LPCWSTR lpCalendar);
3867 #endif // ENABLE_DOWNLEVEL_FOR_NLS
3873 IN LPCWSTR lpLocaleName,
3875 IN CONST SYSTEMTIME *lpDate,
3876 IN LPCWSTR lpFormat,
3877 OUT LPWSTR lpDateStr,
3879 LPCWSTR lpCalendar);
3883 #define GetDateFormat GetDateFormatW
3890 PAL_GetResourceString(
3892 IN LPCSTR lpResourceStr,
3893 OUT LPWSTR lpWideCharStr,
3894 IN int cchWideChar);
3899 PAL_BindResources(IN LPCSTR lpDomain);
3901 #define EXCEPTION_NONCONTINUABLE 0x1
3902 #define EXCEPTION_UNWINDING 0x2
3904 #ifdef FEATURE_PAL_SXS
3906 #define EXCEPTION_EXIT_UNWIND 0x4 // Exit unwind is in progress (not used by PAL SEH)
3907 #define EXCEPTION_NESTED_CALL 0x10 // Nested exception handler call
3908 #define EXCEPTION_TARGET_UNWIND 0x20 // Target unwind in progress
3909 #define EXCEPTION_COLLIDED_UNWIND 0x40 // Collided exception handler call
3910 #define EXCEPTION_SKIP_VEH 0x200
3912 #define EXCEPTION_UNWIND (EXCEPTION_UNWINDING | EXCEPTION_EXIT_UNWIND | \
3913 EXCEPTION_TARGET_UNWIND | EXCEPTION_COLLIDED_UNWIND)
3915 #define IS_DISPATCHING(Flag) ((Flag & EXCEPTION_UNWIND) == 0)
3916 #define IS_UNWINDING(Flag) ((Flag & EXCEPTION_UNWIND) != 0)
3917 #define IS_TARGET_UNWIND(Flag) (Flag & EXCEPTION_TARGET_UNWIND)
3919 #endif // FEATURE_PAL_SXS
3921 #define EXCEPTION_IS_SIGNAL 0x100
3923 #define EXCEPTION_MAXIMUM_PARAMETERS 15
3925 // Index in the ExceptionInformation array where we will keep the reference
3926 // to the native exception that needs to be deleted when dispatching
3927 // exception in managed code.
3928 #define NATIVE_EXCEPTION_ASYNC_SLOT (EXCEPTION_MAXIMUM_PARAMETERS-1)
3930 typedef struct _EXCEPTION_RECORD {
3931 DWORD ExceptionCode;
3932 DWORD ExceptionFlags;
3933 struct _EXCEPTION_RECORD *ExceptionRecord;
3934 PVOID ExceptionAddress;
3935 DWORD NumberParameters;
3936 ULONG_PTR ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS];
3937 } EXCEPTION_RECORD, *PEXCEPTION_RECORD;
3939 typedef struct _EXCEPTION_POINTERS {
3940 PEXCEPTION_RECORD ExceptionRecord;
3941 PCONTEXT ContextRecord;
3942 } EXCEPTION_POINTERS, *PEXCEPTION_POINTERS, *LPEXCEPTION_POINTERS;
3944 #ifdef FEATURE_PAL_SXS
3946 typedef LONG EXCEPTION_DISPOSITION;
3949 ExceptionContinueExecution,
3950 ExceptionContinueSearch,
3951 ExceptionNestedException,
3952 ExceptionCollidedUnwind,
3955 #endif // FEATURE_PAL_SXS
3958 // A function table entry is generated for each frame function.
3960 typedef struct _RUNTIME_FUNCTION {
3962 #ifdef _TARGET_AMD64_
3966 } RUNTIME_FUNCTION, *PRUNTIME_FUNCTION;
3968 #define STANDARD_RIGHTS_REQUIRED (0x000F0000L)
3969 #define SYNCHRONIZE (0x00100000L)
3970 #define READ_CONTROL (0x00020000L)
3971 #define MAXIMUM_ALLOWED (0x02000000L)
3973 #define EVENT_MODIFY_STATE (0x0002)
3974 #define EVENT_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x3)
3976 #define MUTANT_QUERY_STATE (0x0001)
3977 #define MUTANT_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | MUTANT_QUERY_STATE)
3978 #define MUTEX_ALL_ACCESS MUTANT_ALL_ACCESS
3980 #define SEMAPHORE_MODIFY_STATE (0x0002)
3981 #define SEMAPHORE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x3)
3983 #define PROCESS_TERMINATE (0x0001)
3984 #define PROCESS_CREATE_THREAD (0x0002)
3985 #define PROCESS_SET_SESSIONID (0x0004)
3986 #define PROCESS_VM_OPERATION (0x0008)
3987 #define PROCESS_VM_READ (0x0010)
3988 #define PROCESS_VM_WRITE (0x0020)
3989 #define PROCESS_DUP_HANDLE (0x0040)
3990 #define PROCESS_CREATE_PROCESS (0x0080)
3991 #define PROCESS_SET_QUOTA (0x0100)
3992 #define PROCESS_SET_INFORMATION (0x0200)
3993 #define PROCESS_QUERY_INFORMATION (0x0400)
3994 #define PROCESS_SUSPEND_RESUME (0x0800)
3995 #define PROCESS_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | \
4002 IN DWORD dwDesiredAccess, /* PROCESS_DUP_HANDLE or PROCESS_ALL_ACCESS */
4003 IN BOOL bInheritHandle,
4004 IN DWORD dwProcessId
4012 OUT HMODULE *lphModule,
4014 OUT LPDWORD lpcbNeeded
4021 IN LPCSTR lpOutputString);
4027 IN LPCWSTR lpOutputStrig);
4030 #define OutputDebugString OutputDebugStringW
4032 #define OutputDebugString OutputDebugStringA
4045 IN LPCSTR lpString);
4051 IN LPCWSTR lpString);
4054 #define lstrlen lstrlenW
4056 #define lstrlen lstrlenA
4062 GetEnvironmentVariableW(
4064 OUT LPWSTR lpBuffer,
4068 #define GetEnvironmentVariable GetEnvironmentVariableW
4070 #define GetEnvironmentVariable GetEnvironmentVariableA
4076 SetEnvironmentVariableW(
4078 IN LPCWSTR lpValue);
4081 #define SetEnvironmentVariable SetEnvironmentVariableW
4083 #define SetEnvironmentVariable SetEnvironmentVariableA
4089 GetEnvironmentStringsW(
4093 #define GetEnvironmentStrings GetEnvironmentStringsW
4095 #define GetEnvironmentStrings GetEnvironmentStringsA
4101 FreeEnvironmentStringsW(
4105 #define FreeEnvironmentStrings FreeEnvironmentStringsW
4107 #define FreeEnvironmentStrings FreeEnvironmentStringsA
4114 IN OUT HANDLE hObject);
4120 IN DWORD dwExceptionCode,
4121 IN DWORD dwExceptionFlags,
4122 IN DWORD nNumberOfArguments,
4123 IN CONST ULONG_PTR *lpArguments);
4125 #ifdef FEATURE_PAL_SXS
4131 IN PEXCEPTION_POINTERS ExceptionPointers);
4132 #endif // FEATURE_PAL_SXS
4143 GetTickCount64(VOID);
4148 QueryPerformanceCounter(
4149 OUT LARGE_INTEGER *lpPerformanceCount
4155 QueryPerformanceFrequency(
4156 OUT LARGE_INTEGER *lpFrequency
4162 QueryThreadCycleTime(
4163 IN HANDLE ThreadHandle,
4164 OUT PULONG64 CycleTime);
4172 #ifndef FEATURE_PAL_SXS
4174 typedef LONG (PALAPI *PTOP_LEVEL_EXCEPTION_FILTER)(
4175 struct _EXCEPTION_POINTERS *ExceptionInfo);
4176 typedef PTOP_LEVEL_EXCEPTION_FILTER LPTOP_LEVEL_EXCEPTION_FILTER;
4179 LPTOP_LEVEL_EXCEPTION_FILTER
4181 SetUnhandledExceptionFilter(
4182 IN LPTOP_LEVEL_EXCEPTION_FILTER lpTopLevelExceptionFilter);
4184 #else // FEATURE_PAL_SXS
4186 typedef EXCEPTION_DISPOSITION (PALAPI *PVECTORED_EXCEPTION_HANDLER)(
4187 struct _EXCEPTION_POINTERS *ExceptionPointers);
4189 #endif // FEATURE_PAL_SXS
4191 // Define BitScanForward64 and BitScanForward
4192 // Per MSDN, BitScanForward64 will search the mask data from LSB to MSB for a set bit.
4193 // If one is found, its bit position is returned in the out PDWORD argument and 1 is returned.
4194 // Otherwise, 0 is returned.
4196 // On GCC, the equivalent function is __builtin_ffsl. It returns 1+index of the least
4197 // significant set bit, or 0 if if mask is zero.
4199 // The same is true for BitScanForward, except that the GCC function is __builtin_ffs.
4206 IN OUT PDWORD Index,
4209 unsigned char bRet = FALSE;
4210 int iIndex = __builtin_ffsl(qwMask);
4213 // Set the Index after deducting unity
4214 *Index = (DWORD)(iIndex - 1);
4227 IN OUT PDWORD Index,
4230 unsigned char bRet = FALSE;
4231 int iIndex = __builtin_ffsl(qwMask);
4234 // Set the Index after deducting unity
4235 *Index = (DWORD)(iIndex - 1);
4244 InterlockedIncrement
4246 The InterlockedIncrement function increments (increases by one) the
4247 value of the specified variable and checks the resulting value. The
4248 function prevents more than one thread from using the same variable
4254 [in/out] Pointer to the variable to increment.
4258 The return value is the resulting incremented value.
4266 InterlockedIncrement(
4267 IN OUT LONG volatile *lpAddend)
4269 return __sync_add_and_fetch(lpAddend, (LONG)1);
4277 InterlockedIncrement64(
4278 IN OUT LONGLONG volatile *lpAddend)
4280 return __sync_add_and_fetch(lpAddend, (LONGLONG)1);
4285 InterlockedDecrement
4287 The InterlockedDecrement function decrements (decreases by one) the
4288 value of the specified variable and checks the resulting value. The
4289 function prevents more than one thread from using the same variable
4295 [in/out] Pointer to the variable to decrement.
4299 The return value is the resulting decremented value.
4307 InterlockedDecrement(
4308 IN OUT LONG volatile *lpAddend)
4310 return __sync_sub_and_fetch(lpAddend, (LONG)1);
4318 InterlockedDecrement64(
4319 IN OUT LONGLONG volatile *lpAddend)
4321 return __sync_sub_and_fetch(lpAddend, (LONGLONG)1);
4328 The InterlockedExchange function atomically exchanges a pair of
4329 values. The function prevents more than one thread from using the same
4330 variable simultaneously.
4335 [in/out] Pointer to the value to exchange. The function sets
4336 this variable to Value, and returns its prior value.
4338 [in] Specifies a new value for the variable pointed to by Target.
4342 The function returns the initial value pointed to by Target.
4350 InterlockedExchange(
4351 IN OUT LONG volatile *Target,
4354 return __sync_swap(Target, Value);
4362 InterlockedExchange64(
4363 IN OUT LONGLONG volatile *Target,
4366 return __sync_swap(Target, Value);
4371 InterlockedCompareExchange
4373 The InterlockedCompareExchange function performs an atomic comparison
4374 of the specified values and exchanges the values, based on the outcome
4375 of the comparison. The function prevents more than one thread from
4376 using the same variable simultaneously.
4378 If you are exchanging pointer values, this function has been
4379 superseded by the InterlockedCompareExchangePointer function.
4383 Destination [in/out] Specifies the address of the destination value. The sign is ignored.
4384 Exchange [in] Specifies the exchange value. The sign is ignored.
4385 Comperand [in] Specifies the value to compare to Destination. The sign is ignored.
4389 The return value is the initial value of the destination.
4397 InterlockedCompareExchange(
4398 IN OUT LONG volatile *Destination,
4402 return __sync_val_compare_and_swap(
4403 Destination, /* The pointer to a variable whose value is to be compared with. */
4404 Comperand, /* The value to be compared */
4405 Exchange /* The value to be stored */);
4413 InterlockedCompareExchangeAcquire(
4414 IN OUT LONG volatile *Destination,
4418 // TODO: implement the version with only the acquire semantics
4419 return __sync_val_compare_and_swap(
4420 Destination, /* The pointer to a variable whose value is to be compared with. */
4421 Comperand, /* The value to be compared */
4422 Exchange /* The value to be stored */);
4430 InterlockedCompareExchangeRelease(
4431 IN OUT LONG volatile *Destination,
4435 // TODO: implement the version with only the release semantics
4436 return __sync_val_compare_and_swap(
4437 Destination, /* The pointer to a variable whose value is to be compared with. */
4438 Comperand, /* The value to be compared */
4439 Exchange /* The value to be stored */);
4442 // See the 32-bit variant in interlock2.s
4448 InterlockedCompareExchange64(
4449 IN OUT LONGLONG volatile *Destination,
4450 IN LONGLONG Exchange,
4451 IN LONGLONG Comperand)
4453 return __sync_val_compare_and_swap(
4454 Destination, /* The pointer to a variable whose value is to be compared with. */
4455 Comperand, /* The value to be compared */
4456 Exchange /* The value to be stored */);
4461 InterlockedExchangeAdd
4463 The InterlockedExchangeAdd function atomically adds the value of 'Value'
4464 to the variable that 'Addend' points to.
4469 [in/out] Pointer to the variable to to added.
4473 The return value is the original value that 'Addend' pointed to.
4481 InterlockedExchangeAdd(
4482 IN OUT LONG volatile *Addend,
4485 return __sync_fetch_and_add(Addend, Value);
4493 InterlockedExchangeAdd64(
4494 IN OUT LONGLONG volatile *Addend,
4497 return __sync_fetch_and_add(Addend, Value);
4506 IN OUT LONG volatile *Destination,
4509 return __sync_fetch_and_and(Destination, Value);
4518 IN OUT LONG volatile *Destination,
4521 return __sync_fetch_and_or(Destination, Value);
4529 InterlockedBitTestAndReset(
4530 IN OUT LONG volatile *Base,
4533 return (InterlockedAnd(Base, ~(1 << Bit)) & (1 << Bit)) != 0;
4541 InterlockedBitTestAndSet(
4542 IN OUT LONG volatile *Base,
4545 return (InterlockedOr(Base, (1 << Bit)) & (1 << Bit)) != 0;
4549 #define InterlockedExchangePointer(Target, Value) \
4550 ((PVOID)InterlockedExchange64((PLONG64)(Target), (LONGLONG)(Value)))
4552 #define InterlockedCompareExchangePointer(Destination, ExChange, Comperand) \
4553 ((PVOID)InterlockedCompareExchange64((PLONG64)(Destination), (LONGLONG)(ExChange), (LONGLONG)(Comperand)))
4555 #define InterlockedExchangePointer(Target, Value) \
4556 ((PVOID)(UINT_PTR)InterlockedExchange((PLONG)(UINT_PTR)(Target), (LONG)(UINT_PTR)(Value)))
4558 #define InterlockedCompareExchangePointer(Destination, ExChange, Comperand) \
4559 ((PVOID)(UINT_PTR)InterlockedCompareExchange((PLONG)(UINT_PTR)(Destination), (LONG)(UINT_PTR)(ExChange), (LONG)(UINT_PTR)(Comperand)))
4566 The MemoryBarrier function creates a full memory barrier.
4577 __sync_synchronize();
4588 #if defined(_X86_) || defined(_AMD64_)
4589 __asm__ __volatile__(
4592 #elif defined(_ARM64_)
4593 __asm__ __volatile__( "yield");
4602 GetCurrentProcessorNumber(VOID);
4606 PAL_HasGetCurrentProcessorNumber
4608 Checks if GetCurrentProcessorNumber is available in the current environment
4614 PAL_HasGetCurrentProcessorNumber(VOID);
4616 #define FORMAT_MESSAGE_ALLOCATE_BUFFER 0x00000100
4617 #define FORMAT_MESSAGE_IGNORE_INSERTS 0x00000200
4618 #define FORMAT_MESSAGE_FROM_STRING 0x00000400
4619 #define FORMAT_MESSAGE_FROM_SYSTEM 0x00001000
4620 #define FORMAT_MESSAGE_ARGUMENT_ARRAY 0x00002000
4621 #define FORMAT_MESSAGE_MAX_WIDTH_MASK 0x000000FF
4628 IN LPCVOID lpSource,
4629 IN DWORD dwMessageId,
4630 IN DWORD dwLanguageId,
4633 IN va_list *Arguments);
4636 #define FormatMessage FormatMessageW
4650 IN DWORD dwErrCode);
4659 #define GetCommandLine GetCommandLineW
4666 IN PCONTEXT ContextRecord,
4667 IN PEXCEPTION_RECORD ExceptionRecord
4674 OUT PCONTEXT ContextRecord
4682 IN PVOID lpBaseAddress,
4683 IN SIZE_T dwRegionSize,
4684 OUT PVOID *lpAddresses,
4685 IN OUT PULONG_PTR lpdwCount,
4686 OUT PULONG lpdwGranularity
4693 IN LPVOID lpBaseAddress,
4694 IN SIZE_T dwRegionSize
4700 FlushProcessWriteBuffers(VOID);
4702 typedef void (*PAL_ActivationFunction)(CONTEXT *context);
4703 typedef BOOL (*PAL_SafeActivationCheckFunction)(SIZE_T ip, BOOL checkingCurrentThread);
4708 PAL_SetActivationFunction(
4709 IN PAL_ActivationFunction pActivationFunction,
4710 IN PAL_SafeActivationCheckFunction pSafeActivationCheckFunction);
4715 PAL_InjectActivation(
4719 #define VER_PLATFORM_WIN32_WINDOWS 1
4720 #define VER_PLATFORM_WIN32_NT 2
4721 #define VER_PLATFORM_UNIX 10
4722 #define VER_PLATFORM_MACOSX 11
4724 typedef struct _OSVERSIONINFOA {
4725 DWORD dwOSVersionInfoSize;
4726 DWORD dwMajorVersion;
4727 DWORD dwMinorVersion;
4728 DWORD dwBuildNumber;
4730 CHAR szCSDVersion[ 128 ];
4731 } OSVERSIONINFOA, *POSVERSIONINFOA, *LPOSVERSIONINFOA;
4733 typedef struct _OSVERSIONINFOW {
4734 DWORD dwOSVersionInfoSize;
4735 DWORD dwMajorVersion;
4736 DWORD dwMinorVersion;
4737 DWORD dwBuildNumber;
4739 WCHAR szCSDVersion[ 128 ];
4740 } OSVERSIONINFOW, *POSVERSIONINFOW, *LPOSVERSIONINFOW;
4743 typedef OSVERSIONINFOW OSVERSIONINFO;
4744 typedef POSVERSIONINFOW POSVERSIONINFO;
4745 typedef LPOSVERSIONINFOW LPOSVERSIONINFO;
4747 typedef OSVERSIONINFOA OSVERSIONINFO;
4748 typedef POSVERSIONINFOA POSVERSIONINFO;
4749 typedef LPOSVERSIONINFOA LPOSVERSIONINFO;
4752 typedef struct _OSVERSIONINFOEXA {
4753 DWORD dwOSVersionInfoSize;
4754 DWORD dwMajorVersion;
4755 DWORD dwMinorVersion;
4756 DWORD dwBuildNumber;
4758 CHAR szCSDVersion[ 128 ];
4759 WORD wServicePackMajor;
4760 WORD wServicePackMinor;
4764 } OSVERSIONINFOEXA, *POSVERSIONINFOEXA, *LPOSVERSIONINFOEXA;
4766 typedef struct _OSVERSIONINFOEXW {
4767 DWORD dwOSVersionInfoSize;
4768 DWORD dwMajorVersion;
4769 DWORD dwMinorVersion;
4770 DWORD dwBuildNumber;
4772 WCHAR szCSDVersion[ 128 ];
4773 WORD wServicePackMajor;
4774 WORD wServicePackMinor;
4778 } OSVERSIONINFOEXW, *POSVERSIONINFOEXW, *LPOSVERSIONINFOEXW;
4781 typedef OSVERSIONINFOEXW OSVERSIONINFOEX;
4782 typedef POSVERSIONINFOEXW POSVERSIONINFOEX;
4783 typedef LPOSVERSIONINFOEXW LPOSVERSIONINFOEX;
4785 typedef OSVERSIONINFOEXA OSVERSIONINFOEX;
4786 typedef POSVERSIONINFOEXA POSVERSIONINFOEX;
4787 typedef LPOSVERSIONINFOEXA LPOSVERSIONINFOEX;
4790 #define IMAGE_FILE_MACHINE_I386 0x014c
4791 #define IMAGE_FILE_MACHINE_ARM64 0xAA64 // ARM64 Little-Endian
4793 typedef struct _SYSTEM_INFO {
4794 WORD wProcessorArchitecture_PAL_Undefined;
4795 WORD wReserved_PAL_Undefined; // NOTE: diff from winbase.h - no obsolete dwOemId union
4797 LPVOID lpMinimumApplicationAddress;
4798 LPVOID lpMaximumApplicationAddress;
4799 DWORD_PTR dwActiveProcessorMask_PAL_Undefined;
4800 DWORD dwNumberOfProcessors;
4801 DWORD dwProcessorType_PAL_Undefined;
4802 DWORD dwAllocationGranularity;
4803 WORD wProcessorLevel_PAL_Undefined;
4804 WORD wProcessorRevision_PAL_Undefined;
4805 } SYSTEM_INFO, *LPSYSTEM_INFO;
4811 OUT LPSYSTEM_INFO lpSystemInfo);
4817 LPCWSTR lpDirectoryName,
4818 LPDWORD lpSectorsPerCluster,
4819 LPDWORD lpBytesPerSector,
4820 LPDWORD lpNumberOfFreeClusters,
4821 LPDWORD lpTotalNumberOfClusters);
4824 #define GetDiskFreeSpace GetDiskFreeSpaceW
4831 OUT PHANDLE hReadPipe,
4832 OUT PHANDLE hWritePipe,
4833 IN LPSECURITY_ATTRIBUTES lpPipeAttributes,
4840 DeregisterEventSource (
4847 RegisterEventSourceA (
4848 IN OPTIONAL LPCSTR lpUNCServerName,
4849 IN LPCSTR lpSourceName
4854 RegisterEventSourceW (
4855 IN OPTIONAL LPCWSTR lpUNCServerName,
4856 IN LPCWSTR lpSourceName
4859 #define RegisterEventSource RegisterEventSourceW
4861 #define RegisterEventSource RegisterEventSourceA
4865 // NUMA related APIs
4868 typedef enum _PROCESSOR_CACHE_TYPE {
4873 } PROCESSOR_CACHE_TYPE;
4875 typedef struct _PROCESSOR_NUMBER {
4879 } PROCESSOR_NUMBER, *PPROCESSOR_NUMBER;
4881 typedef enum _LOGICAL_PROCESSOR_RELATIONSHIP {
4882 RelationProcessorCore,
4885 RelationProcessorPackage,
4887 RelationAll = 0xffff
4888 } LOGICAL_PROCESSOR_RELATIONSHIP;
4890 typedef ULONG_PTR KAFFINITY;
4892 #define ANYSIZE_ARRAY 1
4894 typedef struct _GROUP_AFFINITY {
4898 } GROUP_AFFINITY, *PGROUP_AFFINITY;
4900 typedef struct _PROCESSOR_GROUP_INFO {
4901 BYTE MaximumProcessorCount;
4902 BYTE ActiveProcessorCount;
4904 KAFFINITY ActiveProcessorMask;
4905 } PROCESSOR_GROUP_INFO, *PPROCESSOR_GROUP_INFO;
4907 typedef struct _PROCESSOR_RELATIONSHIP {
4909 BYTE EfficiencyClass;
4912 GROUP_AFFINITY GroupMask[ANYSIZE_ARRAY];
4913 } PROCESSOR_RELATIONSHIP, *PPROCESSOR_RELATIONSHIP;
4915 typedef struct _GROUP_RELATIONSHIP {
4916 WORD MaximumGroupCount;
4917 WORD ActiveGroupCount;
4919 PROCESSOR_GROUP_INFO GroupInfo[ANYSIZE_ARRAY];
4920 } GROUP_RELATIONSHIP, *PGROUP_RELATIONSHIP;
4922 typedef struct _NUMA_NODE_RELATIONSHIP {
4925 GROUP_AFFINITY GroupMask;
4926 } NUMA_NODE_RELATIONSHIP, *PNUMA_NODE_RELATIONSHIP;
4928 typedef struct _CACHE_RELATIONSHIP {
4933 PROCESSOR_CACHE_TYPE Type;
4935 GROUP_AFFINITY GroupMask;
4936 } CACHE_RELATIONSHIP, *PCACHE_RELATIONSHIP;
4938 typedef struct _SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX {
4939 LOGICAL_PROCESSOR_RELATIONSHIP Relationship;
4942 PROCESSOR_RELATIONSHIP Processor;
4943 NUMA_NODE_RELATIONSHIP NumaNode;
4944 CACHE_RELATIONSHIP Cache;
4945 GROUP_RELATIONSHIP Group;
4947 } SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX, *PSYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX;
4953 GetNumaHighestNodeNumber(
4954 OUT PULONG HighestNodeNumber
4960 GetNumaProcessorNodeEx(
4961 IN PPROCESSOR_NUMBER Processor,
4962 OUT PUSHORT NodeNumber
4970 IN OPTIONAL LPVOID lpAddress,
4972 IN DWORD flAllocationType,
4974 IN DWORD nndPreferred
4980 GetLogicalProcessorInformationEx(
4981 IN LOGICAL_PROCESSOR_RELATIONSHIP RelationshipType,
4982 OUT OPTIONAL PSYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX Buffer,
4983 IN OUT PDWORD ReturnedLength
4989 SetThreadAffinityMask(
4991 IN DWORD_PTR dwThreadAffinityMask
4997 SetThreadGroupAffinity(
4999 IN const GROUP_AFFINITY *GroupAffinity,
5000 OUT OPTIONAL PGROUP_AFFINITY PreviousGroupAffinity
5006 GetThreadGroupAffinity(
5008 OUT PGROUP_AFFINITY GroupAffinity
5014 GetCurrentProcessorNumberEx(
5015 OUT PPROCESSOR_NUMBER ProcNumber
5021 GetProcessAffinityMask(
5023 OUT PDWORD_PTR lpProcessAffinityMask,
5024 OUT PDWORD_PTR lpSystemAffinityMask
5028 // The types of events that can be logged.
5030 #define EVENTLOG_SUCCESS 0x0000
5031 #define EVENTLOG_ERROR_TYPE 0x0001
5032 #define EVENTLOG_WARNING_TYPE 0x0002
5033 #define EVENTLOG_INFORMATION_TYPE 0x0004
5034 #define EVENTLOG_AUDIT_SUCCESS 0x0008
5035 #define EVENTLOG_AUDIT_FAILURE 0x0010
5041 IN HANDLE hEventLog,
5045 IN OPTIONAL PSID lpUserSid,
5046 IN WORD wNumStrings,
5047 IN DWORD dwDataSize,
5048 IN OPTIONAL LPCSTR *lpStrings,
5049 IN OPTIONAL LPVOID lpRawData
5055 IN HANDLE hEventLog,
5059 IN OPTIONAL PSID lpUserSid,
5060 IN WORD wNumStrings,
5061 IN DWORD dwDataSize,
5062 IN OPTIONAL LPCWSTR *lpStrings,
5063 IN OPTIONAL LPVOID lpRawData
5066 #define ReportEvent ReportEventW
5068 #define ReportEvent ReportEventA
5074 CoCreateGuid(OUT GUID * pguid);
5076 #if defined FEATURE_PAL_ANSI
5077 #include "palprivate.h"
5078 #endif //FEATURE_PAL_ANSI
5079 /******************* C Runtime Entrypoints *******************************/
5081 /* Some C runtime functions needs to be reimplemented by the PAL.
5082 To avoid name collisions, those functions have been renamed using
5084 #ifndef PAL_STDCPP_COMPAT
5085 #define exit PAL_exit
5086 #define atexit PAL_atexit
5087 #define printf PAL_printf
5088 #define vprintf PAL_vprintf
5089 #define wprintf PAL_wprintf
5090 #define wcsspn PAL_wcsspn
5091 #define wcstod PAL_wcstod
5092 #define wcstol PAL_wcstol
5093 #define wcstoul PAL_wcstoul
5094 #define wcscat PAL_wcscat
5095 #define wcscpy PAL_wcscpy
5096 #define wcslen PAL_wcslen
5097 #define wcsncmp PAL_wcsncmp
5098 #define wcschr PAL_wcschr
5099 #define wcsrchr PAL_wcsrchr
5100 #define wcsstr PAL_wcsstr
5101 #define swscanf PAL_swscanf
5102 #define wcspbrk PAL_wcspbrk
5103 #define wcscmp PAL_wcscmp
5104 #define wcsncat PAL_wcsncat
5105 #define wcsncpy PAL_wcsncpy
5106 #define wcstok PAL_wcstok
5107 #define wcscspn PAL_wcscspn
5108 #define iswprint PAL_iswprint
5109 #define iswalpha PAL_iswalpha
5110 #define iswdigit PAL_iswdigit
5111 #define iswspace PAL_iswspace
5112 #define iswupper PAL_iswupper
5113 #define iswxdigit PAL_iswxdigit
5114 #define towlower PAL_towlower
5115 #define towupper PAL_towupper
5116 #define realloc PAL_realloc
5117 #define fopen PAL_fopen
5118 #define strtok PAL_strtok
5119 #define strtoul PAL_strtoul
5120 #define fprintf PAL_fprintf
5121 #define fwprintf PAL_fwprintf
5122 #define vfprintf PAL_vfprintf
5123 #define vfwprintf PAL_vfwprintf
5124 #define ctime PAL_ctime
5125 #define localtime PAL_localtime
5126 #define mktime PAL_mktime
5127 #define rand PAL_rand
5128 #define time PAL_time
5129 #define getenv PAL_getenv
5130 #define fgets PAL_fgets
5131 #define fgetws PAL_fgetws
5132 #define fputc PAL_fputc
5133 #define putchar PAL_putchar
5134 #define qsort PAL_qsort
5135 #define bsearch PAL_bsearch
5136 #define ferror PAL_ferror
5137 #define fread PAL_fread
5138 #define fwrite PAL_fwrite
5139 #define feof PAL_feof
5140 #define ftell PAL_ftell
5141 #define fclose PAL_fclose
5142 #define setbuf PAL_setbuf
5143 #define fflush PAL_fflush
5144 #define fputs PAL_fputs
5145 #define fseek PAL_fseek
5146 #define fgetpos PAL_fgetpos
5147 #define fsetpos PAL_fsetpos
5148 #define getc PAL_getc
5149 #define fgetc PAL_getc // not a typo
5150 #define ungetc PAL_ungetc
5151 #define setvbuf PAL_setvbuf
5152 #define atol PAL_atol
5153 #define labs PAL_labs
5154 #define acos PAL_acos
5155 #define asin PAL_asin
5156 #define atan2 PAL_atan2
5159 #define log10 PAL_log10
5161 #define acosf PAL_acosf
5162 #define asinf PAL_asinf
5163 #define atan2f PAL_atan2f
5164 #define expf PAL_expf
5165 #define logf PAL_logf
5166 #define log10f PAL_log10f
5167 #define powf PAL_powf
5168 #define malloc PAL_malloc
5169 #define free PAL_free
5170 #define mkstemp PAL_mkstemp
5171 #define rename PAL_rename
5172 #define _strdup PAL__strdup
5173 #define _getcwd PAL__getcwd
5174 #define _open PAL__open
5175 #define _close PAL__close
5176 #define _wcstoui64 PAL__wcstoui64
5177 #define _flushall PAL__flushall
5178 #define strnlen PAL_strnlen
5179 #define wcsnlen PAL_wcsnlen
5182 #define _mm_getcsr PAL__mm_getcsr
5183 #define _mm_setcsr PAL__mm_setcsr
5186 #endif // !PAL_STDCPP_COMPAT
5188 #ifndef _CONST_RETURN
5190 #define _CONST_RETURN const
5191 #define _CRT_CONST_CORRECT_OVERLOADS
5193 #define _CONST_RETURN
5197 /* For backwards compatibility */
5198 #define _WConst_return _CONST_RETURN
5202 typedef int errno_t;
5204 #ifndef PAL_STDCPP_COMPAT
5211 PALIMPORT div_t div(int numer, int denom);
5219 Overlapping buffer-safe version of memcpy.
5220 See MSDN doc for memcpy
5224 void *PAL_memcpy (void *dest, const void *src, size_t count);
5226 PALIMPORT void * __cdecl memcpy(void *, const void *, size_t);
5228 #define memcpy PAL_memcpy
5229 #define IS_PAL_memcpy 1
5230 #define TEST_PAL_DEFERRED(def) IS_##def
5231 #define IS_REDEFINED_IN_PAL(def) TEST_PAL_DEFERRED(def)
5232 #else //defined(_DEBUG)
5233 PALIMPORT void * __cdecl memcpy(void *, const void *, size_t);
5234 #endif //defined(_DEBUG)
5235 PALIMPORT int __cdecl memcmp(const void *, const void *, size_t);
5236 PALIMPORT void * __cdecl memset(void *, int, size_t);
5237 PALIMPORT void * __cdecl memmove(void *, const void *, size_t);
5238 PALIMPORT void * __cdecl memchr(const void *, int, size_t);
5239 PALIMPORT long long int __cdecl atoll(const char *);
5240 PALIMPORT size_t __cdecl strlen(const char *);
5241 PALIMPORT int __cdecl strcmp(const char*, const char *);
5242 PALIMPORT int __cdecl strncmp(const char*, const char *, size_t);
5243 PALIMPORT int __cdecl _strnicmp(const char *, const char *, size_t);
5244 PALIMPORT char * __cdecl strcat(char *, const char *);
5245 PALIMPORT char * __cdecl strncat(char *, const char *, size_t);
5246 PALIMPORT char * __cdecl strcpy(char *, const char *);
5247 PALIMPORT char * __cdecl strncpy(char *, const char *, size_t);
5248 PALIMPORT char * __cdecl strchr(const char *, int);
5249 PALIMPORT char * __cdecl strrchr(const char *, int);
5250 PALIMPORT char * __cdecl strpbrk(const char *, const char *);
5251 PALIMPORT char * __cdecl strstr(const char *, const char *);
5252 PALIMPORT char * __cdecl strtok(char *, const char *);
5253 PALIMPORT size_t __cdecl strspn(const char *, const char *);
5254 PALIMPORT size_t __cdecl strcspn(const char *, const char *);
5255 PALIMPORT int __cdecl atoi(const char *);
5256 PALIMPORT LONG __cdecl atol(const char *);
5257 PALIMPORT ULONG __cdecl strtoul(const char *, char **, int);
5258 PALIMPORT double __cdecl atof(const char *);
5259 PALIMPORT double __cdecl strtod(const char *, char **);
5260 PALIMPORT int __cdecl isprint(int);
5261 PALIMPORT int __cdecl isspace(int);
5262 PALIMPORT int __cdecl isalpha(int);
5263 PALIMPORT int __cdecl isalnum(int);
5264 PALIMPORT int __cdecl isdigit(int);
5265 PALIMPORT int __cdecl isxdigit(int);
5266 PALIMPORT int __cdecl isupper(int);
5267 PALIMPORT int __cdecl islower(int);
5268 PALIMPORT int __cdecl tolower(int);
5269 PALIMPORT int __cdecl toupper(int);
5271 #endif // PAL_STDCPP_COMPAT
5274 #if !defined(_TRUNCATE)
5275 #define _TRUNCATE ((size_t)-1)
5278 PALIMPORT errno_t __cdecl memcpy_s(void *, size_t, const void *, size_t);
5279 PALIMPORT errno_t __cdecl memmove_s(void *, size_t, const void *, size_t);
5280 PALIMPORT char * __cdecl _strlwr(char *);
5281 PALIMPORT int __cdecl _stricmp(const char *, const char *);
5282 PALIMPORT int __cdecl vsprintf_s(char *, size_t, const char *, va_list);
5283 PALIMPORT char * __cdecl _gcvt_s(char *, int, double, int);
5284 PALIMPORT char * __cdecl _ecvt(double, int, int *, int *);
5285 PALIMPORT int __cdecl __iscsym(int);
5286 PALIMPORT unsigned char * __cdecl _mbsinc(const unsigned char *);
5287 PALIMPORT unsigned char * __cdecl _mbsninc(const unsigned char *, size_t);
5288 PALIMPORT unsigned char * __cdecl _mbsdec(const unsigned char *, const unsigned char *);
5289 PALIMPORT int __cdecl _wcsicmp(const WCHAR *, const WCHAR*);
5290 PALIMPORT int __cdecl _wcsnicmp(const WCHAR *, const WCHAR *, size_t);
5291 PALIMPORT int __cdecl _vsnprintf(char *, size_t, const char *, va_list);
5292 PALIMPORT int __cdecl _vsnprintf_s(char *, size_t, size_t, const char *, va_list);
5293 PALIMPORT int __cdecl _vsnwprintf_s(WCHAR *, size_t, size_t, const WCHAR *, va_list);
5294 PALIMPORT int __cdecl _snwprintf_s(WCHAR *, size_t, size_t, const WCHAR *, ...);
5295 PALIMPORT int __cdecl _snprintf_s(char *, size_t, size_t, const char *, ...);
5296 PALIMPORT int __cdecl sprintf_s(char *, size_t, const char *, ... );
5297 PALIMPORT int __cdecl swprintf_s(WCHAR *, size_t, const WCHAR *, ... );
5298 PALIMPORT int __cdecl _snwprintf_s(WCHAR *, size_t, size_t, const WCHAR *, ...);
5299 PALIMPORT int __cdecl vswprintf_s( WCHAR *, size_t, const WCHAR *, va_list);
5300 PALIMPORT int __cdecl sscanf_s(const char *, const char *, ...);
5301 PALIMPORT errno_t __cdecl _itow_s(int, WCHAR *, size_t, int);
5303 PALIMPORT size_t __cdecl PAL_wcslen(const WCHAR *);
5304 PALIMPORT int __cdecl PAL_wcscmp(const WCHAR*, const WCHAR*);
5305 PALIMPORT int __cdecl PAL_wcsncmp(const WCHAR *, const WCHAR *, size_t);
5306 PALIMPORT WCHAR * __cdecl PAL_wcscat(WCHAR *, const WCHAR *);
5307 PALIMPORT WCHAR * __cdecl PAL_wcsncat(WCHAR *, const WCHAR *, size_t);
5308 PALIMPORT WCHAR * __cdecl PAL_wcscpy(WCHAR *, const WCHAR *);
5309 PALIMPORT WCHAR * __cdecl PAL_wcsncpy(WCHAR *, const WCHAR *, size_t);
5310 PALIMPORT const WCHAR * __cdecl PAL_wcschr(const WCHAR *, WCHAR);
5311 PALIMPORT const WCHAR * __cdecl PAL_wcsrchr(const WCHAR *, WCHAR);
5312 PALIMPORT WCHAR _WConst_return * __cdecl PAL_wcspbrk(const WCHAR *, const WCHAR *);
5313 PALIMPORT WCHAR _WConst_return * __cdecl PAL_wcsstr(const WCHAR *, const WCHAR *);
5314 PALIMPORT WCHAR * __cdecl PAL_wcstok(WCHAR *, const WCHAR *);
5315 PALIMPORT size_t __cdecl PAL_wcscspn(const WCHAR *, const WCHAR *);
5316 PALIMPORT int __cdecl PAL_swprintf(WCHAR *, const WCHAR *, ...);
5317 PALIMPORT int __cdecl PAL_vswprintf(WCHAR *, const WCHAR *, va_list);
5318 PALIMPORT int __cdecl PAL_swscanf(const WCHAR *, const WCHAR *, ...);
5319 PALIMPORT LONG __cdecl PAL_wcstol(const WCHAR *, WCHAR **, int);
5320 PALIMPORT ULONG __cdecl PAL_wcstoul(const WCHAR *, WCHAR **, int);
5321 PALIMPORT size_t __cdecl PAL_wcsspn (const WCHAR *, const WCHAR *);
5322 PALIMPORT double __cdecl PAL_wcstod(const WCHAR *, WCHAR **);
5323 PALIMPORT int __cdecl PAL_iswalpha(WCHAR);
5324 PALIMPORT int __cdecl PAL_iswprint(WCHAR);
5325 PALIMPORT int __cdecl PAL_iswupper(WCHAR);
5326 PALIMPORT int __cdecl PAL_iswspace(WCHAR);
5327 PALIMPORT int __cdecl PAL_iswdigit(WCHAR);
5328 PALIMPORT int __cdecl PAL_iswxdigit(WCHAR);
5329 PALIMPORT WCHAR __cdecl PAL_towlower(WCHAR);
5330 PALIMPORT WCHAR __cdecl PAL_towupper(WCHAR);
5332 PALIMPORT WCHAR * __cdecl _wcslwr(WCHAR *);
5333 PALIMPORT ULONGLONG _wcstoui64(const WCHAR *, WCHAR **, int);
5334 PALIMPORT errno_t __cdecl _i64tow_s(long long, WCHAR *, size_t, int);
5335 PALIMPORT int __cdecl _wtoi(const WCHAR *);
5339 inline WCHAR *PAL_wcschr(WCHAR *_S, WCHAR _C)
5340 {return ((WCHAR *)PAL_wcschr((const WCHAR *)_S, _C)); }
5341 inline WCHAR *PAL_wcsrchr(WCHAR *_S, WCHAR _C)
5342 {return ((WCHAR *)PAL_wcsrchr((const WCHAR *)_S, _C)); }
5343 inline WCHAR *PAL_wcspbrk(WCHAR *_S, const WCHAR *_P)
5344 {return ((WCHAR *)PAL_wcspbrk((const WCHAR *)_S, _P)); }
5345 inline WCHAR *PAL_wcsstr(WCHAR *_S, const WCHAR *_P)
5346 {return ((WCHAR *)PAL_wcsstr((const WCHAR *)_S, _P)); }
5350 #if !__has_builtin(_rotl)
5360 unsigned int __cdecl _rotl(unsigned int value, int shift)
5362 unsigned int retval = 0;
5365 retval = (value << shift) | (value >> (sizeof(int) * CHAR_BIT - shift));
5368 #endif // !__has_builtin(_rotl)
5370 // On 64 bit unix, make the long an int.
5372 #define _lrotl _rotl
5375 #if !__has_builtin(_rotr)
5386 unsigned int __cdecl _rotr(unsigned int value, int shift)
5388 unsigned int retval;
5391 retval = (value >> shift) | (value << (sizeof(int) * CHAR_BIT - shift));
5395 #endif // !__has_builtin(_rotr)
5397 PALIMPORT int __cdecl abs(int);
5398 #ifndef PAL_STDCPP_COMPAT
5399 PALIMPORT LONG __cdecl labs(LONG);
5400 #endif // !PAL_STDCPP_COMPAT
5401 // clang complains if this is declared with __int64
5402 PALIMPORT long long __cdecl llabs(long long);
5404 PALIMPORT int __cdecl _finite(double);
5405 PALIMPORT int __cdecl _isnan(double);
5406 PALIMPORT double __cdecl _copysign(double, double);
5407 PALIMPORT double __cdecl acos(double);
5408 PALIMPORT double __cdecl asin(double);
5409 PALIMPORT double __cdecl atan(double);
5410 PALIMPORT double __cdecl atan2(double, double);
5411 PALIMPORT double __cdecl ceil(double);
5412 PALIMPORT double __cdecl cos(double);
5413 PALIMPORT double __cdecl cosh(double);
5414 PALIMPORT double __cdecl exp(double);
5415 PALIMPORT double __cdecl fabs(double);
5416 PALIMPORT double __cdecl floor(double);
5417 PALIMPORT double __cdecl fmod(double, double);
5418 PALIMPORT double __cdecl log(double);
5419 PALIMPORT double __cdecl log10(double);
5420 PALIMPORT double __cdecl modf(double, double*);
5421 PALIMPORT double __cdecl pow(double, double);
5422 PALIMPORT double __cdecl sin(double);
5423 PALIMPORT double __cdecl sinh(double);
5424 PALIMPORT double __cdecl sqrt(double);
5425 PALIMPORT double __cdecl tan(double);
5426 PALIMPORT double __cdecl tanh(double);
5428 PALIMPORT int __cdecl _finitef(float);
5429 PALIMPORT int __cdecl _isnanf(float);
5430 PALIMPORT float __cdecl _copysignf(float, float);
5431 PALIMPORT float __cdecl acosf(float);
5432 PALIMPORT float __cdecl asinf(float);
5433 PALIMPORT float __cdecl atanf(float);
5434 PALIMPORT float __cdecl atan2f(float, float);
5435 PALIMPORT float __cdecl ceilf(float);
5436 PALIMPORT float __cdecl cosf(float);
5437 PALIMPORT float __cdecl coshf(float);
5438 PALIMPORT float __cdecl expf(float);
5439 PALIMPORT float __cdecl fabsf(float);
5440 PALIMPORT float __cdecl floorf(float);
5441 PALIMPORT float __cdecl fmodf(float, float);
5442 PALIMPORT float __cdecl logf(float);
5443 PALIMPORT float __cdecl log10f(float);
5444 PALIMPORT float __cdecl modff(float, float*);
5445 PALIMPORT float __cdecl powf(float, float);
5446 PALIMPORT float __cdecl sinf(float);
5447 PALIMPORT float __cdecl sinhf(float);
5448 PALIMPORT float __cdecl sqrtf(float);
5449 PALIMPORT float __cdecl tanf(float);
5450 PALIMPORT float __cdecl tanhf(float);
5452 #ifndef PAL_STDCPP_COMPAT
5457 inline __int64 abs(__int64 _X) {
5464 PALIMPORT void * __cdecl malloc(size_t);
5465 PALIMPORT void __cdecl free(void *);
5466 PALIMPORT void * __cdecl realloc(void *, size_t);
5467 PALIMPORT char * __cdecl _strdup(const char *);
5469 #if defined(_MSC_VER)
5470 #define alloca _alloca
5472 #define _alloca alloca
5475 #define alloca __builtin_alloca
5477 #define max(a, b) (((a) > (b)) ? (a) : (b))
5478 #define min(a, b) (((a) < (b)) ? (a) : (b))
5480 #endif // !PAL_STDCPP_COMPAT
5482 PALIMPORT PAL_NORETURN void __cdecl exit(int);
5483 int __cdecl atexit(void (__cdecl *function)(void));
5485 PALIMPORT void __cdecl qsort(void *, size_t, size_t, int (__cdecl *)(const void *, const void *));
5486 PALIMPORT void * __cdecl bsearch(const void *, const void *, size_t, size_t,
5487 int (__cdecl *)(const void *, const void *));
5489 PALIMPORT char * __cdecl _fullpath(char *, const char *, size_t);
5491 #ifndef PAL_STDCPP_COMPAT
5492 PALIMPORT time_t __cdecl time(time_t *);
5495 int tm_sec; /* seconds after the minute - [0,59] */
5496 int tm_min; /* minutes after the hour - [0,59] */
5497 int tm_hour; /* hours since midnight - [0,23] */
5498 int tm_mday; /* day of the month - [1,31] */
5499 int tm_mon; /* months since January - [0,11] */
5500 int tm_year; /* years since 1900 */
5501 int tm_wday; /* days since Sunday - [0,6] */
5502 int tm_yday; /* days since January 1 - [0,365] */
5503 int tm_isdst; /* daylight savings time flag */
5506 PALIMPORT struct tm * __cdecl localtime(const time_t *);
5507 PALIMPORT time_t __cdecl mktime(struct tm *);
5508 PALIMPORT char * __cdecl ctime(const time_t *);
5509 #endif // !PAL_STDCPP_COMPAT
5511 PALIMPORT int __cdecl _open_osfhandle(INT_PTR, int);
5512 PALIMPORT int __cdecl _close(int);
5513 PALIMPORT int __cdecl _flushall();
5515 #ifdef PAL_STDCPP_COMPAT
5518 typedef struct _PAL_FILE PAL_FILE;
5520 #else // PAL_STDCPP_COMPAT
5523 typedef struct _FILE FILE;
5524 typedef struct _FILE PAL_FILE;
5530 /* Locale categories */
5532 #define LC_COLLATE 1
5534 #define LC_MONETARY 3
5535 #define LC_NUMERIC 4
5538 #define _IOFBF 0 /* setvbuf should set fully buffered */
5539 #define _IOLBF 1 /* setvbuf should set line buffered */
5540 #define _IONBF 2 /* setvbuf should set unbuffered */
5542 #endif // PAL_STDCPP_COMPAT
5544 PALIMPORT int __cdecl PAL_fclose(PAL_FILE *);
5545 PALIMPORT void __cdecl PAL_setbuf(PAL_FILE *, char*);
5546 PALIMPORT int __cdecl PAL_fflush(PAL_FILE *);
5547 PALIMPORT size_t __cdecl PAL_fwrite(const void *, size_t, size_t, PAL_FILE *);
5548 PALIMPORT size_t __cdecl PAL_fread(void *, size_t, size_t, PAL_FILE *);
5549 PALIMPORT char * __cdecl PAL_fgets(char *, int, PAL_FILE *);
5550 PALIMPORT int __cdecl PAL_fputs(const char *, PAL_FILE *);
5551 PALIMPORT int __cdecl PAL_fputc(int c, PAL_FILE *stream);
5552 PALIMPORT int __cdecl PAL_putchar(int c);
5553 PALIMPORT int __cdecl PAL_fprintf(PAL_FILE *, const char *, ...);
5554 PALIMPORT int __cdecl PAL_vfprintf(PAL_FILE *, const char *, va_list);
5555 PALIMPORT int __cdecl PAL_fseek(PAL_FILE *, LONG, int);
5556 PALIMPORT LONG __cdecl PAL_ftell(PAL_FILE *);
5557 PALIMPORT int __cdecl PAL_feof(PAL_FILE *);
5558 PALIMPORT int __cdecl PAL_ferror(PAL_FILE *);
5559 PALIMPORT PAL_FILE * __cdecl PAL_fopen(const char *, const char *);
5560 PALIMPORT int __cdecl PAL_getc(PAL_FILE *stream);
5561 PALIMPORT int __cdecl PAL_fgetc(PAL_FILE *stream);
5562 PALIMPORT int __cdecl PAL_ungetc(int c, PAL_FILE *stream);
5563 PALIMPORT int __cdecl PAL_setvbuf(PAL_FILE *stream, char *, int, size_t);
5564 PALIMPORT WCHAR * __cdecl PAL_fgetws(WCHAR *, int, PAL_FILE *);
5565 PALIMPORT int __cdecl PAL_fwprintf(PAL_FILE *, const WCHAR *, ...);
5566 PALIMPORT int __cdecl PAL_vfwprintf(PAL_FILE *, const WCHAR *, va_list);
5567 PALIMPORT int __cdecl PAL_wprintf(const WCHAR*, ...);
5569 PALIMPORT int __cdecl _getw(PAL_FILE *);
5570 PALIMPORT int __cdecl _putw(int, PAL_FILE *);
5571 PALIMPORT PAL_FILE * __cdecl _fdopen(int, const char *);
5572 PALIMPORT PAL_FILE * __cdecl _wfopen(const WCHAR *, const WCHAR *);
5573 PALIMPORT PAL_FILE * __cdecl _wfsopen(const WCHAR *, const WCHAR *, int);
5575 /* Maximum value that can be returned by the rand function. */
5577 #ifndef PAL_STDCPP_COMPAT
5578 #define RAND_MAX 0x7fff
5579 #endif // !PAL_STDCPP_COMPAT
5581 PALIMPORT int __cdecl rand(void);
5582 PALIMPORT void __cdecl srand(unsigned int);
5584 PALIMPORT int __cdecl printf(const char *, ...);
5585 PALIMPORT int __cdecl vprintf(const char *, va_list);
5588 #define PAL_get_caller _MSC_VER
5590 #define PAL_get_caller 0
5593 PALIMPORT PAL_FILE * __cdecl PAL_get_stdout(int caller);
5594 PALIMPORT PAL_FILE * __cdecl PAL_get_stdin(int caller);
5595 PALIMPORT PAL_FILE * __cdecl PAL_get_stderr(int caller);
5596 PALIMPORT int * __cdecl PAL_errno(int caller);
5598 #ifdef PAL_STDCPP_COMPAT
5599 #define PAL_stdout (PAL_get_stdout(PAL_get_caller))
5600 #define PAL_stdin (PAL_get_stdin(PAL_get_caller))
5601 #define PAL_stderr (PAL_get_stderr(PAL_get_caller))
5602 #define PAL_errno (*PAL_errno(PAL_get_caller))
5603 #else // PAL_STDCPP_COMPAT
5604 #define stdout (PAL_get_stdout(PAL_get_caller))
5605 #define stdin (PAL_get_stdin(PAL_get_caller))
5606 #define stderr (PAL_get_stderr(PAL_get_caller))
5607 #define errno (*PAL_errno(PAL_get_caller))
5608 #endif // PAL_STDCPP_COMPAT
5610 PALIMPORT char * __cdecl getenv(const char *);
5611 PALIMPORT int __cdecl _putenv(const char *);
5615 /******************* PAL-specific I/O completion port *****************/
5617 typedef struct _PAL_IOCP_CPU_INFORMATION {
5619 FILETIME ftLastRecordedIdleTime;
5620 FILETIME ftLastRecordedCurrentTime;
5622 FILETIME ftLastRecordedKernelTime;
5623 FILETIME ftLastRecordedUserTime;
5624 } PAL_IOCP_CPU_INFORMATION;
5630 IN OUT PAL_IOCP_CPU_INFORMATION *lpPrevCPUInfo);
5632 /****************PAL Perf functions for PInvoke*********************/
5637 PAL_EnableProcessProfile(VOID);
5642 PAL_DisableProcessProfile(VOID);
5647 PAL_IsProcessProfileEnabled(VOID);
5652 PAL_GetCpuTickCount(VOID);
5655 /******************* PAL functions for SIMD extensions *****************/
5658 unsigned int _mm_getcsr(void);
5661 void _mm_setcsr(unsigned int i);
5663 /******************* PAL side-by-side support ************************/
5665 #ifdef FEATURE_PAL_SXS
5667 // Some versions of the PAL support several PALs side-by-side
5668 // in the process. To avoid those PALs interfering with one
5669 // another, they need to be told by clients when they are active
5670 // and when they are not.
5673 // To avoid performance problems incurred by swapping thread
5674 // exception ports every time we leave the PAL, there's also
5675 // the concept of entering/leaving the PAL at its top boundary
5676 // (entering down/leaving up) or at the bottom boundary
5677 // (leaving down/entering up).
5679 typedef enum _PAL_Boundary {
5680 PAL_BoundaryTop, // closer to main()
5681 PAL_BoundaryBottom, // closer to execution
5682 PAL_BoundaryEH, // out-of-band during EH
5684 PAL_BoundaryMax = PAL_BoundaryEH
5687 // This function needs to be called on a thread when it enters
5688 // a region of code that depends on this instance of the PAL
5689 // in the process, and the current thread may or may not be
5690 // known to the PAL. This function can fail (for something else
5691 // than an internal error) if this is the first time that the
5692 // current thread entered this PAL. Note that PAL_Initialize
5693 // implies a call to this function. Does not modify LastError.
5697 PAL_Enter(PAL_Boundary boundary);
5699 // Returns TRUE if we this thread has already entered the PAL,
5700 // returns FALSE if we have not entered the PAL.
5704 PAL_HasEntered(VOID);
5706 // Equivalent to PAL_Enter(PAL_BoundaryTop) and is for stub
5707 // code generation use.
5713 // This function needs to be called on a thread when it enters
5714 // a region of code that depends on this instance of the PAL
5715 // in the process, and the current thread is already known to
5716 // the PAL. Does not modify LastError.
5720 PAL_Reenter(PAL_Boundary boundary);
5722 // This function needs to be called on a thread when it enters
5723 // a region of code that depends on this instance of the PAL
5724 // in the process, and it is unknown whether the current thread
5725 // is already running in the PAL. Returns TRUE if and only if
5726 // the thread was not running in the PAL previously. Does not
5727 // modify LastError.
5731 PAL_ReenterForEH(VOID);
5733 // This function needs to be called on a thread when it leaves
5734 // a region of code that depends on this instance of the PAL
5735 // in the process. Does not modify LastError.
5739 PAL_Leave(PAL_Boundary boundary);
5741 // This function is equivalent to PAL_Leave(PAL_BoundaryBottom)
5742 // and is available to limit the creation of stub code.
5746 PAL_LeaveBottom(VOID);
5748 // This function is equivalent to PAL_Leave(PAL_BoundaryTop)
5749 // and is available to limit the creation of stub code.
5757 // A holder to enter the PAL for a specific region of code.
5758 // Previously, we must have been executing outside the PAL
5759 // (unless fEnter is set to FALSE).
5761 class PAL_EnterHolder
5767 PAL_EnterHolder(BOOL fEnter = TRUE) : m_palError(ERROR_SUCCESS)
5771 m_palError = PAL_Enter(PAL_BoundaryTop);
5772 m_fEntered = m_palError == ERROR_SUCCESS;
5784 PAL_Leave(PAL_BoundaryTop);
5793 void SuppressRelease()
5795 // Used to avoid calling PAL_Leave() when
5796 // another code path will explicitly do so.
5801 class PAL_LeaveHolder
5806 PAL_Leave(PAL_BoundaryBottom);
5811 PAL_Reenter(PAL_BoundaryBottom);
5814 #endif // __cplusplus
5816 #else // FEATURE_PAL_SXS
5818 #define PAL_Enter(boundary) ERROR_SUCCESS
5819 #define PAL_Reenter(boundary)
5820 #define PAL_Leave(boundary)
5823 class PAL_EnterHolder {
5825 // using constructor to suppress the "unused variable" warnings
5826 PAL_EnterHolder() {}
5828 class PAL_LeaveHolder {
5830 // using constructor to suppress the "unused variable" warnings
5831 PAL_LeaveHolder() {}
5833 #endif // __cplusplus
5835 #endif // FEATURE_PAL_SXS
5839 #include "pal_unwind.h"
5844 PAL_FreeExceptionRecords(
5845 IN EXCEPTION_RECORD *exceptionRecord,
5846 IN CONTEXT *contextRecord);
5848 #define EXCEPTION_CONTINUE_SEARCH 0
5849 #define EXCEPTION_EXECUTE_HANDLER 1
5850 #define EXCEPTION_CONTINUE_EXECUTION -1
5852 struct PAL_SEHException
5855 static const SIZE_T NoTargetFrameSp = SIZE_MAX;
5857 void Move(PAL_SEHException& ex)
5859 ExceptionPointers.ExceptionRecord = ex.ExceptionPointers.ExceptionRecord;
5860 ExceptionPointers.ContextRecord = ex.ExceptionPointers.ContextRecord;
5861 TargetFrameSp = ex.TargetFrameSp;
5868 if (ExceptionPointers.ExceptionRecord != NULL)
5870 PAL_FreeExceptionRecords(ExceptionPointers.ExceptionRecord, ExceptionPointers.ContextRecord);
5871 ExceptionPointers.ExceptionRecord = NULL;
5872 ExceptionPointers.ContextRecord = NULL;
5877 EXCEPTION_POINTERS ExceptionPointers;
5878 // Target frame stack pointer set before the 2nd pass.
5879 SIZE_T TargetFrameSp;
5881 PAL_SEHException(EXCEPTION_RECORD *pExceptionRecord, CONTEXT *pContextRecord)
5883 ExceptionPointers.ExceptionRecord = pExceptionRecord;
5884 ExceptionPointers.ContextRecord = pContextRecord;
5885 TargetFrameSp = NoTargetFrameSp;
5893 // The copy constructor and copy assignment operators are deleted so that the PAL_SEHException
5894 // can never be copied, only moved. This enables simple lifetime management of the exception and
5895 // context records, since there is always just one PAL_SEHException instance referring to the same records.
5896 PAL_SEHException(const PAL_SEHException& ex) = delete;
5897 PAL_SEHException& operator=(const PAL_SEHException& ex) = delete;
5899 PAL_SEHException(PAL_SEHException&& ex)
5904 PAL_SEHException& operator=(PAL_SEHException&& ex)
5918 ExceptionPointers.ExceptionRecord = NULL;
5919 ExceptionPointers.ContextRecord = NULL;
5920 TargetFrameSp = NoTargetFrameSp;
5923 CONTEXT* GetContextRecord()
5925 return ExceptionPointers.ContextRecord;
5928 EXCEPTION_RECORD* GetExceptionRecord()
5930 return ExceptionPointers.ExceptionRecord;
5935 return (TargetFrameSp == NoTargetFrameSp);
5938 void SecondPassDone()
5940 TargetFrameSp = NoTargetFrameSp;
5944 typedef BOOL (*PHARDWARE_EXCEPTION_HANDLER)(PAL_SEHException* ex);
5945 typedef BOOL (*PHARDWARE_EXCEPTION_SAFETY_CHECK_FUNCTION)(PCONTEXT contextRecord, PEXCEPTION_RECORD exceptionRecord);
5946 typedef VOID (*PTERMINATION_REQUEST_HANDLER)();
5947 typedef DWORD (*PGET_GCMARKER_EXCEPTION_CODE)(LPVOID ip);
5952 PAL_SetHardwareExceptionHandler(
5953 IN PHARDWARE_EXCEPTION_HANDLER exceptionHandler,
5954 IN PHARDWARE_EXCEPTION_SAFETY_CHECK_FUNCTION exceptionCheckFunction);
5959 PAL_SetGetGcMarkerExceptionCode(
5960 IN PGET_GCMARKER_EXCEPTION_CODE getGcMarkerExceptionCode);
5965 PAL_ThrowExceptionFromContext(
5966 IN CONTEXT* context,
5967 IN PAL_SEHException* ex);
5972 PAL_SetTerminationRequestHandler(
5973 IN PTERMINATION_REQUEST_HANDLER terminationRequestHandler);
5976 // This holder is used to indicate that a hardware
5977 // exception should be raised as a C++ exception
5978 // to better emulate SEH on the xplat platforms.
5980 class CatchHardwareExceptionHolder
5983 CatchHardwareExceptionHolder();
5985 ~CatchHardwareExceptionHolder();
5987 static bool IsEnabled();
5991 // NOTE: Catching hardware exceptions are only enabled in the DAC and SOS
5992 // builds. A hardware exception in coreclr code will fail fast/terminate
5995 #ifdef FEATURE_ENABLE_HARDWARE_EXCEPTIONS
5996 #define HardwareExceptionHolder CatchHardwareExceptionHolder __catchHardwareException;
5998 #define HardwareExceptionHolder
5999 #endif // FEATURE_ENABLE_HARDWARE_EXCEPTIONS
6001 #ifdef FEATURE_PAL_SXS
6006 // This is the base class of native exception holder used to provide
6007 // the filter function to the exception dispatcher. This allows the
6008 // filter to be called during the first pass to better emulate SEH
6009 // the xplat platforms that only have C++ exception support.
6011 class NativeExceptionHolderBase
6013 // Save the address of the holder head so the destructor
6014 // doesn't have access the slow (on Linux) TLS value again.
6015 NativeExceptionHolderBase **m_head;
6017 // The next holder on the stack
6018 NativeExceptionHolderBase *m_next;
6021 NativeExceptionHolderBase();
6023 ~NativeExceptionHolderBase();
6026 // Calls the holder's filter handler.
6027 virtual EXCEPTION_DISPOSITION InvokeFilter(PAL_SEHException& ex) = 0;
6029 // Adds the holder to the "stack" of holders. This is done explicitly instead
6030 // of in the constructor was to avoid the mess of move constructors combined
6031 // with return value optimization (in CreateHolder).
6034 // Given the currentHolder and locals stack range find the next holder starting with this one
6035 // To find the first holder, pass nullptr as the currentHolder.
6036 static NativeExceptionHolderBase *FindNextHolder(NativeExceptionHolderBase *currentHolder, void *frameLowAddress, void *frameHighAddress);
6040 // This is the second part of the native exception filter holder. It is
6041 // templated because the lambda used to wrap the exception filter is a
6044 template<class FilterType>
6045 class NativeExceptionHolder : public NativeExceptionHolderBase
6047 FilterType* m_exceptionFilter;
6050 NativeExceptionHolder(FilterType* exceptionFilter)
6051 : NativeExceptionHolderBase()
6053 m_exceptionFilter = exceptionFilter;
6056 virtual EXCEPTION_DISPOSITION InvokeFilter(PAL_SEHException& ex)
6058 return (*m_exceptionFilter)(ex);
6063 // This is a native exception holder that is used when the catch catches
6066 class NativeExceptionHolderCatchAll : public NativeExceptionHolderBase
6070 NativeExceptionHolderCatchAll()
6071 : NativeExceptionHolderBase()
6075 virtual EXCEPTION_DISPOSITION InvokeFilter(PAL_SEHException& ex)
6077 return EXCEPTION_EXECUTE_HANDLER;
6081 // This is a native exception holder that doesn't catch any exceptions.
6082 class NativeExceptionHolderNoCatch : public NativeExceptionHolderBase
6086 NativeExceptionHolderNoCatch()
6087 : NativeExceptionHolderBase()
6091 virtual EXCEPTION_DISPOSITION InvokeFilter(PAL_SEHException& ex)
6093 return EXCEPTION_CONTINUE_SEARCH;
6098 // This factory class for the native exception holder is necessary because
6099 // templated functions don't need the explicit type parameter and can infer
6100 // the template type from the parameter.
6102 class NativeExceptionHolderFactory
6105 template<class FilterType>
6106 static NativeExceptionHolder<FilterType> CreateHolder(FilterType* exceptionFilter)
6108 return NativeExceptionHolder<FilterType>(exceptionFilter);
6112 // Start of a try block for exceptions raised by RaiseException
6113 #define PAL_TRY(__ParamType, __paramDef, __paramRef) \
6115 __ParamType __param = __paramRef; \
6116 auto tryBlock = [](__ParamType __paramDef) \
6119 // Start of an exception handler. If an exception raised by the RaiseException
6120 // occurs in the try block and the disposition is EXCEPTION_EXECUTE_HANDLER,
6121 // the handler code is executed. If the disposition is EXCEPTION_CONTINUE_SEARCH,
6122 // the exception is rethrown. The EXCEPTION_CONTINUE_EXECUTION disposition is
6124 #define PAL_EXCEPT(dispositionExpression) \
6126 const bool isFinally = false; \
6127 auto finallyBlock = []() {}; \
6128 EXCEPTION_DISPOSITION disposition = EXCEPTION_CONTINUE_EXECUTION; \
6129 auto exceptionFilter = [&disposition, &__param](PAL_SEHException& ex) \
6131 disposition = dispositionExpression; \
6132 _ASSERTE(disposition != EXCEPTION_CONTINUE_EXECUTION); \
6133 return disposition; \
6137 HardwareExceptionHolder \
6138 auto __exceptionHolder = NativeExceptionHolderFactory::CreateHolder(&exceptionFilter); \
6139 __exceptionHolder.Push(); \
6140 tryBlock(__param); \
6142 catch (PAL_SEHException& ex) \
6144 if (disposition == EXCEPTION_CONTINUE_EXECUTION) \
6146 exceptionFilter(ex); \
6148 if (disposition == EXCEPTION_CONTINUE_SEARCH) \
6152 ex.SecondPassDone();
6154 // Start of an exception handler. It works the same way as the PAL_EXCEPT except
6155 // that the disposition is obtained by calling the specified filter.
6156 #define PAL_EXCEPT_FILTER(filter) PAL_EXCEPT(filter(&ex.ExceptionPointers, __param))
6158 // Start of a finally block. The finally block is executed both when the try block
6159 // finishes or when an exception is raised using the RaiseException in it.
6160 #define PAL_FINALLY \
6162 const bool isFinally = true; \
6163 auto finallyBlock = [&]() \
6166 // End of an except or a finally block.
6167 #define PAL_ENDTRY \
6173 tryBlock(__param); \
6186 #endif // FEATURE_PAL_SXS
6188 #define PAL_CPP_THROW(type, obj) { throw obj; }
6189 #define PAL_CPP_RETHROW { throw; }
6190 #define PAL_CPP_TRY try { HardwareExceptionHolder
6191 #define PAL_CPP_CATCH_EXCEPTION(ident) } catch (Exception *ident) { PAL_Reenter(PAL_BoundaryBottom);
6192 #define PAL_CPP_CATCH_EXCEPTION_NOARG } catch (Exception *) { PAL_Reenter(PAL_BoundaryBottom);
6193 #define PAL_CPP_CATCH_DERIVED(type, ident) } catch (type *ident) { PAL_Reenter(PAL_BoundaryBottom);
6194 #define PAL_CPP_CATCH_ALL } catch (...) { \
6195 PAL_Reenter(PAL_BoundaryBottom); \
6197 catch (PAL_SEHException& ex) { ex.SecondPassDone(); } \
6200 #define PAL_CPP_ENDTRY }
6203 #pragma warning(disable:4611) // interaction between '_setjmp' and C++ object destruction is non-portable
6206 #ifdef FEATURE_PAL_SXS
6208 #define PAL_TRY_FOR_DLLMAIN(ParamType, paramDef, paramRef, _reason) PAL_TRY(ParamType, paramDef, paramRef)
6210 #else // FEATURE_PAL_SXS
6212 #define PAL_TRY(ParamType, paramDef, paramRef) \
6214 ParamType __param = paramRef; \
6215 ParamType paramDef; paramDef = __param; \
6217 HardwareExceptionHolder
6219 #define PAL_TRY_FOR_DLLMAIN(ParamType, paramDef, paramRef, _reason) \
6221 ParamType __param = paramRef; \
6222 ParamType paramDef; paramDef = __param; \
6224 HardwareExceptionHolder
6226 #define PAL_ENDTRY \
6230 #endif // FEATURE_PAL_SXS
6232 #endif // __cplusplus
6234 // Platform-specific library naming
6237 #define MAKEDLLNAME_W(name) u"lib" name u".dylib"
6238 #define MAKEDLLNAME_A(name) "lib" name ".dylib"
6240 #define MAKEDLLNAME_W(name) u"lib" name u".so"
6241 #define MAKEDLLNAME_A(name) "lib" name ".so"
6245 #define MAKEDLLNAME(x) MAKEDLLNAME_W(x)
6247 #define MAKEDLLNAME(x) MAKEDLLNAME_A(x)
6250 #define PAL_SHLIB_PREFIX "lib"
6253 #define PAL_SHLIB_SUFFIX ".dylib"
6255 #define PAL_SHLIB_SUFFIX ".so"
6258 #define DBG_EXCEPTION_HANDLED ((DWORD )0x00010001L)
6259 #define DBG_CONTINUE ((DWORD )0x00010002L)
6260 #define DBG_EXCEPTION_NOT_HANDLED ((DWORD )0x80010001L)
6262 #define DBG_TERMINATE_THREAD ((DWORD )0x40010003L)
6263 #define DBG_TERMINATE_PROCESS ((DWORD )0x40010004L)
6264 #define DBG_CONTROL_C ((DWORD )0x40010005L)
6265 #define DBG_RIPEXCEPTION ((DWORD )0x40010007L)
6266 #define DBG_CONTROL_BREAK ((DWORD )0x40010008L)
6267 #define DBG_COMMAND_EXCEPTION ((DWORD )0x40010009L)
6269 #define STATUS_USER_APC ((DWORD )0x000000C0L)
6270 #define STATUS_GUARD_PAGE_VIOLATION ((DWORD )0x80000001L)
6271 #define STATUS_DATATYPE_MISALIGNMENT ((DWORD )0x80000002L)
6272 #define STATUS_BREAKPOINT ((DWORD )0x80000003L)
6273 #define STATUS_SINGLE_STEP ((DWORD )0x80000004L)
6274 #define STATUS_LONGJUMP ((DWORD )0x80000026L)
6275 #define STATUS_UNWIND_CONSOLIDATE ((DWORD )0x80000029L)
6276 #define STATUS_ACCESS_VIOLATION ((DWORD )0xC0000005L)
6277 #define STATUS_IN_PAGE_ERROR ((DWORD )0xC0000006L)
6278 #define STATUS_INVALID_HANDLE ((DWORD )0xC0000008L)
6279 #define STATUS_NO_MEMORY ((DWORD )0xC0000017L)
6280 #define STATUS_ILLEGAL_INSTRUCTION ((DWORD )0xC000001DL)
6281 #define STATUS_NONCONTINUABLE_EXCEPTION ((DWORD )0xC0000025L)
6282 #define STATUS_INVALID_DISPOSITION ((DWORD )0xC0000026L)
6283 #define STATUS_ARRAY_BOUNDS_EXCEEDED ((DWORD )0xC000008CL)
6284 #define STATUS_FLOAT_DENORMAL_OPERAND ((DWORD )0xC000008DL)
6285 #define STATUS_FLOAT_DIVIDE_BY_ZERO ((DWORD )0xC000008EL)
6286 #define STATUS_FLOAT_INEXACT_RESULT ((DWORD )0xC000008FL)
6287 #define STATUS_FLOAT_INVALID_OPERATION ((DWORD )0xC0000090L)
6288 #define STATUS_FLOAT_OVERFLOW ((DWORD )0xC0000091L)
6289 #define STATUS_FLOAT_STACK_CHECK ((DWORD )0xC0000092L)
6290 #define STATUS_FLOAT_UNDERFLOW ((DWORD )0xC0000093L)
6291 #define STATUS_INTEGER_DIVIDE_BY_ZERO ((DWORD )0xC0000094L)
6292 #define STATUS_INTEGER_OVERFLOW ((DWORD )0xC0000095L)
6293 #define STATUS_PRIVILEGED_INSTRUCTION ((DWORD )0xC0000096L)
6294 #define STATUS_STACK_OVERFLOW ((DWORD )0xC00000FDL)
6295 #define STATUS_CONTROL_C_EXIT ((DWORD )0xC000013AL)
6297 #define WAIT_IO_COMPLETION STATUS_USER_APC
6299 #define EXCEPTION_ACCESS_VIOLATION STATUS_ACCESS_VIOLATION
6300 #define EXCEPTION_DATATYPE_MISALIGNMENT STATUS_DATATYPE_MISALIGNMENT
6301 #define EXCEPTION_BREAKPOINT STATUS_BREAKPOINT
6302 #define EXCEPTION_SINGLE_STEP STATUS_SINGLE_STEP
6303 #define EXCEPTION_ARRAY_BOUNDS_EXCEEDED STATUS_ARRAY_BOUNDS_EXCEEDED
6304 #define EXCEPTION_FLT_DENORMAL_OPERAND STATUS_FLOAT_DENORMAL_OPERAND
6305 #define EXCEPTION_FLT_DIVIDE_BY_ZERO STATUS_FLOAT_DIVIDE_BY_ZERO
6306 #define EXCEPTION_FLT_INEXACT_RESULT STATUS_FLOAT_INEXACT_RESULT
6307 #define EXCEPTION_FLT_INVALID_OPERATION STATUS_FLOAT_INVALID_OPERATION
6308 #define EXCEPTION_FLT_OVERFLOW STATUS_FLOAT_OVERFLOW
6309 #define EXCEPTION_FLT_STACK_CHECK STATUS_FLOAT_STACK_CHECK
6310 #define EXCEPTION_FLT_UNDERFLOW STATUS_FLOAT_UNDERFLOW
6311 #define EXCEPTION_INT_DIVIDE_BY_ZERO STATUS_INTEGER_DIVIDE_BY_ZERO
6312 #define EXCEPTION_INT_OVERFLOW STATUS_INTEGER_OVERFLOW
6313 #define EXCEPTION_PRIV_INSTRUCTION STATUS_PRIVILEGED_INSTRUCTION
6314 #define EXCEPTION_IN_PAGE_ERROR STATUS_IN_PAGE_ERROR
6315 #define EXCEPTION_ILLEGAL_INSTRUCTION STATUS_ILLEGAL_INSTRUCTION
6316 #define EXCEPTION_NONCONTINUABLE_EXCEPTION STATUS_NONCONTINUABLE_EXCEPTION
6317 #define EXCEPTION_STACK_OVERFLOW STATUS_STACK_OVERFLOW
6318 #define EXCEPTION_INVALID_DISPOSITION STATUS_INVALID_DISPOSITION
6319 #define EXCEPTION_GUARD_PAGE STATUS_GUARD_PAGE_VIOLATION
6320 #define EXCEPTION_INVALID_HANDLE STATUS_INVALID_HANDLE
6322 #define CONTROL_C_EXIT STATUS_CONTROL_C_EXIT
6324 /* These are from the <FCNTL.H> file in windows.
6325 They are needed for _open_osfhandle.*/
6326 #define _O_RDONLY 0x0000
6327 #define _O_APPEND 0x0008
6328 #define _O_TEXT 0x4000
6329 #define _O_BINARY 0x8000