flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
LocoDelAssembly 17 Aug 2006, 05:27
That's because SetWindowText sends WM_SETTEXT every time you call it and since your WindowProc always calls SetWindowText you enter in an infinite recursion which is broken inmediatelly by a stack overflow.
A quick solution is to add Code: cmp [wmsg], WM_SETTEXT je defwndproc |
|||
![]() |
|
daluca 17 Aug 2006, 06:43
well now i understand the infinite recursion thing
but i add to the code your quick solution and still doesn't work it causes a error in KERNEL .i use OllyDbg as my just-in-time debuger an only displays: INT3 command at KERNEL32.DebugBreak did you actually assembled the source and test it? so i can't use functions that send messages to my own window? |
|||
![]() |
|
LocoDelAssembly 18 Aug 2006, 01:27
I tested this:
Code: ; Template for program using standard Win32 headers format PE GUI 4.0 include 'win32ax.inc' section '.data' data readable writeable _title db 'Win32 program template',0 _class db 'FASMWIN32',0 ;---added-------------- buffer db 'xxxxxxxxxx',0 winH dd 0 ;to keep the window handle msg_counter dd 0 ;the counter of the messages ;---added-------------- wc WNDCLASS 0,WindowProc,0,0,NULL,NULL,NULL,COLOR_BTNFACE+1,NULL,_class msg MSG section '.code' code readable executable 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 invoke CreateWindowEx,0,_class,_title,WS_VISIBLE+WS_DLGFRAME+WS_SYSMENU,128,128,192,192,NULL,NULL,[wc.hInstance],NULL ;-----added-------------- mov [winH],eax ;------------------------ msg_loop: invoke GetMessage,msg,NULL,0,0 or eax,eax jz end_loop invoke TranslateMessage,msg invoke DispatchMessage,msg jmp msg_loop end_loop: invoke ExitProcess,[msg.wParam] proc WindowProc hwnd,wmsg,wparam,lparam push ebx esi edi cmp [wmsg],WM_DESTROY je wmdestroy cmp [wmsg], WM_SETTEXT je defwndproc ;-----proc added-------- inc dword[msg_counter] mov eax,[msg_counter] mov esi,buffer call bin2str invoke SetWindowText,[winH],buffer ;----------------------- defwndproc: invoke DefWindowProc,[hwnd],[wmsg],[wparam],[lparam] jmp finish wmdestroy: invoke PostQuitMessage,0 xor eax,eax finish: pop edi esi ebx ret endp ;---------ADDED--------------------- bin2str: ;EAX number to convert push ecx ;ESI pointer to buffer push edi mov ecx,1 mov edi,esi add esi,10 ;-------div10 .divide: push eax mov edx,3435973837 mul edx pop eax and dl,$f8 sub eax,edx shr edx,2 sub eax,edx shr edx,1 xchg eax,edx ;------------------- or dl,$30 dec esi mov [esi],dl inc ecx cmp eax,0 je .salir jmp .divide ;------------------- .salir: cld rep movsb pop edi pop ecx ret ;-------------------- .end start Works on WinXP SP2 |
|||
![]() |
|
daluca 19 Aug 2006, 05:41
thanks..... well I assemble that and it doesn't work in windows ME
and about XP: I will tested later,since i don't have access to it right now. |
|||
![]() |
|
LocoDelAssembly 19 Aug 2006, 15:52
To get out any problems I suggest use another window for the counter, that way you call SetWindowText for that window so your main window will not recieve any undesire message anymore
Code: ; Template for program using standard Win32 headers format PE GUI 4.0 include 'win32ax.inc' section '.data' data readable writeable _title db 'Win32 program template',0 _class db 'FASMWIN32',0 ;---added-------------- buffer db 'xxxxxxxxxx',0 winH dd 0 ;to keep the window handle winC dd 0 msg_counter dd 0 ;the counter of the messages ;---added-------------- wc WNDCLASS 0,WindowProc,0,0,NULL,NULL,NULL,COLOR_BTNFACE+1,NULL,_class msg MSG section '.code' code readable executable 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 invoke CreateWindowEx,0,_class,_title,WS_VISIBLE+WS_DLGFRAME+WS_SYSMENU,128,128,192,192,NULL,NULL,[wc.hInstance],NULL ;-----added-------------- mov [winH],eax invoke CreateWindowEx,0,_class,_title,WS_VISIBLE+WS_DLGFRAME+WS_SYSMENU,128+192,128,192,192,NULL,NULL,[wc.hInstance],NULL mov [winC], eax ;------------------------ msg_loop: invoke GetMessage,msg,NULL,0,0 or eax,eax jz end_loop invoke TranslateMessage,msg invoke DispatchMessage,msg jmp msg_loop end_loop: invoke ExitProcess,[msg.wParam] proc WindowProc hwnd,wmsg,wparam,lparam push ebx esi edi cmp [wmsg],WM_DESTROY je wmdestroy mov eax, [winH] cmp eax, [hwnd] jne defwndproc ;-----proc added-------- inc dword[msg_counter] mov eax,[msg_counter] mov esi,buffer call bin2str invoke SetWindowText,[winC],buffer ;----------------------- defwndproc: invoke DefWindowProc,[hwnd],[wmsg],[wparam],[lparam] jmp finish wmdestroy: invoke PostQuitMessage,0 xor eax,eax finish: pop edi esi ebx ret endp ;---------ADDED--------------------- bin2str: ;EAX number to convert push ecx ;ESI pointer to buffer push edi mov ecx,1 mov edi,esi add esi,10 ;-------div10 .divide: push eax mov edx,3435973837 mul edx pop eax and dl,$f8 sub eax,edx shr edx,2 sub eax,edx shr edx,1 xchg eax,edx ;------------------- or dl,$30 dec esi mov [esi],dl inc ecx cmp eax,0 je .salir jmp .divide ;------------------- .salir: cld rep movsb pop edi pop ecx ret ;-------------------- .end start |
|||
![]() |
|
daluca 20 Aug 2006, 05:45
yeah: thanks that works just fine.
![]() btw: I tested the "other way" (the one that works in your XP sp2 but not in my ME) and it worked to in XP (no-servicepack), strange. |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.