[VCRUNTIME] Add some missing definitions to vcruntime*.h

This commit is contained in:
Timo Kreuzer 2024-05-12 13:32:45 +03:00
parent 90e95d15a2
commit 2955b1f0e9
3 changed files with 210 additions and 0 deletions

View file

@ -11,6 +11,32 @@
#define _CRT_WIDE_(_String) L ## _String
#define _CRT_WIDE(_String) _CRT_WIDE_(_String)
#define _CRT_CONCATENATE_(a, b) a ## b
#define _CRT_CONCATENATE(a, b) _CRT_CONCATENATE_(a, b)
#define _CRT_UNPARENTHESIZE_(...) __VA_ARGS__
#define _CRT_UNPARENTHESIZE(...) _CRT_UNPARENTHESIZE_ __VA_ARGS__
#ifndef _MSC_VER
#define __pragma(x) _Pragma(_CRT_STRINGIZE(x))
#endif
#ifdef __cplusplus
#define _CRT_BEGIN_C_HEADER \
__pragma(pack(push, _CRT_PACKING_IDENTIFIER, _CRT_PACKING)) \
extern "C" {
#define _CRT_END_C_HEADER \
} \
__pragma(pack(pop, _CRT_PACKING_IDENTIFIER))
#else
#define _CRT_BEGIN_C_HEADER \
__pragma(pack(push, _CRT_PACKING_IDENTIFIER, _CRT_PACKING))
#define _CRT_END_C_HEADER \
__pragma(pack(pop, _CRT_PACKING_IDENTIFIER))
#endif
_CRT_BEGIN_C_HEADER
#ifndef _CRTIMP
#ifdef CRTDLL /* Defined for ntdll, crtdll, msvcrt, etc */
#define _CRTIMP
@ -21,6 +47,16 @@
#endif /* CRTDLL || _DLL */
#endif /* !_CRTIMP */
#ifndef _VCRTIMP
#ifndef _VCRT_DEFINED_CRTIMP
#define _VCRTIMP _CRTIMP
#elif defined(_VCRT_BUILD) && defined(CRTDLL) && !defined(_VCRT_SAT_1)
#define _VCRTIMP __declspec(dllexport)
#else
#define _VCRTIMP
#endif
#endif
#ifndef __CRTDECL
#define __CRTDECL __cdecl
#endif
@ -118,3 +154,55 @@
#define _CRT_ALIGN(x) __attribute__ ((aligned(x)))
#endif
#endif
#if defined (__midl) || defined(__WIDL__)
#define _VCRT_ALIGN(x)
#elif defined(_MSC_VER)
#define _CRT_ALIGN(x) __declspec(align(x))
#else
#define _VCRT_ALIGN(x) __attribute__ ((aligned(x)))
#endif
#if defined __cplusplus
typedef bool __vcrt_bool;
#elif defined __midl
typedef char __vcrt_bool;
#else
typedef _Bool __vcrt_bool;
#endif
#ifndef _HAS_NODISCARD
#ifndef __has_cpp_attribute
#define _HAS_NODISCARD 0
#elif __has_cpp_attribute(nodiscard) >= 201603L
#define _HAS_NODISCARD 1
#else
#define _HAS_NODISCARD 0
#endif
#endif // _HAS_NODISCARD
#if _HAS_NODISCARD
#define _NODISCARD [[nodiscard]]
#else
#define _NODISCARD
#endif // _HAS_NODISCARD
#if defined _M_X64 || defined _M_ARM || defined _M_ARM64
#define _UNALIGNED __unaligned
#else
#define _UNALIGNED
#endif
#ifdef __cplusplus
// Safer than the C definition, as it ensures that the argument is not a pointer
extern "C++" template<typename _T, size_t _Size>
char (*__crt_countof_helper(_UNALIGNED _T(&_Array)[_Size]))[_Size];
#define __crt_countof(_Array) sizeof(*__crt_countof_helper(_Array))
#else
#define __crt_countof(_Array) (sizeof(_Array) / sizeof(_Array[0]))
#endif
void __cdecl __security_init_cookie(void);
extern uintptr_t __security_cookie;
_CRT_END_C_HEADER

View file

@ -7,3 +7,18 @@ typedef enum _crt_argv_mode
_crt_argv_unexpanded_arguments,
_crt_argv_expanded_arguments,
} _crt_argv_mode;
typedef enum _crt_exit_cleanup_mode
{
_crt_exit_full_cleanup,
_crt_exit_quick_cleanup,
_crt_exit_no_cleanup
} _crt_exit_cleanup_mode;
typedef enum _crt_exit_return_mode
{
_crt_exit_terminate_process,
_crt_exit_return_to_caller
} _crt_exit_return_mode;
__vcrt_bool __cdecl __vcrt_uninitialize(_In_ __vcrt_bool _Terminating);

View file

@ -2,3 +2,110 @@
#pragma once
#include <vcruntime.h>
_CRT_BEGIN_C_HEADER
void*
__cdecl
memset(
_Out_writes_bytes_all_(_Size) void *_Dst,
_In_ int _Val,
_In_ size_t _Size);
_CRT_INSECURE_DEPRECATE_MEMORY(memcpy_s)
_Post_equal_to_(_Dst)
_At_buffer_((unsigned char*)_Dst, _Iter_, _Size,
_Post_satisfies_(((unsigned char*)_Dst)[_Iter_] == ((unsigned char*)_Src)[_Iter_]))
void*
__cdecl
memcpy(
_Out_writes_bytes_all_(_Size) void *_Dst,
_In_reads_bytes_(_Size) void const *_Src,
_In_ size_t _Size);
_CRT_INSECURE_DEPRECATE_MEMORY(memmove_s)
_VCRTIMP
void*
__cdecl
memmove(
_Out_writes_bytes_all_opt_(_Size) void *_Dst,
_In_reads_bytes_opt_(_Size) void const *_Src,
_In_ size_t _Size);
_NODISCARD
_Check_return_
_VCRTIMP
char _CONST_RETURN*
__cdecl
strchr(
_In_z_ const char *_Str,
_In_ int _Val);
_NODISCARD
_Check_return_
_When_(return != NULL, _Ret_range_(_Str, _Str + _String_length_(_Str) - 1))
_VCRTIMP
wchar_t _CONST_RETURN*
__cdecl
wcschr(
_In_z_ const wchar_t *_Str,
_In_ wchar_t _Ch);
_NODISCARD
_Check_return_
_VCRTIMP
char _CONST_RETURN*
__cdecl strrchr(
_In_z_ const char *_Str,
_In_ int _Ch);
_NODISCARD
_Check_return_
_Ret_maybenull_
_VCRTIMP
char _CONST_RETURN*
__cdecl
strstr(
_In_z_ const char *_Str,
_In_z_ const char *_SubStr);
_NODISCARD
_Check_return_
int
__cdecl
memcmp(
_In_reads_bytes_(_Size) const void *_Buf1,
_In_reads_bytes_(_Size) const void *_Buf2,
_In_ size_t _Size);
_NODISCARD
_Check_return_
_Ret_maybenull_
_When_(return != NULL, _Ret_range_(_Str, _Str + _String_length_(_Str) - 1))
_VCRTIMP
wchar_t _CONST_RETURN*
__cdecl
wcsstr(
_In_z_ const wchar_t *_Str,
_In_z_ const wchar_t *_SubStr);
_NODISCARD
_Check_return_
_VCRTIMP
void _CONST_RETURN*
__cdecl
memchr(
_In_reads_bytes_opt_(_MaxCount) const void *_Buf,
_In_ int _Val,
_In_ size_t _MaxCount);
_NODISCARD
_Check_return_
_VCRTIMP
wchar_t _CONST_RETURN*
__cdecl
wcsrchr(
_In_z_ const wchar_t *_Str,
_In_ wchar_t _Ch);
_CRT_END_C_HEADER