flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
edemko 18 Jun 2010, 08:36
i'm between ';;' marks
![]() Code: ; Template for program using standard Win32 headers format PE GUI 4.0 entry start include 'win32wx.inc' section '.text' code readable executable ;; ;ps PAINTSTRUCT ;wnd dd ? ;; start: invoke GetModuleHandle,0 mov [wc.hInstance],eax invoke LoadIcon,0,IDI_APPLICATION mov [wc.hIcon],eax invoke LoadCursor,0,IDC_ARROW mov [wc.hCursor],eax invoke RegisterClass,wc test eax,eax jz error invoke CreateWindowEx,0,_class,_title,WS_VISIBLE+WS_DLGFRAME+WS_SYSMENU,128,128,256,192,NULL,NULL,[wc.hInstance],NULL test eax,eax jz error ;INVOKE ShowWindow, HWND,SW_SHOWNORMAL ; INVOKE UpdateWindow, hwnd msg_loop: invoke GetMessage,msg,NULL,0,0 cmp eax,1 jb end_loop jne msg_loop invoke TranslateMessage,msg invoke DispatchMessage,msg jmp msg_loop error: invoke MessageBox,NULL,_error,NULL,MB_ICONERROR+MB_OK end_loop: invoke ExitProcess,[msg.wParam] ;1(return) 2(push ebp) 3 4 5 proc WindowProc uses ebx esi edi, hwnd,wmsg,wparam,lparam ;; ;local .ps:PAINTSTRUCT,\ ; prepend "." before var name to make it visible inside the proc only ; .hwnd:DWORD,\ ; .hi:BYTE ; still .hi:byte will produce an error: a macro is responsible for it ; ; as for me it's better to use handstyle sub esp,sizeof.PAINTSTRUCT+4 label .ps at ebp-5*4-sizeof.PAINTSTRUCT label .wnd at ebp-5*5-sizeof.PAINTSTRUCT ;; cmp [wmsg],WM_DESTROY je .wmdestroy ;; cmp [wmsg],WM_PAINT je .wmpaint ;; .defwndproc: invoke DefWindowProc,[hwnd],[wmsg],[wparam],[lparam] jmp .finish .wmpaint: ;; lea eax,[.ps] push eax ;addr smth = lea edx,[smth], so we save ti:me push eax invoke BeginPaint,[hwnd] call ScrConv inc [score_int32] ;you might wanted square braces invoke EndPaint,[hwnd] jmp .finish ;; .wmdestroy: invoke PostQuitMessage,0 xor eax,eax .finish: ret ScrConv: mov eax, [score_int32] ;you might wanted square braces mov ecx, 4 ;Se isto for alterado ,alterar a intrucao seg. lea ebx, [ecx+6] lp: xor edx, edx div ebx add edx, 48 mov [score_str+ecx-1], dl loop lp ret endp section '.data' data readable writeable _class TCHAR 'FASMWIN32',0 _title TCHAR 'Win32 program template',0 _error TCHAR 'Startup failed.',0 wc WNDCLASS 0,WindowProc,0,0,NULL,NULL,NULL,COLOR_BTNFACE+1,NULL,_class msg MSG score_int32 dd 999 score_str db "CAFECAFE",0 color dd 0 section '.bss' readable writeable hwnd dd ? section '.idata' import data readable writeable library kernel32,'KERNEL32.DLL',\ user32,'USER32.DLL' include 'api\kernel32.inc' include 'api\user32.inc' include 'api\gdi32.inc' |
|||
![]() |
|
edemko 18 Jun 2010, 08:41
to my mind enter,%sizeof.all_vars%,0 would be better instead of standard push ebp + mov ebp,esp: looks smart + variables follow ebp(so easy to count manually)
|
|||
![]() |
|
Elektron 18 Jun 2010, 12:42
Thank you edemko.
The code know compile but trying to execute, windows tells the exe is not ok and not attempt to execute. |
|||
![]() |
|
LocoDelAssembly 18 Jun 2010, 15:36
With your original source replace the WindowProc with this:
Code: proc WindowProc uses ebx esi edi, hwnd,wmsg,wparam,lparam local ps:PAINTSTRUCT,\ hdc: DWORD cmp [wmsg],WM_DESTROY je .wmdestroy .defwndproc: invoke DefWindowProc,[hwnd],[wmsg],[wparam],[lparam] jmp .finish .wmpaint: invoke BeginPaint,[hwnd], addr ps mov [hdc],eax call ScrConv inc [score_int32] invoke EndPaint,[hdc], addr ps .wmdestroy: invoke PostQuitMessage,0 xor eax,eax .finish: ret ScrConv: mov eax, (score_int32) mov ecx, 4 ;Se isto for alterado ,alterar a intrução seg. lea ebx, [ecx+6] lp: xor edx, edx div ebx add edx, 48 mov [score_str+ecx-1], dl loop lp ret endp |
|||
![]() |
|
baldr 18 Jun 2010, 18:51
Elektron,
Are you trying to convert score_int32 offset instead of its value? |
|||
![]() |
|
edemko 18 Jun 2010, 19:26
i press F9 and see the window
OS = WinXp sp3 prof |
|||
![]() |
|
baldr 19 Jun 2010, 01:06
edemko,
That's good, your vision isn't impaired then. ![]() There isn't any output done (yet, I suppose). |
|||
![]() |
|
edemko 19 Jun 2010, 04:55
edemko wrote:
i'm sorry for "the yellow press": it concerns labels only barld wrote:
there is |
|||
![]() |
|
baldr 19 Jun 2010, 06:46
edemko wrote: there is Wait a minute. I thought you wrote "and see the window" in the sense "it doesn't show anything except basic window, just as the original template does". I'd better not read between lines. ;-) |
|||
![]() |
|
edemko 19 Jun 2010, 07:00
i meant there was output executable and the window template it created - a thing Electron had asked
![]() |
|||
![]() |
|
edemko 19 Jun 2010, 07:02
still Electron said Windows had refused executable launching and ours one WinXpSp3 did not
|
|||
![]() |
|
Elektron 26 Jun 2010, 11:29
I am using windows Vista.
Only locodelassembly´s code run here. Anyway thank you all for the replies. Sorry for the my delayed reply but i am busy reading fasm documentation and intel manuals. My nick is Elektron not Electron. |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.