Name: Anonymous 2010-07-20 8:24
7kb of code for hello world?
.00401016: 55 push ebp
.00401017: 8BEC mov ebp,esp
.00401019: 6808104000 push 000401008 ;'Hello world!' --↑1
.0040101E: FF1500104000 call printf
.00401024: 59 pop ecx
.00401025: 33C0 xor eax,eax
.00401027: 5D pop ebp
.00401028: C3 retn
.00401029: CC int 3
.0040102A: CC int 3
.0040102B: CC int 3
[code]
So you have the function prologue/epilogue (can be eliminated by increasing optimization settings, /Ox should do the trick:
[code]
00401016: 6808104000 push 00401008 ;'Hello world!' --↑1
0040101B: FF1500104000 call printf
00401021: 59 pop ecx
00401022: 33C0 xor eax,eax
00401024: C3 retn)
Application starts with top of stack looking like:
0012FFC4 7C816FD7 RETURN to kernel32.7C816FD7
7C816FD7 50 PUSH EAX
7C816FD8 E8 7B50FFFF CALL kernel32.ExitThread), so you'd get the expected results (it also places a SEH handler and some other useful things), but it doesn't have to do any of that(it's undocumented behaviour), so a compliant Win32 application should call ExitProcess or ExitThread when they need to exit (or do it portably through libc).