23#define _CRTALLOC(x) __declspec(allocate(x))
25#define _CRTALLOC(x) __attribute__((section(x)))
29#pragma section(".CRT$XIC", long, read)
30#pragma section(".CRT$XPX", long, read)
31#pragma section(".CRT$XPXA", long, read)
33#pragma section(".CRT$XIA", long, read)
34#pragma section(".CRT$XIAA", long, read)
35#pragma section(".CRT$XIZ", long, read)
36#pragma section(".CRT$XCA", long, read)
37#pragma section(".CRT$XCZ", long, read)
38#pragma section(".CRT$XPA", long, read)
39#pragma section(".CRT$XPZ", long, read)
40#pragma section(".CRT$XTA", long, read)
41#pragma section(".CRT$XTZ", long, read)
44#pragma section(".CRT$XDA",long,read)
45#pragma section(".CRT$XDC",long,read)
46#pragma section(".CRT$XDZ",long,read)
48#pragma section(".CRT$XLA",long,read)
49#pragma section(".CRT$XLC",long,read)
50#pragma section(".CRT$XLD",long,read)
51#pragma section(".CRT$XLZ",long,read)
53#pragma section(".tls",long,read,write)
54#pragma section(".tls$AAA",long,read,write)
55#pragma section(".tls$ZZZ",long,read,write)
71#define CRT_WARNING_DISABLE_PUSH(wn, message) \
72 __pragma(warning(push)) \
73 __pragma(warning(disable: wn))
75#define CRT_WARNING_POP \
76 __pragma(warning(pop))
78#define _BEGIN_SECURE_CRT_DEPRECATION_DISABLE \
79 __pragma(warning(push)) \
80 __pragma(warning(disable: 4996))
82#define _END_SECURE_CRT_DEPRECATION_DISABLE \
83 __pragma(warning(pop))
85#define _CRT_DEBUGGER_IGNORE -1
86#define _CRT_DEBUGGER_GSFAILURE 1
87#define _CRT_DEBUGGER_INVALIDPARAMETER 2
88#define _CRT_DEBUGGER_ABORT 3
90#define _CRT_DEBUGGER_HOOK(x)
92#define _CRT_SECURITYCRITICAL_ATTRIBUTE
93#define _CRT_SECURITYSAFECRITICAL_ATTRIBUTE
103 #define _INVALID_PARAMETER(expr) _invalid_parameter(expr, __FUNCTIONW__, __FILEW__, __LINE__, 0)
105 #define _INVALID_PARAMETER(expr) _invalid_parameter_noinfo()
108#define _VALIDATE_RETURN(expr, errorcode, retexpr) \
110 int _Expr_val = !!(expr); \
111 _ASSERT_EXPR((_Expr_val), _CRT_WIDE(#expr)); \
114 *_errno() = (errorcode); \
115 _INVALID_PARAMETER(_CRT_WIDE(#expr)); \
120#define _VALIDATE_RETURN_VOID(expr, errorcode) \
122 int _Expr_val = !!(expr); \
123 _ASSERT_EXPR((_Expr_val), _CRT_WIDE(#expr)); \
126 *_errno() = (errorcode); \
127 _INVALID_PARAMETER(_CRT_WIDE(#expr)); \
132#define _VALIDATE_RETURN_NOERRNO(expr, retexpr) \
134 int _Expr_val = !!(expr); \
135 _ASSERT_EXPR((_Expr_val), _CRT_WIDE(#expr)); \
138 _INVALID_PARAMETER(_CRT_WIDE(#expr)); \
143#define _VALIDATE_RETURN_ERRCODE(expr, errorcode) \
144 _VALIDATE_RETURN(expr, errorcode, errorcode)
146#define _VALIDATE_CLEAR_OSSERR_RETURN(expr, errorcode, retexpr) \
148 int _Expr_val = !!(expr); \
149 _ASSERT_EXPR((_Expr_val), _CRT_WIDE(#expr)); \
152 *__doserrno() = 0L; \
153 *_errno() = errorcode; \
154 _INVALID_PARAMETER(_CRT_WIDE(#expr) ); \
159#define _VALIDATE_CLEAR_OSSERR_RETURN_ERRCODE(expr, errorcode) \
160 _VALIDATE_CLEAR_OSSERR_RETURN(expr, errorcode, errorcode)
162#define _VALIDATE_RETURN_NOEXC(expr, errorcode, retexpr) \
166 *_errno() = errorcode; \
171#define _VALIDATE_RETURN_ERRCODE_NOEXC(expr, errorcode) \
172 _VALIDATE_RETURN_NOEXC(expr, errorcode, errorcode)
174#define _malloc_crt malloc
175#define _free_crt free
176#define _calloc_crt calloc
177#define _recalloc_crt _recalloc
178#define _malloca_crt _malloca
179#define _freea_crt _freea
186T __crt_fast_encode_pointer(
T ptr)
188 return reinterpret_cast<T>(
195class encoded_nullptr_t
199 inline encoded_nullptr_t(
void*
P) : m_ptr(
P) { };
200 template<
typename T>
operator T*() {
return (
T*)m_ptr; }
204encoded_nullptr_t __crt_fast_encode_pointer(
decltype(
nullptr)
ptr)
206 void* encoded_null = __crt_fast_encode_pointer((
void*)
ptr);
207 return encoded_nullptr_t(encoded_null);
212T __crt_fast_decode_pointer(
T ptr)
214 return reinterpret_cast<T>(
219T __crt_interlocked_read(
const T volatile*
ptr)
225T __crt_interlocked_read_pointer(
const T volatile*
ptr)
231T __crt_interlocked_exchange_pointer(
T *
ptr,
void*
value)
237struct __crt_seh_guarded_call
239 template<
typename Init,
typename Action,
typename Cleanup>
258struct __crt_seh_guarded_call<
void>
260 template<
typename Init,
typename Action,
typename Cleanup>
276template<
typename FuncPtr>
282template<
typename Action,
typename Cleanup>
289struct __crt_malloc_free_policy
292 void operator()(
T*
const ptr)
throw()
298struct __crt_public_free_policy
301 void operator()(
T*
const ptr)
throw()
307struct __crt_malloca_free_policy
309 void operator()(
void*
const ptr)
throw()
315template <
typename T,
typename FreePolicy = __crt_malloc_free_policy>
316class __crt_unique_heap_ptr
320 __crt_unique_heap_ptr() : _ptr(
nullptr) {}
321 __crt_unique_heap_ptr(
T*
ptr) : _ptr(
ptr) {}
322 __crt_unique_heap_ptr(__crt_unique_heap_ptr&&
from) : _ptr(
from._ptr) {
from._ptr =
nullptr; }
323 ~__crt_unique_heap_ptr() { FreePolicy()(_ptr); }
324 void attach(
T*
ptr) { FreePolicy()(_ptr); _ptr =
ptr; }
325 T* detach() {
T*
ptr = _ptr; _ptr =
nullptr;
return ptr; }
326 operator bool()
const {
return _ptr !=
nullptr; }
327 T*
get()
const {
return _ptr; }
328 T** get_address_of() {
return &_ptr; }
331 __crt_unique_heap_ptr& operator=(__crt_unique_heap_ptr&&
from)
341using __crt_scoped_stack_ptr = __crt_unique_heap_ptr<T, __crt_malloca_free_policy>;
343#define _malloc_crt_t(t, n) (__crt_unique_heap_ptr<t>(static_cast<t*>(_malloc_crt((n) * sizeof(t)))))
344#define _calloc_crt_t(t, n) (__crt_unique_heap_ptr<t>(static_cast<t*>(_calloc_crt((n), sizeof(t)))))
345#define _recalloc_crt_t(t, p, n) (__crt_unique_heap_ptr<t>(static_cast<t*>(_recalloc_crt(p, (n), sizeof(t)))))
346#define _malloca_crt_t(t, n) (__crt_scoped_stack_ptr<t>(static_cast<t*>(_malloca_crt((n) * sizeof(t)))))
void get(int argc, const char *argv[])
int(__cdecl * _PIFV)(void)
void(__cdecl * _PVFV)(void)
#define GetProcAddress(x, y)
static void cleanup(void)
static const WCHAR Cleanup[]
const IMAGE_TLS_DIRECTORY _tls_used
void * _InterlockedExchangePointer(_Interlocked_operand_ void *volatile *_Target, void *_Value)
uintptr_t __security_cookie
_In_ WDFIOTARGET _In_ _Strict_type_match_ WDF_IO_TARGET_SENT_IO_ACTION Action