flat assembler
Message board for the users of flat assembler.
Index
> Windows > Simple code crashes. Is it my system or the code? |
Author |
|
Feryno 14 Aug 2013, 06:30
this is wrong:
Code: je exit the jump outside of procedure corrupts the stack but I don't believe this causes crash because ExitProcess is called then immediately anyway briefly looking at your sample I don't see anything suspicious there seems you compiled your app as 32 bit - if you compile as 64 bit then also take care of aligning stack at 16 (no need for 32 bits) try to search some examples here in forum, e.g. use this search pattern: DefWindowProc being stuck for 24 hours with so simple thing is too depressive |
|||
14 Aug 2013, 06:30 |
|
tthsqe 14 Aug 2013, 06:37
Code: format PE GUI 6.0 include "win32axp.inc" invoke GetModuleHandle, 0 mov [wc.hInstance], eax invoke RegisterClass, wc invoke CreateWindowEx, WS_EX_WINDOWEDGE, class, title, WS_CAPTION+WS_SYSMENU+WS_VISIBLE, 300, 300, 300, 300, 0, 0, 0, 0 ; ^^^^ use class here msg_loop: invoke GetMessage, msg, 0, 0, 0 test eax,eax ; jz exit ; must check for exit ! invoke TranslateMessage, msg invoke DispatchMessage, msg jmp msg_loop exit: invoke ExitProcess, 0 proc WindowProc hwnd,wmsg,wparam,lparam ; < no comma after WindowProc cmp [wmsg], WM_DESTROY je .wmdestroy invoke DefWindowProc,[hwnd],[wmsg],[wparam],[lparam] jmp .finish .wmdestroy: invoke PostQuitMessage,0 xor eax,eax .finish: ret endp msg MSG wc WNDCLASS 0,WindowProc,0,0,0,0,0,COLOR_WINDOW,0,class class db 'opengl',0 ; <<< class here title db "Hello, OpenGL!",0 data import library kernel32,'KERNEL32.DLL',\ user32,'USER32.DLL' include "api\kernel32.inc" include "api\user32.inc" end data |
|||
14 Aug 2013, 06:37 |
|
bitRAKE 14 Aug 2013, 06:41
Do you still get the error if you align wc. I'm not able to produce the error here, but I've had similar errors with passing unaligned structures. I'm sure the convention is to align by largest item in structure. Sure it works sometimes without alignment, but it doesn't have to.
_________________ ¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup |
|||
14 Aug 2013, 06:41 |
|
rohagymeg 14 Aug 2013, 08:27
The error had nothing to do with aligning as far as I can tell...
I made a mistake with mixing up the 2 strings, and also, giving the return value of RegisterClass to the lpClassName instead of putting the class name pointer there. Thank you tthsqe for the help! |
|||
14 Aug 2013, 08:27 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.