Pelles C forum

C language => Windows questions => Topic started by: Stefan Pendl on October 16, 2011, 03:47:31 PM

Title: Entry point usage
Post by: Stefan Pendl on October 16, 2011, 03:47:31 PM
Reading the information of the MSDN articles /ENTRY (Entry-Point Symbol) (http://msdn.microsoft.com/en-us/library/f9t8842e%28VS.71%29.aspx) and UMENTRYABS (http://msdn.microsoft.com/en-us/library/ff553995%28VS.85%29.aspx) results in the following table of entry points.

Environment| Default Entry Point| Absolute Entry Point
EXE native| | NtProcessStartup
EXE console| main| mainCRTStartup
EXE GUI| WinMain| WinMainCRTStartup
DLL| DllMain| _DllMainCRTStartup

Why would one use the absolute entry points, except for a native application where only the absolute one exists.

What is the advantage of using the absolute entry point, since Timo seems to use them quite frequently, or is this just a personal preference?

Thanks in advance.
Title: Re: Entry point usage
Post by: TimoVJL on October 16, 2011, 04:58:44 PM
Maybe bad habit  ;)
Just leaving out unnessary code (RTL/CRT) from executable when not needed, mostly when testing something.
Sometimes if i disassemble code with podump /DISASM to make shorter list to output window.
Title: Re: Entry point usage
Post by: Stefan Pendl on October 16, 2011, 07:39:20 PM
For testing to reduce the size of the executable it makes sense.

Thanks for your insight ;)
Title: Re: Entry point usage
Post by: CommonTater on October 16, 2011, 11:38:21 PM
Reading the information of the MSDN articles /ENTRY (Entry-Point Symbol) (http://msdn.microsoft.com/en-us/library/f9t8842e%28VS.71%29.aspx) and UMENTRYABS (http://msdn.microsoft.com/en-us/library/ff553995%28VS.85%29.aspx) results in the following table of entry points.

Environment| Default Entry Point| Absolute Entry Point
EXE native| | NtProcessStartup
EXE console| main| mainCRTStartup
EXE GUI| WinMain| WinMainCRTStartup
DLL| DllMain| _DllMainCRTStartup

Why would one use the absolute entry points, except for a native application where only the absolute one exists.

What is the advantage of using the absolute entry point, since Timo seems to use them quite frequently, or is this just a personal preference?

Thanks in advance.

The application is always entered at the absolute entry point, Stefan.  Most programming languages do some startup stuff (memory manager, command line parsing, etc,) before calling their user entry point functions.   This startup code ends up in the executable.

For example:
Pelles C help file... Contents -> Appendix -> Program startup (two entries)... interesting stuff.