flat assembler
Message board for the users of flat assembler.

Index > Windows > [SOLVED] TaskDialog question

Author
Thread Post new topic Reply to topic
bzdashek



Joined: 15 Feb 2012
Posts: 147
Location: Tolstokvashino, Russia
bzdashek 17 May 2012, 05:39
Has anyone tried to invoke the TaskDialog?

The API reference: http://msdn.microsoft.com/en-us/library/windows/desktop/bb760540(v=vs.85).aspx

states that TaskDialog is exported by comctl32.dll, but I ran etl.exe on COMCTL32.DLL, and there was no such export (application also shows an error message).

But the OS clearly shows that TaskDialogs. There's something in this world that I don't understand.

The internets keep silence (searched MASM forums also).

OS: Win7.

Any ideas?


Last edited by bzdashek on 18 May 2012, 05:19; edited 1 time in total
Post 17 May 2012, 05:39
View user's profile Send private message Reply with quote
bzdashek



Joined: 15 Feb 2012
Posts: 147
Location: Tolstokvashino, Russia
bzdashek 17 May 2012, 05:40
Code:


; Template for program using standard Win32 headers

format PE GUI 6.0
entry start

include 'win32w.inc'

section '.text' code readable executable

  start:
  invoke  InitCommonControls,0
        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
    test    eax,eax
     jz      error

   invoke  CreateWindowEx,0,_class,_title,WS_VISIBLE+WS_DLGFRAME+WS_SYSMENU,128,128,256,192,NULL,NULL,[wc.hInstance],NULL
      test    eax,eax
     jz      error

  msg_loop:
        invoke  GetMessage,msg,NULL,0,0
     cmp     eax,1
       jb      end_loop
    jne     msg_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]


TD_WARNING_ICON = -1
TD_ERROR_ICON = -2
TD_INFORMATION_ICON = -3
TD_SHIELD_ICON = -4

TDCBF_OK_BUTTON = 1
TDCBF_YES_BUTTON = 2
TDCBF_NO_BUTTON = 4
TDCBF_CANCEL_BUTTON = 8
TDCBF_RETRY_BUTTON = $10
TDCBF_CLOSE_BUTTON = $20


proc WindowProc uses ebx esi edi, hwnd,wmsg,wparam,lparam
 cmp     [wmsg],WM_CREATE
    je      .wmcreate
   cmp     [wmsg],WM_DESTROY
   je      .wmdestroy
  .defwndproc:
    invoke  DefWindowProc,[hwnd],[wmsg],[wparam],[lparam]
       jmp     .finish
  .wmcreate:
 invoke  TaskDialog,HWND_DESKTOP,[wc.hInstance],_title,_error,0,TDCBF_OK_BUTTON,TD_WARNING_ICON,0
    mov     eax,1
       jmp     .finish 

  .wmdestroy:
   invoke  PostQuitMessage,0
   xor     eax,eax
  .finish:
   ret
endp

section '.data' data readable writeable

  _class TCHAR 'FASMWIN32',0
  _title TCHAR 'Win32 program template',0
  _error TCHAR 'Startup failed.',0

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

  msg MSG

section '.idata' import data readable writeable

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

  include 'api\kernel32.inc'
  include 'api\user32.inc'

  import comctl32,\
      InitCommonControls,'InitCommonControls',\
        TaskDialog,'TaskDialog'
    
Post 17 May 2012, 05:40
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20445
Location: In your JS exploiting you and your system
revolution 17 May 2012, 06:44
Minimum supported client Windows Vista
Post 17 May 2012, 06:44
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: 20445
Location: In your JS exploiting you and your system
revolution 17 May 2012, 06:55
You probably need a manifest to access the extra functionality in COMCTL32.
Post 17 May 2012, 06:55
View user's profile Send private message Visit poster's website Reply with quote
bzdashek



Joined: 15 Feb 2012
Posts: 147
Location: Tolstokvashino, Russia
bzdashek 17 May 2012, 12:48
Sorry, I get it.

But if that's a vista function then could someone please tell me how can I call a MessageBox of the new type, like that in an attached picture in Windows 7?


Description:
Filesize: 18.82 KB
Viewed: 4960 Time(s)

NewTypeMsgBox.png


Post 17 May 2012, 12:48
View user's profile Send private message Reply with quote
typedef



Joined: 25 Jul 2010
Posts: 2909
Location: 0x77760000
typedef 18 May 2012, 00:03
Most of these are custom made dialogs. Wink
Post 18 May 2012, 00:03
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20445
Location: In your JS exploiting you and your system
revolution 18 May 2012, 00:50
bzdashek wrote:
But if that's a vista function then could someone please tell me how can I call a MessageBox of the new type, like that in an attached picture in Windows 7?
You'll need a manifest.

Maybe this will work?
Code:
TD_WARNING_ICON = -1
TD_ERROR_ICON = -2
TD_INFORMATION_ICON = -3
TD_SHIELD_ICON = -4

TDCBF_OK_BUTTON = 1
TDCBF_YES_BUTTON = 2
TDCBF_NO_BUTTON = 4
TDCBF_CANCEL_BUTTON = 8
TDCBF_RETRY_BUTTON = $10
TDCBF_CLOSE_BUTTON = $20

format PE GUI 6.0
entry start

include 'win32w.inc'

section '.text' code readable executable

  start:
     invoke  InitCommonControls
  invoke  TaskDialog,HWND_DESKTOP,0,_title,_error,0,TDCBF_OK_BUTTON,0,0
       invoke  ExitProcess,0


section '.data' data readable writeable

  _class TCHAR 'FASMWIN32',0
  _title TCHAR 'Win32 program template',0
  _error TCHAR 'Startup failed.',0

section '.idata' import data readable writeable

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

  include 'api\kernel32.inc'
  include 'api\user32.inc'

  import comctl32,\
      InitCommonControls,'InitCommonControls',\
        TaskDialog,'TaskDialog'

section '.rsrc' resource data readable

      directory 24,manifest

   resource manifest,\
                1, LANG_NEUTRAL, win7

resdata win7
   db '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>',13,10
    db '<asmv1:assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">',13,10
                db '<assemblyIdentity',13,10
           db 'version="1.0.0.0"',13,10
            db 'processorArchitecture="X86"',13,10
          db 'name="CompanyName.ProductName.Application"',13,10
           db 'type="win32"',13,10
         db '/>',13,10

              db '<description>Your application description here.</description>',13,10

          db '<dependency>',13,10
                     db '<dependentAssembly>',13,10
                              db '<assemblyIdentity',13,10
                           db 'type="win32"',13,10
                         db 'name="Microsoft.Windows.Common-Controls"',13,10
                             db 'version="6.0.0.0"',13,10
                            db 'processorArchitecture="X86"',13,10
                          db 'publicKeyToken="6595b64144ccf1df"',13,10
                            db 'language="*"',13,10
                         db '/>',13,10
                  db '</dependentAssembly>',13,10
             db '</dependency>',13,10

                db '<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">',13,10
                     db '<application>',13,10
                    ;       <!--The ID below indicates application support for Windows Vista -->
                  ;       db '<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>',13,10
                   ;       <!--The ID below indicates application support for Windows 7 -->
                              db '<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>',13,10
                   db '</application>',13,10
           db '</compatibility>',13,10

     db '</asmv1:assembly>'

endres    
Post 18 May 2012, 00:50
View user's profile Send private message Visit poster's website Reply with quote
bzdashek



Joined: 15 Feb 2012
Posts: 147
Location: Tolstokvashino, Russia
bzdashek 18 May 2012, 04:50
@revolution
Thank you very much, it works!

That manifest thing is really pain in the @rse.
Post 18 May 2012, 04:50
View user's profile Send private message Reply with quote
bzdashek



Joined: 15 Feb 2012
Posts: 147
Location: Tolstokvashino, Russia
bzdashek 18 May 2012, 05:12
It also works with this manifest:
Code:
directory 24,manifest 
resource manifest,\ 
         1,LANG_NEUTRAL,man 
resdata man 
         db '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>',13,10 
         db '<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">',13,10 
         db '<assemblyIdentity name="x.x.x" processorArchitecture="x86" version="5.1.0.0" type="win32"/> ',13,10 
         db '<description>no</description>',13,10 
         db '<dependency>',13,10 
         db '<dependentAssembly>',13,10 
         db '<assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="x86" publicKeyToken="6595b64144ccf1df" language="*" />',13,10 
         db '</dependentAssembly>',13,10 
         db '</dependency>',13,10 
         db '</assembly>',13,10 
endres
    


It's strange, yesterday I also created the simple app like this (initcommoncontrols, taskdialog, exitprocess), but it crashed every time when i tried to run it. Must have messed with the parameter order.
Pasted your call to TaskDialog to it and it worked.

@typedef:
Yesterday, while messing with TaskDialog, I managed to find all kind of stuff - from VB examples to Java, and in this whole bunch of stuff, there's also an example of creating custom TaskDialogs on CPP, I hope someone will also find it useful:

http://msdn.microsoft.com/en-us/library/bb756938.aspx
Post 18 May 2012, 05:12
View user's profile Send private message Reply with quote
CoolCmd



Joined: 27 Dec 2023
Posts: 11
CoolCmd 06 Mar 2024, 16:49
revolution wrote:

TD_INFORMATION_ICON = -3

This line does not work. It generates push -3 which is 0xFFFFFFFD. But TD_INFORMATION_ICON must be 0xFFFD.

OK, this is expected. But this line
Code:
TD_INFORMATION_ICON = -3 and 0xFFFF    

also generates -3. WTF?
Post 06 Mar 2024, 16:49
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8358
Location: Kraków, Poland
Tomasz Grysztar 06 Mar 2024, 17:05
CoolCmd wrote:
OK, this is expected. But this line
Code:
TD_INFORMATION_ICON = -3 and 0xFFFF    

also generates -3. WTF?
In fasm's language AND has higher precedence than minus. "-3 and 0xFFFF" is not the same as "(-3) and 0xFFFF".
Post 06 Mar 2024, 17:05
View user's profile Send private message Visit poster's website Reply with quote
CoolCmd



Joined: 27 Dec 2023
Posts: 11
CoolCmd 06 Mar 2024, 17:23
So, there is no "unary minus" operator? This is weird.
Post 06 Mar 2024, 17:23
View user's profile Send private message 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-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.