/***
*crtexe.c - Initialization for console EXE using CRT DLL
*
* Copyright (c) Microsoft Corporation. All rights reserved.
*
*Purpose:
* This is the actual startup routine for apps linking to the CRT DLL.
* It calls the user's main routine [w]main() or [w]WinMain after
* performing C Run-Time Library initialization.
*
* With ifdefs, this source file also provides the source code for:
* wcrtexe.c the startup routine for console apps with wide chars
* crtexew.c the startup routine for Windows apps
* wcrtexew.c the startup routine for Windows apps with wide chars
*
*******************************************************************************/
#ifdef CRTDLL
/*
* SPECIAL BUILD MACROS! Note that crtexe.c (and crtexew.c) is linked in with
* the client's code. It does not go into crtdll.dll! Therefore, it must be
* built under the _DLL switch (like user code) and CRTDLL must be undefined.
* The symbol SPECIAL_CRTEXE is turned on to suppress the normal CRT DLL
* definition of _fmode and _commode using __declspec(dllexport). Otherwise
* this module would not be able to refer to both the local and DLL versions
* of these two variables.
*/
#undef CRTDLL
#ifndef _DLL
#define _DLL
#endif /* _DLL */
/*
* We need to pull in the manifest information so that user exe's which
* do not include any headers get a manifest
*/
#if defined (_M_IX86)
#pragma comment(linker, "/include:__forceCRTManifestRTM")
#else /* defined (_M_IX86) */
#pragma comment(linker, "/include:_forceCRTManifestRTM")
#endif /* defined (_M_IX86) */
#define SPECIAL_CRTEXE
#include <cruntime.h>
#include <oscalls.h>
#include <internal.h>
#include <process.h>
#include <math.h>
#include <rterr.h>
#include <stdlib.h>
#include <tchar.h>
#include <rtcapi.h>
#include <sect_attribs.h>
#include <locale.h>
#if defined (_WIN64) && defined (_M_IA64)
#pragma section(".base", long, read)
__declspec(allocate(".base"))
extern
IMAGE_DOS_HEADER __ImageBase;
#else /* defined (_WIN64) && defined (_M_IA64) */
extern
IMAGE_DOS_HEADER __ImageBase;
#endif /* defined (_WIN64) && defined (_M_IA64) */
/*
* This has been moved from unhandld.cpp to here because, we only
* want to set the UnhandledExceptionFilter when this crt is loaded
* by an EXE (ie. not loaded by a DLL)
*/
int __cdecl __CxxSetUnhandledExceptionFilter(void);
_CRTALLOC(".CRT$XIY") static _PIFV pinit = &__CxxSetUnhandledExceptionFilter;
#define SPACECHAR _T(' ')
#define DQUOTECHAR _T('\"')
#ifdef _M_IX86
/*
* The local copy of the Pentium FDIV adjustment flag
* and the address of the flag in MSVCRT*.DLL.
*/
extern int _adjust_fdiv;
extern int * _imp___adjust_fdiv;
#endif /* _M_IX86 */
/* default floating point precision - X86 only! */
#ifdef _M_IX86
extern void _setdefaultprecision();
#endif /* _M_IX86 */
/*
* Declare function used to install a user-supplied _matherr routine.
*/
_CRTIMP void __setusermatherr( int (__cdecl *)(struct _exception *) );
/*
* Declare the names of the exports corresponding to _fmode and _commode
*/
#ifdef _M_IX86
#define _IMP___FMODE (__p__fmode())
#define _IMP___COMMODE (__p__commode())
#else /* _M_IX86 */
/* assumed to be MIPS or Alpha */
#define _IMP___FMODE __imp__fmode
#define _IMP___COMMODE __imp__commode
#endif /* _M_IX86 */
#if !defined (_M_IX86)
extern int * _IMP___FMODE; /* exported from the CRT DLL */
extern int * _IMP___COMMODE; /* these names are implementation-specific */
#endif /* !defined (_M_IX86) */
extern int _fmode; /* must match the definition in <stdlib.h> */
extern int _commode; /* must match the definition in <internal.h> */
extern int _dowildcard; /* passed to __getmainargs() */
/*
* Declare/define communal that serves as indicator the default matherr
* routine is being used.
*/
int __defaultmatherr;
/*
* routine in DLL to do initialization (in this case, C++ constructors)
*/
extern int __cdecl _initterm_e(_PIFV *, _PIFV *);
extern void __cd
*crtexe.c - Initialization for console EXE using CRT DLL
*
* Copyright (c) Microsoft Corporation. All rights reserved.
*
*Purpose:
* This is the actual startup routine for apps linking to the CRT DLL.
* It calls the user's main routine [w]main() or [w]WinMain after
* performing C Run-Time Library initialization.
*
* With ifdefs, this source file also provides the source code for:
* wcrtexe.c the startup routine for console apps with wide chars
* crtexew.c the startup routine for Windows apps
* wcrtexew.c the startup routine for Windows apps with wide chars
*
*******************************************************************************/
#ifdef CRTDLL
/*
* SPECIAL BUILD MACROS! Note that crtexe.c (and crtexew.c) is linked in with
* the client's code. It does not go into crtdll.dll! Therefore, it must be
* built under the _DLL switch (like user code) and CRTDLL must be undefined.
* The symbol SPECIAL_CRTEXE is turned on to suppress the normal CRT DLL
* definition of _fmode and _commode using __declspec(dllexport). Otherwise
* this module would not be able to refer to both the local and DLL versions
* of these two variables.
*/
#undef CRTDLL
#ifndef _DLL
#define _DLL
#endif /* _DLL */
/*
* We need to pull in the manifest information so that user exe's which
* do not include any headers get a manifest
*/
#if defined (_M_IX86)
#pragma comment(linker, "/include:__forceCRTManifestRTM")
#else /* defined (_M_IX86) */
#pragma comment(linker, "/include:_forceCRTManifestRTM")
#endif /* defined (_M_IX86) */
#define SPECIAL_CRTEXE
#include <cruntime.h>
#include <oscalls.h>
#include <internal.h>
#include <process.h>
#include <math.h>
#include <rterr.h>
#include <stdlib.h>
#include <tchar.h>
#include <rtcapi.h>
#include <sect_attribs.h>
#include <locale.h>
#if defined (_WIN64) && defined (_M_IA64)
#pragma section(".base", long, read)
__declspec(allocate(".base"))
extern
IMAGE_DOS_HEADER __ImageBase;
#else /* defined (_WIN64) && defined (_M_IA64) */
extern
IMAGE_DOS_HEADER __ImageBase;
#endif /* defined (_WIN64) && defined (_M_IA64) */
/*
* This has been moved from unhandld.cpp to here because, we only
* want to set the UnhandledExceptionFilter when this crt is loaded
* by an EXE (ie. not loaded by a DLL)
*/
int __cdecl __CxxSetUnhandledExceptionFilter(void);
_CRTALLOC(".CRT$XIY") static _PIFV pinit = &__CxxSetUnhandledExceptionFilter;
#define SPACECHAR _T(' ')
#define DQUOTECHAR _T('\"')
#ifdef _M_IX86
/*
* The local copy of the Pentium FDIV adjustment flag
* and the address of the flag in MSVCRT*.DLL.
*/
extern int _adjust_fdiv;
extern int * _imp___adjust_fdiv;
#endif /* _M_IX86 */
/* default floating point precision - X86 only! */
#ifdef _M_IX86
extern void _setdefaultprecision();
#endif /* _M_IX86 */
/*
* Declare function used to install a user-supplied _matherr routine.
*/
_CRTIMP void __setusermatherr( int (__cdecl *)(struct _exception *) );
/*
* Declare the names of the exports corresponding to _fmode and _commode
*/
#ifdef _M_IX86
#define _IMP___FMODE (__p__fmode())
#define _IMP___COMMODE (__p__commode())
#else /* _M_IX86 */
/* assumed to be MIPS or Alpha */
#define _IMP___FMODE __imp__fmode
#define _IMP___COMMODE __imp__commode
#endif /* _M_IX86 */
#if !defined (_M_IX86)
extern int * _IMP___FMODE; /* exported from the CRT DLL */
extern int * _IMP___COMMODE; /* these names are implementation-specific */
#endif /* !defined (_M_IX86) */
extern int _fmode; /* must match the definition in <stdlib.h> */
extern int _commode; /* must match the definition in <internal.h> */
extern int _dowildcard; /* passed to __getmainargs() */
/*
* Declare/define communal that serves as indicator the default matherr
* routine is being used.
*/
int __defaultmatherr;
/*
* routine in DLL to do initialization (in this case, C++ constructors)
*/
extern int __cdecl _initterm_e(_PIFV *, _PIFV *);
extern void __cd