user2214913
user2214913

Reputation: 1511

What arguments are passed to entry point of a PE (Portable Executable) file?

If you assemble a PE (.exe, portable executable for Win32) file it has an entry point which you could call _start, _main or whatever you like.

The question is - is this entry point called with some args? If so, are they accessible in the stack? If so, does this entry point function need to clear the stack? Where can I find some documentation about this?

Upvotes: 8

Views: 1964

Answers (1)

typ1232
typ1232

Reputation: 5607

No the process does not have any information about it's arguments on the stack at the entry point. You have to call GetCommandLine or access the information in the PEB via RTL_USER_PROCESS_PARAMETERS, but that's not a stable API.

Every language support library (like the CRT) has to do this as well.

Upvotes: 6

Related Questions