flat assembler
Message board for the users of flat assembler.
Index
> Windows > bug in me or fasm macros |
Author |
|
kohlrak 03 Jun 2007, 01:50
Your problem is the variables.
Code: include 'win32axp.inc' .data _hpen dd 0 _class db 'FooClass',0 _title db 'Foo',0 wcx WNDCLASSEX msg MSG .code proc wndProc hWnd, umsg, wpar, lpar local ps:PAINTSTRUCT local rect:RECT local hdc:DWORD .if [umsg] = WM_PAINT invoke BeginPaint, [hWnd], addr ps mov [hdc], eax invoke GetClientRect, [hWnd], addr rect inc [rect.left] inc [rect.top] dec [rect.right] dec [rect.bottom] invoke Ellipse, [hdc], [rect.left], [rect.top], [rect.right], [rect.bottom] invoke EndPaint, [hWnd], addr ps .elseif [umsg] = WM_DESTROY invoke PostQuitMessage, 0 .else invoke DefWindowProc, [hWnd], [umsg], [wpar], [lpar] ret .endif xor eax, eax ret endp proc start ; Uncomment the following line and program stops working. Why? ; Well it still compiles and executes, but window does not show up. Why? ; I am foxed ! ; local hwnd:DWORD ; *** This line causes error *** mov [wcx.cbSize], sizeof.WNDCLASSEX mov [wcx.style], CS_HREDRAW+CS_VREDRAW mov [wcx.lpfnWndProc], wndProc invoke GetModuleHandle, NULL mov [wcx.hInstance], eax invoke LoadIcon, 0, IDI_APPLICATION mov [wcx.hIcon], eax mov [wcx.hIconSm], eax invoke LoadCursor, 0, IDC_ARROW mov [wcx.hCursor], eax mov [wcx.hbrBackground], COLOR_WINDOW+1 mov [wcx.lpszMenuName], NULL mov [wcx.lpszClassName], _class invoke RegisterClassEx, addr wcx invoke CreateWindowEx, 0, _class, _title, WS_OVERLAPPEDWINDOW, \ 20, 20, 400, 300, 0, 0, [wcx.hInstance], 0 invoke ShowWindow, eax, SW_NORMAL .while TRUE invoke GetMessage, addr wcx, 0, 0, 0 .if eax = 0 invoke ExitProcess, 0 .endif invoke TranslateMessage, addr wcx invoke DispatchMessage, addr wcx .endw endp .end start Just move them to where i put them and it's all fine. |
|||
03 Jun 2007, 01:50 |
|
m 03 Jun 2007, 02:03
I am even more confused now ! ! !
Why I have to do that ? As an aside, I have run the same code in MASM32, without a problem ! |
|||
03 Jun 2007, 02:03 |
|
kohlrak 03 Jun 2007, 02:10
FASMFORMAT != MASMFORMAT
|
|||
03 Jun 2007, 02:10 |
|
m 03 Jun 2007, 02:53
Thank you, Mr. Kohlrak !
The high-level-macros of fasm always confuse me. I feel more comfortable, without them (macros) ! |
|||
03 Jun 2007, 02:53 |
|
Yardman 03 Jun 2007, 03:09
[ Post removed by author. ]
Last edited by Yardman on 04 Apr 2012, 02:14; edited 1 time in total |
|||
03 Jun 2007, 03:09 |
|
kohlrak 03 Jun 2007, 03:42
I've never used those macro, so i'm not 100% sure, but theoretically the code gets placed in the execution area, which if placed carefully could give the right spots the values they need to work, but dangerously.
|
|||
03 Jun 2007, 03:42 |
|
Yardman 03 Jun 2007, 04:46
[ Post removed by author. ]
Last edited by Yardman on 04 Apr 2012, 02:15; edited 1 time in total |
|||
03 Jun 2007, 04:46 |
|
m 03 Jun 2007, 11:29
Yardman is right ! Changing the order or variables did help me!
And if I completely ignore the macros available with fasm, I do feel the the guilt, but my programs work just fine, and are in my total control. T.G. should check his macros (may be), cause I never dared to even try to do something like understanding his macros. |
|||
03 Jun 2007, 11:29 |
|
asmfan 03 Jun 2007, 12:05
Macro is allright. Just as Yardman said the problem is in clearing local vars (the space where esp points). With different sequence of params some portion of local space is initially equal to zero but some not. And calling api funcs that receive pointers on structs we must remember that those structs (or some field of struct e.g. size) should be initialized with values from documentation (e.g. MSDN) or with zeros at least.
|
|||
03 Jun 2007, 12:05 |
|
m 20 Jul 2007, 13:31
It was a BUG in me.
|
|||
20 Jul 2007, 13:31 |
|
FrozenKnight 22 Jul 2007, 08:30
i agree it is nice to know how to do the same thing without macros. but the macros make it much easier. (PS. i have been avoiding using local in a large number of my apps to try to get a better idea of local memory management. just i wish i knew how the macros worked so dynamically.)
|
|||
22 Jul 2007, 08:30 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.