flat assembler
Message board for the users of flat assembler.

Index > Windows > Why doesn't process terminate?

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



Joined: 21 Jul 2003
Posts: 4024
Location: vpcmpistri
bitRAKE 01 Apr 2008, 02:59
itsnobody wrote:
Here it is works perfectly without a useless wasted parent window...
I just had to import 2 functions and add a variable
Nice solution - appears to work well.

_________________
¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup
Post 01 Apr 2008, 02:59
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, 03:13
bitRAKE wrote:
itsnobody wrote:
Here it is works perfectly without a useless wasted parent window...
I just had to import 2 functions and add a variable
Nice solution - appears to work well.


Thanks

There still might be some better solution somewhere
Post 01 Apr 2008, 03:13
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 4024
Location: vpcmpistri
bitRAKE 01 Apr 2008, 04:42
Lessthan 1k without compression is pretty good. Laughing
(yeah, I was board and this is more fun than TV.)
Code:
hInstance = $100000

format PE GUI 4.0 at hInstance
;       Reserve,        Commit
stack   $1000,          $1000
heap    $10000,         $10000


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
        __SendMessageA     dd RVA _SendMessageA
        __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"

DestroyProc:
        label .uMsg dword at esp+8

        cmp [.uMsg],WM_DESTROY
        pop eax
        je @F
        db $68 ; push imm32
  .old: dd hInstance
        push eax
        jmp [__CallWindowProc]

_Failed   db "Failed",0

Fail:   lea eax,[_Failed-(_AtlAxWinInit+2)+ebx]
        push MB_ICONEXCLAMATION
        push ebx
        push eax ; push _Failed
        push ebp
        call [MessageBoxA]

@@:     push 0
        call [__ExitProcess]

_AtlAxWinInit: db 0,0,"AtlAxWinInit",0



;label ExitProcess      dword at ebx+__ExitProcess     -(_AtlAxWinInit+2)
;label CallWindowProc   dword at ebx+__CallWindowProc  -(_AtlAxWinInit+2)
label CreateWindowExA  dword at ebx+__CreateWindowExA -(_AtlAxWinInit+2)
label DispatchMessageA dword at ebx+__DispatchMessageA-(_AtlAxWinInit+2)
label GetMessageA      dword at ebx+__GetMessageA     -(_AtlAxWinInit+2)
label SendMessageA     dword at ebx+__SendMessageA    -(_AtlAxWinInit+2)
label GetSystemMetrics dword at ebx+__GetSystemMetrics-(_AtlAxWinInit+2)
label MessageBoxA      dword at ebx+__MessageBoxA     -(_AtlAxWinInit+2)
label SetWindowLong    dword at ebx+__SetWindowLong   -(_AtlAxWinInit+2)
label AtlAxWinInit     dword at ebx+__AtlAxWinInit    -(_AtlAxWinInit+2)


entry $
        mov ebx,_AtlAxWinInit+2
        xchg eax,ebp ;xor ebp,ebp
        call [AtlAxWinInit]
        xchg eax,ecx
        jecxz Fail

        push ebp        ; CreateWindowExA.lParam
        ; CreateWindowExA.hInstance
        push dword [ebx+DestroyProc.old-(_AtlAxWinInit+2)]
        push ebp        ; CreateWindowExA.hMenu
        push ebp        ; CreateWindowExA.hParent

        push SM_CYSCREEN
        call [GetSystemMetrics]
        push eax        ; CreateWindowExA.Height

        push ebp ; SM_CXSCREEN
        call [GetSystemMetrics]
        push eax        ; CreateWindowExA.Width

        mov [ebx+8],ebp

        lea eax,[_url-(_AtlAxWinInit+2)+ebx]
        lea esi,[ebx+DestroyProc-(_AtlAxWinInit+2)]
        push ebp        ; CreateWindowExA.Y
        push ebp        ; CreateWindowExA.X
        push WS_VISIBLE or WS_POPUP or WS_HSCROLL or WS_VSCROLL
        push eax ; _url ; CreateWindowExA.Title
        push ebx        ; CreateWindowExA.Class
        push WS_EX_ACCEPTFILES or WS_EX_OVERLAPPEDWINDOW
        call [CreateWindowExA]

        push esi
        push GWL_WNDPROC
        push eax
        xchg eax,esi
        call [SetWindowLong]
        ; seems dangerous to set this after the fact
        mov [ebx+DestroyProc.old-(_AtlAxWinInit+2)],eax

        ; reuse EBX for MSG structure
.get:   push ebp
        push ebp
        push ebp
        push ebx
        call [GetMessageA]
        xchg eax,ecx
        jecxz @B

        push ebx
        push ebp
        push $37F ; WM_FORWARDMSG
        push esi
        call [SendMessageA]
        test eax,eax
        jne .get

        push ebx
        call [DispatchMessageA]
        jmp .get

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

_url db "http://board.flatassembler.net",0

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

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
_SendMessageA     db 0,0,'SendMessageA',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    
(24 bytes to spare for longer URLs.)

The accellerator keys don't work (need to send WM_FORWARDMSG to have ATL process messages).

Edit: I've fixed the message processing to support accellerators. Quite a bit more work to keep it under 1k - still more bytes to spare. Enjoy. Razz

Edit, again: shaved off some more bytes, made code more concise...

_________________
¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup


Last edited by bitRAKE on 11 Apr 2008, 20:33; edited 1 time in total
Post 01 Apr 2008, 04:42
View user's profile Send private message Visit poster's website Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 4024
Location: vpcmpistri
bitRAKE 01 Apr 2008, 17:00
ShowHTMLDialog works with some Flash files, for example:

Haven't found a way to embed the Flash file in the resource section, yet. Figure it's something silly like needing full path name.


Description: http://lightforce.freestuff.gr/ FullHex game.
Download
Filename: FullHex.rar
Filesize: 1.27 KB
Downloaded: 142 Time(s)


_________________
¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup
Post 01 Apr 2008, 17:00
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:  
Goto page Previous  1, 2

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

Website powered by rwasa.