flat assembler
Message board for the users of flat assembler.

Index > Windows > AnimateWindow() worst f at all

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



Joined: 11 Jul 2020
Posts: 202
Overclick
Code:
wmsyscommand:
        cmp             [wParam],SC_RESTORE,SC_MAXIMIZE
        je              sc_restore
        invoke  DefWindowProc,[hWnd],[wMsg],[wParam],[lParam]
        ret
        sc_restore:
                invoke          AnimateWindow,[hWnd],DWORD 300,0x00060008
                invoke          ShowWindow,[hWnd],SW_RESTORE
                mov             rax,1
                ret
    

I trying to use animated Restore for dialogue from TaskBar but it's never happen. It just restores as default by ShowWindow. At same time Minimize animation works just fine. I tried different keys for animation with or without AW_ACTIVATE too.
Also I tried to force animation class:
Code:
wminitdialog:
        .data
                ControlClasses  INITCOMMONCONTROLSEX\
                        sizeof.INITCOMMONCONTROLSEX,0x00000080
        .code
        invoke          InitCommonControlsEx,ControlClasses
    

Don't ask me why I use DefWindowProc instead of DefDlgProc. It is usual Dialogue created by DialogBoxParam. DefDlgProc not working for me at all. No time to waste for finding why Very Happy


Last edited by Overclick on 20 Aug 2020, 10:43; edited 2 times in total
Post 19 Aug 2020, 10:59
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17669
Location: In your JS exploiting you and your system
revolution
What value does AnimateWindow return? True or False?

BTW: We can't test your code because you appear to be using some custom macros that we don't have. .data and .code, along with a three operand form of cmp.

If you want better help it would be helpful to post something we can assemble ourselves.
Post 19 Aug 2020, 13:44
View user's profile Send private message Visit poster's website Reply with quote
DimonSoft



Joined: 03 Mar 2010
Posts: 821
Location: Belarus
DimonSoft
revolution wrote:
to post something we can assemble ourselves.

Is there some feature on the forum to avoid typing frequently used phrases? Smile
Post 19 Aug 2020, 14:43
View user's profile Send private message Visit poster's website Reply with quote
Overclick



Joined: 11 Jul 2020
Posts: 202
Overclick
Don't look at my macros. It just to show where it is and how I call it. U can insert it to any Dialogue example file.

It returns ZERO at rax, that mean:

1 If the window is already visible and you are trying to show the window.
2 If the window is already hidden and you are trying to hide the window.
3 If there is no direction specified for the slide or roll animation.
4 When trying to animate a child window with AW_BLEND.
5 If the thread does not own the window. Note that, in this case, AnimateWindow fails but GetLastError returns ERROR_SUCCESS.


1)No it is minimized
2)No I don't use AW_HIDE
3)No
4)It is not Child
5)GetLastError shows nothing

Does it work at Dialogue at all???
Post 19 Aug 2020, 14:51
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17669
Location: In your JS exploiting you and your system
revolution
Overclick wrote:
5)GetLastError shows nothing
GetLastError must be called immediately after the failed API function for it to return a valid result.

When you say "shows nothing", do you mean GetLastError returns zero?
https://docs.microsoft.com/en-us/windows/win32/debug/system-error-codes
Post 19 Aug 2020, 15:09
View user's profile Send private message Visit poster's website Reply with quote
Overclick



Joined: 11 Jul 2020
Posts: 202
Overclick
Yes
Post 19 Aug 2020, 15:14
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17669
Location: In your JS exploiting you and your system
revolution
Perhaps you can show your error check code. I think you have a mistake in there. GetLastError will return an error code, not zero, when a function fails.
Post 19 Aug 2020, 15:20
View user's profile Send private message Visit poster's website Reply with quote
Overclick



Joined: 11 Jul 2020
Posts: 202
Overclick
Trust me )


Description:
Filesize: 36.76 KB
Viewed: 670 Time(s)

Capture.PNG


Post 19 Aug 2020, 15:23
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17669
Location: In your JS exploiting you and your system
revolution
When do you call GetLastError? Immediately, or after some other API calls?
Post 19 Aug 2020, 15:26
View user's profile Send private message Visit poster's website Reply with quote
Overclick



Joined: 11 Jul 2020
Posts: 202
Overclick
I created little example code special for revolution
Code:
format PE64 GUI 5.0
entry start
include 'win64a.inc'
section '.text' code readable executable
  start:
        push    rbp
        invoke  GetModuleHandle,0
        invoke  DialogBoxParam,rax,37,HWND_DESKTOP,DialogProc,0
        invoke  ExitProcess,0
proc DialogProc uses rbx rsi rdi,hWnd,wMsg,wParam,lParam
        mov             [hWnd],rcx
        mov             [wMsg],rdx
        mov             [wParam],r8
        mov             [lParam],r9

        cmp     [wMsg],WM_COMMAND
        je      wmcommand
        cmp     [wMsg],WM_CLOSE
        je      wmclose
        cmp     [wMsg],WM_SYSCOMMAND
        je      wmsyscommand
        xor     rax,rax
        jmp     finish
wmsyscommand:
        cmp     [wParam],SC_RESTORE
        je      sc_restore
        invoke  DefWindowProc,[hWnd],[wMsg],[wParam],[lParam]
        ret
   sc_restore:
        invoke  AnimateWindow,[hWnd],DWORD 1000,0x00040004      ;HERE IT IS
        invoke  ShowWindow,[hWnd],SW_RESTORE
        mov     rax,1
        ret
wmcommand:
        cmp     [wParam],BN_CLICKED shl 16 + IDOK
        jne     processed
        invoke  ShowWindow,[hWnd],SW_MINIMIZE
        ret
wmclose:
        invoke  EndDialog,[hWnd],0
processed:
        mov     rax,1
finish:
        ret
endp
section '.idata' import data readable writeable
  library kernel,'KERNEL32.DLL',\
          user,'USER32.DLL'
  import kernel,\
         GetModuleHandle,'GetModuleHandleA',\
         ExitProcess,'ExitProcess'
  import user,\
         DialogBoxParam,'DialogBoxParamA',\
         CheckRadioButton,'CheckRadioButton',\
         GetDlgItemText,'GetDlgItemTextA',\
         IsDlgButtonChecked,'IsDlgButtonChecked',\
         MessageBox,'MessageBoxA',\
         DefWindowProc,'DefWindowProcA',\
         EndDialog,'EndDialog',\
         AnimateWindow,'AnimateWindow',\
         ShowWindow,'ShowWindow'
section '.rsrc' resource data readable
  directory RT_DIALOG,dialogs
  resource dialogs,\
           37,LANG_ENGLISH+SUBLANG_DEFAULT,demonstration
  dialog demonstration,'Create message box',70,70,190,175,WS_CAPTION+WS_POPUP+WS_SYSMENU+DS_MODALFRAME
       dialogitem 'BUTTON','OK',IDOK,85,150,45,15,WS_VISIBLE+WS_TABSTOP+BS_DEFPUSHBUTTON
  enddialog    
Post 19 Aug 2020, 15:26
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17669
Location: In your JS exploiting you and your system
revolution
I don't see any error checking code there. You blindly execute AnimateWindow without checking anything.
Post 19 Aug 2020, 15:27
View user's profile Send private message Visit poster's website Reply with quote
Overclick



Joined: 11 Jul 2020
Posts: 202
Overclick
As I told you, it is not working. Default animation only. LastError=0, rax=0
Post 19 Aug 2020, 15:30
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17669
Location: In your JS exploiting you and your system
revolution
Overclick wrote:
LastError=0, rax=0
I don't believe this part. This is not possible in Windows. Show your error checking code.
Post 19 Aug 2020, 15:32
View user's profile Send private message Visit poster's website Reply with quote
Overclick



Joined: 11 Jul 2020
Posts: 202
Overclick
Did you see attached picture? What else you want to see?
insert
Code:
cmp rax,0
je ...
invoke GetLastError
cmp rax,0
je ...    
Post 19 Aug 2020, 15:35
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17669
Location: In your JS exploiting you and your system
revolution
Overclick wrote:
Did you see attached picture? What else you want to see?
I saw the picture but not the code generated it. I suspect you have a bug in that code.
Post 19 Aug 2020, 15:42
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: 17669
Location: In your JS exploiting you and your system
revolution
Overclick wrote:
Code:
cmp rax,0
je ...
invoke GetLastError
cmp rax,0
je ...    
That code is not correct. You only call GetLastError upon a success/true value in eax.
Post 19 Aug 2020, 15:45
View user's profile Send private message Visit poster's website Reply with quote
Overclick



Joined: 11 Jul 2020
Posts: 202
Overclick
OMG, how did I use it before? ))
You are quite difficult person...
Code:
format PE64 GUI 5.0
entry start
include 'win64a.inc'
section '.text' code readable executable
  start:
        push    rbp
        invoke  GetModuleHandle,0
        invoke  DialogBoxParam,rax,37,HWND_DESKTOP,DialogProc,0
        invoke  ExitProcess,0
proc DialogProc uses rbx rsi rdi,hWnd,wMsg,wParam,lParam
        mov             [hWnd],rcx
        mov             [wMsg],rdx
        mov             [wParam],r8
        mov             [lParam],r9

        cmp     [wMsg],WM_COMMAND
        je      wmcommand
        cmp     [wMsg],WM_CLOSE
        je      wmclose
        cmp     [wMsg],WM_SYSCOMMAND
        je      wmsyscommand
        xor     rax,rax
        jmp     finish
wmsyscommand:
        cmp     [wParam],SC_RESTORE
        je      sc_restore
        invoke  DefWindowProc,[hWnd],[wMsg],[wParam],[lParam]
        ret
   sc_restore:
        invoke  AnimateWindow,[hWnd],DWORD 1000,0x00040004
        ;cmp rax,0                                                    ;test number 1
        ;je show_error
        invoke GetLastError                                        ;test number 2  (switch them)
        cmp rax,0
        je show_error
        invoke  ShowWindow,[hWnd],SW_RESTORE
        mov     rax,1
        ret
show_error:
        invoke  MessageBox,NULL,'it is zero',NULL,MB_ICONERROR+MB_OK
wmcommand:
        cmp     [wParam],BN_CLICKED shl 16 + IDOK
        jne     processed
        invoke  ShowWindow,[hWnd],SW_MINIMIZE
        ret
wmclose:
        invoke  EndDialog,[hWnd],0
processed:
        mov     rax,1
finish:
        ret
endp
section '.idata' import data readable writeable
  library kernel,'KERNEL32.DLL',\
          user,'USER32.DLL'
  import kernel,\
         GetModuleHandle,'GetModuleHandleA',\
         ExitProcess,'ExitProcess',\
         GetLastError,'GetLastError'
  import user,\
         DialogBoxParam,'DialogBoxParamA',\
         CheckRadioButton,'CheckRadioButton',\
         GetDlgItemText,'GetDlgItemTextA',\
         IsDlgButtonChecked,'IsDlgButtonChecked',\
         MessageBox,'MessageBoxA',\
         DefWindowProc,'DefWindowProcA',\
         EndDialog,'EndDialog',\
         AnimateWindow,'AnimateWindow',\
         ShowWindow,'ShowWindow'
section '.rsrc' resource data readable
  directory RT_DIALOG,dialogs
  resource dialogs,\
           37,LANG_ENGLISH+SUBLANG_DEFAULT,demonstration
  dialog demonstration,'Create message box',70,70,190,175,WS_CAPTION+WS_POPUP+WS_SYSMENU+DS_MODALFRAME
       dialogitem 'BUTTON','OK',IDOK,85,150,45,15,WS_VISIBLE+WS_TABSTOP+BS_DEFPUSHBUTTON
  enddialog     
Post 19 Aug 2020, 15:47
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17669
Location: In your JS exploiting you and your system
revolution
Your error code is incorrect.

More like this:
Code:
        invoke  AnimateWindow,[hWnd],DWORD 1000,0x00040004
        cmp rax,0
        je show_error
;...
show_error:
        invoke  GetLastError ;must call this first and save the result before doing anything else
        invoke  wsprintf,...
        invoke  MessageBox,...    
Post 19 Aug 2020, 15:51
View user's profile Send private message Visit poster's website Reply with quote
Overclick



Joined: 11 Jul 2020
Posts: 202
Overclick
What it changes if rax is already ZERO??? (after GetLastError)
It have to return ERROR code to be translated later but it is ZERO. What do you want to translate
ERROR_SUCCESS ?

I gived to you full example code to test it as you know how to do that. Show me that strange error code I don't see


Last edited by Overclick on 19 Aug 2020, 15:58; edited 1 time in total
Post 19 Aug 2020, 15:55
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17669
Location: In your JS exploiting you and your system
revolution
If RAX is zero (failure) then you need to call GetLastError to know what the error was. But you must call it immediately, before any other API calls, else the error code is overwritten and you lose it.
Post 19 Aug 2020, 15:57
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 1, 2, 3  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-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.