The MASM Forum

General => The Workshop => Topic started by: buck12 on December 27, 2013, 12:45:04 PM

Title: EXE Entry Point
Post by: buck12 on December 27, 2013, 12:45:04 PM
Newbie here so bare with me.
I am using MASM32 and looking at the example files to get going.
I compiled the exe and ran it. Work like it is supposed to.
Now, I am looking at the assembly code to see the guts of the program.
I can see the functions, the calls to the functions, some kernel calls etc.

So here is my question and yes I have done some googling with no results.
Where is the application point stored?
I notice that the first thing in the application is the "press any key..." function in the hello example.
How does the application know where to start executing?
In the code its where it says start but the hex data is not organized as such.

Any references are also welcome.
:t
Title: Re: EXE Entry Point
Post by: dedndave on December 27, 2013, 01:10:49 PM
at the end of the source, you will see an END directive
for executable application source files, the END directive should also have the entry point label
the label can be any public code symbol - i usually use a PROC around my Main code
Main    PROC

    INVOKE  ExitProcess,0

Main    ENDP

        END     Main


Start:

    INVOKE  ExitProcess,0

        END     Start


you can also do it in the linker command line, i think - but, why ? - lol
Title: Re: EXE Entry Point
Post by: buck12 on December 28, 2013, 04:10:08 AM
dadndave, I am looking at the hex data in the executable for this information.
I guess I was not clear, when windows goes to execute the program, where does it find the entry point?
Title: Re: EXE Entry Point
Post by: dedndave on December 28, 2013, 04:15:57 AM
ohhh - in the PE header

Tedd posted a nice recent version of the pe/coff v 8.3 spec

http://masm32.com/board/index.php?topic=240.msg26288#msg26288 (http://masm32.com/board/index.php?topic=240.msg26288#msg26288)
Title: Re: EXE Entry Point
Post by: TWell on December 28, 2013, 06:05:23 AM
PEView is a nice tool to examine exe-file, look here (http://wjradburn.com/software/)
IMAGE_NT_HEADERS -> IMAGE_OPTIONAL_HEADER -> Address of Entry Point
Title: Re: EXE Entry Point
Post by: Vortex on December 28, 2013, 06:17:03 AM
Tutorial 4: Optional Header :

http://win32assembly.programminghorizon.com/pe-tut4.html
Title: Re: EXE Entry Point
Post by: buck12 on December 29, 2013, 04:06:29 AM
This is great information, thanks guys!
:t
Title: Re: EXE Entry Point
Post by: Gunther on December 29, 2013, 06:06:53 AM
Hi Erol,

Quote from: Vortex on December 28, 2013, 06:17:03 AM
Tutorial 4: Optional Header :

http://win32assembly.programminghorizon.com/pe-tut4.html

thank you for the link. You're a devil of a fellow.  :t

Gunther