flat assembler
Message board for the users of flat assembler.

Index > Windows > Why doesn't process terminate?

Goto page 1, 2  Next
Author
Thread Post new topic Reply to topic
bitRAKE



Joined: 21 Jul 2003
Posts: 4177
Location: vpcmpistri
bitRAKE 17 Dec 2007, 23:21
This seems to be a common problem for me. All the ATL threads are still active. How do I get them to terminate?
Code:
format PE GUI 4.0

hInstance = $400000

section '.bitRAKE' code import readable executable writeable

dd 0,0,0, RVA kernel_name,   RVA kernel_table
dd 0,0,0, RVA user_name,     RVA user_table
dd 0,0,0, RVA atl_name,      RVA atl_table
dd 0,0,0, 0,                 0

kernel_table:
        ExitProcess      dd RVA _ExitProcess
                         dd 0
user_table:
        CreateWindowExA  dd RVA _CreateWindowExA
        DispatchMessageA dd RVA _DispatchMessageA
        GetMessageA      dd RVA _GetMessageA
        GetSystemMetrics dd RVA _GetSystemMetrics
        MessageBoxA      dd RVA _MessageBoxA
                         dd 0
atl_table:
        AtlAxWinInit     dd RVA _AtlAxWinInit
                         dd 0

;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
include "%fasminc%/WIN32AX.INC"

entry $
        xor ebp,ebp
        call [AtlAxWinInit]
        test eax,eax
        jne .ok
        invoke MessageBoxA,ebp,"Failed!",_AtlAxWinInit+2,MB_ICONEXCLAMATION
        jmp .x

.ok:    invoke GetSystemMetrics,SM_CXSCREEN
        mov esi,eax
        invoke GetSystemMetrics,SM_CYSCREEN
        mov edi,eax

        invoke CreateWindowExA,\
          WS_EX_ACCEPTFILES or WS_EX_OVERLAPPEDWINDOW,\
          "AtlAxWin",\
          "http://board.flatassembler.net/index.php",\
          WS_VISIBLE or WS_POPUP or WS_HSCROLL or WS_VSCROLL,\
          ebp,ebp,esi,edi,\
          ebp,ebp,hInstance,ebp

        mov ebx,msg
        jmp .get
.msg:   push ebx
        call [DispatchMessageA]
.get:   invoke GetMessageA,ebx,ebp,ebp,ebp
        test eax,eax
        jne .msg

.x:     push eax
        call [ExitProcess]
        retn


;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

kernel_name db 'KERNEL32',0
user_name   db 'USER32',0
atl_name    db "ATL",0

_ExitProcess      db 0,0,'ExitProcess',0

_CreateWindowExA  db 0,0,'CreateWindowExA',0
_DispatchMessageA db 0,0,'DispatchMessageA',0
_GetMessageA      db 0,0,'GetMessageA',0
_GetSystemMetrics db 0,0,'GetSystemMetrics',0
_MessageBoxA      db 0,0,'MessageBoxA',0

_AtlAxWinInit     db 0,0,"AtlAxWinInit",0

;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

msg MSG    
Post 17 Dec 2007, 23:21
View user's profile Send private message Visit poster's website Reply with quote
MichaelH



Joined: 03 May 2005
Posts: 402
MichaelH 18 Dec 2007, 08:00
http://board.flatassembler.net/topic.php?t=6085


Tomasz Grysztar wrote:

The plugin system is in its final design stage. Actually, there are actually many things already prepared




Yippee, a plugin system for fasm is in its final design stage ..... should be any day now Wink
Post 18 Dec 2007, 08:00
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 4177
Location: vpcmpistri
bitRAKE 18 Dec 2007, 10:33
I'm very interested in what Tomasz has devised. Currently, I'm just marking the changes that have been made in the source to make it easier to forward patches.

I really don't like any of the syntax highlighting solutions thus far. Instead it would be better to have different color sets for different purposes. For example, the instructions can be divided into groups based on function, or architecture, or data type, or flags effected, etc... Each grouping has a specific use and coloring would help assist debugging or composing algorithms.

Additionally, assembly directives should be colored differently than preprocessing directives (I like these bold). This way a sharp division in functionality of language syntax can be clearly seen.
Post 18 Dec 2007, 10:33
View user's profile Send private message Visit poster's website Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3175
Location: Denmark
f0dder 18 Dec 2007, 12:53
bitRAKE: do you ever reach the ExitProcess call? If you do, the process really ought to terminate, on matter how many ATL threads have been created...
Post 18 Dec 2007, 12:53
View user's profile Send private message Visit poster's website Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 18 Dec 2007, 13:06
I think f0dder is right. Study MSDN about when GetMessage returns 0.
Post 18 Dec 2007, 13:06
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8367
Location: Kraków, Poland
Tomasz Grysztar 18 Dec 2007, 13:16
Good, that you reminded me. I should finally make at least the elementary plugin interface available, so people could start to extend fasmw in at least the basic areas.
Post 18 Dec 2007, 13:16
View user's profile Send private message Visit poster's website Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 18 Dec 2007, 13:42
Code:
        test eax,eax
        jne .msg
    


Could be changed to
Code:
        inc eax
        cmp eax, 1
        ja  .msg
    


To also handle the case in which GetMessage could return -1. It is documented but normally no one cares about the possibility of a -1 result. Perhaps there is something that guarantees that such result will never happen?
Post 18 Dec 2007, 13:42
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 4177
Location: vpcmpistri
bitRAKE 18 Dec 2007, 17:37
f0dder wrote:
bitRAKE: do you ever reach the ExitProcess call? If you do, the process really ought to terminate, on matter how many ATL threads have been created...
No, it never gets there. I suspect it needs a parent window? Scripts are crashing within the browser window, too, but the keys are working.
Code:
.msg:   invoke SendMessageA,esi,WM_FORWARDMSG,0,ebx
        test eax,eax
        jne .get
        invoke DispatchMessageA,ebx
.get:   invoke GetMessageA,ebx,ebp,ebp,ebp
        test eax,eax
        je .x
        inc eax
        jne .msg    
...and it now covers the -1 GetMessage return value.
Post 18 Dec 2007, 17:37
View user's profile Send private message Visit poster's website Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3175
Location: Denmark
f0dder 18 Dec 2007, 23:47
Yeah, you probably need to stuff it inside a parent window, and let the parent window handle WM_CLOSE and WM_DESTROY... think of it, it'd be hilarious for a child control to PostQuitMessage when it's destroyed Smile
Post 18 Dec 2007, 23:47
View user's profile Send private message Visit poster's website Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 4177
Location: vpcmpistri
bitRAKE 19 Dec 2007, 00:49
Was going to setup event handler for quit message from browser, but then I noticed other stuff not working - can't even post to the forum without it choking on some script.

There is one example ( http://www.codeproject.com/KB/cpp/FlashGui.aspx ) that doesn't pass a parent window, but everything else I've come across does. And there is a good article which doesn't indicate the need for a parent window, but their code always has it as a child window. It says the control sub-classes the AtlAxWin window. Anyhow, I can't imagine it posting the WM_QUIT message - something must be done about that.

Obviously, much more involved than I wish it to be. Laughing
Post 19 Dec 2007, 00:49
View user's profile Send private message Visit poster's website Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3175
Location: Denmark
f0dder 19 Dec 2007, 12:10
Well, if you subclass the window, you can have it PostQuitMessage on window close, and probably don't need a parent window then...
Post 19 Dec 2007, 12:10
View user's profile Send private message Visit poster's website Reply with quote
Yardman



Joined: 12 Apr 2005
Posts: 244
Location: US
Yardman 20 Dec 2007, 18:45
[ Post removed by author. ]


Last edited by Yardman on 04 Apr 2012, 02:57; edited 1 time in total
Post 20 Dec 2007, 18:45
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 4177
Location: vpcmpistri
bitRAKE 20 Dec 2007, 19:08
Thank you, that is a cute game. (c:

I was just trying to find a way around creating the parent window - silly, I know!
Post 20 Dec 2007, 19:08
View user's profile Send private message Visit poster's website Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3175
Location: Denmark
f0dder 20 Dec 2007, 23:37
bitRAKE wrote:
Thank you, that is a cute game. (c:

I was just trying to find a way around creating the parent window - silly, I know!


Well, subclass and have WM_CLOSE do PostQuitMessage. But you might as well go for parent window right away, will make it easier to add toolbars and whatnot if you want to do that later on.

_________________
Image - carpe noctem
Post 20 Dec 2007, 23:37
View user's profile Send private message Visit poster's website Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 4177
Location: vpcmpistri
bitRAKE 21 Dec 2007, 11:34
Couple changes:
  • full screen
  • keyboard input is forwarded


(parent window of course solved all the previous problems. yet, I still have no idea why it is required.)


Description: Requires Yardman's frogleap.swf
Download
Filename: frogleap.asm
Filesize: 3.78 KB
Downloaded: 230 Time(s)

Post 21 Dec 2007, 11:34
View user's profile Send private message Visit poster's website Reply with quote
Yardman



Joined: 12 Apr 2005
Posts: 244
Location: US
Yardman 21 Dec 2007, 17:48
[ Post removed by author. ]


Last edited by Yardman on 04 Apr 2012, 02:58; edited 1 time in total
Post 21 Dec 2007, 17:48
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 4177
Location: vpcmpistri
bitRAKE 31 Mar 2008, 18:38
Another example of using Javascript and HTML from fasm:
(I just converted it to FASM, author is http://www.kakeeware.com/i_htmldialog.php)
Code:
include 'win32wx.inc'

.end start

start:
.frame = 4096
        sub esp,.frame
        xor ebx,ebx
        mov ebp,esp

        invoke lstrcpy,ebp,uRes
        lea eax,[ebp+uRes.bytes-2]
        invoke GetModuleFileName,ebx,eax,.frame-uRes.bytes
        invoke lstrcat,ebp,uMet
        invoke CoInitialize,ebx

        push ebp
        invoke CreateURLMoniker,ebx,ebp,esp

        invoke ShowHTMLDialog,ebx,dword[esp+12],ebx,ebx,ebx

        invoke CoUninitialize
        invoke ExitProcess,ebx


uRes du "res://",0
.bytes = $-uRes

uMet du "/#1",0



data resource

  directory \
        RT_HTML,html

  resource html,\
        1,LANG_ENGLISH+SUBLANG_DEFAULT,html_data

  resdata html_data
    db \
    '<html>',\
      '<head>',\
        '<title>HTMLDialog</title>',\
        '<script>',\
          'function init()',\
          '{',\
            'C=Math.cos;',\
            'L=H.filters.Light;',\
            't=144;',\
            'x=520;',\
            'A=setInterval("A+=.1;L.clear();',\
              'L.addPoint(t+256*C(A),t-t*C(A*3),t+96*C(A*2),192,x,x,x);',\
              'L.addPoint(t-128*C(A*1.7),192+t*C(A*2),t+32*C(A*2),x,x,192,x);',\
              'L.addPoint(t-64*C(A*1.3),t+64*C(A*2),128+t*C(A*2),x,255-x,64,x)",9)',\
          '}',\
        '</script>',\
      '</head>',\
      '<body onload=init(); scroll=no style="border:0;margin:0;padding;0" bgcolor=#000000>',\
        '<table align=center valign=middle cellpadding=0 cellspacing=0 width=100 style="border:0;margin:0;padding;0">',\
          '<tr valign=middle>',\
            '<td align=center>',\
              '<textarea id=H style=filter:Light;height:500;width:500>',\
                'JavaScript code ripped (and modified :) ',\
                'from an amazing HTML Metaballs demo by poi ;)',\
              '</textarea>',\
            '</td>',\
          '</tr>',\
        '</table>',\
      '</body>',\
    '</html>',0
  endres

end data    
Works on my system without CoInitialize / CoUnInitialize.

_________________
¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup
Post 31 Mar 2008, 18:38
View user's profile Send private message Visit poster's website Reply with quote
itsnobody



Joined: 01 Feb 2008
Posts: 93
Location: Silver Spring, MD
itsnobody 01 Apr 2008, 00:47
The reason it doesn't terminate is because it's just a message loop...I don't think a parent window is required

if you just have a message loop in any program it won't terminate
Post 01 Apr 2008, 00:47
View user's profile Send private message Reply with quote
itsnobody



Joined: 01 Feb 2008
Posts: 93
Location: Silver Spring, MD
itsnobody 01 Apr 2008, 02:35
I got it kind of working without a Parent window, you have to use Sub-classing for child windows...
Post 01 Apr 2008, 02:35
View user's profile Send private message Reply with quote
itsnobody



Joined: 01 Feb 2008
Posts: 93
Location: Silver Spring, MD
itsnobody 01 Apr 2008, 02:45
Here it is works perfectly without a useless wasted parent window:
Code:
format PE GUI 4.0

hInstance = $400000 

section '.bitRAKE' code import readable executable writeable 

dd 0,0,0, RVA kernel_name,   RVA kernel_table 
dd 0,0,0, RVA user_name,     RVA user_table 
dd 0,0,0, RVA atl_name,      RVA atl_table 
dd 0,0,0, 0,                 0 

kernel_table: 
        ExitProcess      dd RVA _ExitProcess 
                         dd 0 
user_table:
        CallWindowProc   dd RVA _CallWindowProc
        CreateWindowExA  dd RVA _CreateWindowExA 
        DispatchMessageA dd RVA _DispatchMessageA 
        GetMessageA      dd RVA _GetMessageA 
        GetSystemMetrics dd RVA _GetSystemMetrics 
        MessageBoxA      dd RVA _MessageBoxA
        SetWindowLong    dd RVA _SetWindowLong
                         dd 0 
atl_table: 
        AtlAxWinInit     dd RVA _AtlAxWinInit 
                         dd 0 

;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 
include "WIN32AX.INC"

oldProc dd ?

entry $ 
        xor ebp,ebp 
        call [AtlAxWinInit] 
        test eax,eax 
        jne .ok 
        invoke MessageBoxA,ebp,"Failed!",_AtlAxWinInit+2,MB_ICONEXCLAMATION 
        jmp .x 

.ok:    invoke GetSystemMetrics,SM_CXSCREEN 
        mov esi,eax 
        invoke GetSystemMetrics,SM_CYSCREEN 
        mov edi,eax 

        invoke CreateWindowExA,\ 
          WS_EX_ACCEPTFILES or WS_EX_OVERLAPPEDWINDOW,\ 
          "AtlAxWin",\ 
          "http://board.flatassembler.net/index.php",\ 
          WS_VISIBLE or WS_POPUP or WS_HSCROLL or WS_VSCROLL,\ 
          ebp,ebp,esi,edi,\ 
          ebp,ebp,hInstance,ebp 
          invoke SetWindowLong,eax,GWL_WNDPROC,DestroyProc
          mov [oldProc],eax
        mov ebx,msg 
        jmp .get 
.msg:   push ebx 
        call [DispatchMessageA] 
.get:   invoke GetMessageA,ebx,ebp,ebp,ebp 
        test eax,eax 
        jne .msg 

.x:     push eax 
        call [ExitProcess] 
        retn


proc DestroyProc hwnd,wmsg,wparam,lparam
        cmp     [wmsg],WM_DESTROY
        je      .wmdestroy
        invoke CallWindowProc,[oldProc],[hwnd],[wmsg],[wparam],[lparam]
        ret
  .wmdestroy:
        invoke ExitProcess,0
endp




;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 

kernel_name db 'KERNEL32',0 
user_name   db 'USER32',0 
atl_name    db "ATL",0 

_ExitProcess      db 0,0,'ExitProcess',0 

_CreateWindowExA  db 0,0,'CreateWindowExA',0 
_DispatchMessageA db 0,0,'DispatchMessageA',0 
_GetMessageA      db 0,0,'GetMessageA',0 
_GetSystemMetrics db 0,0,'GetSystemMetrics',0 
_MessageBoxA      db 0,0,'MessageBoxA',0 
_SetWindowLong    db 0,0,'SetWindowLongA',0
_CallWindowProc   db 0,0,'CallWindowProcA',0
_AtlAxWinInit     db 0,0,"AtlAxWinInit",0 

;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 

msg MSG
    


I just had to import 2 functions and add a variable
Post 01 Apr 2008, 02:45
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page 1, 2  Next

< 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-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.