I am playing a little around with MASM. I wanted to make the Executable even smaller. And i know it might not work on other Computers, because the Address could be different there. I just want to have fun and to understand :D

My Problem is, it crashes when i start it by doubleclicking. But when i open it in OllyDbg and start to Run it from there it works. Whats the problem ?

Here the code:

.model flat, stdcall

lpCaption          db "ASM",0
lpText            db "Only",0

mov eax, 2010449130      ;77D504EA MsgBox
push 64
push offset lpCaption
push offset lpText
push 0
call eax
mov eax, 2088880802      ;7C81CAA2 ExitProcess
push 0
call eax
end start

Thanks in Advance
Posted on 2005-10-28 09:59:54 by DeepBlue
I can only guess that it is because kernel32.dll and user32.dll are not loaded. Correct me if I am wrong, but if you load it via a debugger, kernel32.dll and user32.dll are definitely loaded.

Btw as you would have known, it is bad coding practice. Don't do it. Hardcoding API address is bad. Bad.
Posted on 2005-10-28 10:26:01 by roticv
Damn. You are right. Thank you.
But that gives me another problem. How can i load these DLLs, when i cant access LoadLibraryA, because kernel32.dll is not loaded.

i do it just for fun. I just want to see if it is possible to write it this way, without including  *.lib and *.inc files.
Posted on 2005-10-28 10:45:42 by DeepBlue
Why don't you just call ExitProcess. Once you have kernel32.dll mapped in your space, you can call LoadLibrary and GetProcAddr  ;)
Posted on 2005-10-28 22:48:56 by roticv