I have been debugging some .exe and noticied that before I start debugging step by step, at the very beginning of the program, there are already some values loaded in the stack? What are these?
I am using OllyDbg and some of the “labels” for these values are:
- return to kernel32.7C8…
- ntdll.7C9…
- End of SEH chain
- SE handler
Thanks.
The kernel gives special treatment to the “system DLL”, a.k.a. ntdll. This DLL is mapped into every process no matter what. When the system starts the kernel looks up the address of RtlUserThreadStart in ntdll, and this serves as the lowest-level user-mode entry point of a new thread. This function then initializes the “Win32” subsystem. The address of your program’s main function is stored in the executable header, and that is retrieved and called. Note that the you may have C runtime code as the entry point.
If there is C or C++ runtime, you’ll get the stock ‘CRTStartup’ function, which will eventually get around to calling
main.