I compiled the following C++ code with MinGW and opened it in OllyDbg 2.01. And the program stops at the following lines:
CPU Disasm
Address Hex dump Command Comments
00401570 /$ 83EC 1C SUB ESP,1C
00401573 |. C70424 010000 MOV DWORD PTR SS:[LOCAL.6],1
0040157A |. FF15 68814000 CALL DWORD PTR DS:[<&msvcrt.__set_app_ty
00401580 \. E8 FBFBFFFF CALL 00401180
Names in Project1, item 20
Address = 00401570
Section = .text
Type = Export
Ordinal =
Name = <ModuleEntryPoint>
Comments =
However, this is not what I want. I prefer when OllyDbg stop at the following lines:
CPU Disasm
Address Hex dump Command Comments
004016B0 /$ 55 PUSH EBP ; Project1.004016B0(guessed void)
004016B1 |. 89E5 MOV EBP,ESP
004016B3 |. 83E4 F0 AND ESP,FFFFFFF0 ; DQWORD (16.-byte) stack alignment
004016B6 |. 83EC 10 SUB ESP,10
004016B9 |. E8 A2050000 CALL 00401C60
004016BE |. C70424 645040 MOV DWORD PTR SS:[LOCAL.4],OFFSET 004050 ; /format => "Hello World!"
004016C5 |. E8 9E1F0000 CALL <JMP.&msvcrt.printf> ; \MSVCRT.printf
004016CA |. B8 00000000 MOV EAX,0
004016CF |. C9 LEAVE
004016D0 \. C3 RETN
Is that a bug? Why did MinGW set SUB ESP, 1C
as the entrypoint? Can I set Ollydbg to start at the correct entrypoint?