flat assembler
Message board for the users of flat assembler.

Index > Windows > adding manifest + 64bit Dialog

Author
Thread Post new topic Reply to topic
jochenvnltn



Joined: 15 Jul 2011
Posts: 96
jochenvnltn 14 Feb 2019, 10:21
I have a problem adding a manifest to a 64bit Dialog.
I first had the program as 32bit, but made a 64bit version.
Everything works okay without the manifest, but when i add the the whole file does not work anymore. I first thought that there was an error in my code so i took the Dialog box example from the included FASM examples and tested with that. It seems to have the same problem.. The file does not work with the manifest, but works fine without. The problem seems to be on 64bit only .. On 32bit it works fine. Can someone explain why it does not works on 64bit ? Ill use the example i did my second test with. The dialog shows normal without the manifest but not with..
Code:

; DialogBox example

format PE64 GUI 4.0


include 'win64a.inc'
entry start

ID_CAPTION         = 101
ID_MESSAGE         = 102
ID_ICONERROR       = 201
ID_ICONINFORMATION = 202
ID_ICONQUESTION    = 203
ID_ICONWARNING     = 204
ID_TOPMOST         = 301

section '.text' code readable executable

  start:

        sub rsp,8
        invoke  GetModuleHandle,0
        invoke  DialogBoxParam,rax,37,HWND_DESKTOP,DialogProc,0
        or      rax,rax
        jz      exit
        invoke  MessageBox,HWND_DESKTOP,message,caption,[flags]
  exit:
        invoke  ExitProcess,0

proc DialogProc uses rsi rdi rbx,hwnddlg,msg,wparam,lparam

        mov rcx, [hwnddlg]
        mov r8, [wparam]


        cmp     edx,WM_INITDIALOG
        je      .wminitdialog
        cmp     edx,WM_COMMAND
        je      .wmcommand
        cmp     edx,WM_CLOSE
        je      .wmclose
        xor     rax,rax
        jmp     .finish
  .wminitdialog:
        invoke  CheckRadioButton,[hwnddlg],ID_ICONERROR,ID_ICONWARNING,ID_ICONINFORMATION
        jmp     .processed
  .wmcommand:
        cmp     [wparam],BN_CLICKED shl 16 + IDCANCEL
        je      .wmclose
        cmp     [wparam],BN_CLICKED shl 16 + IDOK
        jne     .processed
        invoke  GetDlgItemText,[hwnddlg],ID_CAPTION,caption,40h
        invoke  GetDlgItemText,[hwnddlg],ID_MESSAGE,message,100h
        mov     [flags],MB_OK
        invoke  IsDlgButtonChecked,[hwnddlg],ID_ICONERROR
        cmp     eax,BST_CHECKED
        jne     .iconerror_ok
        or      [flags],MB_ICONERROR
      .iconerror_ok:
        invoke  IsDlgButtonChecked,[hwnddlg],ID_ICONINFORMATION
        cmp     eax,BST_CHECKED
        jne     .iconinformation_ok
        or      [flags],MB_ICONINFORMATION
      .iconinformation_ok:
        invoke  IsDlgButtonChecked,[hwnddlg],ID_ICONQUESTION
        cmp     eax,BST_CHECKED
        jne     .iconquestion_ok
        or      [flags],MB_ICONQUESTION
      .iconquestion_ok:
        invoke  IsDlgButtonChecked,[hwnddlg],ID_ICONWARNING
        cmp     eax,BST_CHECKED
        jne     .iconwarning_ok
        or      [flags],MB_ICONWARNING
      .iconwarning_ok:
        invoke  IsDlgButtonChecked,[hwnddlg],ID_TOPMOST
        cmp     eax,BST_CHECKED
        jne     .topmost_ok
        or      [flags],MB_TOPMOST
      .topmost_ok:
        invoke  EndDialog,[hwnddlg],1
        jmp     .processed
  .wmclose:
        invoke  EndDialog,[hwnddlg],0
  .processed:
        mov     rax,1
  .finish:
        ;pop     edi esi ebx
        ret
        endp

section '.bss' readable writeable

  flags dq ?
  caption rb 40h
  message rb 100h

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',\
         EndDialog,'EndDialog'


section '.rsrc' resource data readable

  directory RT_DIALOG,dialogs,\
            RT_MANIFEST,manifest

  resource dialogs,\
           37,LANG_ENGLISH+SUBLANG_DEFAULT,demonstration
  resource manifest,\
           1,LANG_NEUTRAL,man

  dialog demonstration,'Create message box',70,70,190,175,WS_CAPTION+WS_POPUP+WS_SYSMENU+DS_MODALFRAME
    dialogitem 'STATIC','&Caption:',-1,10,10,70,8,WS_VISIBLE
    dialogitem 'EDIT','',ID_CAPTION,10,20,170,13,WS_VISIBLE+WS_BORDER+WS_TABSTOP
    dialogitem 'STATIC','&Message:',-1,10,40,70,8,WS_VISIBLE
    dialogitem 'EDIT','',ID_MESSAGE,10,50,170,13,WS_VISIBLE+WS_BORDER+WS_TABSTOP+ES_AUTOHSCROLL
    dialogitem 'BUTTON','&Icon',-1,10,70,80,70,WS_VISIBLE+BS_GROUPBOX
    dialogitem 'BUTTON','&Error',ID_ICONERROR,20,82,60,13,WS_VISIBLE+BS_AUTORADIOBUTTON+WS_TABSTOP+WS_GROUP
    dialogitem 'BUTTON','I&nformation',ID_ICONINFORMATION,20,95,60,13,WS_VISIBLE+BS_AUTORADIOBUTTON
    dialogitem 'BUTTON','&Question',ID_ICONQUESTION,20,108,60,13,WS_VISIBLE+BS_AUTORADIOBUTTON
    dialogitem 'BUTTON','&Warning',ID_ICONWARNING,20,121,60,13,WS_VISIBLE+BS_AUTORADIOBUTTON
    dialogitem 'BUTTON','&Style',-1,100,70,80,70,WS_VISIBLE+BS_GROUPBOX
    dialogitem 'BUTTON','&Top most',ID_TOPMOST,110,82,60,13,WS_VISIBLE+WS_TABSTOP+BS_AUTOCHECKBOX
    dialogitem 'BUTTON','OK',IDOK,85,150,45,15,WS_VISIBLE+WS_TABSTOP+BS_DEFPUSHBUTTON
    dialogitem 'BUTTON','C&ancel',IDCANCEL,135,150,45,15,WS_VISIBLE+WS_TABSTOP+BS_PUSHBUTTON
  enddialog

   resdata man
   db '<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">'
   db '<dependency><dependentAssembly><assemblyIdentity '
   db 'type="win32" name="Microsoft.Windows.Common-Controls" '
   db 'version="6.0.0.0" processorArchitecture="X86" '
   db 'publicKeyToken="6595b64144ccf1df" language="*" />'
   db '</dependentAssembly></dependency></assembly>'
   endres   
    
Post 14 Feb 2019, 10:21
View user's profile Send private message MSN Messenger Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20517
Location: In your JS exploiting you and your system
revolution 14 Feb 2019, 10:25
Your manifest is for win32.
Code:
db 'type="win32" name="Microsoft.Windows.Common-Controls" '    
Maybe that needs updating.
Post 14 Feb 2019, 10:25
View user's profile Send private message Visit poster's website Reply with quote
jochenvnltn



Joined: 15 Jul 2011
Posts: 96
jochenvnltn 14 Feb 2019, 10:28
revolution wrote:
Your manifest is for win32.
Code:
db 'type="win32" name="Microsoft.Windows.Common-Controls" '    
Maybe that needs updating.
Oh .. I did not even see that. Ill try Wink
Post 14 Feb 2019, 10:28
View user's profile Send private message MSN Messenger Reply with quote
jochenvnltn



Joined: 15 Jul 2011
Posts: 96
jochenvnltn 14 Feb 2019, 10:31
changing it to 'type="win64" name="Microsoft.Windows.Common-Controls" '
db 'version="6.0.0.0" processorArchitecture="X64"

Did not help.
Post 14 Feb 2019, 10:31
View user's profile Send private message MSN Messenger Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20517
Location: In your JS exploiting you and your system
revolution 14 Feb 2019, 10:40
Looking at regedit.exe I see this:
Code:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!-- Copyright (c) Microsoft Corporation -->
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity 
        processorArchitecture="amd64"
        version="1.0.0.0" 
        name="Microsoft.Windows.Regedit" type="win32" />
<description>Registry Editor</description>
<dependency>
    <dependentAssembly>
        <assemblyIdentity
            type="win32"
            name="Microsoft.Windows.Common-Controls"
            version="6.0.0.0"
            publicKeyToken="6595b64144ccf1df"
            processorArchitecture="amd64"
        />
    </dependentAssembly>
</dependency>
<application  xmlns="urn:schemas-microsoft-com:asm.v3">
    <windowsSettings>
        <dpiAware  xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
    </windowsSettings>
</application>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
    <security>
        <requestedPrivileges>
            <requestedExecutionLevel
                level="highestAvailable"
                uiAccess="false"
            />
        </requestedPrivileges>
    </security>
</trustInfo>
</assembly>    
It mixes amd64 and win32.
Post 14 Feb 2019, 10:40
View user's profile Send private message Visit poster's website Reply with quote
jochenvnltn



Joined: 15 Jul 2011
Posts: 96
jochenvnltn 14 Feb 2019, 10:43
Oh nice Smile Ill try that.

I was looking here https://docs.microsoft.com/en-us/windows/desktop/sbscs/application-manifests

Could not find anything besides

Specifies the processor. The valid values are x86 for 32-bit Windows and ia64 for 64-bit Windows. Optional.
Post 14 Feb 2019, 10:43
View user's profile Send private message MSN Messenger Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20517
Location: In your JS exploiting you and your system
revolution 14 Feb 2019, 10:46
Yeah. fontview.exe has this
Code:
<dependency>
    <dependentAssembly>
        <assemblyIdentity
            type="win32"
            name="Microsoft.Windows.Common-Controls"
            version="6.0.0.0"
            processorArchitecture="*"
            publicKeyToken="6595b64144ccf1df"
            language="*"
        />
    </dependentAssembly>
</dependency>    
Post 14 Feb 2019, 10:46
View user's profile Send private message Visit poster's website Reply with quote
jochenvnltn



Joined: 15 Jul 2011
Posts: 96
jochenvnltn 14 Feb 2019, 10:49
I have it Revolution Smile I only had to change this --> processorArchitecture="amd64"

Problem solved Smile

Code:
   resdata man
   db '<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">'
   db '<dependency><dependentAssembly><assemblyIdentity '
   db 'type="win32" name="Microsoft.Windows.Common-Controls" '
   db 'version="6.0.0.0" processorArchitecture="amd64" '
   db 'publicKeyToken="6595b64144ccf1df" language="*" />'
   db '</dependentAssembly></dependency></assembly>'
   endres
    
Post 14 Feb 2019, 10:49
View user's profile Send private message MSN Messenger Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20517
Location: In your JS exploiting you and your system
revolution 14 Feb 2019, 10:52
Try with the * also.
Post 14 Feb 2019, 10:52
View user's profile Send private message Visit poster's website Reply with quote
jochenvnltn



Joined: 15 Jul 2011
Posts: 96
jochenvnltn 14 Feb 2019, 10:59
revolution wrote:
Try with the * also.


Yep! That also seems to work just fine !

Code:
resdata man
   db '<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">'
   db '<dependency><dependentAssembly><assemblyIdentity '
   db 'type="win32" name="Microsoft.Windows.Common-Controls" '
   db 'version="6.0.0.0" processorArchitecture= "*" '
   db 'publicKeyToken="6595b64144ccf1df" language="*" />'
   db '</dependentAssembly></dependency></assembly>'
   endres
    
Post 14 Feb 2019, 10:59
View user's profile Send private message MSN Messenger Reply with quote
jochenvnltn



Joined: 15 Jul 2011
Posts: 96
jochenvnltn 14 Feb 2019, 11:03
revolution wrote:
Try with the * also.


Using it like that seems to work for both x86 & x64 PE !
Awesome ! I'm happy i learned something new Smile

Thank you Revolution ! Very Happy
Post 14 Feb 2019, 11:03
View user's profile Send private message MSN Messenger Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20517
Location: In your JS exploiting you and your system
revolution 14 Feb 2019, 11:05
jochenvnltn wrote:
Awesome ! I'm happy i learned something new Smile

Thank you Revolution ! Very Happy
Smile
Post 14 Feb 2019, 11:05
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-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.