// If this module has any dynamically initialized __declspec(thread) // variables, then we invoke their initialization for the primary thread // used to start the process: _tls_callback_type const* const tls_init_callback = __scrt_get_dyn_tls_init_callback(); if (*tls_init_callback != nullptr && __scrt_is_nonwritable_in_current_image(tls_init_callback)) { (*tls_init_callback)(nullptr, DLL_THREAD_ATTACH, nullptr); }
// If this module has any thread-local destructors, register the // callback function with the Unified CRT to run on exit. _tls_callback_type const * const tls_dtor_callback = __scrt_get_dyn_tls_dtor_callback(); if (*tls_dtor_callback != nullptr && __scrt_is_nonwritable_in_current_image(tls_dtor_callback)) { _register_thread_local_exe_atexit_callback(*tls_dtor_callback); }
// // 初始化完成,调用main函数 //
intconst main_result = invoke_main();
// // main has returned; exit somehow... //
if (!__scrt_is_managed_app()) exit(main_result);
if (!has_cctor) _cexit();
// 终止CRT // 本来我打算用ollydbg一把梭的,但跟进mainCRTStartup会直接跳到这里,暂时还没研究明白,被迫用vs2022。 __scrt_uninitialize_crt(true, false); return main_result; } __except (_seh_filter_exe(GetExceptionCode(), GetExceptionInformation())) { // Note: We should never reach this except clause. intconst main_result = GetExceptionCode();