📄 internal.h
字号:
#ifndef CRTDLL
extern int _cflush;
#endif /* CRTDLL */
extern unsigned int _tempoff;
extern unsigned int _old_pfxlen;
extern int _umaskval; /* the umask value */
extern char _pipech[]; /* pipe lookahead */
extern char _exitflag; /* callable termination flag */
extern int _C_Termination_Done; /* termination done flag */
char * __cdecl _getpath(_In_z_ const char * _Src, _Out_z_cap_(_SizeInChars) char * _Dst, _In_ size_t _SizeInChars);
wchar_t * __cdecl _wgetpath(_In_z_ const wchar_t * _Src, _Out_z_cap_(_SizeInWords) wchar_t * _Dst, _In_ size_t _SizeInWords);
extern int _dowildcard; /* flag to enable argv[] wildcard expansion */
#ifndef _PNH_DEFINED
typedef int (__cdecl * _PNH)( size_t );
#define _PNH_DEFINED
#endif /* _PNH_DEFINED */
#if defined (_M_CEE)
#ifndef __MPNH_DEFINED
typedef int (__clrcall * __MPNH)( size_t );
#define __MPNH_DEFINED
#endif /* __MPNH_DEFINED */
#endif /* defined (_M_CEE) */
/* calls the currently installed new handler */
int __cdecl _callnewh(_In_ size_t _Size);
extern int _newmode; /* malloc new() handler mode */
/* pointer to initial environment block that is passed to [w]main */
#ifndef _M_CEE_PURE
extern _CRTIMP wchar_t **__winitenv;
extern _CRTIMP char **__initenv;
#endif /* _M_CEE_PURE */
/* _calloca helper */
#define _calloca(count, size) ((count<=0 || size<=0 || ((((size_t)_HEAP_MAXREQ) / ((size_t)count)) < ((size_t)size)))? NULL : _malloca(count * size))
/* startup set values */
extern char *_aenvptr; /* environment ptr */
extern wchar_t *_wenvptr; /* wide environment ptr */
/* command line */
#if defined (_DLL)
_CRTIMP char ** __cdecl __p__acmdln(void);
_CRTIMP wchar_t ** __cdecl __p__wcmdln(void);
#endif /* defined (_DLL) */
#ifndef _M_CEE_PURE
_CRTIMP extern char *_acmdln;
_CRTIMP extern wchar_t *_wcmdln;
#else /* _M_CEE_PURE */
#define _acmdln (*__p__acmdln())
#define _wcmdln (*__p__wcmdln())
#endif /* _M_CEE_PURE */
/*
* prototypes for internal startup functions
*/
int __cdecl _cwild(void); /* wild.c */
int __cdecl _wcwild(void); /* wwild.c */
int __cdecl _mtinit(void); /* tidtable.c */
void __cdecl _mtterm(void); /* tidtable.c */
int __cdecl _mtinitlocks(void); /* mlock.c */
void __cdecl _mtdeletelocks(void); /* mlock.c */
int __cdecl _mtinitlocknum(_In_ int); /* mlock.c */
#define _CRT_SPINCOUNT 4000
/*
* C source build only!!!!
*
* more prototypes for internal startup functions
*/
void __cdecl _amsg_exit(int); /* crt0.c */
void __cdecl __crtExitProcess(int); /* crt0dat.c */
void __cdecl __crtCorExitProcess(int); /* crt0dat.c */
void __cdecl __crtdll_callstaticterminators(void); /* crt0dat.c */
/*
_cinit now allows the caller to suppress floating point precision init
This allows the DLLs that use the CRT to not initialise FP precision,
allowing the EXE's setting to persist even when a DLL is loaded
*/
int __cdecl _cinit(int /* initFloatingPrecision */); /* crt0dat.c */
void __cdecl __doinits(void); /* astart.asm */
void __cdecl __doterms(void); /* astart.asm */
void __cdecl __dopreterms(void); /* astart.asm */
void __cdecl _FF_MSGBANNER(void);
void __cdecl _fpmath(int /*initPrecision*/);
void __cdecl _fptrap(void); /* crt0fp.c */
int __cdecl _heap_init(void);
void __cdecl _heap_term(void);
void __cdecl _heap_abort(void);
void __cdecl __initconin(void); /* initcon.c */
void __cdecl __initconout(void); /* initcon.c */
int __cdecl _ioinit(void); /* crt0.c, crtlib.c */
void __cdecl _ioterm(void); /* crt0.c, crtlib.c */
const wchar_t * __cdecl _GET_RTERRMSG(int);
void __cdecl _NMSG_WRITE(int);
int __CRTDECL _setargv(void); /* setargv.c, stdargv.c */
int __CRTDECL __setargv(void); /* stdargv.c */
int __CRTDECL _wsetargv(void); /* wsetargv.c, wstdargv.c */
int __CRTDECL __wsetargv(void); /* wstdargv.c */
int __cdecl _setenvp(void); /* stdenvp.c */
int __cdecl _wsetenvp(void); /* wstdenvp.c */
void __cdecl __setmbctable(unsigned int); /* mbctype.c */
#ifdef _MBCS
int __cdecl __initmbctable(void); /* mbctype.c */
#endif /* _MBCS */
#ifndef _MANAGED_MAIN
int __CRTDECL main(_In_ int _Argc, _In_count_(_Argc) _Pre_z_ char ** _Argv, _In_z_ char ** _Env);
int __CRTDECL wmain(_In_ int _Argc, _In_count_(_Argc) _Pre_z_ wchar_t ** _Argv, _In_z_ wchar_t ** _Env);
#endif /* _MANAGED_MAIN */
/* helper functions for wide/multibyte environment conversion */
int __cdecl __mbtow_environ (void);
int __cdecl __wtomb_environ (void);
/* These two functions take a char ** for the environment option
At some point during their execution, they take ownership of the
memory block passed in using option. At this point, they
NULL out the incoming char * / wchar_t * to ensure there is no
double-free
*/
int __cdecl __crtsetenv (_Inout_ _Deref_prepost_opt_valid_ char ** _POption, _In_ const int _Primary);
int __cdecl __crtwsetenv (_Inout_ _Deref_prepost_opt_valid_ wchar_t ** _POption, _In_ const int _Primary);
#if defined (_DLL) || defined (CRTDLL)
#ifndef _STARTUP_INFO_DEFINED
typedef struct
{
int newmode;
} _startupinfo;
#define _STARTUP_INFO_DEFINED
#endif /* _STARTUP_INFO_DEFINED */
_CRTIMP int __cdecl __getmainargs(_Out_ int * _Argc, _Out_ _Deref_post_cap_(*_Argc) char *** _Argv,
_Deref_out_opt_ char *** _Env, _In_ int _DoWildCard,
_In_ _startupinfo * _StartInfo);
_CRTIMP int __cdecl __wgetmainargs(_Out_ int * _Argc, _Out_ _Deref_post_cap_(*_Argc)wchar_t *** _Argv,
_Deref_out_opt_ wchar_t *** _Env, _In_ int _DoWildCard,
_In_ _startupinfo * _StartInfo);
#endif /* defined (_DLL) || defined (CRTDLL) */
/*
* Prototype, variables and constants which determine how error messages are
* written out.
*/
#define _UNKNOWN_APP 0
#define _CONSOLE_APP 1
#define _GUI_APP 2
extern int __app_type;
#if !defined (_M_CEE_PURE)
typedef enum {
__uninitialized,
__initializing,
__initialized
} __enative_startup_state;
extern volatile __enative_startup_state __native_startup_state;
extern void * volatile __native_startup_lock;
#define __NO_REASON UINT_MAX
extern volatile unsigned int __native_dllmain_reason;
extern volatile unsigned int __native_vcclrit_reason;
#if defined (__cplusplus)
#pragma warning(push)
#pragma warning(disable: 4483)
#define _NATIVE_STARTUP_NAMESPACE __identifier("<CrtImplementationDetails>")
namespace _NATIVE_STARTUP_NAMESPACE
{
class NativeDll
{
private:
static const unsigned int ProcessDetach = 0;
static const unsigned int ProcessAttach = 1;
static const unsigned int ThreadAttach = 2;
static const unsigned int ThreadDetach = 3;
static const unsigned int ProcessVerifier = 4;
public:
inline static bool IsInDllMain()
{
return (__native_dllmain_reason != __NO_REASON);
}
inline static bool IsInProcessAttach()
{
return (__native_dllmain_reason == ProcessAttach);
}
inline static bool IsInProcessDetach()
{
return (__native_dllmain_reason == ProcessDetach);
}
inline static bool IsInVcclrit()
{
return (__native_vcclrit_reason != __NO_REASON);
}
inline static bool IsSafeForManagedCode()
{
if (!IsInDllMain())
{
return true;
}
if (IsInVcclrit())
{
return true;
}
return !IsInProcessAttach() && !IsInProcessDetach();
}
};
}
#pragma warning(pop)
#endif /* defined (__cplusplus) */
#endif /* !defined (_M_CEE_PURE) */
extern int __error_mode;
_CRTIMP void __cdecl __set_app_type(int);
/*
* C source build only!!!!
*
* map Win32 errors into Xenix errno values -- for modules written in C
*/
_CRTIMP void __cdecl _dosmaperr(unsigned long);
extern int __cdecl _get_errno_from_oserr(unsigned long);
/*
* internal routines used by the exec/spawn functions
*/
extern intptr_t __cdecl _dospawn(_In_ int _Mode, _In_opt_z_ const char * _Name, _Inout_z_ char * _Cmd, _In_opt_z_ char * _Env);
extern intptr_t __cdecl _wdospawn(_In_ int _Mode, _In_opt_z_ const wchar_t * _Name, _Inout_z_ wchar_t * _Cmd, _In_opt_z_ wchar_t * _Env);
extern int __cdecl _cenvarg(_In_z_ const char * const * _Argv, _In_opt_z_ const char * const * _Env,
_Deref_out_opt_ char ** _ArgBlk, _Deref_out_opt_ char ** _EnvBlk, _In_z_ const char *_Name);
extern int __cdecl _wcenvarg(_In_z_ const wchar_t * const * _Argv, _In_opt_z_ const wchar_t * const * _Env,
_Deref_out_opt_ wchar_t ** _ArgBlk, _Deref_out_opt_ wchar_t ** _EnvBlk, _In_z_ const wchar_t * _Name);
#ifndef _M_IX86
extern char ** _capture_argv(_In_ va_list *, _In_z_ const char * _FirstArg, _Out_z_cap_(_MaxCount) char ** _Static_argv, _In_ size_t _MaxCount);
extern wchar_t ** _wcapture_argv(_In_ va_list *, _In_z_ const wchar_t * _FirstArg, _Out_z_cap_(_MaxCount) wchar_t ** _Static_argv, _In_ size_t _MaxCount);
#endif /* _M_IX86 */
/*
* internal routine used by the abort
*/
extern _PHNDLR __cdecl __get_sigabrt(void);
/*
* Type from ntdef.h
*/
typedef LONG NTSTATUS;
/*
* Exception code used in _invalid_parameter
*/
#ifndef STATUS_INVALID_PARAMETER
#define STATUS_INVALID_PARAMETER ((NTSTATUS)0xC000000DL)
#endif /* STATUS_INVALID_PARAMETER */
/*
* Exception code used for abort and _CALL_REPORTFAULT
*/
#ifndef STATUS_FATAL_APP_EXIT
#define STATUS_FATAL_APP_EXIT ((NTSTATUS)0x40000015L)
#endif /* STATUS_FATAL_APP_EXIT */
/*
* Validate functions
*/
#include <crtdbg.h> /* _ASSERTE */
#include <errno.h>
#define __STR2WSTR(str) L##str
#define _STR2WSTR(str) __STR2WSTR(str)
#define __FILEW__ _STR2WSTR(__FILE__)
#define __FUNCTIONW__ _STR2WSTR(__FUNCTION__)
/* We completely fill the buffer only in debug (see _SECURECRT__FILL_STRING
* and _SECURECRT__FILL_BYTE macros).
*/
#if !defined (_SECURECRT_FILL_BUFFER)
#ifdef _DEBUG
#define _SECURECRT_FILL_BUFFER 1
#else /* _DEBUG */
#define _SECURECRT_FILL_BUFFER 0
#endif /* _DEBUG */
#endif /* !defined (_SECURECRT_FILL_BUFFER) */
void __cdecl _call_reportfault(int nDbgHookCode, DWORD dwExceptionCode, DWORD dwExceptionFlags);
/* Invoke Watson if _ExpressionError is not 0; otherwise simply return _EspressionError */
SECURITYCRITICAL_ATTRIBUTE
__forceinline
void _invoke_watson_if_error(
errno_t _ExpressionError,
_In_opt_z_ const wchar_t *_Expression,
_In_opt_z_ const wchar_t *_Function,
_In_opt_z_ const wchar_t *_File,
unsigned int _Line,
uintptr_t _Reserved
)
{
if (_ExpressionError == 0)
{
return;
}
_invoke_watson(_Expression, _Function, _File, _Line, _Reserved);
}
/* Invoke Watson if _ExpressionError is not 0 and equal to _ErrorValue1 or _ErrorValue2; otherwise simply return _EspressionError */
__forceinline
errno_t _invoke_watson_if_oneof(
errno_t _ExpressionError,
errno_t _ErrorValue1,
errno_t _ErrorValue2,
_In_opt_z_ const wchar_t *_Expression,
_In_opt_z_ const wchar_t *_Function,
_In_opt_z_ const wchar_t *_File,
unsigned int _Line,
uintptr_t _Reserved
)
{
if (_ExpressionError == 0 || (_ExpressionError != _ErrorValue1 && _ExpressionError != _ErrorValue2))
{
return _ExpressionError;
}
_invoke_watson(_Expression, _Function, _File, _Line, _Reserved);
return _ExpressionError;
}
/*
* Assert in debug builds.
* set errno and return
*
*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -