I think you'll be happy with MASM. Most of the examples you'll find are MASM, and I think it's fair to say that most here use, or at least know MASM, and will be able to help with any problems. :)
Posted on 2003-12-10 22:52:15 by S/390
well i code NASM win32 assembly since 1999 , and started with

the first visual assembler project :

http://www.fortunecity.com/skyscraper/lycos/403/

and it was based on NASM .


if some one wants to start code with NASM i recomend to download this package

TomCat's Win32 Programming with NASM: w32nasm.zip, w32nasm.txt
ftp://ftp.szif.hu/pub/demos/tool/w32nasm.zip

there are a lot of examples there.


then you can use NAGOA RAD IDE for NASM , that has a lot of macros to help you code.



your problem is that you do not understand the stack , and use parameters like

ebp+8 etc..... without knoing what your are doing , then the RET ... the RET in NASM is REAl assembly not like in MASM ...




parameter can be esp+4 depends on the aproax you do.

then you have to restore the stack .



look what you have done:


DisreguardMessageA:
push dword PARAM4
push dword PARAM3
push dword PARAM2
push dword
call
leave
ret


?????


mmmm do you no assembly?






i will show an example my be can help you.
imagine a rotin that use 3 arguments:

push arg_3
push arg_2
push arg_1
CALL rotin


stack is :

arg_3 = esp+12
arg_2 = esp+8
arg_1 = esp+4



rotin:

; here we use or not the arguments...
; but then we have to restore the stack !!!

ret 12 ; VERY IMPORTANT !!!




push arg_3
push arg_2
push arg_1
call rotin


stack is :

arg_3 = esp+12
arg_2 = esp+8
arg_3 = esp+4



if we use stack frame :





the our arguments are at diferent position :)



becouse we pushed ebp in to the stack !

rotin :

push ebp ; same of enter 0,0
mov ebp,esp ;

know arguments are here

arg_1 = esp+8
arg_2 = esp+12
arg_3 = esp+16
ebp = esp +4
esp


but we sad -> mov ebp,esp

so ebp = esp

lets use ebp then


so the arguments are ( using stack frame ) :

arg_1 = ebp+8
arg_2 = ebp+12
arg_3 = ebp+16


stack in win32 is organized in 32 bits = 4 bytes .



so we walk on the stack adding 4 :)




rotin :

push ebp ; make stack frame
mov ebp,esp

; use or not the arguments.....

mov esp,ebp ; destroy stack frame
pop ebp
ret 16 ; supose that the last argument is ebp+16 so ret 16





formula is RET 4 x ( number arguments)





if you want to use NASM NAGOA it is like this :



proc rotina , arg_1,arg_2,arg_3

;use or not arguments

endproc




i hope i help :)


some links :

old win32n.inc

http://194.65.3.199/win32asm/examples.html


using NASM NAGOA.INC :

http://sapp.telepac.pt/win32asm/

http://groups.yahoo.com/group/win32-nasm-users/
Posted on 2003-12-11 12:32:13 by Nguga
thanks. perhaps there's hope for a future with nasm after all.
my whole stack manipulation is pretty stupid now that im looking at it.. i didnt really look at it before because i figured the problem would happen before WndProc. :tongue: :notsure:
Posted on 2003-12-11 12:44:37 by bnice2137

The problem is in CreateWindowEx. Somehow the return value is 0 and the error code is ERROR_INVALID_WINDOW_HANDLE but I could not figure out why.


A bit off topic, but it's strange we got different error codes from the same call.
Maybe because we used different OS vesions? :confused:
And anyway both error codes are absurd! :grin:
Posted on 2003-12-11 14:14:09 by QvasiModo
just posting using NASM without any proc macro

%include "\lab\vasm\inc\nagoa.inc"



AppName db 'My First Window',0
ClassName db 'Simple WindowClass',0
wc resb WNDCLASSEX_size
msg resb MSG_size
hInstance dd 0
CommandLine dd 0
hParentWnd dd 0



..start:
push 0
call GetModuleHandleA
mov dword , eax
invoke WinMain
push eax
call ExitProcess

WinMain:
mov dword ,WNDCLASSEX_size
mov dword , CS_HREDRAW | CS_VREDRAW
mov dword , WndProc
mov dword , 0
mov dword , 0
mov dword eax,
mov dword , eax
mov dword , COLOR_WINDOW + 1
mov dword , 0
mov dword , ClassName
mov dword , 0
push dword IDC_ARROW
push dword
call LoadCursorA
mov dword , eax
push dword IDI_APPLICATION
push dword
call LoadIconA
mov dword , eax
push wc
call RegisterClassExA
push dword 0
push dword
push dword 0
push dword 0
push dword CW_USEDEFAULT
push dword CW_USEDEFAULT
push dword CW_USEDEFAULT
push dword CW_USEDEFAULT
push dword WS_CAPTION + WS_MAXIMIZEBOX + WS_MINIMIZEBOX + WS_SIZEBOX | WS_SYSMENU + WS_VISIBLE
push dword AppName
push dword ClassName
push dword WS_EX_CLIENTEDGE + WS_EX_WINDOWEDGE
call CreateWindowExA
mov dword , eax
push dword SW_SHOWDEFAULT
push dword
call ShowWindow
push dword
call UpdateWindow

.MSGloop
call GetMessage, msg, NULL, 0, 0
cmp eax, 0
je .fin
call TranslateMessage, msg
call DispatchMessage, msg
jmp .MSGloop
.fin
mov eax, dword
ret

WndProc:
push ebp
mov ebp,esp
mov eax, dword
cmp eax, WM_DESTROY
jne .next_1
call PostQuitMessage, 0
.next_1
call DefWindowProc, , , ,
mov esp,ebp
pop ebp
ret 16
Posted on 2003-12-11 14:32:19 by Nguga
call DefWindowProc, [ebp+8], [ebp+12], [ebp+16],[ebp+20]

Didn't know NASM could do that. Isn't it the same as MASM's invoke? ;)
Posted on 2003-12-11 14:49:40 by QvasiModo
its a macro in NAGOA inc it also does this :



call MessageBox, 0, "Assembler is easy.", "NASM (Netwide Assembler)", 0


call WriteConsole, , {"hello", 13, 10}, 7, n, 0










http://www.artolindsay.com/invoke.htm :)





just found this links:

http://www.gametutorials.com/Tutorials/Win32/Win32_Pg1.htm

http://www.relisoft.com/win32/winnie.html
Posted on 2003-12-11 18:11:05 by Nguga