问题
I am writing my own little user mode debugger for fun. I know that the entry point specified in the PE header is not the programs defined main() (as far as microsoft c++ runtime is concerned anyway)
Where can I find some documentation on the calls that take place between this entry point, up until the actual main() function, and why they are called, and what they do?
回答1:
You can't. In fact main may not exist. E.g: you can override the default CRT entry point used by the linker, the main can be inlined into the CRT startup function, etc...
回答2:
The source code for the CRT comes with Visual Studio. For example, for Visual Studio 2010 default installation location, it's at:
C:\Program Files\Microsoft Visual Studio 10.0\VC\crt\src
The actual main()
is in crt0.c
.
The different types of CRT (static, DLL, MT, x86, x64, etc.) are controlled by some defines like CRTDLL
, _M_IA64
and more. You'll see when you dig in.
回答3:
AFAIK the calls etc., the action of the code, is not documented except by the source code itself.
Place cursor first in main
and use debugger "run to here". Or set a breakpoint there. Then just inspect the calls in the call stack.
Cheers & hth.,
来源:https://stackoverflow.com/questions/7420284/c-entry-point-main