#ifdef WPRFLAG int wWinMainCRTStartup( #else /* WPRFLAG */ int WinMainCRTStartup( #endif /* WPRFLAG */
#else /* _WINMAIN_ */
#ifdef WPRFLAG int wmainCRTStartup( #else /* WPRFLAG */ int mainCRTStartup( #endif /* WPRFLAG */
#endif /* _WINMAIN_ */ void ) { /* * The /GS security cookie must be initialized before any exception * handling targetting the current image is registered. No function * using exception handling can be called in the current image until * after __security_init_cookie has been called. */ __security_init_cookie();
__declspec(noinline) int __tmainCRTStartup( void ) { int initret; int mainret=0; int managedapp; #ifdef _WINMAIN_ _TUCHAR *lpszCommandLine; STARTUPINFO StartupInfo;
__try { /* Note: MSDN specifically notes that GetStartupInfo returns no error, and throws unspecified SEH if it fails, so the very general exception handler below is appropriate */ GetStartupInfo( amp;StartupInfo ); } __except(EXCEPTION_EXECUTE_HANDLER) { return 255; } #endif /* _WINMAIN_ */ /* * Determine if this is a managed application */ managedapp = check_managed_app();
if ( !_heap_init(1) ) /* initialize heap */ fast_error_exit(_RT_HEAPINIT); /* write message and die */
if( !_mtinit() ) /* initialize multi-thread */ fast_error_exit(_RT_THREAD); /* write message and die */
/* Enable buffer count checking if linking against static lib */ _CrtSetCheckCount(TRUE);
/* * Initialize the Runtime Checks stuff */ #ifdef _RTC _RTC_Initialize(); #endif /* _RTC */ /* * Guard the remainder of the initialization code and the call * to user's main, or WinMain, function in a __try/__except * statement. */
int __cdecl _cinit ( int initFloatingPrecision ) { int initret;
/* * initialize floating point package, if present */ #ifdef CRTDLL _fpmath(initFloatingPrecision); #else /* CRTDLL */ if (_FPinit != NULL amp;amp; _IsNonwritableInCurrentImage((PBYTE)amp;_FPinit)) { (*_FPinit)(initFloatingPrecision); } _initp_misc_cfltcvt_tab(); #endif /* CRTDLL */
/* * do initializations */ initret = _initterm_e( __xi_a, __xi_z ); if ( initret != 0 ) return initret;
#ifdef _RTC atexit(_RTC_Terminate); #endif /* _RTC */ /* * do C++ initializations */ _initterm( __xc_a, __xc_z );
#ifndef CRTDLL /* * If we have any dynamically initialized __declspec(thread) * variables, then invoke their initialization for the thread on * which the DLL is being loaded, by calling __dyn_tls_init through * a callback defined in tlsdyn.obj. We can't rely on the OS * calling __dyn_tls_init with DLL_PROCESS_ATTACH because, on * Win2K3 and before, that call happens before the CRT is * initialized. */ if (__dyn_tls_init_callback != NULL amp;amp; _IsNonwritableInCurrentImage((PBYTE)amp;__dyn_tls_init_callback)) { __dyn_tls_init_callback(NULL, DLL_THREAD_ATTACH, NULL); } #endif /* CRTDLL */