The Win32 program is divided into two types:
1. Console (/subsystem:console)
2.GUI (/subsystem:windows)
First look at the console version:
Write a paragraph that is the simplest, or simply use the default main function of the compiler parameter, as follows:
[CPP] view plain copy//EntryFunction.cpp: Defines the entry point for a console application. #include "stdafx.h" int _tmain (int argc, _tchar* argv[]) {return 0; }
1. Using the/MD option
F9 down to the tag of the main function, F11 back to _tmaincrtstartup () in call stack, and the current file is crtexe.c. As follows:
2. Using the/MT option
F9 down to the tag of the main function, F11 back to _tmaincrtstartup () in call stack, and the current file is crt0.c. As follows:
That is, different runtime links, the implementation of the code is also different. But the name of the entry point function is the same, it is _tmaincrtstartup. This is the startup function (the real entry function) under Windows.
Let's discuss separately what the two do in the entry function.
First look at the _security_init_cookie, this function is the same in the two implementation files, the code is as follows:
[CPP] View Plain copy /*** *__security_init_cookie (cookie) - init buffer overrun security cookie. * *purpose: * initialize the global buffer overrun security cookie which is used by * the /gs compile switch to detect overwrites to local array variables * the potentially corrupt the return address. this routine is called * at exe/dll startup. * *entry: * *exit: * *exceptions: * **************************************** / Void __cdecl __security_init_cookie ( void) { UINT_PTR cookie; FT systime={0}; LARGE_INTEGER perfctr; /* * do nothing if the global cookie has already been initialized. On x86, * reinitialize the cookie if it has been previously initialized to a * value with the high word 0x0000. some versions of windows will init * the cookie in the loader, but using an older mechanism which forced the * high word to zero.  */