flat assembler
Message board for the users of flat assembler.

Index > Windows > What type of window\control are these?

Author
Thread Post new topic Reply to topic
DergMoney



Joined: 29 Apr 2015
Posts: 34
DergMoney
At the end of this post are 2 images, the first is a poker table with a HUD (Heads Up Display). A HUD is used to display various statistics regarding each player. In the image there are 9 of these with the text vp:, pfr:, aFq:, just so you know what to look for Wink

I am trying to figure out what type of window\controls these are.

What I do know...

The transparency can be changed so they must be a top-level window (I run Win7 and layered child windows weren't implemented until Win8).
They can be split into rows and columns, a cell for each stat. The ones in the image below have 2 rows and 3 columns.
Tooltips can be displayed by hovering over each cell, giving more information (shown in 2nd image).
They are 'clickable', popping up a similar type window with even more stats.

From my previous post you will see that I tried making a layered popup without success.

Does anyone have any idea what type of window\control these are?

Many thanks


Description:
Filesize: 91.81 KB
Viewed: 1537 Time(s)

hud.jpg


Description:
Filesize: 19.45 KB
Viewed: 1537 Time(s)

hover - tooltip.jpg


Post 13 May 2015, 16:56
View user's profile Send private message Reply with quote
DergMoney



Joined: 29 Apr 2015
Posts: 34
DergMoney
OK, I'll try to give myself a hand and hope someone chips in with ideas.
From the transparent window example file I failed to make a separate popup that I could change the transparency for.
However, if I simply change the original files main window from OVERLAPPEDWINDOW to POPUP the controls do affect the transparency.
Why don't they work if the popup is a separate window?
Post 15 May 2015, 01:09
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17473
Location: In your JS exploiting you and your system
revolution
They could be anything the program wishes. They might not even be "windows" but simply be something the program overlays onto the background text.

The simple answer is we have no way of knowing what the program in the screenshot is doing to draw the images. It might not even be using the Windows windowing objects.
Post 15 May 2015, 01:17
View user's profile Send private message Visit poster's website Reply with quote
DergMoney



Joined: 29 Apr 2015
Posts: 34
DergMoney
Fair enough revolution, thanks for the reply.

Any idea why I can't alter a separate windows transparency?
Post 15 May 2015, 10:58
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17473
Location: In your JS exploiting you and your system
revolution
Show your code.
Post 15 May 2015, 11:02
View user's profile Send private message Visit poster's website Reply with quote
DergMoney



Joined: 29 Apr 2015
Posts: 34
DergMoney
I was messing about with the transparent window example file to try to make a popup window that would have *its* transparency affected by moving the slider in the main window, leaving the transparency of the main window unaffected.

I changed the handle of
Code:
invoke  SetLayeredWindowAttributes,[hwnd],0,ecx,LWA_ALPHA 
    

to
Code:
invoke  SetLayeredWindowAttributes,[hwndpopup],0,ecx,LWA_ALPHA 
    

and added
Code:
invoke  CreateWindowEx, WS_EX_LAYERED,_class, NULL, WS_POPUP + WS_VISIBLE, 400,400,256,192,[hwnd],NULL,[wc.hInstance],NULL 
mov     [hwndpopup], eax 
    

to the .wmcreate event. The main window and the popup are displayed ok but moving the slider has no effect on either window Confused

Here's the full code...
Code:
;setting window transparency example by carlos hernandez/coconut 

format PE GUI 4.0 
entry start 

ID_SCROLLBAR = 1000 
ID_STATIC = 1001 

include '%fasminc%\win32a.inc'  

section '.data' data readable writeable 

  _class TCHAR 'FASMWIN32',0 
  _title TCHAR 'Layered window example',0 
  _error TCHAR 'Startup failed.',0 
  _scrollbar TCHAR 'scrollbar',0 
  _static TCHAR 'static',0 
  _conv TCHAR '%i',0 

  hwndmain   dd ? 
  hwndstatic dd ? 
  hwndscroll dd ? 
  hwndpopup  dd ? 
  buffer rb 32 

  wc      WNDCLASS 0,WindowProc,0,0,NULL,NULL,NULL,COLOR_BTNFACE+1,NULL,_class 

  lpsi    SCROLLINFO sizeof.SCROLLINFO,SIF_ALL,5,255,1,255,0 

  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 
        or      eax,eax 
        jz      error 
        invoke  CreateWindowEx, WS_EX_LAYERED,_class,_title, WS_OVERLAPPEDWINDOW + WS_VISIBLE, 100, 100,256,192,NULL,NULL,[wc.hInstance],NULL 
        test    eax,eax 
        jz      error 
    mov     [hwndmain], eax 

    msg_loop: 
        invoke  GetMessage,msg,NULL,0,0 
        or      eax,eax 
        jz      end_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] 

proc WindowProc hwnd,wmsg,wparam,lparam 
        push    ebx esi edi 
        cmp     [wmsg],WM_HSCROLL 
        je      wmhscroll 
        cmp     [wmsg],WM_CREATE 
        je      wmcreate 
        cmp     [wmsg],WM_DESTROY 
        je      wmdestroy 
  defwndproc: 
        invoke  DefWindowProc,[hwnd],[wmsg],[wparam],[lparam] 
        jmp     finish 
  wmhscroll: 
        mov     eax,[wparam] 
        cmp     ax,SB_THUMBPOSITION                      ;received when thumb stops dragging 
        je      thumbposition 
        cmp     ax,SB_THUMBTRACK                         ;received while thumb is dragging 
        je      thumbposition 
        cmp     ax,SB_LINELEFT                           ;left arrow clicked 
        je      lineleft 
        cmp     ax,SB_LINERIGHT                          ;right arrow clicked 
        je      lineright 
        cmp     ax,SB_PAGELEFT                           ;left space between arrow and thumb clicked 
        je      pageleft 
        cmp     ax,SB_PAGERIGHT                          ;right space between arrow and thumb clicked 
        je      pageright 
        jmp     defwndproc 
  thumbposition:                                         ;for our purposes we'll handle both drag/stop events here 
        mov     [lpsi.fMask],SIF_TRACKPOS 
        invoke  GetScrollInfo,[hwndscroll],SB_CTL,lpsi 
        push    [lpsi.nTrackPos] 
        pop     [lpsi.nPos] 
        mov     [lpsi.fMask],SIF_ALL 
        jmp     update_window 
  lineleft: 
        cmp     [lpsi.nPos],6                           ;transparency under 5 will make window invisible/useless 
        jb      defwndproc 
        dec     [lpsi.nPos] 
        jmp     update_window 
  lineright: 
        cmp     [lpsi.nPos],254                         ;transparency over 255 will make window invisible/useless 
        jg      defwndproc 
        inc     [lpsi.nPos] 
        jmp     update_window 
  pageleft: 
        mov     eax,[lpsi.nPage] 
        sub     [lpsi.nPos],eax 
        jmp     update_window 
  pageright: 
        mov     eax,[lpsi.nPage] 
        add     [lpsi.nPos],eax 
  update_window: 
        mov     ecx,[lpsi.nPos] 
        push    ecx 
        cinvoke wsprintf,buffer,_conv,ecx 
        invoke  SendMessage,[hwndstatic],WM_SETTEXT,0,buffer 
        pop     ecx 
        invoke  SetLayeredWindowAttributes,[hwndpopup],0,ecx,LWA_ALPHA 
        invoke  SetScrollInfo,[hwndscroll],SB_CTL,lpsi,1 
        xor     eax,eax 
        jmp     finish 
  wmcreate:                                                         ;x,y,width,height 
    invoke      CreateWindowEx, WS_EX_LAYERED,_class, NULL, WS_POPUP + WS_VISIBLE, 400,400,256,192,[hwnd],NULL,[wc.hInstance],NULL 
    mov     [hwndpopup], eax 

    invoke      CreateWindowEx,0,_static,_title,WS_VISIBLE+WS_CHILD,25,20,195,25,[hwnd],ID_STATIC,[wc.hInstance],NULL 
        mov     [hwndstatic],eax 

        invoke  CreateWindowEx,0,_scrollbar,NULL,WS_VISIBLE+WS_CHILD+SBS_HORZ,25,55,195,15,[hwnd],ID_SCROLLBAR,[wc.hInstance],NULL 
        mov     [hwndscroll],eax 

        invoke  SetScrollInfo,[hwndscroll],SB_CTL,lpsi,0 
        invoke  SetLayeredWindowAttributes,[hwnd],0,255,LWA_ALPHA 
        xor     eax,eax 
        jmp     finish 
  wmdestroy: 
        invoke  PostQuitMessage,0 
        xor     eax,eax 
  finish: 
        pop     edi esi ebx 
        ret 
endp 

section '.idata' import data readable writeable  
library kernel32,'KERNEL32.DLL',\  
        user32,  'USER32.DLL',\  
        gdi32,   'GDI32.DLL',\  
        comdlg32,'COMDLG32.DLL',\  
        advapi32,'ADVAPI32.DLL',\  
        comctl32,'COMCTL32.DLL'  

include '%fasminc%\api\Kernel32.inc'  
include '%fasminc%\api\User32.inc'  
include '%fasminc%\api\Gdi32.inc'  
include '%fasminc%\api\Comdlg32.inc'  
include '%fasminc%\api\Advapi32.inc'  
include '%fasminc%\api\Comctl32.inc' 



;section '.idata' import data readable writeable 
; 
;  library kernel32,'KERNEL32.DLL',\ 
;         user32,'USER32.DLL' 
; 
;  include 'api\kernel32.inc' 
;  include 'api\user32.inc' 
    


If I don't add the separate window but simply change the main window from WS_OVERLAPPEDWINDOW to WS_POPUP then the transparency is changed.
Post 15 May 2015, 11:19
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17473
Location: In your JS exploiting you and your system
revolution
You are using the same class for both windows so I expect your "hwndpopup" variable is being corrupted when the popup window makes its own popup window.
Post 15 May 2015, 12:31
View user's profile Send private message Visit poster's website Reply with quote
DergMoney



Joined: 29 Apr 2015
Posts: 34
DergMoney
I thought that being the same class might be the case also so I altered the code to make the popup a different class.
It made no difference Sad
btw, the main window is not a popup, it is WS_OVERLAPPEDWINDOW
not sure how you think the window handle could be getting corrupted?

Code:
;setting window transparency example by carlos hernandez/coconut

format PE GUI 4.0
entry start

ID_SCROLLBAR = 1000
ID_STATIC = 1001

include '%fasminc%\win32a.inc' 

section '.data' data readable writeable

  _class TCHAR 'FASMWIN32',0
  _title TCHAR 'Layered window example',0
  _error TCHAR 'Startup failed.',0
  _scrollbar TCHAR 'scrollbar',0
  _static TCHAR 'static',0
  _conv TCHAR '%i',0
  _hud_class TCHAR   'HUD', 00

  hwndmain   dd ?
  hwndstatic dd ?
  hwndscroll dd ?
  hwndpopup  dd ?
  hwndnew1   dd ?
  buffer rb 32

  wc      WNDCLASS 0,WindowProc,0,0,NULL,NULL,NULL,COLOR_BTNFACE+1,NULL,_class
  wcHUD   WNDCLASS 0,WindowProc,0,0,NULL,NULL,NULL,COLOR_BTNFACE+4,NULL,_hud_class

  lpsi    SCROLLINFO sizeof.SCROLLINFO,SIF_ALL,5,255,1,255,0

  msg MSG

section '.code' code readable executable

  start:
        invoke  GetModuleHandle,0
        mov     [wc.hInstance],eax
        mov     [wcHUD.hInstance],eax
        invoke  LoadIcon,0,IDI_APPLICATION
        mov     [wc.hIcon],eax
        mov     [wcHUD.hIcon],eax
        invoke  LoadCursor,0,IDC_ARROW
        mov     [wc.hCursor],eax
        mov     [wcHUD.hCursor],eax
        invoke  RegisterClass,wc
        or      eax,eax
        jz      error
        invoke  RegisterClass,wcHUD
        or      eax,eax
        jz      error
        invoke  CreateWindowEx, WS_EX_LAYERED,_class,_title, WS_OVERLAPPEDWINDOW + WS_VISIBLE, 100, 100,256,192,NULL,NULL,[wc.hInstance],NULL
        test    eax,eax
        jz      error
    mov     [hwndmain], eax

    msg_loop:
        invoke  GetMessage,msg,NULL,0,0
        or      eax,eax
        jz      end_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]

proc WindowProc hwnd,wmsg,wparam,lparam
        push    ebx esi edi
        cmp     [wmsg],WM_HSCROLL
        je      wmhscroll
        cmp     [wmsg],WM_CREATE
        je      wmcreate
        cmp     [wmsg],WM_DESTROY
        je      wmdestroy
  defwndproc:
        invoke  DefWindowProc,[hwnd],[wmsg],[wparam],[lparam]
        jmp     finish
  wmhscroll:
        mov     eax,[wparam]
        cmp     ax,SB_THUMBPOSITION                      ;received when thumb stops dragging
        je      thumbposition
        cmp     ax,SB_THUMBTRACK                         ;received while thumb is dragging
        je      thumbposition
        cmp     ax,SB_LINELEFT                           ;left arrow clicked
        je      lineleft
        cmp     ax,SB_LINERIGHT                          ;right arrow clicked
        je      lineright
        cmp     ax,SB_PAGELEFT                           ;left space between arrow and thumb clicked
        je      pageleft
        cmp     ax,SB_PAGERIGHT                          ;right space between arrow and thumb clicked
        je      pageright
        jmp     defwndproc
  thumbposition:                                         ;for our purposes we'll handle both drag/stop events here
        mov     [lpsi.fMask],SIF_TRACKPOS
        invoke  GetScrollInfo,[hwndscroll],SB_CTL,lpsi
        push    [lpsi.nTrackPos]
        pop     [lpsi.nPos]
        mov     [lpsi.fMask],SIF_ALL
        jmp     update_window
  lineleft:
        cmp     [lpsi.nPos],6                           ;transparency under 5 will make window invisible/useless
        jb      defwndproc
        dec     [lpsi.nPos]
        jmp     update_window
  lineright:
        cmp     [lpsi.nPos],254                         ;transparency over 255 will make window invisible/useless
        jg      defwndproc
        inc     [lpsi.nPos]
        jmp     update_window
  pageleft:
        mov     eax,[lpsi.nPage]
        sub     [lpsi.nPos],eax
        jmp     update_window
  pageright:
        mov     eax,[lpsi.nPage]
        add     [lpsi.nPos],eax
  update_window:
        mov     ecx,[lpsi.nPos]
        push    ecx
        cinvoke wsprintf,buffer,_conv,ecx
        invoke  SendMessage,[hwndstatic],WM_SETTEXT,0,buffer
        pop     ecx
        invoke  SetLayeredWindowAttributes,[hwndpopup],0,ecx,LWA_ALPHA
        invoke  SetScrollInfo,[hwndscroll],SB_CTL,lpsi,1
        xor     eax,eax
        jmp     finish
  wmcreate:                                                         ;x,y,width,height
    invoke      CreateWindowEx, WS_EX_LAYERED,_hud_class, NULL, WS_POPUP + WS_VISIBLE, 400,400,256,192,[hwnd],NULL,[wcHUD.hInstance],NULL
    mov     [hwndpopup], eax

    invoke      CreateWindowEx,0,_static,_title,WS_VISIBLE+WS_CHILD,25,20,195,25,[hwnd],ID_STATIC,[wc.hInstance],NULL
        mov     [hwndstatic],eax

        invoke  CreateWindowEx,0,_scrollbar,NULL,WS_VISIBLE+WS_CHILD+SBS_HORZ,25,55,195,15,[hwnd],ID_SCROLLBAR,[wc.hInstance],NULL
        mov     [hwndscroll],eax

        invoke  SetScrollInfo,[hwndscroll],SB_CTL,lpsi,0
        invoke  SetLayeredWindowAttributes,[hwndpopup],0,255,LWA_ALPHA
        invoke  SetLayeredWindowAttributes,[hwnd],0,255,LWA_ALPHA
        xor     eax,eax
        jmp     finish
  wmdestroy:
        invoke  PostQuitMessage,0
        xor     eax,eax
  finish:
        pop     edi esi ebx
        ret
endp

section '.idata' import data readable writeable 
library kernel32,'KERNEL32.DLL',\ 
        user32,  'USER32.DLL',\ 
        gdi32,   'GDI32.DLL',\ 
        comdlg32,'COMDLG32.DLL',\ 
        advapi32,'ADVAPI32.DLL',\ 
        comctl32,'COMCTL32.DLL' 

include '%fasminc%\api\Kernel32.inc' 
include '%fasminc%\api\User32.inc' 
include '%fasminc%\api\Gdi32.inc' 
include '%fasminc%\api\Comdlg32.inc' 
include '%fasminc%\api\Advapi32.inc' 
include '%fasminc%\api\Comctl32.inc'



;section '.idata' import data readable writeable
;
;  library kernel32,'KERNEL32.DLL',\
;         user32,'USER32.DLL'
;
;  include 'api\kernel32.inc'
;  include 'api\user32.inc'
    


Last edited by DergMoney on 15 May 2015, 12:37; edited 1 time in total
Post 15 May 2015, 12:34
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17473
Location: In your JS exploiting you and your system
revolution
Both your classes use the same WindowProc so they are still really the same class.
Post 15 May 2015, 12:36
View user's profile Send private message Visit poster's website Reply with quote
DergMoney



Joined: 29 Apr 2015
Posts: 34
DergMoney
not sure how to implement this, I never had to use 2 different wndProcs for anything before Sad

Also I'm not sure how this should make a difference, it's a simple call to SetLayeredWindowAttributes passing window handle and values, I can see no reason this isn't working Confused

Also, I checked your website, couldn't find the answer there either Razz


Last edited by DergMoney on 15 May 2015, 12:49; edited 1 time in total
Post 15 May 2015, 12:45
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17473
Location: In your JS exploiting you and your system
revolution
Just make another WindowProcPopUp for the popup window. In your popup creation you probably don't want to create yet another popup window so you would remove that part from the popup create section.

Note: That because you used global labels you will have to make new names for everything. I'd suggest you might want to consider using a leading dot (.) character to make local labels.

Edit: Yeah, my website has been out for a while now. I should fix that at some point.
Post 15 May 2015, 12:49
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: 17473
Location: In your JS exploiting you and your system
revolution
I made a quick edit. It might do what you were considering:
Code:
;setting window transparency example by carlos hernandez/coconut

format PE GUI 4.0
entry start

ID_SCROLLBAR = 1000
ID_STATIC = 1001

include 'win32a.inc'

section '.data' data readable writeable

  _class TCHAR 'FASMWIN32',0
  _class2 TCHAR 'FASMWIN322',0
  _title TCHAR 'Layered window example',0
  _error TCHAR 'Startup failed.',0
  _scrollbar TCHAR 'scrollbar',0
  _static TCHAR 'static',0
  _conv TCHAR '%i',0

  hwndmain   dd ?
  hwndstatic dd ?
  hwndscroll dd ?
  hwndpopup  dd ?
  buffer rb 32

  wc      WNDCLASS 0,WindowProc,0,0,NULL,NULL,NULL,COLOR_BTNFACE+1,NULL,_class
  wc2      WNDCLASS 0,WindowProcpopup,0,0,NULL,NULL,NULL,COLOR_BTNFACE+1,NULL,_class2

  lpsi    SCROLLINFO sizeof.SCROLLINFO,SIF_ALL,5,255,1,255,0

  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
        or      eax,eax
        jz      error
        invoke  GetModuleHandle,0
        mov     [wc2.hInstance],eax
        invoke  LoadIcon,0,IDI_APPLICATION
        mov     [wc2.hIcon],eax
        invoke  LoadCursor,0,IDC_ARROW
        mov     [wc2.hCursor],eax
        invoke  RegisterClass,wc2
        or      eax,eax
        jz      error
        invoke  CreateWindowEx, WS_EX_LAYERED,_class,_title, WS_OVERLAPPEDWINDOW + WS_VISIBLE, 100, 100,256,192,NULL,NULL,[wc.hInstance],NULL
        test    eax,eax
        jz      error
    mov     [hwndmain], eax

    msg_loop:
        invoke  GetMessage,msg,NULL,0,0
        or      eax,eax
        jz      end_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]

proc WindowProc hwnd,wmsg,wparam,lparam
        push    ebx esi edi
        cmp     [wmsg],WM_HSCROLL
        je      .wmhscroll
        cmp     [wmsg],WM_CREATE
        je      .wmcreate
        cmp     [wmsg],WM_DESTROY
        je      .wmdestroy
  .defwndproc:
        invoke  DefWindowProc,[hwnd],[wmsg],[wparam],[lparam]
        jmp     .finish
  .wmhscroll:
        mov     eax,[wparam]
        cmp     ax,SB_THUMBPOSITION                      ;received when thumb stops dragging
        je      .thumbposition
        cmp     ax,SB_THUMBTRACK                         ;received while thumb is dragging
        je      .thumbposition
        cmp     ax,SB_LINELEFT                           ;left arrow clicked
        je      .lineleft
        cmp     ax,SB_LINERIGHT                          ;right arrow clicked
        je      .lineright
        cmp     ax,SB_PAGELEFT                           ;left space between arrow and thumb clicked
        je      .pageleft
        cmp     ax,SB_PAGERIGHT                          ;right space between arrow and thumb clicked
        je      .pageright
        jmp     .defwndproc
  .thumbposition:                                         ;for our purposes we'll handle both drag/stop events here
        mov     [lpsi.fMask],SIF_TRACKPOS
        invoke  GetScrollInfo,[hwndscroll],SB_CTL,lpsi
        push    [lpsi.nTrackPos]
        pop     [lpsi.nPos]
        mov     [lpsi.fMask],SIF_ALL
        jmp     .update_window
  .lineleft:
        cmp     [lpsi.nPos],6                           ;transparency under 5 will make window invisible/useless
        jb      .defwndproc
        dec     [lpsi.nPos]
        jmp     .update_window
  .lineright:
        cmp     [lpsi.nPos],254                         ;transparency over 255 will make window invisible/useless
        jg      .defwndproc
        inc     [lpsi.nPos]
        jmp     .update_window
  .pageleft:
        mov     eax,[lpsi.nPage]
        sub     [lpsi.nPos],eax
        jmp     .update_window
  .pageright:
        mov     eax,[lpsi.nPage]
        add     [lpsi.nPos],eax
  .update_window:
        mov     ecx,[lpsi.nPos]
        push    ecx
        cinvoke wsprintf,buffer,_conv,ecx
        invoke  SendMessage,[hwndstatic],WM_SETTEXT,0,buffer
        pop     ecx
        invoke  SetLayeredWindowAttributes,[hwndpopup],0,ecx,LWA_ALPHA
        invoke  SetScrollInfo,[hwndscroll],SB_CTL,lpsi,1
        xor     eax,eax
        jmp     .finish
  .wmcreate:                                                         ;x,y,width,height
        invoke  CreateWindowEx, WS_EX_LAYERED,_class2, NULL, WS_POPUP + WS_VISIBLE, 400,400,256,192,[hwnd],NULL,[wc.hInstance],NULL
        mov     [hwndpopup], eax

        invoke  SetLayeredWindowAttributes,[hwndpopup],0,254,LWA_ALPHA
        invoke  CreateWindowEx,0,_static,_title,WS_VISIBLE+WS_CHILD,25,20,195,25,[hwnd],ID_STATIC,[wc.hInstance],NULL
        mov     [hwndstatic],eax

        invoke  CreateWindowEx,0,_scrollbar,NULL,WS_VISIBLE+WS_CHILD+SBS_HORZ,25,55,195,15,[hwnd],ID_SCROLLBAR,[wc.hInstance],NULL
        mov     [hwndscroll],eax

        invoke  SetScrollInfo,[hwndscroll],SB_CTL,lpsi,0
        invoke  SetLayeredWindowAttributes,[hwnd],0,255,LWA_ALPHA
        xor     eax,eax
        jmp     .finish
  .wmdestroy:
        invoke  PostQuitMessage,0
        xor     eax,eax
  .finish:
        pop     edi esi ebx
        ret
endp

proc WindowProcpopup hwnd,wmsg,wparam,lparam
        push    ebx esi edi
        cmp     [wmsg],WM_HSCROLL
        je      .wmhscroll
        cmp     [wmsg],WM_CREATE
        je      .wmcreate
        cmp     [wmsg],WM_DESTROY
        je      .wmdestroy
  .defwndproc:
        invoke  DefWindowProc,[hwnd],[wmsg],[wparam],[lparam]
        jmp     .finish
  .wmhscroll:
        mov     eax,[wparam]
        cmp     ax,SB_THUMBPOSITION                      ;received when thumb stops dragging
        je      .thumbposition
        cmp     ax,SB_THUMBTRACK                         ;received while thumb is dragging
        je      .thumbposition
        cmp     ax,SB_LINELEFT                           ;left arrow clicked
        je      .lineleft
        cmp     ax,SB_LINERIGHT                          ;right arrow clicked
        je      .lineright
        cmp     ax,SB_PAGELEFT                           ;left space between arrow and thumb clicked
        je      .pageleft
        cmp     ax,SB_PAGERIGHT                          ;right space between arrow and thumb clicked
        je      .pageright
        jmp     .defwndproc
  .thumbposition:                                         ;for our purposes we'll handle both drag/stop events here
        mov     [lpsi.fMask],SIF_TRACKPOS
        invoke  GetScrollInfo,[hwndscroll],SB_CTL,lpsi
        push    [lpsi.nTrackPos]
        pop     [lpsi.nPos]
        mov     [lpsi.fMask],SIF_ALL
        jmp     .update_window
  .lineleft:
        cmp     [lpsi.nPos],6                           ;transparency under 5 will make window invisible/useless
        jb      .defwndproc
        dec     [lpsi.nPos]
        jmp     .update_window
  .lineright:
        cmp     [lpsi.nPos],254                         ;transparency over 255 will make window invisible/useless
        jg      .defwndproc
        inc     [lpsi.nPos]
        jmp     .update_window
  .pageleft:
        mov     eax,[lpsi.nPage]
        sub     [lpsi.nPos],eax
        jmp     .update_window
  .pageright:
        mov     eax,[lpsi.nPage]
        add     [lpsi.nPos],eax
  .update_window:
        xor     eax,eax
        jmp     .finish
  .wmcreate:                                                         ;x,y,width,height
        xor     eax,eax
        jmp     .finish
  .wmdestroy:
        invoke  PostQuitMessage,0
        xor     eax,eax
  .finish:
        pop     edi esi ebx
        ret
endp

section '.idata' import data readable writeable
library kernel32,'KERNEL32.DLL',\
        user32,  'USER32.DLL',\
        gdi32,   'GDI32.DLL',\
        comdlg32,'COMDLG32.DLL',\
        advapi32,'ADVAPI32.DLL',\
        comctl32,'COMCTL32.DLL'

include 'api\Kernel32.inc'
include 'api\User32.inc'
include 'api\Gdi32.inc'
include 'api\Comdlg32.inc'
include 'api\Advapi32.inc'
include 'api\Comctl32.inc'    
Post 15 May 2015, 12:59
View user's profile Send private message Visit poster's website Reply with quote
DergMoney



Joined: 29 Apr 2015
Posts: 34
DergMoney
Thanks for your time and effort revolution, it's much appreciated Wink

Your idea of having a separate class and wndproc did the trick. The strange thing is, wndprocpopup (wndprocHUD in my case) can be empty apart from the defwndproc ??? Confused

Anyway, here's the working code and the assembled prog.

Code:
;setting window transparency example by carlos hernandez/coconut

format PE GUI 4.0
entry start

ID_SCROLLBAR = 1000
ID_STATIC = 1001

include '%fasminc%\win32a.inc' 

section '.data' data readable writeable

  _class TCHAR 'FASMWIN32',0
  _title TCHAR 'Layered window example',0
  _error TCHAR 'Startup failed.',0
  _scrollbar TCHAR 'scrollbar',0
  _static TCHAR 'static',0
  _conv TCHAR '%i',0
  _hud_class TCHAR   'HUD', 00

  hwndmain   dd ?
  hwndstatic dd ?
  hwndscroll dd ?
  hwndpopup  dd ?
  hwndnew1   dd ?
  alpha      dd ?
  buffer rb 32
  ErrStrBuff  dd ? 

  wc      WNDCLASS 0,WindowProc,0,0,NULL,NULL,NULL,COLOR_BTNFACE+1,NULL,_class
  wcHUD   WNDCLASS 0,WindowProcHUD,0,0,NULL,NULL,NULL,COLOR_BTNFACE+4,NULL,_hud_class

  lpsi    SCROLLINFO sizeof.SCROLLINFO,SIF_ALL,5,255,1,255,0

  msg MSG

section '.code' code readable executable

  start:
        invoke  GetModuleHandle,0
        mov     [wc.hInstance],eax
        mov     [wcHUD.hInstance],eax
        invoke  LoadIcon,0,IDI_APPLICATION
        mov     [wc.hIcon],eax
        mov     [wcHUD.hIcon],eax
        invoke  LoadCursor,0,IDC_ARROW
        mov     [wc.hCursor],eax
        mov     [wcHUD.hCursor],eax
        invoke  RegisterClass,wc
        or      eax,eax
        jz      error
        invoke  RegisterClass,wcHUD
        or      eax,eax
        jz      error
        invoke  CreateWindowEx, 0,_class,_title, WS_OVERLAPPEDWINDOW + WS_VISIBLE, 100, 100,256,192,NULL,NULL,[wc.hInstance],NULL
        test    eax,eax
        jz      error
    mov     [hwndmain], eax

    msg_loop:
        invoke  GetMessage,msg,NULL,0,0
        or      eax,eax
        jz      end_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]

proc WindowProc hwnd,wmsg,wparam,lparam
        push    ebx esi edi
        cmp     [wmsg],WM_HSCROLL
        je      wmhscroll
        cmp     [wmsg],WM_CREATE
        je      wmcreate
        cmp     [wmsg],WM_DESTROY
        je      wmdestroy
  defwndproc:
        invoke  DefWindowProc,[hwnd],[wmsg],[wparam],[lparam]
        jmp     finish
  wmhscroll:
        mov     eax,[wparam]
        cmp     ax,SB_THUMBPOSITION                      ;received when thumb stops dragging
        je      thumbposition
        cmp     ax,SB_THUMBTRACK                         ;received while thumb is dragging
        je      thumbposition
        cmp     ax,SB_LINELEFT                           ;left arrow clicked
        je      lineleft
        cmp     ax,SB_LINERIGHT                          ;right arrow clicked
        je      lineright
        cmp     ax,SB_PAGELEFT                           ;left space between arrow and thumb clicked
        je      pageleft
        cmp     ax,SB_PAGERIGHT                          ;right space between arrow and thumb clicked
        je      pageright
        jmp     defwndproc
  thumbposition:                                         ;for our purposes we'll handle both drag/stop events here
        mov     [lpsi.fMask],SIF_TRACKPOS
        invoke  GetScrollInfo,[hwndscroll],SB_CTL,lpsi
        push    [lpsi.nTrackPos]
        pop     [lpsi.nPos]
        mov     [lpsi.fMask],SIF_ALL
        jmp     update_window
  lineleft:
        cmp     [lpsi.nPos],6                           ;transparency under 5 will make window invisible/useless
        jb      defwndproc
        dec     [lpsi.nPos]
        jmp     update_window
  lineright:
        cmp     [lpsi.nPos],254                         ;transparency over 255 will make window invisible/useless
        jg      defwndproc
        inc     [lpsi.nPos]
        jmp     update_window
  pageleft:
        mov     eax,[lpsi.nPage]
        sub     [lpsi.nPos],eax
        jmp     update_window
  pageright:
        mov     eax,[lpsi.nPage]
        add     [lpsi.nPos],eax
  update_window:
        push    [lpsi.nPos]
    pop     [alpha]
        cinvoke wsprintf,buffer,_conv, [alpha]
        invoke  SendMessage,[hwndstatic],WM_SETTEXT,0,buffer
        invoke  SetLayeredWindowAttributes,[hwndpopup],0,[alpha],LWA_ALPHA
        invoke  SetScrollInfo,[hwndscroll],SB_CTL,lpsi,1
        xor     eax,eax
        jmp     finish
  wmcreate:                                                         ;x,y,width,height
    invoke      CreateWindowEx, WS_EX_LAYERED,_hud_class, NULL, WS_POPUP + WS_VISIBLE, 400,400,256,192,[hwnd],NULL,[wcHUD.hInstance],NULL
    mov     [hwndpopup], eax
    mov     [alpha], 255
        invoke  SetLayeredWindowAttributes,[hwndpopup],0,[alpha],LWA_ALPHA
    invoke      CreateWindowEx,0,_static,_title,WS_VISIBLE+WS_CHILD,25,20,195,25,[hwnd],ID_STATIC,[wc.hInstance],NULL
        mov     [hwndstatic],eax

        invoke  CreateWindowEx,0,_scrollbar,NULL,WS_VISIBLE+WS_CHILD+SBS_HORZ,25,55,195,15,[hwnd],ID_SCROLLBAR,[wc.hInstance],NULL
        mov     [hwndscroll],eax

        invoke  SetScrollInfo,[hwndscroll],SB_CTL,lpsi,0
        xor     eax,eax
        jmp     finish
  wmdestroy:
        invoke  PostQuitMessage,0
        xor     eax,eax
  finish:
        pop     edi esi ebx
        ret
endp

proc WindowProcHUD hwnd,wmsg,wparam,lparam
        push    ebx esi edi
  .defwndproc:
        invoke  DefWindowProc,[hwnd],[wmsg],[wparam],[lparam]
        pop     edi esi ebx
        ret
endp


section '.idata' import data readable writeable 
library kernel32,'KERNEL32.DLL',\ 
        user32,  'USER32.DLL',\ 
        gdi32,   'GDI32.DLL',\ 
        comdlg32,'COMDLG32.DLL',\ 
        advapi32,'ADVAPI32.DLL',\ 
        comctl32,'COMCTL32.DLL' 

include '%fasminc%\api\Kernel32.inc' 
include '%fasminc%\api\User32.inc' 
include '%fasminc%\api\Gdi32.inc' 
include '%fasminc%\api\Comdlg32.inc' 
include '%fasminc%\api\Advapi32.inc' 
include '%fasminc%\api\Comctl32.inc'



;section '.idata' import data readable writeable
;
;  library kernel32,'KERNEL32.DLL',\
;         user32,'USER32.DLL'
;
;  include 'api\kernel32.inc'
;  include 'api\user32.inc'


    


Description:
Download
Filename: layeredwin.zip
Filesize: 3.02 KB
Downloaded: 40 Time(s)

Post 15 May 2015, 17:26
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17473
Location: In your JS exploiting you and your system
revolution
The real problem was that you were creating a window of the same class inside the window creation code and corrupting your popup handle. You could still have only one class but then you need to create both the windows outside of the WindowsProc function for that to work and have some mechanism to detect which window hwnd is selecting when inside the WindowsProc.
Post 16 May 2015, 00:54
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.