1*04e0dc4aSTimo Kreuzer //
2*04e0dc4aSTimo Kreuzer // corecrt_internal.h
3*04e0dc4aSTimo Kreuzer //
4*04e0dc4aSTimo Kreuzer // Copyright (c) Microsoft Corporation. All rights reserved.
5*04e0dc4aSTimo Kreuzer //
6*04e0dc4aSTimo Kreuzer // CoreCRT Internals
7*04e0dc4aSTimo Kreuzer //
8*04e0dc4aSTimo Kreuzer #pragma once
9*04e0dc4aSTimo Kreuzer
10*04e0dc4aSTimo Kreuzer #include <corecrt.h>
11*04e0dc4aSTimo Kreuzer #include <corecrt_startup.h>
12*04e0dc4aSTimo Kreuzer #include <corecrt_terminate.h>
13*04e0dc4aSTimo Kreuzer #include <corecrt_wctype.h>
14*04e0dc4aSTimo Kreuzer #include <crtdbg.h>
15*04e0dc4aSTimo Kreuzer #include <ctype.h>
16*04e0dc4aSTimo Kreuzer #include <errno.h>
17*04e0dc4aSTimo Kreuzer #include <excpt.h>
18*04e0dc4aSTimo Kreuzer #include <internal_shared.h>
19*04e0dc4aSTimo Kreuzer #include <limits.h>
20*04e0dc4aSTimo Kreuzer #include <malloc.h>
21*04e0dc4aSTimo Kreuzer #include <process.h>
22*04e0dc4aSTimo Kreuzer #include <stdbool.h>
23*04e0dc4aSTimo Kreuzer #include <stdlib.h>
24*04e0dc4aSTimo Kreuzer #include <vcruntime_startup.h>
25*04e0dc4aSTimo Kreuzer #include <windows.h>
26*04e0dc4aSTimo Kreuzer #include <appmodel.h>
27*04e0dc4aSTimo Kreuzer
28*04e0dc4aSTimo Kreuzer #ifdef __cplusplus
29*04e0dc4aSTimo Kreuzer #include <roapi.h>
30*04e0dc4aSTimo Kreuzer #endif
31*04e0dc4aSTimo Kreuzer
32*04e0dc4aSTimo Kreuzer _CRT_BEGIN_C_HEADER
33*04e0dc4aSTimo Kreuzer
34*04e0dc4aSTimo Kreuzer #define _DEFINE_SET_FUNCTION(function_name, type, variable_name) \
35*04e0dc4aSTimo Kreuzer __inline void function_name(type value) \
36*04e0dc4aSTimo Kreuzer { \
37*04e0dc4aSTimo Kreuzer __pragma(warning(push)) \
38*04e0dc4aSTimo Kreuzer __pragma(warning(disable:4996)) \
39*04e0dc4aSTimo Kreuzer variable_name = value; \
40*04e0dc4aSTimo Kreuzer __pragma(warning(pop)) \
41*04e0dc4aSTimo Kreuzer }
42*04e0dc4aSTimo Kreuzer
43*04e0dc4aSTimo Kreuzer
44*04e0dc4aSTimo Kreuzer
45*04e0dc4aSTimo Kreuzer #if defined _M_IX86
46*04e0dc4aSTimo Kreuzer #define _CRT_LINKER_SYMBOL_PREFIX "_"
47*04e0dc4aSTimo Kreuzer #elif defined _M_X64 || defined _M_ARM || defined _M_ARM64
48*04e0dc4aSTimo Kreuzer #define _CRT_LINKER_SYMBOL_PREFIX ""
49*04e0dc4aSTimo Kreuzer #else
50*04e0dc4aSTimo Kreuzer #error Unsupported architecture
51*04e0dc4aSTimo Kreuzer #endif
52*04e0dc4aSTimo Kreuzer
53*04e0dc4aSTimo Kreuzer #define _CRT_LINKER_FORCE_INCLUDE(name) \
54*04e0dc4aSTimo Kreuzer __pragma(comment(linker, \
55*04e0dc4aSTimo Kreuzer "/include:" \
56*04e0dc4aSTimo Kreuzer _CRT_LINKER_SYMBOL_PREFIX #name \
57*04e0dc4aSTimo Kreuzer ))
58*04e0dc4aSTimo Kreuzer
59*04e0dc4aSTimo Kreuzer
60*04e0dc4aSTimo Kreuzer
61*04e0dc4aSTimo Kreuzer //-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
62*04e0dc4aSTimo Kreuzer //
63*04e0dc4aSTimo Kreuzer // CRT SAL Annotations
64*04e0dc4aSTimo Kreuzer //
65*04e0dc4aSTimo Kreuzer //-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
66*04e0dc4aSTimo Kreuzer // This macro can be used to annotate a buffer when it has the option that
67*04e0dc4aSTimo Kreuzer // _CRT_UNBOUNDED_BUFFER_SIZE may be passed as its size in order to invoke unsafe behavior.
68*04e0dc4aSTimo Kreuzer // void example(
69*04e0dc4aSTimo Kreuzer // _Maybe_unsafe_(_Out_writes_z_, buffer_count) char * const buffer,
70*04e0dc4aSTimo Kreuzer // _In_ size_t const buffer_size
71*04e0dc4aSTimo Kreuzer // )
72*04e0dc4aSTimo Kreuzer #define _CRT_UNBOUNDED_BUFFER_SIZE (static_cast<size_t>(-1))
73*04e0dc4aSTimo Kreuzer #define _Maybe_unsafe_(buffer_annotation, expr) \
74*04e0dc4aSTimo Kreuzer _When_((expr < _CRT_UNBOUNDED_BUFFER_SIZE), buffer_annotation(expr)) \
75*04e0dc4aSTimo Kreuzer _When_((expr >= _CRT_UNBOUNDED_BUFFER_SIZE), buffer_annotation(_Inexpressible_("unsafe")))
76*04e0dc4aSTimo Kreuzer
77*04e0dc4aSTimo Kreuzer
78*04e0dc4aSTimo Kreuzer
79*04e0dc4aSTimo Kreuzer //-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
80*04e0dc4aSTimo Kreuzer //
81*04e0dc4aSTimo Kreuzer // Forward declarations of __crt_state_management types
82*04e0dc4aSTimo Kreuzer //
83*04e0dc4aSTimo Kreuzer //-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
84*04e0dc4aSTimo Kreuzer #ifdef __cplusplus
85*04e0dc4aSTimo Kreuzer extern "C++"
86*04e0dc4aSTimo Kreuzer {
87*04e0dc4aSTimo Kreuzer namespace __crt_state_management
88*04e0dc4aSTimo Kreuzer {
89*04e0dc4aSTimo Kreuzer template <typename T>
90*04e0dc4aSTimo Kreuzer class dual_state_global;
91*04e0dc4aSTimo Kreuzer }
92*04e0dc4aSTimo Kreuzer }
93*04e0dc4aSTimo Kreuzer #endif
94*04e0dc4aSTimo Kreuzer
95*04e0dc4aSTimo Kreuzer
96*04e0dc4aSTimo Kreuzer
97*04e0dc4aSTimo Kreuzer //-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
98*04e0dc4aSTimo Kreuzer //
99*04e0dc4aSTimo Kreuzer // Dual-state globals (that shouldn't be exported directly)
100*04e0dc4aSTimo Kreuzer //
101*04e0dc4aSTimo Kreuzer //-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
102*04e0dc4aSTimo Kreuzer #ifdef __cplusplus
103*04e0dc4aSTimo Kreuzer extern __crt_state_management::dual_state_global<int> _fmode;
104*04e0dc4aSTimo Kreuzer extern __crt_state_management::dual_state_global<unsigned char*> _mbctype;
105*04e0dc4aSTimo Kreuzer extern __crt_state_management::dual_state_global<unsigned char*> _mbcasemap;
106*04e0dc4aSTimo Kreuzer #endif
107*04e0dc4aSTimo Kreuzer
108*04e0dc4aSTimo Kreuzer
109*04e0dc4aSTimo Kreuzer
110*04e0dc4aSTimo Kreuzer //-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
111*04e0dc4aSTimo Kreuzer //
112*04e0dc4aSTimo Kreuzer // Dynamic Initialization Support
113*04e0dc4aSTimo Kreuzer //
114*04e0dc4aSTimo Kreuzer //-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
115*04e0dc4aSTimo Kreuzer #define _CORECRT_GENERATE_FORWARDER(prefix, callconv, name, callee_name) \
116*04e0dc4aSTimo Kreuzer __pragma(warning(push)) \
117*04e0dc4aSTimo Kreuzer __pragma(warning(disable: 4100)) /* unreferenced formal parameter */ \
118*04e0dc4aSTimo Kreuzer template <typename... Params> \
119*04e0dc4aSTimo Kreuzer prefix auto callconv name(Params&&... args) throw() -> decltype(callee_name(args...)) \
120*04e0dc4aSTimo Kreuzer { \
121*04e0dc4aSTimo Kreuzer _BEGIN_SECURE_CRT_DEPRECATION_DISABLE \
122*04e0dc4aSTimo Kreuzer return callee_name(args...); \
123*04e0dc4aSTimo Kreuzer _END_SECURE_CRT_DEPRECATION_DISABLE \
124*04e0dc4aSTimo Kreuzer } \
125*04e0dc4aSTimo Kreuzer __pragma(warning(pop))
126*04e0dc4aSTimo Kreuzer
127*04e0dc4aSTimo Kreuzer extern size_t const _sys_first_posix_error;
128*04e0dc4aSTimo Kreuzer extern size_t const _sys_last_posix_error;
129*04e0dc4aSTimo Kreuzer extern char const* const _sys_posix_errlist[];
130*04e0dc4aSTimo Kreuzer
131*04e0dc4aSTimo Kreuzer _Ret_z_
_get_sys_err_msg(size_t const m)132*04e0dc4aSTimo Kreuzer __inline char const* _get_sys_err_msg(size_t const m)
133*04e0dc4aSTimo Kreuzer {
134*04e0dc4aSTimo Kreuzer _BEGIN_SECURE_CRT_DEPRECATION_DISABLE
135*04e0dc4aSTimo Kreuzer if (m > _sys_last_posix_error || ((size_t)_sys_nerr < m && m < _sys_first_posix_error))
136*04e0dc4aSTimo Kreuzer return _sys_errlist[_sys_nerr];
137*04e0dc4aSTimo Kreuzer if (m <= (size_t)_sys_nerr)
138*04e0dc4aSTimo Kreuzer return _sys_errlist[m];
139*04e0dc4aSTimo Kreuzer else
140*04e0dc4aSTimo Kreuzer return _sys_posix_errlist[m - _sys_first_posix_error];
141*04e0dc4aSTimo Kreuzer _END_SECURE_CRT_DEPRECATION_DISABLE
142*04e0dc4aSTimo Kreuzer }
143*04e0dc4aSTimo Kreuzer
144*04e0dc4aSTimo Kreuzer #ifdef __cplusplus
145*04e0dc4aSTimo Kreuzer // The maximum number of characters (including null terminator) of a system
146*04e0dc4aSTimo Kreuzer // error message. Note: This value must correspond to the number of characters
147*04e0dc4aSTimo Kreuzer // in the longest message in the error list.
148*04e0dc4aSTimo Kreuzer size_t const max_system_error_message_count = 38;
149*04e0dc4aSTimo Kreuzer
150*04e0dc4aSTimo Kreuzer // The number of characters in the per-thread strerror buffer. This has room
151*04e0dc4aSTimo Kreuzer // for a 94 character user-provided prefix, a ": " delimiter, and one of the
152*04e0dc4aSTimo Kreuzer // system error messages.
153*04e0dc4aSTimo Kreuzer size_t const strerror_buffer_count = (94 + max_system_error_message_count + 2);
154*04e0dc4aSTimo Kreuzer #endif
155*04e0dc4aSTimo Kreuzer
156*04e0dc4aSTimo Kreuzer
157*04e0dc4aSTimo Kreuzer
158*04e0dc4aSTimo Kreuzer _Success_(return != 0)
159*04e0dc4aSTimo Kreuzer char* __cdecl __acrt_getpath(
160*04e0dc4aSTimo Kreuzer _In_z_ char const* delimited_paths,
161*04e0dc4aSTimo Kreuzer _Out_writes_z_(buffer_count) char* buffer,
162*04e0dc4aSTimo Kreuzer _In_ size_t buffer_count
163*04e0dc4aSTimo Kreuzer );
164*04e0dc4aSTimo Kreuzer
165*04e0dc4aSTimo Kreuzer _Success_(return != 0)
166*04e0dc4aSTimo Kreuzer wchar_t* __cdecl __acrt_wgetpath(
167*04e0dc4aSTimo Kreuzer _In_z_ wchar_t const* delimited_paths,
168*04e0dc4aSTimo Kreuzer _Out_writes_z_(buffer_count) wchar_t* buffer,
169*04e0dc4aSTimo Kreuzer _In_ size_t buffer_count
170*04e0dc4aSTimo Kreuzer );
171*04e0dc4aSTimo Kreuzer
172*04e0dc4aSTimo Kreuzer _Success_(return == 0)
173*04e0dc4aSTimo Kreuzer errno_t __acrt_expand_narrow_argv_wildcards(
174*04e0dc4aSTimo Kreuzer _In_z_ char** argv,
175*04e0dc4aSTimo Kreuzer _Out_ _Deref_post_z_ char*** result
176*04e0dc4aSTimo Kreuzer );
177*04e0dc4aSTimo Kreuzer
178*04e0dc4aSTimo Kreuzer _Success_(return == 0)
179*04e0dc4aSTimo Kreuzer errno_t __acrt_expand_wide_argv_wildcards(
180*04e0dc4aSTimo Kreuzer _In_ wchar_t** argv,
181*04e0dc4aSTimo Kreuzer _Out_ _Deref_post_z_ wchar_t*** result
182*04e0dc4aSTimo Kreuzer );
183*04e0dc4aSTimo Kreuzer
184*04e0dc4aSTimo Kreuzer _Success_(return == 0)
185*04e0dc4aSTimo Kreuzer _Ret_range_(-1, 0)
186*04e0dc4aSTimo Kreuzer int __cdecl __acrt_pack_narrow_command_line_and_environment(
187*04e0dc4aSTimo Kreuzer _In_z_ char const* const* argv,
188*04e0dc4aSTimo Kreuzer _In_opt_z_ char const* const* envp,
189*04e0dc4aSTimo Kreuzer _Outptr_result_maybenull_ char** command_line_result,
190*04e0dc4aSTimo Kreuzer _Outptr_result_maybenull_ char** environment_block_result
191*04e0dc4aSTimo Kreuzer );
192*04e0dc4aSTimo Kreuzer
193*04e0dc4aSTimo Kreuzer _Success_(return == 0)
194*04e0dc4aSTimo Kreuzer _Ret_range_(-1, 0)
195*04e0dc4aSTimo Kreuzer int __cdecl __acrt_pack_wide_command_line_and_environment(
196*04e0dc4aSTimo Kreuzer _In_z_ wchar_t const* const* argv,
197*04e0dc4aSTimo Kreuzer _In_opt_z_ wchar_t const* const* envp,
198*04e0dc4aSTimo Kreuzer _Outptr_result_maybenull_ wchar_t** command_line_result,
199*04e0dc4aSTimo Kreuzer _Outptr_result_maybenull_ wchar_t** environment_block_result
200*04e0dc4aSTimo Kreuzer );
201*04e0dc4aSTimo Kreuzer
202*04e0dc4aSTimo Kreuzer _Ret_z_
203*04e0dc4aSTimo Kreuzer _Success_(return != 0)
204*04e0dc4aSTimo Kreuzer char** __acrt_capture_narrow_argv(
205*04e0dc4aSTimo Kreuzer _In_ va_list* arglist,
206*04e0dc4aSTimo Kreuzer _In_z_ char const* first_argument,
207*04e0dc4aSTimo Kreuzer _When_(return == caller_array, _Post_z_)
208*04e0dc4aSTimo Kreuzer _Out_writes_(caller_array_count) char** caller_array,
209*04e0dc4aSTimo Kreuzer _In_ size_t caller_array_count
210*04e0dc4aSTimo Kreuzer );
211*04e0dc4aSTimo Kreuzer
212*04e0dc4aSTimo Kreuzer _Ret_z_
213*04e0dc4aSTimo Kreuzer _Success_(return != 0)
214*04e0dc4aSTimo Kreuzer wchar_t** __acrt_capture_wide_argv(
215*04e0dc4aSTimo Kreuzer _In_ va_list* arglist,
216*04e0dc4aSTimo Kreuzer _In_z_ wchar_t const* first_argument,
217*04e0dc4aSTimo Kreuzer _When_(return == caller_array, _Post_z_)
218*04e0dc4aSTimo Kreuzer _Out_writes_(caller_array_count) wchar_t** caller_array,
219*04e0dc4aSTimo Kreuzer _In_ size_t caller_array_count
220*04e0dc4aSTimo Kreuzer );
221*04e0dc4aSTimo Kreuzer
222*04e0dc4aSTimo Kreuzer void __cdecl __acrt_call_reportfault(
223*04e0dc4aSTimo Kreuzer int nDbgHookCode,
224*04e0dc4aSTimo Kreuzer DWORD dwExceptionCode,
225*04e0dc4aSTimo Kreuzer DWORD dwExceptionFlags
226*04e0dc4aSTimo Kreuzer );
227*04e0dc4aSTimo Kreuzer
228*04e0dc4aSTimo Kreuzer
229*04e0dc4aSTimo Kreuzer
230*04e0dc4aSTimo Kreuzer #ifndef _M_CEE_PURE
231*04e0dc4aSTimo Kreuzer _DEFINE_SET_FUNCTION(_set_pgmptr, _In_z_ char*, _pgmptr)
232*04e0dc4aSTimo Kreuzer _DEFINE_SET_FUNCTION(_set_wpgmptr, _In_z_ wchar_t*, _wpgmptr)
233*04e0dc4aSTimo Kreuzer #endif
234*04e0dc4aSTimo Kreuzer
235*04e0dc4aSTimo Kreuzer
236*04e0dc4aSTimo Kreuzer
237*04e0dc4aSTimo Kreuzer extern _CRT_ALLOC_HOOK _pfnAllocHook;
238*04e0dc4aSTimo Kreuzer
239*04e0dc4aSTimo Kreuzer BOOL __cdecl __acrt_CreateProcessA(
240*04e0dc4aSTimo Kreuzer _In_opt_ LPCSTR lpApplicationName,
241*04e0dc4aSTimo Kreuzer _Inout_opt_ LPSTR lpCommandLine,
242*04e0dc4aSTimo Kreuzer _In_opt_ LPSECURITY_ATTRIBUTES lpProcessAttributes,
243*04e0dc4aSTimo Kreuzer _In_opt_ LPSECURITY_ATTRIBUTES lpThreadAttributes,
244*04e0dc4aSTimo Kreuzer _In_ BOOL bInheritHandles,
245*04e0dc4aSTimo Kreuzer _In_ DWORD dwCreationFlags,
246*04e0dc4aSTimo Kreuzer _In_opt_ LPVOID lpEnvironment,
247*04e0dc4aSTimo Kreuzer _In_opt_ LPCSTR lpCurrentDirectory,
248*04e0dc4aSTimo Kreuzer _In_ LPSTARTUPINFOW lpStartupInfo,
249*04e0dc4aSTimo Kreuzer _Out_ LPPROCESS_INFORMATION lpProcessInformation
250*04e0dc4aSTimo Kreuzer );
251*04e0dc4aSTimo Kreuzer
252*04e0dc4aSTimo Kreuzer _Success_(return > 0)
253*04e0dc4aSTimo Kreuzer DWORD __cdecl __acrt_GetTempPath2A(
254*04e0dc4aSTimo Kreuzer DWORD nBufferLength,
255*04e0dc4aSTimo Kreuzer _Out_writes_to_(nBufferLength, return + 1) PSTR lpBuffer
256*04e0dc4aSTimo Kreuzer );
257*04e0dc4aSTimo Kreuzer
258*04e0dc4aSTimo Kreuzer DWORD __cdecl __acrt_GetModuleFileNameA(
259*04e0dc4aSTimo Kreuzer _In_opt_ HMODULE hModule,
260*04e0dc4aSTimo Kreuzer _When_(return < nSize, _Out_writes_to_(nSize, return + 1))
261*04e0dc4aSTimo Kreuzer _When_(return == nSize, _Out_writes_all_(nSize) _Null_terminated_) char * lpFilename,
262*04e0dc4aSTimo Kreuzer _In_range_(1, MAX_PATH) DWORD nSize
263*04e0dc4aSTimo Kreuzer );
264*04e0dc4aSTimo Kreuzer
265*04e0dc4aSTimo Kreuzer HMODULE __cdecl __acrt_LoadLibraryExA(
266*04e0dc4aSTimo Kreuzer _In_ LPCSTR lpFileName,
267*04e0dc4aSTimo Kreuzer _Reserved_ HANDLE hFile,
268*04e0dc4aSTimo Kreuzer _In_ DWORD dwFlags
269*04e0dc4aSTimo Kreuzer );
270*04e0dc4aSTimo Kreuzer
271*04e0dc4aSTimo Kreuzer BOOL __cdecl __acrt_SetEnvironmentVariableA(
272*04e0dc4aSTimo Kreuzer _In_ LPCSTR lpName,
273*04e0dc4aSTimo Kreuzer _In_opt_ LPCSTR lpValue
274*04e0dc4aSTimo Kreuzer );
275*04e0dc4aSTimo Kreuzer
276*04e0dc4aSTimo Kreuzer BOOL __cdecl __acrt_SetCurrentDirectoryA(
277*04e0dc4aSTimo Kreuzer _In_ LPCSTR lpPathName
278*04e0dc4aSTimo Kreuzer );
279*04e0dc4aSTimo Kreuzer
280*04e0dc4aSTimo Kreuzer
281*04e0dc4aSTimo Kreuzer // Adding some defines which are used in dbgrpt.c
282*04e0dc4aSTimo Kreuzer #define DBGRPT_MAX_MSG 4096
283*04e0dc4aSTimo Kreuzer #define DBGRPT_TOOLONGMSG "_CrtDbgReport: String too long or IO Error"
284*04e0dc4aSTimo Kreuzer #define DBGRPT_INVALIDMSG "_CrtDbgReport: String too long or Invalid characters in String"
285*04e0dc4aSTimo Kreuzer
286*04e0dc4aSTimo Kreuzer #ifdef __cplusplus
287*04e0dc4aSTimo Kreuzer extern "C++"
288*04e0dc4aSTimo Kreuzer {
289*04e0dc4aSTimo Kreuzer template <typename Character>
290*04e0dc4aSTimo Kreuzer struct __crt_report_hook_node
291*04e0dc4aSTimo Kreuzer {
292*04e0dc4aSTimo Kreuzer using hook_type = int(__CRTDECL*)(int, Character*, int*);
293*04e0dc4aSTimo Kreuzer
294*04e0dc4aSTimo Kreuzer __crt_report_hook_node* prev;
295*04e0dc4aSTimo Kreuzer __crt_report_hook_node* next;
296*04e0dc4aSTimo Kreuzer unsigned refcount;
297*04e0dc4aSTimo Kreuzer hook_type hook;
298*04e0dc4aSTimo Kreuzer };
299*04e0dc4aSTimo Kreuzer }
300*04e0dc4aSTimo Kreuzer #endif
301*04e0dc4aSTimo Kreuzer
302*04e0dc4aSTimo Kreuzer _Success_(return != 0)
303*04e0dc4aSTimo Kreuzer unsigned char* __cdecl __acrt_allocate_buffer_for_argv(
304*04e0dc4aSTimo Kreuzer _In_ size_t argument_count,
305*04e0dc4aSTimo Kreuzer _In_ size_t character_count,
306*04e0dc4aSTimo Kreuzer _In_ size_t character_size
307*04e0dc4aSTimo Kreuzer );
308*04e0dc4aSTimo Kreuzer
309*04e0dc4aSTimo Kreuzer //-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
310*04e0dc4aSTimo Kreuzer //
311*04e0dc4aSTimo Kreuzer // CoreCRT Shared Initialization Support
312*04e0dc4aSTimo Kreuzer //
313*04e0dc4aSTimo Kreuzer //-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
314*04e0dc4aSTimo Kreuzer typedef bool (__cdecl* __acrt_initialize_pft )(void);
315*04e0dc4aSTimo Kreuzer typedef bool (__cdecl* __acrt_uninitialize_pft)(bool);
316*04e0dc4aSTimo Kreuzer
317*04e0dc4aSTimo Kreuzer typedef struct __acrt_initializer
318*04e0dc4aSTimo Kreuzer {
319*04e0dc4aSTimo Kreuzer __acrt_initialize_pft _initialize;
320*04e0dc4aSTimo Kreuzer __acrt_uninitialize_pft _uninitialize;
321*04e0dc4aSTimo Kreuzer } __acrt_initializer;
322*04e0dc4aSTimo Kreuzer
323*04e0dc4aSTimo Kreuzer bool __cdecl __acrt_execute_initializers(
324*04e0dc4aSTimo Kreuzer _In_reads_(last - first) _In_ __acrt_initializer const* first,
325*04e0dc4aSTimo Kreuzer _In_reads_(0) __acrt_initializer const* last
326*04e0dc4aSTimo Kreuzer );
327*04e0dc4aSTimo Kreuzer
328*04e0dc4aSTimo Kreuzer bool __cdecl __acrt_execute_uninitializers(
329*04e0dc4aSTimo Kreuzer _In_reads_(last - first) __acrt_initializer const* first,
330*04e0dc4aSTimo Kreuzer _In_reads_(0) __acrt_initializer const* last
331*04e0dc4aSTimo Kreuzer );
332*04e0dc4aSTimo Kreuzer
333*04e0dc4aSTimo Kreuzer
334*04e0dc4aSTimo Kreuzer
335*04e0dc4aSTimo Kreuzer //-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
336*04e0dc4aSTimo Kreuzer //
337*04e0dc4aSTimo Kreuzer // CoreCRT Fatal Runtime Error Reporting
338*04e0dc4aSTimo Kreuzer //
339*04e0dc4aSTimo Kreuzer //-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
340*04e0dc4aSTimo Kreuzer void __cdecl __acrt_report_runtime_error(_In_z_ wchar_t const* message);
341*04e0dc4aSTimo Kreuzer
342*04e0dc4aSTimo Kreuzer int __cdecl __acrt_show_narrow_message_box(
343*04e0dc4aSTimo Kreuzer _In_opt_z_ char const* text,
344*04e0dc4aSTimo Kreuzer _In_opt_z_ char const* caption,
345*04e0dc4aSTimo Kreuzer _In_ unsigned type
346*04e0dc4aSTimo Kreuzer );
347*04e0dc4aSTimo Kreuzer
348*04e0dc4aSTimo Kreuzer int __cdecl __acrt_show_wide_message_box(
349*04e0dc4aSTimo Kreuzer _In_opt_z_ wchar_t const* text,
350*04e0dc4aSTimo Kreuzer _In_opt_z_ wchar_t const* caption,
351*04e0dc4aSTimo Kreuzer _In_ unsigned type
352*04e0dc4aSTimo Kreuzer );
353*04e0dc4aSTimo Kreuzer
354*04e0dc4aSTimo Kreuzer
355*04e0dc4aSTimo Kreuzer
356*04e0dc4aSTimo Kreuzer //-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
357*04e0dc4aSTimo Kreuzer //
358*04e0dc4aSTimo Kreuzer // AppCRT Initialization
359*04e0dc4aSTimo Kreuzer //
360*04e0dc4aSTimo Kreuzer //-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
361*04e0dc4aSTimo Kreuzer bool __cdecl __acrt_initialize_winapi_thunks(void);
362*04e0dc4aSTimo Kreuzer bool __cdecl __acrt_uninitialize_winapi_thunks(_In_ bool terminating);
363*04e0dc4aSTimo Kreuzer
364*04e0dc4aSTimo Kreuzer bool __cdecl __acrt_initialize_locks(void);
365*04e0dc4aSTimo Kreuzer bool __cdecl __acrt_uninitialize_locks(_In_ bool terminating);
366*04e0dc4aSTimo Kreuzer
367*04e0dc4aSTimo Kreuzer bool __cdecl __acrt_initialize_heap(void);
368*04e0dc4aSTimo Kreuzer bool __cdecl __acrt_uninitialize_heap(_In_ bool terminating);
369*04e0dc4aSTimo Kreuzer
370*04e0dc4aSTimo Kreuzer bool __cdecl __acrt_initialize_ptd(void);
371*04e0dc4aSTimo Kreuzer bool __cdecl __acrt_uninitialize_ptd(_In_ bool terminating);
372*04e0dc4aSTimo Kreuzer
373*04e0dc4aSTimo Kreuzer bool __cdecl __acrt_initialize_lowio(void);
374*04e0dc4aSTimo Kreuzer bool __cdecl __acrt_uninitialize_lowio(_In_ bool terminating);
375*04e0dc4aSTimo Kreuzer
376*04e0dc4aSTimo Kreuzer bool __cdecl __acrt_initialize_command_line(void);
377*04e0dc4aSTimo Kreuzer bool __cdecl __acrt_uninitialize_command_line(_In_ bool terminating);
378*04e0dc4aSTimo Kreuzer
379*04e0dc4aSTimo Kreuzer void __cdecl __acrt_initialize_invalid_parameter_handler(_In_opt_ void* encoded_null);
380*04e0dc4aSTimo Kreuzer void __cdecl __acrt_initialize_new_handler(_In_opt_ void* encoded_null);
381*04e0dc4aSTimo Kreuzer void __cdecl __acrt_initialize_signal_handlers(_In_opt_ void* encoded_null);
382*04e0dc4aSTimo Kreuzer void __cdecl __acrt_initialize_thread_local_exit_callback(_In_opt_ void * encoded_null);
383*04e0dc4aSTimo Kreuzer
384*04e0dc4aSTimo Kreuzer
385*04e0dc4aSTimo Kreuzer
386*04e0dc4aSTimo Kreuzer //-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
387*04e0dc4aSTimo Kreuzer //
388*04e0dc4aSTimo Kreuzer // AppCRT Locale
389*04e0dc4aSTimo Kreuzer //
390*04e0dc4aSTimo Kreuzer //-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
391*04e0dc4aSTimo Kreuzer // The offset to where ctype will point. Look in initctype.cpp for how it is
392*04e0dc4aSTimo Kreuzer // being used. It was introduced so that pctype can work with unsigned char
393*04e0dc4aSTimo Kreuzer // types and EOF. It is used only in initctype and setlocale.
394*04e0dc4aSTimo Kreuzer #define _COFFSET 127
395*04e0dc4aSTimo Kreuzer
396*04e0dc4aSTimo Kreuzer // Maximum lengths for the language name, country name, and full locale name.
397*04e0dc4aSTimo Kreuzer #define MAX_LANG_LEN 64
398*04e0dc4aSTimo Kreuzer #define MAX_CTRY_LEN 64
399*04e0dc4aSTimo Kreuzer #define MAX_LC_LEN (MAX_LANG_LEN + MAX_CTRY_LEN + 3)
400*04e0dc4aSTimo Kreuzer
401*04e0dc4aSTimo Kreuzer #define MAX_CP_LEN 16 // Maximum code page name length
402*04e0dc4aSTimo Kreuzer #define CATNAMES_LEN 57 // "LC_COLLATE=;LC_CTYPE=;..." length
403*04e0dc4aSTimo Kreuzer
404*04e0dc4aSTimo Kreuzer #define LC_INT_TYPE 0
405*04e0dc4aSTimo Kreuzer #define LC_STR_TYPE 1
406*04e0dc4aSTimo Kreuzer #define LC_WSTR_TYPE 2
407*04e0dc4aSTimo Kreuzer
408*04e0dc4aSTimo Kreuzer #define _WSETLOCALE_AVOID_SYNC_LOCALE_BIT 0x10
409*04e0dc4aSTimo Kreuzer #define _PER_THREAD_LOCALE_BIT 0x2
410*04e0dc4aSTimo Kreuzer #define _GLOBAL_LOCALE_BIT 0x1
411*04e0dc4aSTimo Kreuzer
412*04e0dc4aSTimo Kreuzer
413*04e0dc4aSTimo Kreuzer
414*04e0dc4aSTimo Kreuzer typedef struct __crt_locale_string_table
415*04e0dc4aSTimo Kreuzer {
416*04e0dc4aSTimo Kreuzer wchar_t* szName;
417*04e0dc4aSTimo Kreuzer wchar_t chAbbrev[4];
418*04e0dc4aSTimo Kreuzer } __crt_locale_string_table;
419*04e0dc4aSTimo Kreuzer
420*04e0dc4aSTimo Kreuzer typedef struct __crt_locale_strings
421*04e0dc4aSTimo Kreuzer {
422*04e0dc4aSTimo Kreuzer wchar_t szLanguage [MAX_LANG_LEN];
423*04e0dc4aSTimo Kreuzer wchar_t szCountry [MAX_CTRY_LEN];
424*04e0dc4aSTimo Kreuzer wchar_t szCodePage [MAX_CP_LEN];
425*04e0dc4aSTimo Kreuzer wchar_t szLocaleName[LOCALE_NAME_MAX_LENGTH];
426*04e0dc4aSTimo Kreuzer } __crt_locale_strings;
427*04e0dc4aSTimo Kreuzer
428*04e0dc4aSTimo Kreuzer typedef struct __crt_lc_time_data
429*04e0dc4aSTimo Kreuzer {
430*04e0dc4aSTimo Kreuzer char* wday_abbr [ 7];
431*04e0dc4aSTimo Kreuzer char* wday [ 7];
432*04e0dc4aSTimo Kreuzer char* month_abbr[12];
433*04e0dc4aSTimo Kreuzer char* month [12];
434*04e0dc4aSTimo Kreuzer char* ampm [ 2];
435*04e0dc4aSTimo Kreuzer char* ww_sdatefmt;
436*04e0dc4aSTimo Kreuzer char* ww_ldatefmt;
437*04e0dc4aSTimo Kreuzer char* ww_timefmt;
438*04e0dc4aSTimo Kreuzer int ww_caltype;
439*04e0dc4aSTimo Kreuzer long refcount;
440*04e0dc4aSTimo Kreuzer wchar_t* _W_wday_abbr [ 7];
441*04e0dc4aSTimo Kreuzer wchar_t* _W_wday [ 7];
442*04e0dc4aSTimo Kreuzer wchar_t* _W_month_abbr[12];
443*04e0dc4aSTimo Kreuzer wchar_t* _W_month [12];
444*04e0dc4aSTimo Kreuzer wchar_t* _W_ampm [ 2];
445*04e0dc4aSTimo Kreuzer wchar_t* _W_ww_sdatefmt;
446*04e0dc4aSTimo Kreuzer wchar_t* _W_ww_ldatefmt;
447*04e0dc4aSTimo Kreuzer wchar_t* _W_ww_timefmt;
448*04e0dc4aSTimo Kreuzer wchar_t* _W_ww_locale_name;
449*04e0dc4aSTimo Kreuzer } __crt_lc_time_data;
450*04e0dc4aSTimo Kreuzer
451*04e0dc4aSTimo Kreuzer typedef struct __crt_ctype_compatibility_data
452*04e0dc4aSTimo Kreuzer {
453*04e0dc4aSTimo Kreuzer unsigned long id;
454*04e0dc4aSTimo Kreuzer int is_clike;
455*04e0dc4aSTimo Kreuzer } __crt_ctype_compatibility_data;
456*04e0dc4aSTimo Kreuzer
457*04e0dc4aSTimo Kreuzer typedef struct __crt_qualified_locale_data
458*04e0dc4aSTimo Kreuzer {
459*04e0dc4aSTimo Kreuzer // Static data for qualified locale code
460*04e0dc4aSTimo Kreuzer wchar_t const* pchLanguage;
461*04e0dc4aSTimo Kreuzer wchar_t const* pchCountry;
462*04e0dc4aSTimo Kreuzer int iLocState;
463*04e0dc4aSTimo Kreuzer int iPrimaryLen;
464*04e0dc4aSTimo Kreuzer BOOL bAbbrevLanguage;
465*04e0dc4aSTimo Kreuzer BOOL bAbbrevCountry;
466*04e0dc4aSTimo Kreuzer UINT _cachecp;
467*04e0dc4aSTimo Kreuzer wchar_t _cachein [MAX_LC_LEN];
468*04e0dc4aSTimo Kreuzer wchar_t _cacheout[MAX_LC_LEN];
469*04e0dc4aSTimo Kreuzer
470*04e0dc4aSTimo Kreuzer // Static data for LC_CTYPE
471*04e0dc4aSTimo Kreuzer __crt_ctype_compatibility_data _Loc_c[5];
472*04e0dc4aSTimo Kreuzer wchar_t _cacheLocaleName[LOCALE_NAME_MAX_LENGTH];
473*04e0dc4aSTimo Kreuzer } __crt_qualified_locale_data;
474*04e0dc4aSTimo Kreuzer
475*04e0dc4aSTimo Kreuzer typedef struct __crt_qualified_locale_data_downlevel
476*04e0dc4aSTimo Kreuzer {
477*04e0dc4aSTimo Kreuzer // Static data for the downlevel qualified locale code
478*04e0dc4aSTimo Kreuzer int iLcidState;
479*04e0dc4aSTimo Kreuzer LCID lcidLanguage;
480*04e0dc4aSTimo Kreuzer LCID lcidCountry;
481*04e0dc4aSTimo Kreuzer } __crt_qualified_locale_data_downlevel;
482*04e0dc4aSTimo Kreuzer
483*04e0dc4aSTimo Kreuzer typedef struct __crt_multibyte_data
484*04e0dc4aSTimo Kreuzer {
485*04e0dc4aSTimo Kreuzer long refcount;
486*04e0dc4aSTimo Kreuzer int mbcodepage;
487*04e0dc4aSTimo Kreuzer int ismbcodepage;
488*04e0dc4aSTimo Kreuzer unsigned short mbulinfo[6];
489*04e0dc4aSTimo Kreuzer unsigned char mbctype[257];
490*04e0dc4aSTimo Kreuzer unsigned char mbcasemap[256];
491*04e0dc4aSTimo Kreuzer wchar_t const* mblocalename;
492*04e0dc4aSTimo Kreuzer } __crt_multibyte_data;
493*04e0dc4aSTimo Kreuzer
494*04e0dc4aSTimo Kreuzer typedef struct __crt_locale_refcount
495*04e0dc4aSTimo Kreuzer {
496*04e0dc4aSTimo Kreuzer char* locale;
497*04e0dc4aSTimo Kreuzer wchar_t* wlocale;
498*04e0dc4aSTimo Kreuzer long* refcount;
499*04e0dc4aSTimo Kreuzer long* wrefcount;
500*04e0dc4aSTimo Kreuzer } __crt_locale_refcount;
501*04e0dc4aSTimo Kreuzer
502*04e0dc4aSTimo Kreuzer typedef struct __crt_locale_data
503*04e0dc4aSTimo Kreuzer {
504*04e0dc4aSTimo Kreuzer __crt_locale_data_public _public;
505*04e0dc4aSTimo Kreuzer long refcount;
506*04e0dc4aSTimo Kreuzer unsigned int lc_collate_cp;
507*04e0dc4aSTimo Kreuzer unsigned int lc_time_cp;
508*04e0dc4aSTimo Kreuzer int lc_clike;
509*04e0dc4aSTimo Kreuzer __crt_locale_refcount lc_category[6];
510*04e0dc4aSTimo Kreuzer long* lconv_intl_refcount;
511*04e0dc4aSTimo Kreuzer long* lconv_num_refcount;
512*04e0dc4aSTimo Kreuzer long* lconv_mon_refcount;
513*04e0dc4aSTimo Kreuzer struct lconv* lconv;
514*04e0dc4aSTimo Kreuzer long* ctype1_refcount;
515*04e0dc4aSTimo Kreuzer unsigned short* ctype1;
516*04e0dc4aSTimo Kreuzer unsigned char const* pclmap;
517*04e0dc4aSTimo Kreuzer unsigned char const* pcumap;
518*04e0dc4aSTimo Kreuzer __crt_lc_time_data const* lc_time_curr;
519*04e0dc4aSTimo Kreuzer wchar_t* locale_name[6];
520*04e0dc4aSTimo Kreuzer } __crt_locale_data;
521*04e0dc4aSTimo Kreuzer
522*04e0dc4aSTimo Kreuzer // Unusual: < 0 => string length
523*04e0dc4aSTimo Kreuzer // else scan up to specified size or string length, whichever comes first
524*04e0dc4aSTimo Kreuzer // The name is based on _In_NLS_string_.
525*04e0dc4aSTimo Kreuzer #define _In_CRT_NLS_string_(size) _When_((size) < 0, _In_z_) \
526*04e0dc4aSTimo Kreuzer _When_((size) >= _String_length_(_Curr_), _Pre_z_) \
527*04e0dc4aSTimo Kreuzer _When_((size) < _String_length_(_Curr_), _In_reads_(size))
528*04e0dc4aSTimo Kreuzer
529*04e0dc4aSTimo Kreuzer // Wrappers for locale-related Windows API functionality
530*04e0dc4aSTimo Kreuzer int __cdecl __acrt_CompareStringA(
531*04e0dc4aSTimo Kreuzer _In_opt_ _locale_t _Plocinfo,
532*04e0dc4aSTimo Kreuzer _In_ LPCWSTR _LocaleName,
533*04e0dc4aSTimo Kreuzer _In_ DWORD _DwCmpFlags,
534*04e0dc4aSTimo Kreuzer _In_CRT_NLS_string_(_CchCount1) PCCH _LpString1,
535*04e0dc4aSTimo Kreuzer _In_ int _CchCount1,
536*04e0dc4aSTimo Kreuzer _In_CRT_NLS_string_(_CchCount2) PCCH _LpString2,
537*04e0dc4aSTimo Kreuzer _In_ int _CchCount2,
538*04e0dc4aSTimo Kreuzer _In_ int _CodePage
539*04e0dc4aSTimo Kreuzer );
540*04e0dc4aSTimo Kreuzer
541*04e0dc4aSTimo Kreuzer int __cdecl __acrt_CompareStringW(
542*04e0dc4aSTimo Kreuzer _In_ LPCWSTR _LocaleName,
543*04e0dc4aSTimo Kreuzer _In_ DWORD _DwCmpFlags,
544*04e0dc4aSTimo Kreuzer _In_CRT_NLS_string_(_CchCount1) PCWCH _LpString1,
545*04e0dc4aSTimo Kreuzer _In_ int _CchCount1,
546*04e0dc4aSTimo Kreuzer _In_CRT_NLS_string_(_CchCount2) PCWCH _LpString2,
547*04e0dc4aSTimo Kreuzer _In_ int _CchCount2
548*04e0dc4aSTimo Kreuzer );
549*04e0dc4aSTimo Kreuzer
550*04e0dc4aSTimo Kreuzer int __cdecl __acrt_GetLocaleInfoA(
551*04e0dc4aSTimo Kreuzer _In_opt_ _locale_t _Locale,
552*04e0dc4aSTimo Kreuzer _In_ int _LCType,
553*04e0dc4aSTimo Kreuzer _In_ LPCWSTR _LocaleName,
554*04e0dc4aSTimo Kreuzer _In_ LCTYPE _FieldType,
555*04e0dc4aSTimo Kreuzer _Out_ void* _Address
556*04e0dc4aSTimo Kreuzer );
557*04e0dc4aSTimo Kreuzer
558*04e0dc4aSTimo Kreuzer _Success_(return)
559*04e0dc4aSTimo Kreuzer BOOL __cdecl __acrt_GetStringTypeA(
560*04e0dc4aSTimo Kreuzer _In_opt_ _locale_t _Plocinfo,
561*04e0dc4aSTimo Kreuzer _In_ DWORD _DWInfoType,
562*04e0dc4aSTimo Kreuzer _In_NLS_string_(_CchSrc) PCCH _LpSrcStr,
563*04e0dc4aSTimo Kreuzer _In_ int _CchSrc,
564*04e0dc4aSTimo Kreuzer _Out_ LPWORD _LpCharType,
565*04e0dc4aSTimo Kreuzer _In_ int _CodePage,
566*04e0dc4aSTimo Kreuzer _In_ BOOL _BError
567*04e0dc4aSTimo Kreuzer );
568*04e0dc4aSTimo Kreuzer
569*04e0dc4aSTimo Kreuzer _Success_(return)
570*04e0dc4aSTimo Kreuzer BOOL __cdecl __acrt_GetStringTypeW(
571*04e0dc4aSTimo Kreuzer _In_ DWORD _DWInfoType,
572*04e0dc4aSTimo Kreuzer _In_NLS_string_(_CchSrc) PCWCH _LpSrcStr,
573*04e0dc4aSTimo Kreuzer _In_ int _CchSrc,
574*04e0dc4aSTimo Kreuzer _Out_ LPWORD _LpCharType
575*04e0dc4aSTimo Kreuzer );
576*04e0dc4aSTimo Kreuzer
577*04e0dc4aSTimo Kreuzer _Success_(return != 0)
578*04e0dc4aSTimo Kreuzer int __cdecl __acrt_LCMapStringA(
579*04e0dc4aSTimo Kreuzer _In_opt_ _locale_t _Plocinfo,
580*04e0dc4aSTimo Kreuzer _In_ LPCWSTR _LocaleName,
581*04e0dc4aSTimo Kreuzer _In_ DWORD _DwMapFlag,
582*04e0dc4aSTimo Kreuzer _In_CRT_NLS_string_(_CchSrc) PCCH _LpSrcStr,
583*04e0dc4aSTimo Kreuzer _In_ int _CchSrc,
584*04e0dc4aSTimo Kreuzer _Out_writes_opt_(_CchDest) PCH _LpDestStr,
585*04e0dc4aSTimo Kreuzer _In_ int _CchDest,
586*04e0dc4aSTimo Kreuzer _In_ int _CodePage,
587*04e0dc4aSTimo Kreuzer _In_ BOOL _BError
588*04e0dc4aSTimo Kreuzer );
589*04e0dc4aSTimo Kreuzer
590*04e0dc4aSTimo Kreuzer _Success_(return != 0)
591*04e0dc4aSTimo Kreuzer int __cdecl __acrt_LCMapStringW(
592*04e0dc4aSTimo Kreuzer _In_ LPCWSTR _LocaleName,
593*04e0dc4aSTimo Kreuzer _In_ DWORD _DWMapFlag,
594*04e0dc4aSTimo Kreuzer _In_CRT_NLS_string_(_CchSrc) PCWCH _LpSrcStr,
595*04e0dc4aSTimo Kreuzer _In_ int _CchSrc,
596*04e0dc4aSTimo Kreuzer _Out_writes_opt_(_CchDest) PWCH _LpDestStr,
597*04e0dc4aSTimo Kreuzer _In_ int _CchDest
598*04e0dc4aSTimo Kreuzer );
599*04e0dc4aSTimo Kreuzer
600*04e0dc4aSTimo Kreuzer _Success_(return != 0)
601*04e0dc4aSTimo Kreuzer int __cdecl __acrt_MultiByteToWideChar(
602*04e0dc4aSTimo Kreuzer _In_ UINT _CodePage,
603*04e0dc4aSTimo Kreuzer _In_ DWORD _DWFlags,
604*04e0dc4aSTimo Kreuzer _In_ LPCSTR _LpMultiByteStr,
605*04e0dc4aSTimo Kreuzer _In_ int _CbMultiByte,
606*04e0dc4aSTimo Kreuzer _Out_writes_opt_(_CchWideChar) LPWSTR _LpWideCharStr,
607*04e0dc4aSTimo Kreuzer _In_ int _CchWideChar
608*04e0dc4aSTimo Kreuzer );
609*04e0dc4aSTimo Kreuzer
610*04e0dc4aSTimo Kreuzer _Success_(return != 0)
611*04e0dc4aSTimo Kreuzer int __cdecl __acrt_WideCharToMultiByte(
612*04e0dc4aSTimo Kreuzer _In_ UINT _CodePage,
613*04e0dc4aSTimo Kreuzer _In_ DWORD _DWFlags,
614*04e0dc4aSTimo Kreuzer _In_ LPCWSTR _LpWideCharStr,
615*04e0dc4aSTimo Kreuzer _In_ int _CchWideChar,
616*04e0dc4aSTimo Kreuzer _Out_writes_opt_(_CbMultiByte) LPSTR _LpMultiByteStr,
617*04e0dc4aSTimo Kreuzer _In_ int _CbMultiByte,
618*04e0dc4aSTimo Kreuzer _In_opt_ LPCSTR _LpDefaultChar,
619*04e0dc4aSTimo Kreuzer _Out_opt_ LPBOOL _LpUsedDefaultChar
620*04e0dc4aSTimo Kreuzer );
621*04e0dc4aSTimo Kreuzer
622*04e0dc4aSTimo Kreuzer // Case-insensitive ASCII comparisons
623*04e0dc4aSTimo Kreuzer _Check_return_
624*04e0dc4aSTimo Kreuzer int __cdecl __ascii_memicmp(
625*04e0dc4aSTimo Kreuzer _In_reads_bytes_(count) void const * lhs,
626*04e0dc4aSTimo Kreuzer _In_reads_bytes_(count) void const * rhs,
627*04e0dc4aSTimo Kreuzer _In_ size_t count
628*04e0dc4aSTimo Kreuzer );
629*04e0dc4aSTimo Kreuzer
630*04e0dc4aSTimo Kreuzer _Check_return_
631*04e0dc4aSTimo Kreuzer int __cdecl __ascii_stricmp(
632*04e0dc4aSTimo Kreuzer _In_z_ char const * lhs,
633*04e0dc4aSTimo Kreuzer _In_z_ char const * rhs
634*04e0dc4aSTimo Kreuzer );
635*04e0dc4aSTimo Kreuzer
636*04e0dc4aSTimo Kreuzer _Check_return_
637*04e0dc4aSTimo Kreuzer int __cdecl __ascii_strnicmp(
638*04e0dc4aSTimo Kreuzer _In_reads_or_z_(count) char const * lhs,
639*04e0dc4aSTimo Kreuzer _In_reads_or_z_(count) char const * rhs,
640*04e0dc4aSTimo Kreuzer _In_ size_t count
641*04e0dc4aSTimo Kreuzer );
642*04e0dc4aSTimo Kreuzer
643*04e0dc4aSTimo Kreuzer _Check_return_
644*04e0dc4aSTimo Kreuzer int __cdecl __ascii_wcsicmp(
645*04e0dc4aSTimo Kreuzer _In_z_ const wchar_t * lhs,
646*04e0dc4aSTimo Kreuzer _In_z_ const wchar_t * rhs
647*04e0dc4aSTimo Kreuzer );
648*04e0dc4aSTimo Kreuzer
649*04e0dc4aSTimo Kreuzer _Check_return_
650*04e0dc4aSTimo Kreuzer int __cdecl __ascii_wcsnicmp(
651*04e0dc4aSTimo Kreuzer _In_reads_or_z_(count) const wchar_t * lhs,
652*04e0dc4aSTimo Kreuzer _In_reads_or_z_(count) const wchar_t * rhs,
653*04e0dc4aSTimo Kreuzer _In_ size_t count
654*04e0dc4aSTimo Kreuzer );
655*04e0dc4aSTimo Kreuzer
656*04e0dc4aSTimo Kreuzer
657*04e0dc4aSTimo Kreuzer // Locale reference counting
658*04e0dc4aSTimo Kreuzer void __cdecl __acrt_add_locale_ref (__crt_locale_data*);
659*04e0dc4aSTimo Kreuzer void __cdecl __acrt_release_locale_ref(__crt_locale_data*);
660*04e0dc4aSTimo Kreuzer void __cdecl __acrt_free_locale (__crt_locale_data*);
661*04e0dc4aSTimo Kreuzer
662*04e0dc4aSTimo Kreuzer long __cdecl __acrt_locale_add_lc_time_reference(
663*04e0dc4aSTimo Kreuzer _In_opt_ __crt_lc_time_data const* lc_time
664*04e0dc4aSTimo Kreuzer );
665*04e0dc4aSTimo Kreuzer
666*04e0dc4aSTimo Kreuzer long __cdecl __acrt_locale_release_lc_time_reference(
667*04e0dc4aSTimo Kreuzer _In_opt_ __crt_lc_time_data const* lc_time
668*04e0dc4aSTimo Kreuzer );
669*04e0dc4aSTimo Kreuzer
670*04e0dc4aSTimo Kreuzer void __cdecl __acrt_locale_free_lc_time_if_unreferenced(
671*04e0dc4aSTimo Kreuzer _In_opt_ __crt_lc_time_data const* lc_time
672*04e0dc4aSTimo Kreuzer );
673*04e0dc4aSTimo Kreuzer
674*04e0dc4aSTimo Kreuzer // Initialization and cleanup functions for locale categories
675*04e0dc4aSTimo Kreuzer _Success_(return == 0)
676*04e0dc4aSTimo Kreuzer int __cdecl __acrt_locale_initialize_ctype(
677*04e0dc4aSTimo Kreuzer _Inout_ __crt_locale_data* locale_data
678*04e0dc4aSTimo Kreuzer );
679*04e0dc4aSTimo Kreuzer
680*04e0dc4aSTimo Kreuzer _Success_(return == 0)
681*04e0dc4aSTimo Kreuzer int __cdecl __acrt_locale_initialize_monetary(
682*04e0dc4aSTimo Kreuzer _Inout_ __crt_locale_data* locale_data
683*04e0dc4aSTimo Kreuzer );
684*04e0dc4aSTimo Kreuzer
685*04e0dc4aSTimo Kreuzer _Success_(return == 0)
686*04e0dc4aSTimo Kreuzer int __cdecl __acrt_locale_initialize_numeric(
687*04e0dc4aSTimo Kreuzer _Inout_ __crt_locale_data* locale_data
688*04e0dc4aSTimo Kreuzer );
689*04e0dc4aSTimo Kreuzer
690*04e0dc4aSTimo Kreuzer _Success_(return == 0)
691*04e0dc4aSTimo Kreuzer int __cdecl __acrt_locale_initialize_time(
692*04e0dc4aSTimo Kreuzer _Inout_ __crt_locale_data* locale_data
693*04e0dc4aSTimo Kreuzer );
694*04e0dc4aSTimo Kreuzer
695*04e0dc4aSTimo Kreuzer void __cdecl __acrt_locale_free_monetary(
696*04e0dc4aSTimo Kreuzer _Inout_ struct lconv* lconv
697*04e0dc4aSTimo Kreuzer );
698*04e0dc4aSTimo Kreuzer
699*04e0dc4aSTimo Kreuzer void __cdecl __acrt_locale_free_numeric(
700*04e0dc4aSTimo Kreuzer _Inout_ struct lconv* lconv
701*04e0dc4aSTimo Kreuzer );
702*04e0dc4aSTimo Kreuzer
703*04e0dc4aSTimo Kreuzer void __cdecl __acrt_locale_free_time(
704*04e0dc4aSTimo Kreuzer _Inout_opt_ __crt_lc_time_data* lc_time_data
705*04e0dc4aSTimo Kreuzer );
706*04e0dc4aSTimo Kreuzer
707*04e0dc4aSTimo Kreuzer
708*04e0dc4aSTimo Kreuzer
709*04e0dc4aSTimo Kreuzer // Locale synchronization
710*04e0dc4aSTimo Kreuzer __crt_locale_data* __cdecl __acrt_update_thread_locale_data (void);
711*04e0dc4aSTimo Kreuzer __crt_multibyte_data* __cdecl __acrt_update_thread_multibyte_data(void);
712*04e0dc4aSTimo Kreuzer
713*04e0dc4aSTimo Kreuzer
714*04e0dc4aSTimo Kreuzer
715*04e0dc4aSTimo Kreuzer _Success_(return != 0)
716*04e0dc4aSTimo Kreuzer _Ret_z_
717*04e0dc4aSTimo Kreuzer _Check_return_
718*04e0dc4aSTimo Kreuzer wchar_t* __cdecl __acrt_copy_locale_name(
719*04e0dc4aSTimo Kreuzer _In_z_ wchar_t const* locale_name
720*04e0dc4aSTimo Kreuzer );
721*04e0dc4aSTimo Kreuzer
722*04e0dc4aSTimo Kreuzer _Success_(return != 0)
723*04e0dc4aSTimo Kreuzer BOOL __cdecl __acrt_get_qualified_locale(
724*04e0dc4aSTimo Kreuzer _In_ __crt_locale_strings const* input_strings,
725*04e0dc4aSTimo Kreuzer _Out_opt_ UINT* code_page,
726*04e0dc4aSTimo Kreuzer _Out_opt_ __crt_locale_strings* result_strings
727*04e0dc4aSTimo Kreuzer );
728*04e0dc4aSTimo Kreuzer
729*04e0dc4aSTimo Kreuzer _Success_(return != 0)
730*04e0dc4aSTimo Kreuzer BOOL __cdecl __acrt_get_qualified_locale_downlevel(
731*04e0dc4aSTimo Kreuzer _In_ __crt_locale_strings const* input_strings,
732*04e0dc4aSTimo Kreuzer _Out_opt_ UINT* code_page,
733*04e0dc4aSTimo Kreuzer _Out_opt_ __crt_locale_strings* result_strings
734*04e0dc4aSTimo Kreuzer );
735*04e0dc4aSTimo Kreuzer
736*04e0dc4aSTimo Kreuzer
737*04e0dc4aSTimo Kreuzer // Global variable that is nonzero if the locale has been changed on any thread.
738*04e0dc4aSTimo Kreuzer // Do not touch this global variable; call __acrt_locale_changed instead.
739*04e0dc4aSTimo Kreuzer extern long __acrt_locale_changed_data;
740*04e0dc4aSTimo Kreuzer
741*04e0dc4aSTimo Kreuzer #ifdef __cplusplus
742*04e0dc4aSTimo Kreuzer
743*04e0dc4aSTimo Kreuzer // Returns true if the locale has been changed on any thread.
__acrt_locale_changed()744*04e0dc4aSTimo Kreuzer __inline bool __cdecl __acrt_locale_changed()
745*04e0dc4aSTimo Kreuzer {
746*04e0dc4aSTimo Kreuzer // No need for __crt_interlocked_read, since __acrt_locale_changed_data
747*04e0dc4aSTimo Kreuzer // is a 4 byte natural aligned memory, guaranteed to be atomic
748*04e0dc4aSTimo Kreuzer // accessed on all platforms.
749*04e0dc4aSTimo Kreuzer return __acrt_locale_changed_data != FALSE;
750*04e0dc4aSTimo Kreuzer }
751*04e0dc4aSTimo Kreuzer
752*04e0dc4aSTimo Kreuzer #endif
753*04e0dc4aSTimo Kreuzer
754*04e0dc4aSTimo Kreuzer void __cdecl __acrt_set_locale_changed(void);
755*04e0dc4aSTimo Kreuzer
756*04e0dc4aSTimo Kreuzer
757*04e0dc4aSTimo Kreuzer // Non-NLS language and country/region string tables:
758*04e0dc4aSTimo Kreuzer extern __crt_locale_string_table const __acrt_rg_language[];
759*04e0dc4aSTimo Kreuzer extern size_t const __acrt_rg_language_count;
760*04e0dc4aSTimo Kreuzer
761*04e0dc4aSTimo Kreuzer extern __crt_locale_string_table const __acrt_rg_country[];
762*04e0dc4aSTimo Kreuzer extern size_t const __acrt_rg_country_count;
763*04e0dc4aSTimo Kreuzer
764*04e0dc4aSTimo Kreuzer // The lconv and LC TIME structures for the C locale:
765*04e0dc4aSTimo Kreuzer extern struct lconv __acrt_lconv_c;
766*04e0dc4aSTimo Kreuzer extern __crt_lc_time_data const __lc_time_c;
767*04e0dc4aSTimo Kreuzer
768*04e0dc4aSTimo Kreuzer // The initial and current locale states:
769*04e0dc4aSTimo Kreuzer extern __crt_multibyte_data __acrt_initial_multibyte_data;
770*04e0dc4aSTimo Kreuzer extern __crt_locale_data __acrt_initial_locale_data;
771*04e0dc4aSTimo Kreuzer extern __crt_locale_pointers __acrt_initial_locale_pointers;
772*04e0dc4aSTimo Kreuzer
773*04e0dc4aSTimo Kreuzer #ifdef __cplusplus
774*04e0dc4aSTimo Kreuzer
775*04e0dc4aSTimo Kreuzer extern __crt_state_management::dual_state_global<
776*04e0dc4aSTimo Kreuzer __crt_locale_data*
777*04e0dc4aSTimo Kreuzer > __acrt_current_locale_data;
778*04e0dc4aSTimo Kreuzer
779*04e0dc4aSTimo Kreuzer extern __crt_state_management::dual_state_global<
780*04e0dc4aSTimo Kreuzer __crt_multibyte_data*
781*04e0dc4aSTimo Kreuzer > __acrt_current_multibyte_data;
782*04e0dc4aSTimo Kreuzer
783*04e0dc4aSTimo Kreuzer #endif
784*04e0dc4aSTimo Kreuzer
785*04e0dc4aSTimo Kreuzer
786*04e0dc4aSTimo Kreuzer // The current lconv structure:
787*04e0dc4aSTimo Kreuzer extern struct lconv* __acrt_lconv;
788*04e0dc4aSTimo Kreuzer
789*04e0dc4aSTimo Kreuzer // Character tables:
790*04e0dc4aSTimo Kreuzer extern unsigned short const __newctype[];
791*04e0dc4aSTimo Kreuzer extern unsigned char const __newclmap[];
792*04e0dc4aSTimo Kreuzer extern unsigned char const __newcumap[];
793*04e0dc4aSTimo Kreuzer
794*04e0dc4aSTimo Kreuzer // The name of the C locale, as a wide string ("C")
795*04e0dc4aSTimo Kreuzer extern wchar_t __acrt_wide_c_locale_string[];
796*04e0dc4aSTimo Kreuzer
797*04e0dc4aSTimo Kreuzer
798*04e0dc4aSTimo Kreuzer
799*04e0dc4aSTimo Kreuzer // The global locale status, to support the threadlocale.obj link option
800*04e0dc4aSTimo Kreuzer extern int __globallocalestatus;
801*04e0dc4aSTimo Kreuzer
802*04e0dc4aSTimo Kreuzer
803*04e0dc4aSTimo Kreuzer
804*04e0dc4aSTimo Kreuzer bool __cdecl __acrt_initialize_multibyte(void);
805*04e0dc4aSTimo Kreuzer
806*04e0dc4aSTimo Kreuzer
807*04e0dc4aSTimo Kreuzer
__acrt_isleadbyte_l_noupdate(_In_ int const c,_In_ _locale_t const locale)808*04e0dc4aSTimo Kreuzer __inline int __CRTDECL __acrt_isleadbyte_l_noupdate(
809*04e0dc4aSTimo Kreuzer _In_ int const c,
810*04e0dc4aSTimo Kreuzer _In_ _locale_t const locale
811*04e0dc4aSTimo Kreuzer )
812*04e0dc4aSTimo Kreuzer {
813*04e0dc4aSTimo Kreuzer return __acrt_locale_get_ctype_array_value(locale->locinfo->_public._locale_pctype, c, _LEADBYTE);
814*04e0dc4aSTimo Kreuzer }
815*04e0dc4aSTimo Kreuzer
816*04e0dc4aSTimo Kreuzer
817*04e0dc4aSTimo Kreuzer
818*04e0dc4aSTimo Kreuzer //-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
819*04e0dc4aSTimo Kreuzer //
820*04e0dc4aSTimo Kreuzer // AppCRT Math
821*04e0dc4aSTimo Kreuzer //
822*04e0dc4aSTimo Kreuzer //-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
823*04e0dc4aSTimo Kreuzer void __cdecl __acrt_initialize_user_matherr(void* encoded_null);
824*04e0dc4aSTimo Kreuzer bool __cdecl __acrt_has_user_matherr(void);
825*04e0dc4aSTimo Kreuzer int __cdecl __acrt_invoke_user_matherr(struct _exception*);
826*04e0dc4aSTimo Kreuzer
827*04e0dc4aSTimo Kreuzer
828*04e0dc4aSTimo Kreuzer
829*04e0dc4aSTimo Kreuzer //-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
830*04e0dc4aSTimo Kreuzer //
831*04e0dc4aSTimo Kreuzer // AppCRT Threading
832*04e0dc4aSTimo Kreuzer //
833*04e0dc4aSTimo Kreuzer //-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
834*04e0dc4aSTimo Kreuzer typedef struct __acrt_thread_parameter
835*04e0dc4aSTimo Kreuzer {
836*04e0dc4aSTimo Kreuzer // The thread procedure and context argument
837*04e0dc4aSTimo Kreuzer void* _procedure;
838*04e0dc4aSTimo Kreuzer void* _context;
839*04e0dc4aSTimo Kreuzer
840*04e0dc4aSTimo Kreuzer // The handle for the newly created thread. This is initialized only from
841*04e0dc4aSTimo Kreuzer // _beginthread (not _beginthreadex). When a thread created via _beginthread
842*04e0dc4aSTimo Kreuzer // exits, it frees this handle.
843*04e0dc4aSTimo Kreuzer HANDLE _thread_handle;
844*04e0dc4aSTimo Kreuzer
845*04e0dc4aSTimo Kreuzer // The handle for the module in which the user's thread procedure is defined.
846*04e0dc4aSTimo Kreuzer // This may be null if the handle could not be obtained. This handle enables
847*04e0dc4aSTimo Kreuzer // us to bump the reference count of the user's module, to ensure that the
848*04e0dc4aSTimo Kreuzer // module will not be unloaded while the thread is executing. When the thread
849*04e0dc4aSTimo Kreuzer // exits, it frees this handle.
850*04e0dc4aSTimo Kreuzer HMODULE _module_handle;
851*04e0dc4aSTimo Kreuzer
852*04e0dc4aSTimo Kreuzer // This flag is true if RoInitialized was called on the thread to initialize
853*04e0dc4aSTimo Kreuzer // it into the MTA.
854*04e0dc4aSTimo Kreuzer bool _initialized_apartment;
855*04e0dc4aSTimo Kreuzer } __acrt_thread_parameter;
856*04e0dc4aSTimo Kreuzer
857*04e0dc4aSTimo Kreuzer
858*04e0dc4aSTimo Kreuzer
859*04e0dc4aSTimo Kreuzer //-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
860*04e0dc4aSTimo Kreuzer //
861*04e0dc4aSTimo Kreuzer // AppCRT Per-Thread Data
862*04e0dc4aSTimo Kreuzer //
863*04e0dc4aSTimo Kreuzer //-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
864*04e0dc4aSTimo Kreuzer typedef struct __acrt_ptd
865*04e0dc4aSTimo Kreuzer {
866*04e0dc4aSTimo Kreuzer // These three data members support signal handling and runtime errors
867*04e0dc4aSTimo Kreuzer struct __crt_signal_action_t* _pxcptacttab; // Pointer to the exception-action table
868*04e0dc4aSTimo Kreuzer EXCEPTION_POINTERS* _tpxcptinfoptrs; // Pointer to the exception info pointers
869*04e0dc4aSTimo Kreuzer int _tfpecode; // Last floating point exception code
870*04e0dc4aSTimo Kreuzer
871*04e0dc4aSTimo Kreuzer terminate_handler _terminate; // terminate() routine
872*04e0dc4aSTimo Kreuzer
873*04e0dc4aSTimo Kreuzer int _terrno; // errno value
874*04e0dc4aSTimo Kreuzer unsigned long _tdoserrno; // _doserrno value
875*04e0dc4aSTimo Kreuzer
876*04e0dc4aSTimo Kreuzer unsigned int _rand_state; // Previous value of rand()
877*04e0dc4aSTimo Kreuzer
878*04e0dc4aSTimo Kreuzer // Per-thread strtok(), wcstok(), and mbstok() data:
879*04e0dc4aSTimo Kreuzer char* _strtok_token;
880*04e0dc4aSTimo Kreuzer unsigned char* _mbstok_token;
881*04e0dc4aSTimo Kreuzer wchar_t* _wcstok_token;
882*04e0dc4aSTimo Kreuzer
883*04e0dc4aSTimo Kreuzer // Per-thread tmpnam() data:
884*04e0dc4aSTimo Kreuzer char* _tmpnam_narrow_buffer;
885*04e0dc4aSTimo Kreuzer wchar_t* _tmpnam_wide_buffer;
886*04e0dc4aSTimo Kreuzer
887*04e0dc4aSTimo Kreuzer // Per-thread time library data:
888*04e0dc4aSTimo Kreuzer char* _asctime_buffer; // Pointer to asctime() buffer
889*04e0dc4aSTimo Kreuzer wchar_t* _wasctime_buffer; // Pointer to _wasctime() buffer
890*04e0dc4aSTimo Kreuzer struct tm* _gmtime_buffer; // Pointer to gmtime() structure
891*04e0dc4aSTimo Kreuzer
892*04e0dc4aSTimo Kreuzer char* _cvtbuf; // Pointer to the buffer used by ecvt() and fcvt().
893*04e0dc4aSTimo Kreuzer
894*04e0dc4aSTimo Kreuzer // Per-thread error message data:
895*04e0dc4aSTimo Kreuzer char* _strerror_buffer; // Pointer to strerror() / _strerror() buffer
896*04e0dc4aSTimo Kreuzer wchar_t* _wcserror_buffer; // Pointer to _wcserror() / __wcserror() buffer
897*04e0dc4aSTimo Kreuzer
898*04e0dc4aSTimo Kreuzer // Locale data:
899*04e0dc4aSTimo Kreuzer __crt_multibyte_data* _multibyte_info;
900*04e0dc4aSTimo Kreuzer __crt_locale_data* _locale_info;
901*04e0dc4aSTimo Kreuzer __crt_qualified_locale_data _setloc_data;
902*04e0dc4aSTimo Kreuzer __crt_qualified_locale_data_downlevel* _setloc_downlevel_data;
903*04e0dc4aSTimo Kreuzer int _own_locale; // See _configthreadlocale() and __acrt_should_sync_with_global_locale()
904*04e0dc4aSTimo Kreuzer
905*04e0dc4aSTimo Kreuzer // The buffer used by _putch(), and the flag indicating whether the buffer
906*04e0dc4aSTimo Kreuzer // is currently in use or not.
907*04e0dc4aSTimo Kreuzer unsigned char _putch_buffer[MB_LEN_MAX];
908*04e0dc4aSTimo Kreuzer unsigned short _putch_buffer_used;
909*04e0dc4aSTimo Kreuzer
910*04e0dc4aSTimo Kreuzer // The thread-local invalid parameter handler
911*04e0dc4aSTimo Kreuzer _invalid_parameter_handler _thread_local_iph;
912*04e0dc4aSTimo Kreuzer
913*04e0dc4aSTimo Kreuzer // If this thread was started by the CRT (_beginthread or _beginthreadex),
914*04e0dc4aSTimo Kreuzer // then this points to the context with which the thread was created. If
915*04e0dc4aSTimo Kreuzer // this thread was not started by the CRT, this pointer is null.
916*04e0dc4aSTimo Kreuzer __acrt_thread_parameter* _beginthread_context;
917*04e0dc4aSTimo Kreuzer
918*04e0dc4aSTimo Kreuzer } __acrt_ptd;
919*04e0dc4aSTimo Kreuzer
920*04e0dc4aSTimo Kreuzer __acrt_ptd* __cdecl __acrt_getptd(void);
921*04e0dc4aSTimo Kreuzer __acrt_ptd* __cdecl __acrt_getptd_head(void);
922*04e0dc4aSTimo Kreuzer __acrt_ptd* __cdecl __acrt_getptd_noexit(void);
923*04e0dc4aSTimo Kreuzer void __cdecl __acrt_freeptd(void);
924*04e0dc4aSTimo Kreuzer
925*04e0dc4aSTimo Kreuzer
926*04e0dc4aSTimo Kreuzer
927*04e0dc4aSTimo Kreuzer void __cdecl __acrt_errno_map_os_error (unsigned long);
928*04e0dc4aSTimo Kreuzer int __cdecl __acrt_errno_from_os_error(unsigned long);
929*04e0dc4aSTimo Kreuzer
930*04e0dc4aSTimo Kreuzer
931*04e0dc4aSTimo Kreuzer //-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
932*04e0dc4aSTimo Kreuzer //
933*04e0dc4aSTimo Kreuzer // AppCRT Multi-Threading and Synchronization
934*04e0dc4aSTimo Kreuzer //
935*04e0dc4aSTimo Kreuzer //-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
936*04e0dc4aSTimo Kreuzer typedef enum __acrt_lock_id
937*04e0dc4aSTimo Kreuzer {
938*04e0dc4aSTimo Kreuzer __acrt_heap_lock,
939*04e0dc4aSTimo Kreuzer __acrt_debug_lock,
940*04e0dc4aSTimo Kreuzer __acrt_exit_lock,
941*04e0dc4aSTimo Kreuzer __acrt_signal_lock,
942*04e0dc4aSTimo Kreuzer __acrt_locale_lock,
943*04e0dc4aSTimo Kreuzer __acrt_multibyte_cp_lock,
944*04e0dc4aSTimo Kreuzer __acrt_time_lock,
945*04e0dc4aSTimo Kreuzer __acrt_lowio_index_lock,
946*04e0dc4aSTimo Kreuzer __acrt_stdio_index_lock,
947*04e0dc4aSTimo Kreuzer __acrt_conio_lock,
948*04e0dc4aSTimo Kreuzer __acrt_popen_lock,
949*04e0dc4aSTimo Kreuzer __acrt_environment_lock,
950*04e0dc4aSTimo Kreuzer __acrt_tempnam_lock,
951*04e0dc4aSTimo Kreuzer __acrt_os_exit_lock,
952*04e0dc4aSTimo Kreuzer __acrt_lock_count
953*04e0dc4aSTimo Kreuzer } __acrt_lock_id;
954*04e0dc4aSTimo Kreuzer
955*04e0dc4aSTimo Kreuzer #define _CORECRT_SPINCOUNT 4000
956*04e0dc4aSTimo Kreuzer
957*04e0dc4aSTimo Kreuzer void __cdecl __acrt_lock(_In_ __acrt_lock_id lock);
958*04e0dc4aSTimo Kreuzer void __cdecl __acrt_unlock(_In_ __acrt_lock_id lock);
959*04e0dc4aSTimo Kreuzer
960*04e0dc4aSTimo Kreuzer
961*04e0dc4aSTimo Kreuzer
962*04e0dc4aSTimo Kreuzer //-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
963*04e0dc4aSTimo Kreuzer //
964*04e0dc4aSTimo Kreuzer // CoreCRT SEH Encapsulation
965*04e0dc4aSTimo Kreuzer //
966*04e0dc4aSTimo Kreuzer //-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
967*04e0dc4aSTimo Kreuzer #ifdef __cplusplus
968*04e0dc4aSTimo Kreuzer extern "C++"
969*04e0dc4aSTimo Kreuzer {
970*04e0dc4aSTimo Kreuzer template <typename Action>
971*04e0dc4aSTimo Kreuzer auto __acrt_lock_and_call(__acrt_lock_id const lock_id, Action&& action) throw()
972*04e0dc4aSTimo Kreuzer -> decltype(action())
973*04e0dc4aSTimo Kreuzer {
974*04e0dc4aSTimo Kreuzer return __crt_seh_guarded_call<decltype(action())>()(
975*04e0dc4aSTimo Kreuzer [lock_id]() { __acrt_lock(lock_id); },
976*04e0dc4aSTimo Kreuzer action,
977*04e0dc4aSTimo Kreuzer [lock_id]() { __acrt_unlock(lock_id); });
978*04e0dc4aSTimo Kreuzer }
979*04e0dc4aSTimo Kreuzer }
980*04e0dc4aSTimo Kreuzer #endif
981*04e0dc4aSTimo Kreuzer
982*04e0dc4aSTimo Kreuzer
983*04e0dc4aSTimo Kreuzer
984*04e0dc4aSTimo Kreuzer //-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
985*04e0dc4aSTimo Kreuzer //
986*04e0dc4aSTimo Kreuzer // AppCRT Heap Internals and Debug Heap Internals
987*04e0dc4aSTimo Kreuzer //
988*04e0dc4aSTimo Kreuzer //-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
989*04e0dc4aSTimo Kreuzer extern HANDLE __acrt_heap;
990*04e0dc4aSTimo Kreuzer
991*04e0dc4aSTimo Kreuzer _Check_return_ _Ret_maybenull_ _Post_writable_byte_size_(size)
992*04e0dc4aSTimo Kreuzer void* __cdecl _expand_base(
993*04e0dc4aSTimo Kreuzer _Pre_notnull_ void* block,
994*04e0dc4aSTimo Kreuzer _In_ size_t size
995*04e0dc4aSTimo Kreuzer );
996*04e0dc4aSTimo Kreuzer
997*04e0dc4aSTimo Kreuzer // For detection of heap mismatch between MSVCRT and UCRT
998*04e0dc4aSTimo Kreuzer #define _UCRT_HEAP_MISMATCH_DETECTION 0
999*04e0dc4aSTimo Kreuzer #define _UCRT_HEAP_MISMATCH_RECOVERY 0
1000*04e0dc4aSTimo Kreuzer #define _UCRT_HEAP_MISMATCH_BREAK 0
1001*04e0dc4aSTimo Kreuzer
1002*04e0dc4aSTimo Kreuzer #define _UCRT_HEAP_MISMATCH_ANY (_UCRT_HEAP_MISMATCH_DETECTION || _UCRT_HEAP_MISMATCH_RECOVERY || _UCRT_HEAP_MISMATCH_BREAK)
1003*04e0dc4aSTimo Kreuzer
1004*04e0dc4aSTimo Kreuzer #if _UCRT_HEAP_MISMATCH_ANY && (defined _M_IX86 || defined _M_AMD64)
1005*04e0dc4aSTimo Kreuzer HANDLE __cdecl __acrt_get_msvcrt_heap_handle(void);
1006*04e0dc4aSTimo Kreuzer #endif
1007*04e0dc4aSTimo Kreuzer
1008*04e0dc4aSTimo Kreuzer
1009*04e0dc4aSTimo Kreuzer // CRT Allocation macros:
1010*04e0dc4aSTimo Kreuzer #ifndef _DEBUG
1011*04e0dc4aSTimo Kreuzer #define _expand_crt _expand
1012*04e0dc4aSTimo Kreuzer
1013*04e0dc4aSTimo Kreuzer #define _strdup_crt _strdup
1014*04e0dc4aSTimo Kreuzer
1015*04e0dc4aSTimo Kreuzer #define _dupenv_s_crt _dupenv_s
1016*04e0dc4aSTimo Kreuzer #define _wdupenv_s_crt _wdupenv_s
1017*04e0dc4aSTimo Kreuzer
1018*04e0dc4aSTimo Kreuzer #else
1019*04e0dc4aSTimo Kreuzer #define _expand_crt(p, s) _expand_dbg(p, s, _CRT_BLOCK)
1020*04e0dc4aSTimo Kreuzer
1021*04e0dc4aSTimo Kreuzer #define _strdup_crt(s) _strdup_dbg(s, _CRT_BLOCK, __FILE__, __LINE__)
1022*04e0dc4aSTimo Kreuzer
1023*04e0dc4aSTimo Kreuzer #define _dupenv_s_crt(...) _dupenv_s_dbg(__VA_ARGS__, _CRT_BLOCK, __FILE__, __LINE__)
1024*04e0dc4aSTimo Kreuzer #define _wdupenv_s_crt(...) _wdupenv_s_dbg(__VA_ARGS__, _CRT_BLOCK, __FILE__, __LINE__)
1025*04e0dc4aSTimo Kreuzer
1026*04e0dc4aSTimo Kreuzer #endif
1027*04e0dc4aSTimo Kreuzer
1028*04e0dc4aSTimo Kreuzer
1029*04e0dc4aSTimo Kreuzer
1030*04e0dc4aSTimo Kreuzer //-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1031*04e0dc4aSTimo Kreuzer //
1032*04e0dc4aSTimo Kreuzer // CoreCRT Scoped HANDLE Wrappers
1033*04e0dc4aSTimo Kreuzer //
1034*04e0dc4aSTimo Kreuzer //-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1035*04e0dc4aSTimo Kreuzer // These classes are similar to the WRL HandleT and its traits. We cannot use
1036*04e0dc4aSTimo Kreuzer // HandleT because it has a virtual function, InternalClose(). (Every object
1037*04e0dc4aSTimo Kreuzer // that uses a HandleT instantiation also has the RTTI data for that HandleT
1038*04e0dc4aSTimo Kreuzer // instantiation. This RTTI data causes the object to depend on type_info, which
1039*04e0dc4aSTimo Kreuzer // causes an indirect dependency on operator delete. This breaks static linking
1040*04e0dc4aSTimo Kreuzer // of the CRT, when operator delete is replaced in a user-provided object.
1041*04e0dc4aSTimo Kreuzer #ifdef __cplusplus
1042*04e0dc4aSTimo Kreuzer extern "C++"
1043*04e0dc4aSTimo Kreuzer {
1044*04e0dc4aSTimo Kreuzer struct __crt_handle_traits
1045*04e0dc4aSTimo Kreuzer {
1046*04e0dc4aSTimo Kreuzer typedef HANDLE type;
1047*04e0dc4aSTimo Kreuzer
close__crt_handle_traits1048*04e0dc4aSTimo Kreuzer static bool close(_In_ type handle) throw()
1049*04e0dc4aSTimo Kreuzer {
1050*04e0dc4aSTimo Kreuzer return ::CloseHandle(handle) != FALSE;
1051*04e0dc4aSTimo Kreuzer }
1052*04e0dc4aSTimo Kreuzer
get_invalid_value__crt_handle_traits1053*04e0dc4aSTimo Kreuzer static type get_invalid_value() throw()
1054*04e0dc4aSTimo Kreuzer {
1055*04e0dc4aSTimo Kreuzer return INVALID_HANDLE_VALUE;
1056*04e0dc4aSTimo Kreuzer }
1057*04e0dc4aSTimo Kreuzer };
1058*04e0dc4aSTimo Kreuzer
1059*04e0dc4aSTimo Kreuzer struct __crt_hmodule_traits
1060*04e0dc4aSTimo Kreuzer {
1061*04e0dc4aSTimo Kreuzer typedef HMODULE type;
1062*04e0dc4aSTimo Kreuzer
close__crt_hmodule_traits1063*04e0dc4aSTimo Kreuzer static bool close(_In_ type handle) throw()
1064*04e0dc4aSTimo Kreuzer {
1065*04e0dc4aSTimo Kreuzer return ::FreeLibrary(handle) != FALSE;
1066*04e0dc4aSTimo Kreuzer }
1067*04e0dc4aSTimo Kreuzer
get_invalid_value__crt_hmodule_traits1068*04e0dc4aSTimo Kreuzer static type get_invalid_value() throw()
1069*04e0dc4aSTimo Kreuzer {
1070*04e0dc4aSTimo Kreuzer return nullptr;
1071*04e0dc4aSTimo Kreuzer }
1072*04e0dc4aSTimo Kreuzer };
1073*04e0dc4aSTimo Kreuzer
1074*04e0dc4aSTimo Kreuzer struct __crt_findfile_traits
1075*04e0dc4aSTimo Kreuzer {
1076*04e0dc4aSTimo Kreuzer typedef HANDLE type;
1077*04e0dc4aSTimo Kreuzer
close__crt_findfile_traits1078*04e0dc4aSTimo Kreuzer static bool close(_In_ type handle) throw()
1079*04e0dc4aSTimo Kreuzer {
1080*04e0dc4aSTimo Kreuzer return ::FindClose(handle) != FALSE;
1081*04e0dc4aSTimo Kreuzer }
1082*04e0dc4aSTimo Kreuzer
get_invalid_value__crt_findfile_traits1083*04e0dc4aSTimo Kreuzer static type get_invalid_value() throw()
1084*04e0dc4aSTimo Kreuzer {
1085*04e0dc4aSTimo Kreuzer return INVALID_HANDLE_VALUE;
1086*04e0dc4aSTimo Kreuzer }
1087*04e0dc4aSTimo Kreuzer };
1088*04e0dc4aSTimo Kreuzer
1089*04e0dc4aSTimo Kreuzer
1090*04e0dc4aSTimo Kreuzer
1091*04e0dc4aSTimo Kreuzer template <typename Traits>
1092*04e0dc4aSTimo Kreuzer class __crt_unique_handle_t
1093*04e0dc4aSTimo Kreuzer {
1094*04e0dc4aSTimo Kreuzer public:
1095*04e0dc4aSTimo Kreuzer
1096*04e0dc4aSTimo Kreuzer typedef Traits traits_type;
1097*04e0dc4aSTimo Kreuzer typedef typename Traits::type handle_type;
1098*04e0dc4aSTimo Kreuzer
throw()1099*04e0dc4aSTimo Kreuzer explicit __crt_unique_handle_t(handle_type const h = traits_type::get_invalid_value()) throw()
1100*04e0dc4aSTimo Kreuzer : _handle(h)
1101*04e0dc4aSTimo Kreuzer {
1102*04e0dc4aSTimo Kreuzer }
1103*04e0dc4aSTimo Kreuzer
throw()1104*04e0dc4aSTimo Kreuzer __crt_unique_handle_t(_Inout_ __crt_unique_handle_t&& h) throw()
1105*04e0dc4aSTimo Kreuzer : _handle(h._handle)
1106*04e0dc4aSTimo Kreuzer {
1107*04e0dc4aSTimo Kreuzer h._handle = traits_type::get_invalid_value();
1108*04e0dc4aSTimo Kreuzer }
1109*04e0dc4aSTimo Kreuzer
throw()1110*04e0dc4aSTimo Kreuzer ~__crt_unique_handle_t() throw()
1111*04e0dc4aSTimo Kreuzer {
1112*04e0dc4aSTimo Kreuzer close();
1113*04e0dc4aSTimo Kreuzer }
1114*04e0dc4aSTimo Kreuzer
throw()1115*04e0dc4aSTimo Kreuzer __crt_unique_handle_t& operator=(_Inout_ __crt_unique_handle_t&& h) throw()
1116*04e0dc4aSTimo Kreuzer {
1117*04e0dc4aSTimo Kreuzer close();
1118*04e0dc4aSTimo Kreuzer _handle = h._handle;
1119*04e0dc4aSTimo Kreuzer h._handle = traits_type::get_invalid_value();
1120*04e0dc4aSTimo Kreuzer return *this;
1121*04e0dc4aSTimo Kreuzer }
1122*04e0dc4aSTimo Kreuzer
attach(handle_type h)1123*04e0dc4aSTimo Kreuzer void attach(handle_type h) throw()
1124*04e0dc4aSTimo Kreuzer {
1125*04e0dc4aSTimo Kreuzer if (h != _handle)
1126*04e0dc4aSTimo Kreuzer {
1127*04e0dc4aSTimo Kreuzer close();
1128*04e0dc4aSTimo Kreuzer _handle = h;
1129*04e0dc4aSTimo Kreuzer }
1130*04e0dc4aSTimo Kreuzer }
1131*04e0dc4aSTimo Kreuzer
detach()1132*04e0dc4aSTimo Kreuzer handle_type detach() throw()
1133*04e0dc4aSTimo Kreuzer {
1134*04e0dc4aSTimo Kreuzer handle_type h = _handle;
1135*04e0dc4aSTimo Kreuzer _handle = traits_type::get_invalid_value();
1136*04e0dc4aSTimo Kreuzer return h;
1137*04e0dc4aSTimo Kreuzer }
1138*04e0dc4aSTimo Kreuzer
get()1139*04e0dc4aSTimo Kreuzer handle_type get() const throw()
1140*04e0dc4aSTimo Kreuzer {
1141*04e0dc4aSTimo Kreuzer return _handle;
1142*04e0dc4aSTimo Kreuzer }
1143*04e0dc4aSTimo Kreuzer
close()1144*04e0dc4aSTimo Kreuzer void close() throw()
1145*04e0dc4aSTimo Kreuzer {
1146*04e0dc4aSTimo Kreuzer if (_handle == traits_type::get_invalid_value())
1147*04e0dc4aSTimo Kreuzer return;
1148*04e0dc4aSTimo Kreuzer
1149*04e0dc4aSTimo Kreuzer traits_type::close(_handle);
1150*04e0dc4aSTimo Kreuzer _handle = traits_type::get_invalid_value();
1151*04e0dc4aSTimo Kreuzer }
1152*04e0dc4aSTimo Kreuzer
is_valid()1153*04e0dc4aSTimo Kreuzer bool is_valid() const throw()
1154*04e0dc4aSTimo Kreuzer {
1155*04e0dc4aSTimo Kreuzer return _handle != traits_type::get_invalid_value();
1156*04e0dc4aSTimo Kreuzer }
1157*04e0dc4aSTimo Kreuzer
throw()1158*04e0dc4aSTimo Kreuzer operator bool() const throw()
1159*04e0dc4aSTimo Kreuzer {
1160*04e0dc4aSTimo Kreuzer return is_valid();
1161*04e0dc4aSTimo Kreuzer }
1162*04e0dc4aSTimo Kreuzer
get_address_of()1163*04e0dc4aSTimo Kreuzer handle_type* get_address_of() throw()
1164*04e0dc4aSTimo Kreuzer {
1165*04e0dc4aSTimo Kreuzer return &_handle;
1166*04e0dc4aSTimo Kreuzer }
1167*04e0dc4aSTimo Kreuzer
release_and_get_address_of()1168*04e0dc4aSTimo Kreuzer handle_type* release_and_get_address_of() throw()
1169*04e0dc4aSTimo Kreuzer {
1170*04e0dc4aSTimo Kreuzer close();
1171*04e0dc4aSTimo Kreuzer return &_handle;
1172*04e0dc4aSTimo Kreuzer }
1173*04e0dc4aSTimo Kreuzer
1174*04e0dc4aSTimo Kreuzer private:
1175*04e0dc4aSTimo Kreuzer
1176*04e0dc4aSTimo Kreuzer __crt_unique_handle_t(__crt_unique_handle_t const&) throw();
1177*04e0dc4aSTimo Kreuzer __crt_unique_handle_t& operator=(__crt_unique_handle_t const&) throw();
1178*04e0dc4aSTimo Kreuzer
1179*04e0dc4aSTimo Kreuzer handle_type _handle;
1180*04e0dc4aSTimo Kreuzer };
1181*04e0dc4aSTimo Kreuzer
1182*04e0dc4aSTimo Kreuzer typedef __crt_unique_handle_t<__crt_handle_traits> __crt_unique_handle;
1183*04e0dc4aSTimo Kreuzer typedef __crt_unique_handle_t<__crt_hmodule_traits> __crt_unique_hmodule;
1184*04e0dc4aSTimo Kreuzer typedef __crt_unique_handle_t<__crt_findfile_traits> __crt_findfile_handle;
1185*04e0dc4aSTimo Kreuzer
1186*04e0dc4aSTimo Kreuzer } // extern "C++"
1187*04e0dc4aSTimo Kreuzer #endif // __cplusplus
1188*04e0dc4aSTimo Kreuzer
1189*04e0dc4aSTimo Kreuzer
1190*04e0dc4aSTimo Kreuzer
1191*04e0dc4aSTimo Kreuzer //-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1192*04e0dc4aSTimo Kreuzer //
1193*04e0dc4aSTimo Kreuzer // AppCRT Windows API Thunks
1194*04e0dc4aSTimo Kreuzer //
1195*04e0dc4aSTimo Kreuzer //-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1196*04e0dc4aSTimo Kreuzer BOOL WINAPI __acrt_AreFileApisANSI(void);
1197*04e0dc4aSTimo Kreuzer
1198*04e0dc4aSTimo Kreuzer int WINAPI __acrt_CompareStringEx(
1199*04e0dc4aSTimo Kreuzer _In_opt_ LPCWSTR locale_name,
1200*04e0dc4aSTimo Kreuzer _In_ DWORD flags,
1201*04e0dc4aSTimo Kreuzer _In_NLS_string_(string1_count) LPCWCH string1,
1202*04e0dc4aSTimo Kreuzer _In_ int string1_count,
1203*04e0dc4aSTimo Kreuzer _In_NLS_string_(string2_count) LPCWCH string2,
1204*04e0dc4aSTimo Kreuzer _In_ int string2_count,
1205*04e0dc4aSTimo Kreuzer _Reserved_ LPNLSVERSIONINFO version,
1206*04e0dc4aSTimo Kreuzer _Reserved_ LPVOID reserved,
1207*04e0dc4aSTimo Kreuzer _Reserved_ LPARAM param
1208*04e0dc4aSTimo Kreuzer );
1209*04e0dc4aSTimo Kreuzer
1210*04e0dc4aSTimo Kreuzer BOOL WINAPI __acrt_EnumSystemLocalesEx(
1211*04e0dc4aSTimo Kreuzer _In_ LOCALE_ENUMPROCEX enum_proc,
1212*04e0dc4aSTimo Kreuzer _In_ DWORD flags,
1213*04e0dc4aSTimo Kreuzer _In_ LPARAM param,
1214*04e0dc4aSTimo Kreuzer _In_opt_ LPVOID reserved
1215*04e0dc4aSTimo Kreuzer );
1216*04e0dc4aSTimo Kreuzer
1217*04e0dc4aSTimo Kreuzer DWORD WINAPI __acrt_FlsAlloc(
1218*04e0dc4aSTimo Kreuzer _In_opt_ PFLS_CALLBACK_FUNCTION lpCallback
1219*04e0dc4aSTimo Kreuzer );
1220*04e0dc4aSTimo Kreuzer
1221*04e0dc4aSTimo Kreuzer BOOL WINAPI __acrt_FlsFree(
1222*04e0dc4aSTimo Kreuzer _In_ DWORD dwFlsIndex
1223*04e0dc4aSTimo Kreuzer );
1224*04e0dc4aSTimo Kreuzer
1225*04e0dc4aSTimo Kreuzer PVOID WINAPI __acrt_FlsGetValue(
1226*04e0dc4aSTimo Kreuzer _In_ DWORD dwFlsIndex
1227*04e0dc4aSTimo Kreuzer );
1228*04e0dc4aSTimo Kreuzer
1229*04e0dc4aSTimo Kreuzer BOOL WINAPI __acrt_FlsSetValue(
1230*04e0dc4aSTimo Kreuzer _In_ DWORD dwFlsIndex,
1231*04e0dc4aSTimo Kreuzer _In_opt_ PVOID lpFlsData
1232*04e0dc4aSTimo Kreuzer );
1233*04e0dc4aSTimo Kreuzer
1234*04e0dc4aSTimo Kreuzer int WINAPI __acrt_GetDateFormatEx(
1235*04e0dc4aSTimo Kreuzer _In_opt_ LPCWSTR locale_name,
1236*04e0dc4aSTimo Kreuzer _In_ DWORD flags,
1237*04e0dc4aSTimo Kreuzer _In_opt_ SYSTEMTIME CONST* date,
1238*04e0dc4aSTimo Kreuzer _In_opt_ LPCWSTR format,
1239*04e0dc4aSTimo Kreuzer _Out_writes_opt_(buffer_count) LPWSTR buffer,
1240*04e0dc4aSTimo Kreuzer _In_opt_ int buffer_count,
1241*04e0dc4aSTimo Kreuzer _In_opt_ LPCWSTR calendar
1242*04e0dc4aSTimo Kreuzer );
1243*04e0dc4aSTimo Kreuzer
1244*04e0dc4aSTimo Kreuzer int WINAPI __acrt_GetTempPath2W(
1245*04e0dc4aSTimo Kreuzer _In_ DWORD nBufferLength,
1246*04e0dc4aSTimo Kreuzer _Out_writes_to_opt_(BufferLength, return +1) LPWSTR lpBuffer
1247*04e0dc4aSTimo Kreuzer );
1248*04e0dc4aSTimo Kreuzer
1249*04e0dc4aSTimo Kreuzer DWORD64 WINAPI __acrt_GetEnabledXStateFeatures(void);
1250*04e0dc4aSTimo Kreuzer
1251*04e0dc4aSTimo Kreuzer int WINAPI __acrt_GetLocaleInfoEx(
1252*04e0dc4aSTimo Kreuzer _In_opt_ LPCWSTR locale_name,
1253*04e0dc4aSTimo Kreuzer _In_ LCTYPE lc_type,
1254*04e0dc4aSTimo Kreuzer _Out_writes_opt_(data_count) LPWSTR data,
1255*04e0dc4aSTimo Kreuzer _In_ int data_count
1256*04e0dc4aSTimo Kreuzer );
1257*04e0dc4aSTimo Kreuzer
1258*04e0dc4aSTimo Kreuzer VOID WINAPI __acrt_GetSystemTimePreciseAsFileTime(
1259*04e0dc4aSTimo Kreuzer _Out_ LPFILETIME system_time
1260*04e0dc4aSTimo Kreuzer );
1261*04e0dc4aSTimo Kreuzer
1262*04e0dc4aSTimo Kreuzer int WINAPI __acrt_GetTimeFormatEx(
1263*04e0dc4aSTimo Kreuzer _In_opt_ LPCWSTR locale_name,
1264*04e0dc4aSTimo Kreuzer _In_ DWORD flags,
1265*04e0dc4aSTimo Kreuzer _In_opt_ SYSTEMTIME CONST* time,
1266*04e0dc4aSTimo Kreuzer _In_opt_ LPCWSTR format,
1267*04e0dc4aSTimo Kreuzer _Out_writes_opt_(buffer_count) LPWSTR buffer,
1268*04e0dc4aSTimo Kreuzer _In_opt_ int buffer_count
1269*04e0dc4aSTimo Kreuzer );
1270*04e0dc4aSTimo Kreuzer
1271*04e0dc4aSTimo Kreuzer int WINAPI __acrt_GetUserDefaultLocaleName(
1272*04e0dc4aSTimo Kreuzer _Out_writes_(locale_name_count) LPWSTR locale_name,
1273*04e0dc4aSTimo Kreuzer _In_ int locale_name_count
1274*04e0dc4aSTimo Kreuzer );
1275*04e0dc4aSTimo Kreuzer
1276*04e0dc4aSTimo Kreuzer _Must_inspect_result_
1277*04e0dc4aSTimo Kreuzer BOOL WINAPI __acrt_GetXStateFeaturesMask(
1278*04e0dc4aSTimo Kreuzer _In_ PCONTEXT context,
1279*04e0dc4aSTimo Kreuzer _Out_ PDWORD64 feature_mask
1280*04e0dc4aSTimo Kreuzer );
1281*04e0dc4aSTimo Kreuzer
1282*04e0dc4aSTimo Kreuzer BOOL WINAPI __acrt_InitializeCriticalSectionEx(
1283*04e0dc4aSTimo Kreuzer _Out_ LPCRITICAL_SECTION critical_section,
1284*04e0dc4aSTimo Kreuzer _In_ DWORD spin_count,
1285*04e0dc4aSTimo Kreuzer _In_ DWORD flags
1286*04e0dc4aSTimo Kreuzer );
1287*04e0dc4aSTimo Kreuzer
1288*04e0dc4aSTimo Kreuzer BOOL WINAPI __acrt_IsValidLocaleName(
1289*04e0dc4aSTimo Kreuzer _In_ LPCWSTR locale_name
1290*04e0dc4aSTimo Kreuzer );
1291*04e0dc4aSTimo Kreuzer
1292*04e0dc4aSTimo Kreuzer int WINAPI __acrt_LCMapStringEx(
1293*04e0dc4aSTimo Kreuzer _In_opt_ LPCWSTR locale_name,
1294*04e0dc4aSTimo Kreuzer _In_ DWORD flags,
1295*04e0dc4aSTimo Kreuzer _In_CRT_NLS_string_(source_count) LPCWSTR source,
1296*04e0dc4aSTimo Kreuzer _In_ int source_count,
1297*04e0dc4aSTimo Kreuzer _Out_writes_opt_(destination_count) LPWSTR destination,
1298*04e0dc4aSTimo Kreuzer _In_ int destination_count,
1299*04e0dc4aSTimo Kreuzer _In_opt_ LPNLSVERSIONINFO version,
1300*04e0dc4aSTimo Kreuzer _In_opt_ LPVOID reserved,
1301*04e0dc4aSTimo Kreuzer _In_opt_ LPARAM sort_handle
1302*04e0dc4aSTimo Kreuzer );
1303*04e0dc4aSTimo Kreuzer
1304*04e0dc4aSTimo Kreuzer int WINAPI __acrt_LCIDToLocaleName(
1305*04e0dc4aSTimo Kreuzer _In_ LCID locale,
1306*04e0dc4aSTimo Kreuzer _Out_writes_opt_(name_count) LPWSTR name,
1307*04e0dc4aSTimo Kreuzer _In_ int name_count,
1308*04e0dc4aSTimo Kreuzer _In_ DWORD flags
1309*04e0dc4aSTimo Kreuzer );
1310*04e0dc4aSTimo Kreuzer
1311*04e0dc4aSTimo Kreuzer DWORD WINAPI __acrt_LocaleNameToLCID(
1312*04e0dc4aSTimo Kreuzer _In_ LPCWSTR name,
1313*04e0dc4aSTimo Kreuzer _In_ DWORD flags
1314*04e0dc4aSTimo Kreuzer );
1315*04e0dc4aSTimo Kreuzer
1316*04e0dc4aSTimo Kreuzer _Success_(return != NULL)
1317*04e0dc4aSTimo Kreuzer PVOID WINAPI __acrt_LocateXStateFeature(
1318*04e0dc4aSTimo Kreuzer _In_ PCONTEXT content,
1319*04e0dc4aSTimo Kreuzer _In_ DWORD feature_id,
1320*04e0dc4aSTimo Kreuzer _Out_opt_ PDWORD length
1321*04e0dc4aSTimo Kreuzer );
1322*04e0dc4aSTimo Kreuzer
1323*04e0dc4aSTimo Kreuzer int WINAPI __acrt_MessageBoxA(
1324*04e0dc4aSTimo Kreuzer _In_opt_ HWND hwnd,
1325*04e0dc4aSTimo Kreuzer _In_opt_ LPCSTR text,
1326*04e0dc4aSTimo Kreuzer _In_opt_ LPCSTR caption,
1327*04e0dc4aSTimo Kreuzer _In_ UINT type
1328*04e0dc4aSTimo Kreuzer );
1329*04e0dc4aSTimo Kreuzer
1330*04e0dc4aSTimo Kreuzer int WINAPI __acrt_MessageBoxW(
1331*04e0dc4aSTimo Kreuzer _In_opt_ HWND hwnd,
1332*04e0dc4aSTimo Kreuzer _In_opt_ LPCWSTR text,
1333*04e0dc4aSTimo Kreuzer _In_opt_ LPCWSTR caption,
1334*04e0dc4aSTimo Kreuzer _In_ UINT type
1335*04e0dc4aSTimo Kreuzer );
1336*04e0dc4aSTimo Kreuzer
1337*04e0dc4aSTimo Kreuzer void WINAPI __acrt_OutputDebugStringA(
1338*04e0dc4aSTimo Kreuzer _In_opt_ LPCSTR text
1339*04e0dc4aSTimo Kreuzer );
1340*04e0dc4aSTimo Kreuzer
1341*04e0dc4aSTimo Kreuzer #ifdef __cplusplus
1342*04e0dc4aSTimo Kreuzer HRESULT WINAPI __acrt_RoInitialize(
1343*04e0dc4aSTimo Kreuzer _In_ RO_INIT_TYPE init_type
1344*04e0dc4aSTimo Kreuzer );
1345*04e0dc4aSTimo Kreuzer #endif
1346*04e0dc4aSTimo Kreuzer
1347*04e0dc4aSTimo Kreuzer void WINAPI __acrt_RoUninitialize(void);
1348*04e0dc4aSTimo Kreuzer
1349*04e0dc4aSTimo Kreuzer _Success_(return != 0)
1350*04e0dc4aSTimo Kreuzer BOOLEAN WINAPI __acrt_RtlGenRandom(
1351*04e0dc4aSTimo Kreuzer _Out_writes_bytes_(buffer_count) PVOID buffer,
1352*04e0dc4aSTimo Kreuzer _In_ ULONG buffer_count
1353*04e0dc4aSTimo Kreuzer );
1354*04e0dc4aSTimo Kreuzer
1355*04e0dc4aSTimo Kreuzer LONG WINAPI __acrt_AppPolicyGetProcessTerminationMethodInternal(_Out_ AppPolicyProcessTerminationMethod* policy);
1356*04e0dc4aSTimo Kreuzer LONG WINAPI __acrt_AppPolicyGetThreadInitializationTypeInternal(_Out_ AppPolicyThreadInitializationType* policy);
1357*04e0dc4aSTimo Kreuzer LONG WINAPI __acrt_AppPolicyGetShowDeveloperDiagnosticInternal(_Out_ AppPolicyShowDeveloperDiagnostic* policy);
1358*04e0dc4aSTimo Kreuzer LONG WINAPI __acrt_AppPolicyGetWindowingModelInternal(_Out_ AppPolicyWindowingModel* policy);
1359*04e0dc4aSTimo Kreuzer
1360*04e0dc4aSTimo Kreuzer BOOL WINAPI __acrt_SetThreadStackGuarantee(
1361*04e0dc4aSTimo Kreuzer _Inout_ PULONG stack_size_in_bytes
1362*04e0dc4aSTimo Kreuzer );
1363*04e0dc4aSTimo Kreuzer
1364*04e0dc4aSTimo Kreuzer
1365*04e0dc4aSTimo Kreuzer bool __cdecl __acrt_can_show_message_box(void);
1366*04e0dc4aSTimo Kreuzer bool __cdecl __acrt_can_use_vista_locale_apis(void);
1367*04e0dc4aSTimo Kreuzer void __cdecl __acrt_eagerly_load_locale_apis(void);
1368*04e0dc4aSTimo Kreuzer bool __cdecl __acrt_can_use_xstate_apis(void);
1369*04e0dc4aSTimo Kreuzer HWND __cdecl __acrt_get_parent_window(void);
1370*04e0dc4aSTimo Kreuzer bool __cdecl __acrt_is_interactive(void);
1371*04e0dc4aSTimo Kreuzer
1372*04e0dc4aSTimo Kreuzer bool __cdecl __acrt_app_verifier_enabled(void);
1373*04e0dc4aSTimo Kreuzer bool __cdecl __acrt_is_secure_process(void);
1374*04e0dc4aSTimo Kreuzer
1375*04e0dc4aSTimo Kreuzer LCID __cdecl __acrt_DownlevelLocaleNameToLCID(
1376*04e0dc4aSTimo Kreuzer _In_opt_ LPCWSTR localeName
1377*04e0dc4aSTimo Kreuzer );
1378*04e0dc4aSTimo Kreuzer
1379*04e0dc4aSTimo Kreuzer _Success_(return != 0)
1380*04e0dc4aSTimo Kreuzer int __cdecl __acrt_DownlevelLCIDToLocaleName(
1381*04e0dc4aSTimo Kreuzer _In_ LCID lcid,
1382*04e0dc4aSTimo Kreuzer _Out_writes_opt_z_(cchLocaleName) LPWSTR outLocaleName,
1383*04e0dc4aSTimo Kreuzer _In_ int cchLocaleName
1384*04e0dc4aSTimo Kreuzer );
1385*04e0dc4aSTimo Kreuzer
1386*04e0dc4aSTimo Kreuzer
1387*04e0dc4aSTimo Kreuzer //-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1388*04e0dc4aSTimo Kreuzer //
1389*04e0dc4aSTimo Kreuzer // AppCRT Signal Handling and Exception Filter
1390*04e0dc4aSTimo Kreuzer //
1391*04e0dc4aSTimo Kreuzer //-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1392*04e0dc4aSTimo Kreuzer
1393*04e0dc4aSTimo Kreuzer // Pointer to a signal handler
1394*04e0dc4aSTimo Kreuzer typedef void (__cdecl* __crt_signal_handler_t)(int);
1395*04e0dc4aSTimo Kreuzer
1396*04e0dc4aSTimo Kreuzer // Exception-action table used by the C runtime to identify and dispose of
1397*04e0dc4aSTimo Kreuzer // exceptions corresponding to C runtime errors or C signals.
1398*04e0dc4aSTimo Kreuzer struct __crt_signal_action_t
1399*04e0dc4aSTimo Kreuzer {
1400*04e0dc4aSTimo Kreuzer // Exception code or number; defined by the host OS.
1401*04e0dc4aSTimo Kreuzer unsigned long _exception_number;
1402*04e0dc4aSTimo Kreuzer
1403*04e0dc4aSTimo Kreuzer // Signal code or number; defined by the CRT.
1404*04e0dc4aSTimo Kreuzer int _signal_number;
1405*04e0dc4aSTimo Kreuzer
1406*04e0dc4aSTimo Kreuzer // Exception action code. Either a special code or the address of
1407*04e0dc4aSTimo Kreuzer // a handler function. Always determines how the exception filter
1408*04e0dc4aSTimo Kreuzer // should dispose of the exception.
1409*04e0dc4aSTimo Kreuzer __crt_signal_handler_t _action;
1410*04e0dc4aSTimo Kreuzer };
1411*04e0dc4aSTimo Kreuzer
1412*04e0dc4aSTimo Kreuzer extern struct __crt_signal_action_t const __acrt_exception_action_table[];
1413*04e0dc4aSTimo Kreuzer
1414*04e0dc4aSTimo Kreuzer // Number of entries in the exception-action table
1415*04e0dc4aSTimo Kreuzer extern size_t const __acrt_signal_action_table_count;
1416*04e0dc4aSTimo Kreuzer
1417*04e0dc4aSTimo Kreuzer // Size of exception-action table (in bytes)
1418*04e0dc4aSTimo Kreuzer extern size_t const __acrt_signal_action_table_size;
1419*04e0dc4aSTimo Kreuzer
1420*04e0dc4aSTimo Kreuzer // Index of the first floating point exception entry
1421*04e0dc4aSTimo Kreuzer extern size_t const __acrt_signal_action_first_fpe_index;
1422*04e0dc4aSTimo Kreuzer
1423*04e0dc4aSTimo Kreuzer // Number of FPE entries
1424*04e0dc4aSTimo Kreuzer extern size_t const __acrt_signal_action_fpe_count;
1425*04e0dc4aSTimo Kreuzer
1426*04e0dc4aSTimo Kreuzer __crt_signal_handler_t __cdecl __acrt_get_sigabrt_handler(void);
1427*04e0dc4aSTimo Kreuzer
1428*04e0dc4aSTimo Kreuzer
1429*04e0dc4aSTimo Kreuzer
1430*04e0dc4aSTimo Kreuzer //-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1431*04e0dc4aSTimo Kreuzer //
1432*04e0dc4aSTimo Kreuzer // DesktopCRT Environment
1433*04e0dc4aSTimo Kreuzer //
1434*04e0dc4aSTimo Kreuzer //-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1435*04e0dc4aSTimo Kreuzer #ifdef __cplusplus
1436*04e0dc4aSTimo Kreuzer extern __crt_state_management::dual_state_global<char**> _environ_table;
1437*04e0dc4aSTimo Kreuzer extern __crt_state_management::dual_state_global<wchar_t**> _wenviron_table;
1438*04e0dc4aSTimo Kreuzer #endif
1439*04e0dc4aSTimo Kreuzer
1440*04e0dc4aSTimo Kreuzer extern wchar_t** __dcrt_initial_wide_environment;
1441*04e0dc4aSTimo Kreuzer extern char** __dcrt_initial_narrow_environment;
1442*04e0dc4aSTimo Kreuzer
1443*04e0dc4aSTimo Kreuzer _Ret_opt_z_
1444*04e0dc4aSTimo Kreuzer char* __cdecl __dcrt_get_narrow_environment_from_os(void) _CRT_NOEXCEPT;
1445*04e0dc4aSTimo Kreuzer
1446*04e0dc4aSTimo Kreuzer _Ret_opt_z_
1447*04e0dc4aSTimo Kreuzer wchar_t* __cdecl __dcrt_get_wide_environment_from_os(void) _CRT_NOEXCEPT;
1448*04e0dc4aSTimo Kreuzer
1449*04e0dc4aSTimo Kreuzer _Deref_ret_opt_z_
1450*04e0dc4aSTimo Kreuzer char** __cdecl __dcrt_get_or_create_narrow_environment_nolock(void);
1451*04e0dc4aSTimo Kreuzer
1452*04e0dc4aSTimo Kreuzer _Deref_ret_opt_z_
1453*04e0dc4aSTimo Kreuzer wchar_t** __cdecl __dcrt_get_or_create_wide_environment_nolock(void);
1454*04e0dc4aSTimo Kreuzer
1455*04e0dc4aSTimo Kreuzer void __cdecl __dcrt_uninitialize_environments_nolock(void);
1456*04e0dc4aSTimo Kreuzer
1457*04e0dc4aSTimo Kreuzer
1458*04e0dc4aSTimo Kreuzer int __cdecl __dcrt_set_variable_in_narrow_environment_nolock(
1459*04e0dc4aSTimo Kreuzer _In_ _Post_invalid_ char* option,
1460*04e0dc4aSTimo Kreuzer _In_ int is_top_level_call
1461*04e0dc4aSTimo Kreuzer );
1462*04e0dc4aSTimo Kreuzer
1463*04e0dc4aSTimo Kreuzer int __cdecl __dcrt_set_variable_in_wide_environment_nolock(
1464*04e0dc4aSTimo Kreuzer _In_ _Post_invalid_ wchar_t* option,
1465*04e0dc4aSTimo Kreuzer _In_ int is_top_level_call
1466*04e0dc4aSTimo Kreuzer );
1467*04e0dc4aSTimo Kreuzer
1468*04e0dc4aSTimo Kreuzer //-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1469*04e0dc4aSTimo Kreuzer //
1470*04e0dc4aSTimo Kreuzer // Internal fast locale functions with no extra checks
1471*04e0dc4aSTimo Kreuzer //
1472*04e0dc4aSTimo Kreuzer //-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1473*04e0dc4aSTimo Kreuzer // Only use these when the input char is validated to be an unsigned char and not EOF.
1474*04e0dc4aSTimo Kreuzer // Ensure locale has already been updated.
_toupper_fast_internal(_In_ unsigned char const c,_In_ _locale_t const locale)1475*04e0dc4aSTimo Kreuzer _Check_return_ __forceinline unsigned char __cdecl _toupper_fast_internal(
1476*04e0dc4aSTimo Kreuzer _In_ unsigned char const c,
1477*04e0dc4aSTimo Kreuzer _In_ _locale_t const locale
1478*04e0dc4aSTimo Kreuzer )
1479*04e0dc4aSTimo Kreuzer {
1480*04e0dc4aSTimo Kreuzer return locale->locinfo->pcumap[c];
1481*04e0dc4aSTimo Kreuzer }
1482*04e0dc4aSTimo Kreuzer
_tolower_fast_internal(_In_ unsigned char const c,_In_ _locale_t const locale)1483*04e0dc4aSTimo Kreuzer _Check_return_ __forceinline unsigned char __cdecl _tolower_fast_internal(
1484*04e0dc4aSTimo Kreuzer _In_ unsigned char const c,
1485*04e0dc4aSTimo Kreuzer _In_ _locale_t const locale
1486*04e0dc4aSTimo Kreuzer )
1487*04e0dc4aSTimo Kreuzer {
1488*04e0dc4aSTimo Kreuzer return locale->locinfo->pclmap[c];
1489*04e0dc4aSTimo Kreuzer }
1490*04e0dc4aSTimo Kreuzer
1491*04e0dc4aSTimo Kreuzer extern const unsigned short _wctype[];
1492*04e0dc4aSTimo Kreuzer
_towupper_fast_internal(_In_ unsigned char const c,_In_ _locale_t const locale)1493*04e0dc4aSTimo Kreuzer _Check_return_ __forceinline wint_t _towupper_fast_internal(
1494*04e0dc4aSTimo Kreuzer _In_ unsigned char const c,
1495*04e0dc4aSTimo Kreuzer _In_ _locale_t const locale
1496*04e0dc4aSTimo Kreuzer )
1497*04e0dc4aSTimo Kreuzer {
1498*04e0dc4aSTimo Kreuzer // Check for iswlower required because upper map assumes using narrow ctype categories.
1499*04e0dc4aSTimo Kreuzer // towupper uses a locale-sensitive transformation, but only if the wide character
1500*04e0dc4aSTimo Kreuzer // is considered lowercase in UTF-16.
1501*04e0dc4aSTimo Kreuzer // _wctype starts at EOF. Add one to map to characters.
1502*04e0dc4aSTimo Kreuzer if (_wctype[c + 1] & _LOWER)
1503*04e0dc4aSTimo Kreuzer {
1504*04e0dc4aSTimo Kreuzer return _toupper_fast_internal(c, locale);
1505*04e0dc4aSTimo Kreuzer }
1506*04e0dc4aSTimo Kreuzer return c;
1507*04e0dc4aSTimo Kreuzer }
1508*04e0dc4aSTimo Kreuzer
_towupper_internal(_In_ unsigned short const c,_In_ _locale_t const locale)1509*04e0dc4aSTimo Kreuzer _Check_return_ inline wint_t _towupper_internal(
1510*04e0dc4aSTimo Kreuzer _In_ unsigned short const c,
1511*04e0dc4aSTimo Kreuzer _In_ _locale_t const locale
1512*04e0dc4aSTimo Kreuzer )
1513*04e0dc4aSTimo Kreuzer {
1514*04e0dc4aSTimo Kreuzer if (c < 256)
1515*04e0dc4aSTimo Kreuzer {
1516*04e0dc4aSTimo Kreuzer return _towupper_fast_internal((unsigned char) c, locale);
1517*04e0dc4aSTimo Kreuzer }
1518*04e0dc4aSTimo Kreuzer
1519*04e0dc4aSTimo Kreuzer return _towupper_l(c, locale);
1520*04e0dc4aSTimo Kreuzer }
1521*04e0dc4aSTimo Kreuzer
_towlower_fast_internal(_In_ unsigned char const c,_In_ _locale_t const locale)1522*04e0dc4aSTimo Kreuzer _Check_return_ __forceinline wint_t _towlower_fast_internal(
1523*04e0dc4aSTimo Kreuzer _In_ unsigned char const c,
1524*04e0dc4aSTimo Kreuzer _In_ _locale_t const locale
1525*04e0dc4aSTimo Kreuzer )
1526*04e0dc4aSTimo Kreuzer {
1527*04e0dc4aSTimo Kreuzer // Check for iswupper required because lower map assumes using narrow ctype categories.
1528*04e0dc4aSTimo Kreuzer // towlower uses a locale-sensitive transformation, but only if the wide character
1529*04e0dc4aSTimo Kreuzer // is considered uppercase in UTF-16.
1530*04e0dc4aSTimo Kreuzer // _wctype starts at EOF. Add one to map to characters.
1531*04e0dc4aSTimo Kreuzer if (_wctype[c + 1] & _UPPER)
1532*04e0dc4aSTimo Kreuzer {
1533*04e0dc4aSTimo Kreuzer return _tolower_fast_internal(c, locale);
1534*04e0dc4aSTimo Kreuzer }
1535*04e0dc4aSTimo Kreuzer
1536*04e0dc4aSTimo Kreuzer return c;
1537*04e0dc4aSTimo Kreuzer }
1538*04e0dc4aSTimo Kreuzer
_towlower_internal(_In_ unsigned short const c,_In_ _locale_t const locale)1539*04e0dc4aSTimo Kreuzer _Check_return_ inline wint_t _towlower_internal(
1540*04e0dc4aSTimo Kreuzer _In_ unsigned short const c,
1541*04e0dc4aSTimo Kreuzer _In_ _locale_t const locale
1542*04e0dc4aSTimo Kreuzer )
1543*04e0dc4aSTimo Kreuzer {
1544*04e0dc4aSTimo Kreuzer if (c < 256)
1545*04e0dc4aSTimo Kreuzer {
1546*04e0dc4aSTimo Kreuzer return _towlower_fast_internal((unsigned char) c, locale);
1547*04e0dc4aSTimo Kreuzer }
1548*04e0dc4aSTimo Kreuzer
1549*04e0dc4aSTimo Kreuzer return _towlower_l(c, locale);
1550*04e0dc4aSTimo Kreuzer }
1551*04e0dc4aSTimo Kreuzer
_ctype_fast_check_internal(_In_ unsigned char const c,_In_ int const _Mask,_In_ _locale_t const locale)1552*04e0dc4aSTimo Kreuzer _Check_return_ __forceinline unsigned short __cdecl _ctype_fast_check_internal(
1553*04e0dc4aSTimo Kreuzer _In_ unsigned char const c,
1554*04e0dc4aSTimo Kreuzer _In_ int const _Mask,
1555*04e0dc4aSTimo Kreuzer _In_ _locale_t const locale
1556*04e0dc4aSTimo Kreuzer )
1557*04e0dc4aSTimo Kreuzer {
1558*04e0dc4aSTimo Kreuzer return locale->locinfo->_public._locale_pctype[c] & _Mask;
1559*04e0dc4aSTimo Kreuzer }
1560*04e0dc4aSTimo Kreuzer
_isdigit_fast_internal(_In_ unsigned char const c,_In_ _locale_t const locale)1561*04e0dc4aSTimo Kreuzer _Check_return_ __forceinline unsigned short __cdecl _isdigit_fast_internal(
1562*04e0dc4aSTimo Kreuzer _In_ unsigned char const c,
1563*04e0dc4aSTimo Kreuzer _In_ _locale_t const locale
1564*04e0dc4aSTimo Kreuzer )
1565*04e0dc4aSTimo Kreuzer {
1566*04e0dc4aSTimo Kreuzer return _ctype_fast_check_internal(c, _DIGIT, locale);
1567*04e0dc4aSTimo Kreuzer }
1568*04e0dc4aSTimo Kreuzer
1569*04e0dc4aSTimo Kreuzer // isleadbyte has a macro that casts the first argument to unsigned char
1570*04e0dc4aSTimo Kreuzer // Instead of using _isleadbyte_l (which requires the caller to cast to unsigned char),
1571*04e0dc4aSTimo Kreuzer // use _isleadbyte_fast_internal to prevent any unintentional casting errors that may occur.
1572*04e0dc4aSTimo Kreuzer // As long as the locale is already updated via _LocaleUpdate or retrieved from __crt_cached_ptd_host,
1573*04e0dc4aSTimo Kreuzer // this function is safe to use.
1574*04e0dc4aSTimo Kreuzer #define _isleadbyte_l(_C, _L) use_isleadbyte_fast_internal_instead_to_prevent_casting_errors()
1575*04e0dc4aSTimo Kreuzer
_isleadbyte_fast_internal(_In_ unsigned char const c,_In_ _locale_t const locale)1576*04e0dc4aSTimo Kreuzer _Check_return_ __forceinline unsigned short __cdecl _isleadbyte_fast_internal(
1577*04e0dc4aSTimo Kreuzer _In_ unsigned char const c,
1578*04e0dc4aSTimo Kreuzer _In_ _locale_t const locale
1579*04e0dc4aSTimo Kreuzer )
1580*04e0dc4aSTimo Kreuzer {
1581*04e0dc4aSTimo Kreuzer return _ctype_fast_check_internal(c, _LEADBYTE, locale);
1582*04e0dc4aSTimo Kreuzer }
1583*04e0dc4aSTimo Kreuzer
1584*04e0dc4aSTimo Kreuzer
1585*04e0dc4aSTimo Kreuzer //-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1586*04e0dc4aSTimo Kreuzer //
1587*04e0dc4aSTimo Kreuzer // Invalid Parameter Macros
1588*04e0dc4aSTimo Kreuzer //
1589*04e0dc4aSTimo Kreuzer //-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1590*04e0dc4aSTimo Kreuzer // Invoke Watson if _ExpressionError is not 0; otherwise simply return
1591*04e0dc4aSTimo Kreuzer // _ExpressionError.
1592*04e0dc4aSTimo Kreuzer _CRT_SECURITYCRITICAL_ATTRIBUTE
_invoke_watson_if_error(_In_ errno_t expression_error,_In_opt_z_ wchar_t const * expression,_In_opt_z_ wchar_t const * function_name,_In_opt_z_ wchar_t const * file_name,_In_ unsigned int line_number,_In_ uintptr_t reserved)1593*04e0dc4aSTimo Kreuzer __forceinline void _invoke_watson_if_error(
1594*04e0dc4aSTimo Kreuzer _In_ errno_t expression_error,
1595*04e0dc4aSTimo Kreuzer _In_opt_z_ wchar_t const* expression,
1596*04e0dc4aSTimo Kreuzer _In_opt_z_ wchar_t const* function_name,
1597*04e0dc4aSTimo Kreuzer _In_opt_z_ wchar_t const* file_name,
1598*04e0dc4aSTimo Kreuzer _In_ unsigned int line_number,
1599*04e0dc4aSTimo Kreuzer _In_ uintptr_t reserved
1600*04e0dc4aSTimo Kreuzer )
1601*04e0dc4aSTimo Kreuzer {
1602*04e0dc4aSTimo Kreuzer if (expression_error == 0)
1603*04e0dc4aSTimo Kreuzer {
1604*04e0dc4aSTimo Kreuzer return;
1605*04e0dc4aSTimo Kreuzer }
1606*04e0dc4aSTimo Kreuzer
1607*04e0dc4aSTimo Kreuzer _invoke_watson(expression, function_name, file_name, line_number, reserved);
1608*04e0dc4aSTimo Kreuzer }
1609*04e0dc4aSTimo Kreuzer
1610*04e0dc4aSTimo Kreuzer // Invoke Watson if _ExpressionError is not 0 and equal to _ErrorValue1 or
1611*04e0dc4aSTimo Kreuzer // _ErrorValue2; otherwise simply return _EspressionError.
_invoke_watson_if_oneof(_In_ errno_t expression_error,_In_ errno_t error_value1,_In_ errno_t error_value2,_In_opt_z_ wchar_t const * expression,_In_opt_z_ wchar_t const * function_name,_In_opt_z_ wchar_t const * file_name,_In_ unsigned int line_number,_In_ uintptr_t reserved)1612*04e0dc4aSTimo Kreuzer __forceinline errno_t _invoke_watson_if_oneof(
1613*04e0dc4aSTimo Kreuzer _In_ errno_t expression_error,
1614*04e0dc4aSTimo Kreuzer _In_ errno_t error_value1,
1615*04e0dc4aSTimo Kreuzer _In_ errno_t error_value2,
1616*04e0dc4aSTimo Kreuzer _In_opt_z_ wchar_t const* expression,
1617*04e0dc4aSTimo Kreuzer _In_opt_z_ wchar_t const* function_name,
1618*04e0dc4aSTimo Kreuzer _In_opt_z_ wchar_t const* file_name,
1619*04e0dc4aSTimo Kreuzer _In_ unsigned int line_number,
1620*04e0dc4aSTimo Kreuzer _In_ uintptr_t reserved
1621*04e0dc4aSTimo Kreuzer )
1622*04e0dc4aSTimo Kreuzer {
1623*04e0dc4aSTimo Kreuzer if (expression_error == 0 || (expression_error != error_value1 && expression_error != error_value2))
1624*04e0dc4aSTimo Kreuzer {
1625*04e0dc4aSTimo Kreuzer return expression_error;
1626*04e0dc4aSTimo Kreuzer }
1627*04e0dc4aSTimo Kreuzer
1628*04e0dc4aSTimo Kreuzer _invoke_watson(expression, function_name, file_name, line_number, reserved);
1629*04e0dc4aSTimo Kreuzer }
1630*04e0dc4aSTimo Kreuzer
1631*04e0dc4aSTimo Kreuzer #ifdef _DEBUG
1632*04e0dc4aSTimo Kreuzer #define _INVOKE_WATSON_IF_ERROR(expr) _invoke_watson_if_error((expr), _CRT_WIDE(#expr), __FUNCTIONW__, __FILEW__, __LINE__, 0)
1633*04e0dc4aSTimo Kreuzer #define _INVOKE_WATSON_IF_ONEOF(expr, errvalue1, errvalue2) _invoke_watson_if_oneof(expr, (errvalue1), (errvalue2), _CRT_WIDE(#expr), __FUNCTIONW__, __FILEW__, __LINE__, 0)
1634*04e0dc4aSTimo Kreuzer #else
1635*04e0dc4aSTimo Kreuzer #define _INVOKE_WATSON_IF_ERROR(expr) _invoke_watson_if_error(expr, NULL, NULL, NULL, 0, 0)
1636*04e0dc4aSTimo Kreuzer #define _INVOKE_WATSON_IF_ONEOF(expr, errvalue1, errvalue2) _invoke_watson_if_oneof((expr), (errvalue1), (errvalue2), NULL, NULL, NULL, 0, 0)
1637*04e0dc4aSTimo Kreuzer #endif
1638*04e0dc4aSTimo Kreuzer
1639*04e0dc4aSTimo Kreuzer #define _ERRCHECK(e) _INVOKE_WATSON_IF_ERROR(e)
1640*04e0dc4aSTimo Kreuzer #define _ERRCHECK_EINVAL(e) _INVOKE_WATSON_IF_ONEOF(e, EINVAL, EINVAL)
1641*04e0dc4aSTimo Kreuzer #define _ERRCHECK_EINVAL_ERANGE(e) _INVOKE_WATSON_IF_ONEOF(e, EINVAL, ERANGE)
1642*04e0dc4aSTimo Kreuzer
1643*04e0dc4aSTimo Kreuzer #define _ERRCHECK_SPRINTF(_PrintfCall) \
1644*04e0dc4aSTimo Kreuzer { \
1645*04e0dc4aSTimo Kreuzer errno_t _SaveErrno = errno; \
1646*04e0dc4aSTimo Kreuzer errno = 0; \
1647*04e0dc4aSTimo Kreuzer if ((_PrintfCall) < 0) \
1648*04e0dc4aSTimo Kreuzer { \
1649*04e0dc4aSTimo Kreuzer _ERRCHECK_EINVAL_ERANGE(errno); \
1650*04e0dc4aSTimo Kreuzer } \
1651*04e0dc4aSTimo Kreuzer errno = _SaveErrno; \
1652*04e0dc4aSTimo Kreuzer }
1653*04e0dc4aSTimo Kreuzer
1654*04e0dc4aSTimo Kreuzer
1655*04e0dc4aSTimo Kreuzer
1656*04e0dc4aSTimo Kreuzer //-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1657*04e0dc4aSTimo Kreuzer //
1658*04e0dc4aSTimo Kreuzer // SecureCRT
1659*04e0dc4aSTimo Kreuzer //
1660*04e0dc4aSTimo Kreuzer //-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1661*04e0dc4aSTimo Kreuzer // We completely fill the buffer only in debug (see _SECURECRT__FILL_STRING and
1662*04e0dc4aSTimo Kreuzer // _SECURECRT__FILL_BYTE macros).
1663*04e0dc4aSTimo Kreuzer #ifndef _SECURECRT_FILL_BUFFER
1664*04e0dc4aSTimo Kreuzer #ifdef _DEBUG
1665*04e0dc4aSTimo Kreuzer #define _SECURECRT_FILL_BUFFER 1
1666*04e0dc4aSTimo Kreuzer #else
1667*04e0dc4aSTimo Kreuzer #define _SECURECRT_FILL_BUFFER 0
1668*04e0dc4aSTimo Kreuzer #endif
1669*04e0dc4aSTimo Kreuzer #endif
1670*04e0dc4aSTimo Kreuzer
1671*04e0dc4aSTimo Kreuzer #ifndef _SECURECRT_FILL_BUFFER_THRESHOLD
1672*04e0dc4aSTimo Kreuzer // _SECURECRT_FILL_BUFFER_THRESHOLD must be a constant for Prefast due to the
1673*04e0dc4aSTimo Kreuzer // double evaluation. Making it something unique like 42 would pollute Prefast's warnings.
1674*04e0dc4aSTimo Kreuzer #if defined _PREFAST_ || !defined _DEBUG
1675*04e0dc4aSTimo Kreuzer #define _SECURECRT_FILL_BUFFER_THRESHOLD ((size_t)0)
1676*04e0dc4aSTimo Kreuzer #else
1677*04e0dc4aSTimo Kreuzer #define _SECURECRT_FILL_BUFFER_THRESHOLD (_CrtGetDebugFillThreshold())
1678*04e0dc4aSTimo Kreuzer #endif
1679*04e0dc4aSTimo Kreuzer #endif
1680*04e0dc4aSTimo Kreuzer
1681*04e0dc4aSTimo Kreuzer // TODO make this a template so that _CrtGetDebugFillThreshold is not called multiple times.
1682*04e0dc4aSTimo Kreuzer #if _SECURECRT_FILL_BUFFER
1683*04e0dc4aSTimo Kreuzer #define _SECURECRT__FILL_STRING(_String, _Count, _Offset) \
1684*04e0dc4aSTimo Kreuzer if ((_Count) != ((size_t)-1) && \
1685*04e0dc4aSTimo Kreuzer (_Count) != INT_MAX && \
1686*04e0dc4aSTimo Kreuzer ((size_t)(_Offset)) < (_Count)) \
1687*04e0dc4aSTimo Kreuzer { \
1688*04e0dc4aSTimo Kreuzer size_t max_buffer_count = _SECURECRT_FILL_BUFFER_THRESHOLD; \
1689*04e0dc4aSTimo Kreuzer memset( \
1690*04e0dc4aSTimo Kreuzer (_String) + (_Offset), \
1691*04e0dc4aSTimo Kreuzer _SECURECRT_FILL_BUFFER_PATTERN, \
1692*04e0dc4aSTimo Kreuzer (max_buffer_count < ((size_t)((_Count) - (_Offset))) \
1693*04e0dc4aSTimo Kreuzer ? max_buffer_count \
1694*04e0dc4aSTimo Kreuzer : ((_Count) - (_Offset))) * sizeof(*(_String))); \
1695*04e0dc4aSTimo Kreuzer }
1696*04e0dc4aSTimo Kreuzer #else
1697*04e0dc4aSTimo Kreuzer #define _SECURECRT__FILL_STRING(_String, _Count, _Offset)
1698*04e0dc4aSTimo Kreuzer #endif
1699*04e0dc4aSTimo Kreuzer
1700*04e0dc4aSTimo Kreuzer #if _SECURECRT_FILL_BUFFER
1701*04e0dc4aSTimo Kreuzer #define _SECURECRT__FILL_BYTE(_Position) \
1702*04e0dc4aSTimo Kreuzer if (_SECURECRT_FILL_BUFFER_THRESHOLD > 0) \
1703*04e0dc4aSTimo Kreuzer { \
1704*04e0dc4aSTimo Kreuzer (_Position) = _SECURECRT_FILL_BUFFER_PATTERN; \
1705*04e0dc4aSTimo Kreuzer }
1706*04e0dc4aSTimo Kreuzer #else
1707*04e0dc4aSTimo Kreuzer #define _SECURECRT__FILL_BYTE(_Position)
1708*04e0dc4aSTimo Kreuzer #endif
1709*04e0dc4aSTimo Kreuzer
1710*04e0dc4aSTimo Kreuzer //-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1711*04e0dc4aSTimo Kreuzer //
1712*04e0dc4aSTimo Kreuzer // Precondition Validation Macros
1713*04e0dc4aSTimo Kreuzer //
1714*04e0dc4aSTimo Kreuzer //-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1715*04e0dc4aSTimo Kreuzer // We use _VALIDATE_STREAM_ANSI_RETURN to ensure that ANSI file operations (e.g.
1716*04e0dc4aSTimo Kreuzer // fprintf) aren't called on files opened as UNICODE. We do this check only if
1717*04e0dc4aSTimo Kreuzer // it's an actual FILE pointer & not a string.
1718*04e0dc4aSTimo Kreuzer #define _VALIDATE_STREAM_ANSI_RETURN(stream, errorcode, retexpr) \
1719*04e0dc4aSTimo Kreuzer { \
1720*04e0dc4aSTimo Kreuzer __crt_stdio_stream const _Stream(stream); \
1721*04e0dc4aSTimo Kreuzer int fn; \
1722*04e0dc4aSTimo Kreuzer _VALIDATE_RETURN(( \
1723*04e0dc4aSTimo Kreuzer (_Stream.is_string_backed()) || \
1724*04e0dc4aSTimo Kreuzer (fn = _fileno(_Stream.public_stream()), \
1725*04e0dc4aSTimo Kreuzer ((_textmode_safe(fn) == __crt_lowio_text_mode::ansi) && \
1726*04e0dc4aSTimo Kreuzer !_tm_unicode_safe(fn)))), \
1727*04e0dc4aSTimo Kreuzer errorcode, retexpr) \
1728*04e0dc4aSTimo Kreuzer }
1729*04e0dc4aSTimo Kreuzer
1730*04e0dc4aSTimo Kreuzer #define _CHECK_FH_RETURN( handle, errorcode, retexpr ) \
1731*04e0dc4aSTimo Kreuzer { \
1732*04e0dc4aSTimo Kreuzer if(handle == _NO_CONSOLE_FILENO) \
1733*04e0dc4aSTimo Kreuzer { \
1734*04e0dc4aSTimo Kreuzer errno = errorcode; \
1735*04e0dc4aSTimo Kreuzer return ( retexpr ); \
1736*04e0dc4aSTimo Kreuzer } \
1737*04e0dc4aSTimo Kreuzer }
1738*04e0dc4aSTimo Kreuzer
1739*04e0dc4aSTimo Kreuzer #define _CHECK_FH_CLEAR_OSSERR_RETURN( handle, errorcode, retexpr ) \
1740*04e0dc4aSTimo Kreuzer { \
1741*04e0dc4aSTimo Kreuzer if(handle == _NO_CONSOLE_FILENO) \
1742*04e0dc4aSTimo Kreuzer { \
1743*04e0dc4aSTimo Kreuzer _doserrno = 0L; \
1744*04e0dc4aSTimo Kreuzer errno = errorcode; \
1745*04e0dc4aSTimo Kreuzer return ( retexpr ); \
1746*04e0dc4aSTimo Kreuzer } \
1747*04e0dc4aSTimo Kreuzer }
1748*04e0dc4aSTimo Kreuzer
1749*04e0dc4aSTimo Kreuzer #define _CHECK_FH_CLEAR_OSSERR_RETURN_ERRCODE( handle, retexpr ) \
1750*04e0dc4aSTimo Kreuzer { \
1751*04e0dc4aSTimo Kreuzer if(handle == _NO_CONSOLE_FILENO) \
1752*04e0dc4aSTimo Kreuzer { \
1753*04e0dc4aSTimo Kreuzer _doserrno = 0L; \
1754*04e0dc4aSTimo Kreuzer return ( retexpr ); \
1755*04e0dc4aSTimo Kreuzer } \
1756*04e0dc4aSTimo Kreuzer }
1757*04e0dc4aSTimo Kreuzer
1758*04e0dc4aSTimo Kreuzer
1759*04e0dc4aSTimo Kreuzer
1760*04e0dc4aSTimo Kreuzer //-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1761*04e0dc4aSTimo Kreuzer //
1762*04e0dc4aSTimo Kreuzer // Redirect-to-Locale Macros
1763*04e0dc4aSTimo Kreuzer //
1764*04e0dc4aSTimo Kreuzer //-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1765*04e0dc4aSTimo Kreuzer #ifdef __cplusplus
1766*04e0dc4aSTimo Kreuzer #define _REDIRECT_TO_L_VERSION_FUNC_PROLOGUE extern "C"
1767*04e0dc4aSTimo Kreuzer #else
1768*04e0dc4aSTimo Kreuzer #define _REDIRECT_TO_L_VERSION_FUNC_PROLOGUE
1769*04e0dc4aSTimo Kreuzer #endif
1770*04e0dc4aSTimo Kreuzer
1771*04e0dc4aSTimo Kreuzer #define _REDIRECT_TO_L_VERSION_1(_ReturnType, _FunctionName, _Type1) \
1772*04e0dc4aSTimo Kreuzer _REDIRECT_TO_L_VERSION_FUNC_PROLOGUE \
1773*04e0dc4aSTimo Kreuzer _ReturnType __cdecl _FunctionName(_Type1 _Arg1) \
1774*04e0dc4aSTimo Kreuzer { \
1775*04e0dc4aSTimo Kreuzer return _FunctionName##_l(_Arg1, NULL); \
1776*04e0dc4aSTimo Kreuzer }
1777*04e0dc4aSTimo Kreuzer
1778*04e0dc4aSTimo Kreuzer #define _REDIRECT_TO_L_VERSION_2(_ReturnType, _FunctionName, _Type1, _Type2) \
1779*04e0dc4aSTimo Kreuzer _REDIRECT_TO_L_VERSION_FUNC_PROLOGUE \
1780*04e0dc4aSTimo Kreuzer _ReturnType __cdecl _FunctionName(_Type1 _Arg1, _Type2 _Arg2) \
1781*04e0dc4aSTimo Kreuzer { \
1782*04e0dc4aSTimo Kreuzer return _FunctionName##_l(_Arg1, _Arg2, NULL); \
1783*04e0dc4aSTimo Kreuzer }
1784*04e0dc4aSTimo Kreuzer
1785*04e0dc4aSTimo Kreuzer #define _REDIRECT_TO_L_VERSION_3(_ReturnType, _FunctionName, _Type1, _Type2, _Type3) \
1786*04e0dc4aSTimo Kreuzer _REDIRECT_TO_L_VERSION_FUNC_PROLOGUE \
1787*04e0dc4aSTimo Kreuzer _ReturnType __cdecl _FunctionName(_Type1 _Arg1, _Type2 _Arg2, _Type3 _Arg3) \
1788*04e0dc4aSTimo Kreuzer { \
1789*04e0dc4aSTimo Kreuzer return _FunctionName##_l(_Arg1, _Arg2, _Arg3, NULL); \
1790*04e0dc4aSTimo Kreuzer }
1791*04e0dc4aSTimo Kreuzer
1792*04e0dc4aSTimo Kreuzer #define _REDIRECT_TO_L_VERSION_4(_ReturnType, _FunctionName, _Type1, _Type2, _Type3, _Type4) \
1793*04e0dc4aSTimo Kreuzer _REDIRECT_TO_L_VERSION_FUNC_PROLOGUE \
1794*04e0dc4aSTimo Kreuzer _ReturnType __cdecl _FunctionName(_Type1 _Arg1, _Type2 _Arg2, _Type3 _Arg3, _Type4 _Arg4) \
1795*04e0dc4aSTimo Kreuzer { \
1796*04e0dc4aSTimo Kreuzer return _FunctionName##_l(_Arg1, _Arg2, _Arg3, _Arg4, NULL); \
1797*04e0dc4aSTimo Kreuzer }
1798*04e0dc4aSTimo Kreuzer
1799*04e0dc4aSTimo Kreuzer
1800*04e0dc4aSTimo Kreuzer
1801*04e0dc4aSTimo Kreuzer #ifdef __cplusplus
1802*04e0dc4aSTimo Kreuzer extern "C++"
1803*04e0dc4aSTimo Kreuzer {
1804*04e0dc4aSTimo Kreuzer //-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1805*04e0dc4aSTimo Kreuzer //
1806*04e0dc4aSTimo Kreuzer // Forward declare PTD propagation host
1807*04e0dc4aSTimo Kreuzer //
1808*04e0dc4aSTimo Kreuzer // To use the PTD propagation utilities, include corecrt_internal_ptd_propagation.h.
1809*04e0dc4aSTimo Kreuzer // That header also opts into removing old validation macros that would use errno,
1810*04e0dc4aSTimo Kreuzer // so the __crt_cached_ptd_host is declared here so that headers don't need to be fully converted.
1811*04e0dc4aSTimo Kreuzer //
1812*04e0dc4aSTimo Kreuzer //-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1813*04e0dc4aSTimo Kreuzer
1814*04e0dc4aSTimo Kreuzer class __crt_cached_ptd_host;
1815*04e0dc4aSTimo Kreuzer
1816*04e0dc4aSTimo Kreuzer //-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1817*04e0dc4aSTimo Kreuzer //
1818*04e0dc4aSTimo Kreuzer // Internals with PTD propagation
1819*04e0dc4aSTimo Kreuzer //
1820*04e0dc4aSTimo Kreuzer //-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1821*04e0dc4aSTimo Kreuzer
1822*04e0dc4aSTimo Kreuzer extern "C" void __cdecl __acrt_errno_map_os_error_ptd(unsigned long, __crt_cached_ptd_host&);
1823*04e0dc4aSTimo Kreuzer
1824*04e0dc4aSTimo Kreuzer extern "C" void __cdecl _invalid_parameter_internal(
1825*04e0dc4aSTimo Kreuzer _In_opt_z_ wchar_t const*,
1826*04e0dc4aSTimo Kreuzer _In_opt_z_ wchar_t const*,
1827*04e0dc4aSTimo Kreuzer _In_opt_z_ wchar_t const*,
1828*04e0dc4aSTimo Kreuzer _In_ unsigned int,
1829*04e0dc4aSTimo Kreuzer _In_ uintptr_t,
1830*04e0dc4aSTimo Kreuzer _Inout_ __crt_cached_ptd_host&
1831*04e0dc4aSTimo Kreuzer );
1832*04e0dc4aSTimo Kreuzer
1833*04e0dc4aSTimo Kreuzer //-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1834*04e0dc4aSTimo Kreuzer //
1835*04e0dc4aSTimo Kreuzer // Locale Update
1836*04e0dc4aSTimo Kreuzer //
1837*04e0dc4aSTimo Kreuzer //-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1838*04e0dc4aSTimo Kreuzer extern "C" void __acrt_update_locale_info(
1839*04e0dc4aSTimo Kreuzer _In_ __acrt_ptd* const ptd,
1840*04e0dc4aSTimo Kreuzer _Inout_ __crt_locale_data** const data
1841*04e0dc4aSTimo Kreuzer );
1842*04e0dc4aSTimo Kreuzer
1843*04e0dc4aSTimo Kreuzer extern "C" void __acrt_update_multibyte_info(
1844*04e0dc4aSTimo Kreuzer _In_ __acrt_ptd* const ptd,
1845*04e0dc4aSTimo Kreuzer _Inout_ __crt_multibyte_data** const data
1846*04e0dc4aSTimo Kreuzer );
1847*04e0dc4aSTimo Kreuzer
1848*04e0dc4aSTimo Kreuzer // Querying the global state index queries TLS.
1849*04e0dc4aSTimo Kreuzer // If the global state index is known, use the explicit functions to avoid a GetFlsValue call.
1850*04e0dc4aSTimo Kreuzer extern "C" void __acrt_update_locale_info_explicit(
1851*04e0dc4aSTimo Kreuzer _In_ __acrt_ptd* const ptd,
1852*04e0dc4aSTimo Kreuzer _Inout_ __crt_locale_data** const data,
1853*04e0dc4aSTimo Kreuzer _In_ size_t const current_global_state_index
1854*04e0dc4aSTimo Kreuzer );
1855*04e0dc4aSTimo Kreuzer
1856*04e0dc4aSTimo Kreuzer extern "C" void __acrt_update_multibyte_info_explicit(
1857*04e0dc4aSTimo Kreuzer _In_ __acrt_ptd* const ptd,
1858*04e0dc4aSTimo Kreuzer _Inout_ __crt_multibyte_data** const data,
1859*04e0dc4aSTimo Kreuzer _In_ size_t const current_global_state_index
1860*04e0dc4aSTimo Kreuzer );
1861*04e0dc4aSTimo Kreuzer
__acrt_should_sync_with_global_locale(_In_ __acrt_ptd * const ptd)1862*04e0dc4aSTimo Kreuzer extern "C" __inline bool __acrt_should_sync_with_global_locale(
1863*04e0dc4aSTimo Kreuzer _In_ __acrt_ptd* const ptd
1864*04e0dc4aSTimo Kreuzer )
1865*04e0dc4aSTimo Kreuzer {
1866*04e0dc4aSTimo Kreuzer // Check whether per-thread locales are enabled either:
1867*04e0dc4aSTimo Kreuzer // * On the thread (_ptd->_own_locale & _PER_THREAD_LOCALE_BIT is set)
1868*04e0dc4aSTimo Kreuzer // * Globally (__globallocalestatus & _GLOBAL_LOCALE_BIT is set)
1869*04e0dc4aSTimo Kreuzer
1870*04e0dc4aSTimo Kreuzer // If neither are enabled then we want to check the global locale setting
1871*04e0dc4aSTimo Kreuzer // and synchronize it to our per-thread-data.
1872*04e0dc4aSTimo Kreuzer
1873*04e0dc4aSTimo Kreuzer // _own_locale
1874*04e0dc4aSTimo Kreuzer // bits: 000000000000000000000000 000W 00P1
1875*04e0dc4aSTimo Kreuzer // P is set after _configthreadlocale(_ENABLE_PER_THREAD_LOCALE).
1876*04e0dc4aSTimo Kreuzer // W is set in _wsetlocale to prevent resynchronization during _wsetlocale.
1877*04e0dc4aSTimo Kreuzer // Note that this means when _wsetlocale is ask whether it should to synchronize,
1878*04e0dc4aSTimo Kreuzer // it should not use __acrt_should_sync_with_global_locale.
1879*04e0dc4aSTimo Kreuzer
1880*04e0dc4aSTimo Kreuzer // __globallocalestatus
1881*04e0dc4aSTimo Kreuzer // bits: 111111111111111111111111 1111 1N1G
1882*04e0dc4aSTimo Kreuzer // G is set if threadlocale.obj was linked to (via _configthreadlocale(-1)).
1883*04e0dc4aSTimo Kreuzer // N is whether new locales use the global locale and is unrelated to locale ptd sync.
1884*04e0dc4aSTimo Kreuzer
1885*04e0dc4aSTimo Kreuzer // if _ENABLE_PER_THREAD_LOCALE is not set and threadlocale.obj is not linked to
1886*04e0dc4aSTimo Kreuzer return (ptd->_own_locale & __globallocalestatus) == 0;
1887*04e0dc4aSTimo Kreuzer }
1888*04e0dc4aSTimo Kreuzer
1889*04e0dc4aSTimo Kreuzer // The per-thread locale is sometimes temporarily protected from resynchronization from
1890*04e0dc4aSTimo Kreuzer // the global locale to ensure calling the public API surface without locale information
1891*04e0dc4aSTimo Kreuzer // will not cause the locale to be reloaded half way through a call.
1892*04e0dc4aSTimo Kreuzer
1893*04e0dc4aSTimo Kreuzer // This is only to protect us from ourselves - a future change can correct the need for these calls.
1894*04e0dc4aSTimo Kreuzer // Allows different 'bit_value' so that _wsetlocale can also use this.
1895*04e0dc4aSTimo Kreuzer extern "C" __inline void __acrt_disable_global_locale_sync(
1896*04e0dc4aSTimo Kreuzer _In_ __acrt_ptd* const ptd,
1897*04e0dc4aSTimo Kreuzer _In_ int const bit_value = _PER_THREAD_LOCALE_BIT
1898*04e0dc4aSTimo Kreuzer )
1899*04e0dc4aSTimo Kreuzer {
1900*04e0dc4aSTimo Kreuzer ptd->_own_locale |= bit_value;
1901*04e0dc4aSTimo Kreuzer }
1902*04e0dc4aSTimo Kreuzer
1903*04e0dc4aSTimo Kreuzer extern "C" __inline void __acrt_enable_global_locale_sync(
1904*04e0dc4aSTimo Kreuzer _In_ __acrt_ptd* const ptd,
1905*04e0dc4aSTimo Kreuzer _In_ int const bit_value = _PER_THREAD_LOCALE_BIT
1906*04e0dc4aSTimo Kreuzer )
1907*04e0dc4aSTimo Kreuzer {
1908*04e0dc4aSTimo Kreuzer ptd->_own_locale &= ~bit_value;
1909*04e0dc4aSTimo Kreuzer }
1910*04e0dc4aSTimo Kreuzer
1911*04e0dc4aSTimo Kreuzer class _LocaleUpdate
1912*04e0dc4aSTimo Kreuzer { // Retained for old code paths - updating/locking/unlocking locale
1913*04e0dc4aSTimo Kreuzer // in every function is costly.
1914*04e0dc4aSTimo Kreuzer // Prefer using __crt_cached_ptd_host&.
1915*04e0dc4aSTimo Kreuzer public:
1916*04e0dc4aSTimo Kreuzer
_LocaleUpdate(_locale_t const locale)1917*04e0dc4aSTimo Kreuzer explicit _LocaleUpdate(_locale_t const locale) throw()
1918*04e0dc4aSTimo Kreuzer : _updated(false)
1919*04e0dc4aSTimo Kreuzer {
1920*04e0dc4aSTimo Kreuzer if (locale)
1921*04e0dc4aSTimo Kreuzer {
1922*04e0dc4aSTimo Kreuzer _locale_pointers = *locale;
1923*04e0dc4aSTimo Kreuzer }
1924*04e0dc4aSTimo Kreuzer else if (!__acrt_locale_changed())
1925*04e0dc4aSTimo Kreuzer {
1926*04e0dc4aSTimo Kreuzer _locale_pointers = __acrt_initial_locale_pointers;
1927*04e0dc4aSTimo Kreuzer }
1928*04e0dc4aSTimo Kreuzer else
1929*04e0dc4aSTimo Kreuzer {
1930*04e0dc4aSTimo Kreuzer _ptd = __acrt_getptd();
1931*04e0dc4aSTimo Kreuzer _locale_pointers.locinfo = _ptd->_locale_info;
1932*04e0dc4aSTimo Kreuzer _locale_pointers.mbcinfo = _ptd->_multibyte_info;
1933*04e0dc4aSTimo Kreuzer
1934*04e0dc4aSTimo Kreuzer __acrt_update_locale_info (_ptd, &_locale_pointers.locinfo);
1935*04e0dc4aSTimo Kreuzer __acrt_update_multibyte_info(_ptd, &_locale_pointers.mbcinfo);
1936*04e0dc4aSTimo Kreuzer
1937*04e0dc4aSTimo Kreuzer if ((_ptd->_own_locale & _PER_THREAD_LOCALE_BIT) == 0)
1938*04e0dc4aSTimo Kreuzer {
1939*04e0dc4aSTimo Kreuzer // Skip re-synchronization with the global locale to prevent the
1940*04e0dc4aSTimo Kreuzer // locale from changing half-way through the call.
1941*04e0dc4aSTimo Kreuzer __acrt_disable_global_locale_sync(_ptd);
1942*04e0dc4aSTimo Kreuzer _updated = true;
1943*04e0dc4aSTimo Kreuzer }
1944*04e0dc4aSTimo Kreuzer }
1945*04e0dc4aSTimo Kreuzer }
1946*04e0dc4aSTimo Kreuzer
throw()1947*04e0dc4aSTimo Kreuzer ~_LocaleUpdate() throw()
1948*04e0dc4aSTimo Kreuzer {
1949*04e0dc4aSTimo Kreuzer if (_updated)
1950*04e0dc4aSTimo Kreuzer {
1951*04e0dc4aSTimo Kreuzer __acrt_enable_global_locale_sync(_ptd);
1952*04e0dc4aSTimo Kreuzer }
1953*04e0dc4aSTimo Kreuzer }
1954*04e0dc4aSTimo Kreuzer
GetLocaleT()1955*04e0dc4aSTimo Kreuzer _locale_t GetLocaleT() throw()
1956*04e0dc4aSTimo Kreuzer {
1957*04e0dc4aSTimo Kreuzer return &_locale_pointers;
1958*04e0dc4aSTimo Kreuzer }
1959*04e0dc4aSTimo Kreuzer
1960*04e0dc4aSTimo Kreuzer private:
1961*04e0dc4aSTimo Kreuzer
1962*04e0dc4aSTimo Kreuzer __acrt_ptd* _ptd;
1963*04e0dc4aSTimo Kreuzer // Using the locale data from the PTD ensures their lifetime
1964*04e0dc4aSTimo Kreuzer // will last through the end of the call - no need to increment/decrement reference count.
1965*04e0dc4aSTimo Kreuzer __crt_locale_pointers _locale_pointers;
1966*04e0dc4aSTimo Kreuzer bool _updated;
1967*04e0dc4aSTimo Kreuzer
1968*04e0dc4aSTimo Kreuzer };
1969*04e0dc4aSTimo Kreuzer
1970*04e0dc4aSTimo Kreuzer
1971*04e0dc4aSTimo Kreuzer //-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1972*04e0dc4aSTimo Kreuzer //
1973*04e0dc4aSTimo Kreuzer // errno Cache
1974*04e0dc4aSTimo Kreuzer //
1975*04e0dc4aSTimo Kreuzer //-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1976*04e0dc4aSTimo Kreuzer // Some operations in this file may need to set or query errno many times. Each
1977*04e0dc4aSTimo Kreuzer // use of errno requires us to get the PTD from FLS. To avoid having to do this
1978*04e0dc4aSTimo Kreuzer // many times, we cache the pointer to errno. This class encapsulates that
1979*04e0dc4aSTimo Kreuzer // caching and also defers the initial acquisition of &errno until the first
1980*04e0dc4aSTimo Kreuzer // time that errno is actually needed (when we aren't calling functions that may
1981*04e0dc4aSTimo Kreuzer // set errno, there's no need to acquire errno at all).
1982*04e0dc4aSTimo Kreuzer class __crt_deferred_errno_cache
1983*04e0dc4aSTimo Kreuzer { // Retained for old code paths - querying errno is a performance issue.
1984*04e0dc4aSTimo Kreuzer // Prefer using __crt_cached_ptd_host&.
1985*04e0dc4aSTimo Kreuzer public:
1986*04e0dc4aSTimo Kreuzer
__crt_deferred_errno_cache()1987*04e0dc4aSTimo Kreuzer __crt_deferred_errno_cache() throw()
1988*04e0dc4aSTimo Kreuzer : _cached_errno{}
1989*04e0dc4aSTimo Kreuzer {
1990*04e0dc4aSTimo Kreuzer }
1991*04e0dc4aSTimo Kreuzer
get()1992*04e0dc4aSTimo Kreuzer errno_t& get() throw()
1993*04e0dc4aSTimo Kreuzer {
1994*04e0dc4aSTimo Kreuzer if (!_cached_errno)
1995*04e0dc4aSTimo Kreuzer {
1996*04e0dc4aSTimo Kreuzer _cached_errno = &errno;
1997*04e0dc4aSTimo Kreuzer }
1998*04e0dc4aSTimo Kreuzer
1999*04e0dc4aSTimo Kreuzer return *_cached_errno;
2000*04e0dc4aSTimo Kreuzer }
2001*04e0dc4aSTimo Kreuzer
2002*04e0dc4aSTimo Kreuzer private:
2003*04e0dc4aSTimo Kreuzer
2004*04e0dc4aSTimo Kreuzer errno_t* _cached_errno;
2005*04e0dc4aSTimo Kreuzer };
2006*04e0dc4aSTimo Kreuzer
2007*04e0dc4aSTimo Kreuzer
2008*04e0dc4aSTimo Kreuzer
2009*04e0dc4aSTimo Kreuzer //-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2010*04e0dc4aSTimo Kreuzer //
2011*04e0dc4aSTimo Kreuzer // errno and LastError Reset
2012*04e0dc4aSTimo Kreuzer //
2013*04e0dc4aSTimo Kreuzer //-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2014*04e0dc4aSTimo Kreuzer #ifndef _M_CEE
2015*04e0dc4aSTimo Kreuzer
2016*04e0dc4aSTimo Kreuzer struct __crt_errno_guard
2017*04e0dc4aSTimo Kreuzer { // Retained for old code paths - querying errno is a performance issue.
2018*04e0dc4aSTimo Kreuzer // Prefer using __crt_cached_ptd_host& (via ->get_errno().create_guard()).
2019*04e0dc4aSTimo Kreuzer public:
2020*04e0dc4aSTimo Kreuzer
throw__crt_errno_guard2021*04e0dc4aSTimo Kreuzer __crt_errno_guard(errno_t* const errno_address = &errno) throw()
2022*04e0dc4aSTimo Kreuzer : _errno_address(errno_address), _stored_errno(*errno_address)
2023*04e0dc4aSTimo Kreuzer {
2024*04e0dc4aSTimo Kreuzer *errno_address = 0;
2025*04e0dc4aSTimo Kreuzer }
2026*04e0dc4aSTimo Kreuzer
throw__crt_errno_guard2027*04e0dc4aSTimo Kreuzer ~__crt_errno_guard() throw()
2028*04e0dc4aSTimo Kreuzer {
2029*04e0dc4aSTimo Kreuzer if (*_errno_address == 0 && _stored_errno != 0)
2030*04e0dc4aSTimo Kreuzer *_errno_address = _stored_errno;
2031*04e0dc4aSTimo Kreuzer }
2032*04e0dc4aSTimo Kreuzer
2033*04e0dc4aSTimo Kreuzer private:
2034*04e0dc4aSTimo Kreuzer
2035*04e0dc4aSTimo Kreuzer __crt_errno_guard(__crt_errno_guard const&) throw(); // not implemented
2036*04e0dc4aSTimo Kreuzer void operator=(__crt_errno_guard const&) throw(); // not implemented
2037*04e0dc4aSTimo Kreuzer
2038*04e0dc4aSTimo Kreuzer errno_t* _errno_address;
2039*04e0dc4aSTimo Kreuzer errno_t _stored_errno;
2040*04e0dc4aSTimo Kreuzer };
2041*04e0dc4aSTimo Kreuzer
2042*04e0dc4aSTimo Kreuzer // Resets the operating system last error (GetLastError) to its original
2043*04e0dc4aSTimo Kreuzer // value on scope exit.
2044*04e0dc4aSTimo Kreuzer class __crt_scoped_get_last_error_reset
2045*04e0dc4aSTimo Kreuzer {
2046*04e0dc4aSTimo Kreuzer public:
2047*04e0dc4aSTimo Kreuzer
__crt_scoped_get_last_error_reset()2048*04e0dc4aSTimo Kreuzer __crt_scoped_get_last_error_reset() throw()
2049*04e0dc4aSTimo Kreuzer {
2050*04e0dc4aSTimo Kreuzer _old_last_error = GetLastError();
2051*04e0dc4aSTimo Kreuzer }
2052*04e0dc4aSTimo Kreuzer
throw()2053*04e0dc4aSTimo Kreuzer ~__crt_scoped_get_last_error_reset() throw()
2054*04e0dc4aSTimo Kreuzer {
2055*04e0dc4aSTimo Kreuzer SetLastError(_old_last_error);
2056*04e0dc4aSTimo Kreuzer }
2057*04e0dc4aSTimo Kreuzer
2058*04e0dc4aSTimo Kreuzer private:
2059*04e0dc4aSTimo Kreuzer __crt_scoped_get_last_error_reset(__crt_scoped_get_last_error_reset const&);
2060*04e0dc4aSTimo Kreuzer __crt_scoped_get_last_error_reset& operator=(__crt_scoped_get_last_error_reset const&);
2061*04e0dc4aSTimo Kreuzer
2062*04e0dc4aSTimo Kreuzer DWORD _old_last_error;
2063*04e0dc4aSTimo Kreuzer };
2064*04e0dc4aSTimo Kreuzer #endif // _M_CEE
2065*04e0dc4aSTimo Kreuzer } // extern "C++"
2066*04e0dc4aSTimo Kreuzer #endif // __cplusplus
2067*04e0dc4aSTimo Kreuzer
2068*04e0dc4aSTimo Kreuzer
2069*04e0dc4aSTimo Kreuzer //-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2070*04e0dc4aSTimo Kreuzer //
2071*04e0dc4aSTimo Kreuzer // Windows policy APIs
2072*04e0dc4aSTimo Kreuzer //
2073*04e0dc4aSTimo Kreuzer //-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2074*04e0dc4aSTimo Kreuzer
2075*04e0dc4aSTimo Kreuzer // Specifies method used to end a process
2076*04e0dc4aSTimo Kreuzer typedef enum
2077*04e0dc4aSTimo Kreuzer {
2078*04e0dc4aSTimo Kreuzer process_end_policy_terminate_process,
2079*04e0dc4aSTimo Kreuzer process_end_policy_exit_process
2080*04e0dc4aSTimo Kreuzer } process_end_policy;
2081*04e0dc4aSTimo Kreuzer
2082*04e0dc4aSTimo Kreuzer process_end_policy __cdecl __acrt_get_process_end_policy(void);
2083*04e0dc4aSTimo Kreuzer
2084*04e0dc4aSTimo Kreuzer // Specifies whether RoInitialize() should be called when creating a thread
2085*04e0dc4aSTimo Kreuzer typedef enum
2086*04e0dc4aSTimo Kreuzer {
2087*04e0dc4aSTimo Kreuzer begin_thread_init_policy_unknown,
2088*04e0dc4aSTimo Kreuzer begin_thread_init_policy_none,
2089*04e0dc4aSTimo Kreuzer begin_thread_init_policy_ro_initialize
2090*04e0dc4aSTimo Kreuzer } begin_thread_init_policy;
2091*04e0dc4aSTimo Kreuzer
2092*04e0dc4aSTimo Kreuzer begin_thread_init_policy __cdecl __acrt_get_begin_thread_init_policy(void);
2093*04e0dc4aSTimo Kreuzer
2094*04e0dc4aSTimo Kreuzer // Specifies whether the Assert dialog should be shown
2095*04e0dc4aSTimo Kreuzer typedef enum
2096*04e0dc4aSTimo Kreuzer {
2097*04e0dc4aSTimo Kreuzer developer_information_policy_unknown,
2098*04e0dc4aSTimo Kreuzer developer_information_policy_none,
2099*04e0dc4aSTimo Kreuzer developer_information_policy_ui
2100*04e0dc4aSTimo Kreuzer } developer_information_policy;
2101*04e0dc4aSTimo Kreuzer
2102*04e0dc4aSTimo Kreuzer developer_information_policy __cdecl __acrt_get_developer_information_policy(void);
2103*04e0dc4aSTimo Kreuzer
2104*04e0dc4aSTimo Kreuzer // Specifies what type of Windowing support is available
2105*04e0dc4aSTimo Kreuzer typedef enum
2106*04e0dc4aSTimo Kreuzer {
2107*04e0dc4aSTimo Kreuzer windowing_model_policy_unknown,
2108*04e0dc4aSTimo Kreuzer windowing_model_policy_hwnd,
2109*04e0dc4aSTimo Kreuzer windowing_model_policy_corewindow,
2110*04e0dc4aSTimo Kreuzer windowing_model_policy_legacyphone,
2111*04e0dc4aSTimo Kreuzer windowing_model_policy_none
2112*04e0dc4aSTimo Kreuzer } windowing_model_policy;
2113*04e0dc4aSTimo Kreuzer
2114*04e0dc4aSTimo Kreuzer windowing_model_policy __cdecl __acrt_get_windowing_model_policy(void);
2115*04e0dc4aSTimo Kreuzer
2116*04e0dc4aSTimo Kreuzer
2117*04e0dc4aSTimo Kreuzer _CRT_END_C_HEADER
2118*04e0dc4aSTimo Kreuzer
2119*04e0dc4aSTimo Kreuzer #include <corecrt_internal_state_isolation.h>
2120