flat assembler
Message board for the users of flat assembler.

Index > Windows > not exiting process

Author
Thread Post new topic Reply to topic
procyon



Joined: 07 Sep 2007
Posts: 12
procyon
Hi,

I had an app finished but then noticed that even though the window closes upon clicking the 'X', the process is not being terminated. I've stripped the code as bare as possible and hope that someone can help.

Code:
format PE GUI 4.0
entry start

include '%fasminc%\win32axp.inc'

section '.code' code readable executable
  start:
        invoke  GetModuleHandle, 0
        mov     [wc.hInstance],eax
        invoke  RegisterClass,wc
        invoke  CreateWindowEx,NULL,myClass,mainTitle,WS_OVERLAPPEDWINDOW+WS_VISIBLE, 0, 0, 1024, 700, HWND_DESKTOP, NULL, [wc.hInstance],NULL
        mov     [hWndMain], eax
        jmp     msg_loop

msg_loop:
        stdcall DoWork
        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, 0

proc wndProc hwnd, wmsg, wparam, lparam
        push    ebx esi edi
        cmp     [wmsg],WM_DESTROY
        je      .wmDESTROY
    .wmDEFAULT:
        invoke  DefWindowProc,[hwnd],[wmsg],[wparam],[lparam]
        jmp     .wmBYE
    .wmDESTROY:
        invoke  PostQuitMessage, 0
        xor     eax,eax
        jmp     .wmBYE
    .wmBYE:
        pop     edi esi ebx
        ret
endp

proc DoWork
    .begin:
        invoke  PeekMessage, msg, [hWndMain], 0, 0, PM_NOREMOVE
        or      eax, eax
        jz      @f
        ret
    @@:
;       Main work of the program is done here
;       but still makes no difference when stripped.
        jmp     .begin
endp

section '.data' data readable writeable

msg             MSG
wc              WNDCLASS NULL, wndProc, 0, 0, NULL, NULL, NULL, COLOR_3DDKSHADOW+1, NULL, myClass
myClass         db "test", 00
mainTitle       db "test", 00
hWndMain        dd ?

section '.idata' import data readable writeable

library kernel32,'KERNEL32.DLL',\
        user32,  'USER32.DLL'

include '%fasminc%\apia\Kernel32.inc'
include '%fasminc%\apia\User32.inc'
    
Post 03 Feb 2009, 01:43
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17280
Location: In your JS exploiting you and your system
revolution
Maybe you should call PeekMessage with a NULL for the window.
Code:
        invoke  PeekMessage, msg, NULL, 0, 0, PM_NOREMOVE    
Post 03 Feb 2009, 01:55
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17280
Location: In your JS exploiting you and your system
revolution
BTW: Why not use a thread to do your work?

That code reminds me of the old Win3.1 days.
Post 03 Feb 2009, 02:00
View user's profile Send private message Visit poster's website Reply with quote
procyon



Joined: 07 Sep 2007
Posts: 12
procyon
Thx revolution, should have spotted that Sad

Quote:

BTW: Why not use a thread to do your work?

That code reminds me of the old Win3.1 days.


Yep, some habits are hard to break. This particular code is just for myself and I always find this way quicker Wink
Post 03 Feb 2009, 08:19
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17280
Location: In your JS exploiting you and your system
revolution
Old habits die hard. Bad habits die harder. @#%@$ bad habits die hard with a vengeance. With apologies to Bruce Willis.
Post 03 Feb 2009, 10:24
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.