News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

GetOpenFileName Hook

Started by ragdog, January 13, 2018, 06:01:51 AM

Previous topic - Next topic

ragdog

Hello

I read by Msdn i can Hook the Common Dialog Box (GetOpenFileName).

I Have look here and found Gunners example (10288_Custom_Open_File_Dialog)
http://www.masmforum.com/archive2012/10288_Custom_Open_File_Dialog.zip

The code is all clear but i need to hook the new Common Dialog Box (Vista or Windows 7)

I make this new look with this flag OFN_EXPLORER .
But if i use both have i no Placesbar (listview) left side with Desktop ,Network etc.

mov   ofn.Flags,OFN_EXPLORER or OFN_ENABLEHOOK

Have you any an idea ?

Regards,


six_L

hello,ragdog
the GetOpenFileName Hook is only worked with 64bit exe and dll, crashed on 32bit  exe and dll.

option casemap:none
option win64:7

include \UASM64\include\windows.inc
include \UASM64\include\commctrl.inc
include \UASM64\include\shlwapi.inc
include \UASM64\include\shellapi.inc

includelib \UASM64\Lib\user32.lib
includelib \UASM64\Lib\kernel32.lib
includelib \UASM64\Lib\ComCtl32.lib
includelib \UASM64\Lib\ComDlg32.lib
includelib \UASM64\Lib\shlwapi.lib
includelib \UASM64\Lib\shell32.lib

ImageList_Remove PROTO :HIMAGELIST,:DWORD
ImageList_GetIcon PROTO :HIMAGELIST,:DWORD,:DWORD
MainDlg PROTO hWin:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM
EnumResNamesProc PROTO hModule:QWORD,lpszType:QWORD,lpszName:QWORD,lParam:QWORD

IDD_MAIN                equ 1000
IDC_OK                  equ 1002
IDC_CANCEL              equ 1001
IDC_IMG_LRG             equ 1003
IDC_IMG_SM              equ 1004
IDD_DLG                 equ 2000
IDC_LSV1                equ 1548
IDC_SHP1                equ 1119

_PExtractIconEx typedef proto lpszFile:qword,nIconIndex:qword,phiconLarge:qword,phiconSmall:qword,nIcons:qword
PExtractIconEx typedef ptr _PExtractIconEx

.data
DlgFilter BYTE "All Supported Files (*.ocx;*.cpl;*.dll;*.ico;*.icl;*.exe;*.scr)", 0, "*.ocx;*.cpl;*.dll;*.ico;*.icl;*.exe;*.scr", 0
BYTE "ActiveX Controls (*.ocx)", 0, "*.ocx", 0
BYTE "Control Panel Applets (*.cpl)", 0, "*.cpl",0
BYTE "Dynamic Link Libraries (*.dll)", 0, "*.dll", 0
BYTE "Icon Files (*.ico)", 0, "*.ico",0
BYTE "Icon Libraries (*.icl)", 0, "*.icl",0
BYTE "Programs (*.exe)", 0, "*.exe", 0
BYTE "Screen Savers(*.scr)", 0, "*.scr",0,0
DlgTitle BYTE 'Browse for Icons' ,0
szExtIco BYTE    ".ico", 0

.data?
hInst QWORD   ?
himlDlg         QWORD   ?
hLVDlg          QWORD   ?
hMainDlg        QWORD   ?
hParent         QWORD   ?
hMainHeap       QWORD   ?
hImg32          QWORD   ?
hImg16          QWORD   ?
ofn             OPENFILENAME <?>
tTR RECT <?>
wLp POINT <?>
lvi             LV_ITEM <?>
DlgFilePath BYTE MAX_PATH + 1 dup (?)
hShell32_dll dq ?
@pExtractIconEx PExtractIconEx ?

.code

Cmpi proc uses rbx rsi rdi src:QWORD,dst:QWORD

mov rsi, src ; src
mov rdi, dst ; dst
sub rax, rax ; zero eax as index
jmp @s
Cmpi_tbl:
db   0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15
db  16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31
db  32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47
db  48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63
db  64, 97, 98, 99,100,101,102,103,104,105,106,107,108,109,110,111
db 112,113,114,115,116,117,118,119,120,121,122, 91, 92, 93, 94, 95
db  96, 97, 98, 99,100,101,102,103,104,105,106,107,108,109,110,111
db 112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127
db 128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143
db 144,145,146,147,148,149,150,151,152,153,154,155,156,156,158,159
db 160,161,162,163,164,165,166,167,168,169,170,171,172,173,173,175
db 176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191
db 192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207
db 208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223
db 224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239
db 240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255
@s:
lea r8, Cmpi_tbl
@@:
movzx rdx, BYTE PTR [rsi+rax]
movzx rbx, BYTE PTR [rdi+rax]
movzx rcx, BYTE PTR [r8+rdx]
add rax, 1
cmp cl, BYTE PTR [r8+rbx]
jne @Exit ; exit on 1st mismatch with
test cl, cl ; non zero value in EAX
jnz @B

xor rax, rax ; set RAX to ZERO on match
@Exit:
ret
Cmpi endp

MainDlg proc hWin:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM
   
mov eax,uMsg
.if eax==WM_INITDIALOG
invoke  GetDlgItem, hWin, IDC_IMG_LRG
mov     hImg32, rax
               
invoke  GetDlgItem, hWin, IDC_IMG_SM
mov     hImg16, rax
.elseif eax==WM_COMMAND
mov rdx,wParam
movzx rax,dx
shr rdx,32
.if rdx==BN_CLICKED
.if rax==IDC_OK
invoke  RtlZeroMemory, addr ofn, sizeof ofn
mov     ofn.lStructSize, sizeof OPENFILENAME
push    hWin
pop     ofn.hwndOwner
push    hInst
pop     ofn.hInstance
mov rax,offset DlgFilter
mov     ofn.lpstrFilter, rax
mov rax,offset DlgTitle
mov     ofn.lpstrTitle, rax
mov     ofn.Flags, OFN_EXPLORER or OFN_ENABLETEMPLATE or OFN_ENABLEHOOK or OFN_HIDEREADONLY
mov rax,offset DlgHook
mov     ofn.lpfnHook, rax
mov     ofn.lpTemplateName, IDD_DLG                
invoke  GetOpenFileName, addr ofn

.elseif rax==IDC_CANCEL
invoke SendMessage,hWin,WM_CLOSE,NULL,NULL
.endif
.endif
.elseif eax==WM_CLOSE
invoke  SendMessage, hImg32, STM_GETICON, 0, 0
invoke  DestroyIcon, rax

invoke  SendMessage, hImg16, STM_GETICON, 0, 0
invoke  DestroyIcon, rax

invoke EndDialog,hWin,0
.else
mov rax,FALSE
ret
.endif
mov rax,TRUE
ret
MainDlg endp

DlgHook proc uses rsi rdi rbx hWin:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM
LOCAL   hIcon32:QWORD
LOCAL   hIcon16:QWORD

mov eax,uMsg
.if eax==WM_INITDIALOG
invoke LoadLibrary,CStr("shell32.dll")
.if rax
mov hShell32_dll,rax
invoke GetProcAddress,hShell32_dll,CStr("ExtractIconEx")
.if rax!=0
mov @pExtractIconEx,rax
.else
invoke MessageBox,NULL,CStr("ExtractIconEx get Failed"),CStr("GetProcAddress"),MB_OK
.endif
.else
invoke MessageBox,NULL,CStr("shell32.dll load Failed"),CStr("LoadLibrary"),MB_OK
.endif

; Image list for browse for icons dialog
invoke  ImageList_Create, 32, 32, ILC_MASK or ILC_COLORDDB, 2, 500
mov     himlDlg, rax

; Get handle to open file dialog
invoke  GetParent, hWin
mov     rbx, rax
mov     hParent, rax
       
; I don't want these 3 controls, so hide em
; Hide file name static control
invoke  SendMessage, rax, CDM_HIDECONTROL, stc3, 0
; Hide file name edit control
invoke  SendMessage, rbx, CDM_HIDECONTROL, edt1, 0
; Hide ok button
invoke  SendMessage, rbx, CDM_HIDECONTROL, IDOK, 0

; Now move the next 3 controls up
; Adjust file type static top
invoke RtlZeroMemory,addr tTR,sizeof RECT
invoke RtlZeroMemory,addr wLp,sizeof POINT

invoke  GetDlgItem, rbx, stc2
mov     rdi, rax
       
invoke  GetWindowRect, rdi, offset tTR
invoke  ScreenToClient, rbx, offset wLp
mov     eax, wLp.x
add     eax, tTR.left
mov     esi, wLp.y
add     esi, tTR.top
sub     esi, 30
invoke  SetWindowPos, rdi, 0, eax, esi, 0, 0, SWP_NOSIZE

; Adjust file type combo top
invoke  GetDlgItem, rbx, cmb1
mov     rdi, rax
       
invoke  GetWindowRect, rdi, offset tTR
mov     eax, wLp.x
add     eax, tTR.left
sub     esi, 4
invoke  SetWindowPos, rdi, 0, eax, esi, 0, 0, SWP_NOSIZE

; Adjust cancel button top
invoke  GetDlgItem, rbx, IDCANCEL
mov     rdi, rax

invoke  GetWindowRect, rdi, offset tTR
mov     eax, wLp.x
add     eax, tTR.left
sub     esi, 4
invoke  SetWindowPos, rdi, 0, eax, esi, 0, 0, SWP_NOSIZE

; Get handle to our listview
invoke  GetDlgItem, hWin, IDC_LSV1
mov     hLVDlg, rax

; Set image list to listview
invoke  SendMessage, hLVDlg, LVM_SETIMAGELIST, LVSIL_NORMAL, himlDlg

push    hWin
pop     hMainDlg
       
.elseif eax==WM_COMMAND
mov rdx,wParam
mov rax,qword ptr [edx]
shr rdx,32
.if rdx==BN_CLICKED
.if rax==IDOK

.elseif rax==IDCANCEL
invoke  SendMessage, hWin, WM_CLOSE, NULL, NULL
.endif
.endif
       
.elseif eax == WM_NOTIFY
.if wParam == IDC_LSV1
mov     rax, lParam
.if dword ptr(NMHDR ptr [rax]).code == LVN_ITEMCHANGING
.if dword ptr(NMLISTVIEW ptr [rax]).uNewState == LVIS_FOCUSED or LVIS_SELECTED
invoke  ImageList_GetIcon, himlDlg, dword ptr(NMLISTVIEW ptr [rax]).iItem, ILD_TRANSPARENT
mov hIcon32,rax
invoke  SendMessage, hImg32, STM_SETICON, rax, 0
                   
invoke  CopyImage, hIcon32, IMAGE_ICON, 16, 16, LR_COPYFROMRESOURCE
mov hIcon16,rax
invoke  SendMessage, hImg16, STM_SETICON, hIcon32, 0
invoke  DestroyIcon, hIcon32
invoke  DestroyIcon, hIcon16

invoke  PostMessage, hParent, WM_CLOSE, 0, 0
ret
.else
jmp     PassThrough
.endif
.else
jmp     PassThrough
.endif
           
.else
mov     rax, lParam
.if dword ptr(NMHDR ptr [rax]).code == CDN_SELCHANGE
; Get path of selected file
mov     byte ptr [DlgFilePath], 0
invoke RtlZeroMemory,addr DlgFilePath,MAX_PATH + 1
invoke  SendMessage, hParent, CDM_GETFILEPATH, MAX_PATH + 1, offset DlgFilePath
invoke  PathFindExtension, offset DlgFilePath
invoke  Cmpi, rax, offset szExtIco
test    rax, rax
jz      @F
call    ShowIcons
@@:
jmp     PassThrough
               
.elseif dword ptr(NMHDR ptr [rax]).code == CDN_FILEOK
invoke  PathFindExtension, offset DlgFilePath
invoke  Cmpi, rax, offset szExtIco
.if rax == 0
; Icon was selected, show 32 and 16 sizes
invoke  LoadImage, NULL, offset DlgFilePath, IMAGE_ICON, 32, 32, LR_LOADFROMFILE
mov hIcon32,rax
invoke  SendMessage, hImg32, STM_SETICON,hIcon32, 0

invoke  CopyImage, hIcon32, IMAGE_ICON, 16, 16, LR_COPYFROMRESOURCE
mov hIcon16,rax
invoke  SendMessage, hImg16, STM_SETICON, hIcon16, 0
invoke  DestroyIcon, hIcon32
invoke  DestroyIcon, hIcon16
; close the dialog
invoke  SetWindowLong, hWin, DWL_MSGRESULT, FALSE
.else
; not an ico file, leave dialog open
invoke  SetWindowLong, hWin, DWL_MSGRESULT, TRUE
.endif
.else
jmp     PassThrough   
.endif
.endif
.elseif eax==WM_CLOSE
invoke  ImageList_Destroy, himlDlg
invoke  DestroyWindow, hWin
invoke FreeLibrary,hShell32_dll
.else
PassThrough:
mov rax, FALSE
ret
.endif
mov rax, TRUE
ret

DlgHook endp

ShowIcons proc
LOCAL   hLib:QWORD

; Clear imagelist
invoke  ImageList_Remove, himlDlg, -1

; Clear listview
invoke  SendMessage, hLVDlg, LVM_DELETEALLITEMS, 0, 0
   
; is the path a directory?  If yes, leave
invoke  PathIsDirectory, offset DlgFilePath
test    rax, rax
jnz     Done
; Get icon count
invoke  @pExtractIconEx, offset DlgFilePath,-1,NULL,NULL,NULL
test    rax, rax
jnz     @F
invoke  SetDlgItemInt, hMainDlg, 2002, eax, FALSE
jmp     Done
   
@@:
invoke  SetDlgItemInt, hMainDlg, 2002, eax, FALSE
; We have icons! load the file
invoke  LoadLibraryEx, offset DlgFilePath, 0, LOAD_LIBRARY_AS_DATAFILE
test    rax, rax
jz      Done
mov     hLib, rax

; Now get all the icon names
invoke  EnumResourceNames, rax, RT_GROUP_ICON, offset EnumResNamesProc, 0
invoke  FreeLibrary, hLib
Done:
ret
ShowIcons endp

XIS_INTRESOURCE proc IcoID:QWORD   
mov   rax, IcoID
shr   rax, 32
ret
XIS_INTRESOURCE endp

dqtoa proc uvar:QWORD,pbuffer:QWORD
invoke wsprintf,pbuffer,CStr("%d"),uvar
ret
dqtoa endp

MemCopy proc uses rsi rdi dqS_addr:QWORD,dqD_addr:QWORD,dq_Size:QWORD

cld
mov rsi, dqS_addr
mov rdi, dqD_addr
mov rcx, dq_Size

shr rcx, 3
rep movsq

mov rcx, dq_Size
and rcx, 7
rep movsb

ret

MemCopy endp

EnumResNamesProc proc hModule:QWORD,lpszType:QWORD, lpszName:QWORD, lParam:QWORD
LOCAL   IconTemp:QWORD
LOCAL   LVParam:QWORD

invoke  LoadImage, hModule, lpszName, IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR
mov     IconTemp, rax
invoke  ImageList_ReplaceIcon, himlDlg, -1, IconTemp
invoke  DestroyIcon, IconTemp
invoke  ImageList_GetImageCount, himlDlg
sub     rax, 1
   
mov     lvi.mask_, LVIF_IMAGE or LVIF_TEXT
mov     lvi.iItem, eax
mov     lvi.iSubItem, 0
mov     lvi.iImage, eax
   
invoke  HeapAlloc, hMainHeap, HEAP_ZERO_MEMORY, 50
mov     LVParam, rax

invoke RtlZeroMemory,LVParam,50
invoke  XIS_INTRESOURCE, lpszName
test    rax, rax
jz      @F
   
invoke  lstrlen, lpszName
invoke  MemCopy, lpszName, LVParam, rax
jmp     @Continue
@@:
invoke  dqtoa, lpszName, LVParam
   
@Continue:
        mov     rax, LVParam
        mov     lvi.pszText, rax

        invoke  SendMessage, hLVDlg, LVM_INSERTITEM, 0, addr lvi
        invoke  HeapFree, hMainHeap, 0, LVParam

        mov     rax, TRUE
        ret
EnumResNamesProc endp

start Proc
invoke GetModuleHandle,NULL
mov hInst,  rax
invoke  GetProcessHeap
mov     hMainHeap, rax
   
invoke DialogBoxParam,hInst,IDD_MAIN,NULL,addr MainDlg,NULL
invoke ExitProcess,NULL

start Endp


end


Quote#include <\UASM64\include\resource.h>
#define MANIFEST 24
#define IDD_MAIN 1000
#define IDC_OK 1002
#define IDC_CANCEL 1001
#define IDC_IMG_LRG 1003
#define IDC_IMG_SM 1004
#define IDD_DLG 2000
#define IDC_LSV1 1548
#define IDC_SHP1 1119
#define IDC_STC1 2001
#define IDC_STC2 2002

IDD_MAIN DIALOGEX 6,6,165,66
CAPTION "DialogApp"
FONT 8,"Tahoma",0,0,0
STYLE 0x10CA0800
BEGIN
  CONTROL "Choose Icon",IDC_OK,"Button",0x50010000,108,48,54,13
  CONTROL "Close",IDC_CANCEL,"Button",0x50010000,48,48,54,13
  CONTROL "",IDC_IMG_LRG,"Static",0x50000203,9,9,32,32
  CONTROL "",IDC_IMG_SM,"Static",0x50000203,51,17,16,16
END

IDD_DLG DIALOGEX 10,150,288,116
FONT 8,"MS Sans Serif",0,0,0
STYLE NOT 0x10000000|0x44000404
EXSTYLE 0x00000008
BEGIN
  CONTROL "",IDC_LSV1,"SysListView32",0x50010000,3,18,281,84,0x00000200
  CONTROL "",IDC_SHP1,"Static",NOT 0x10000000|0x40000004,3,3,279,14
  CONTROL "Totall Icons:",IDC_STC1,"Static",0x50000000,6,105,42,9
  CONTROL "",IDC_STC2,"Static",0x50000000,57,105,51,9
END


Say you, Say me, Say the codes together for ever.

jj2007

The hook works in 32-bit code. FileOpen$() uses it.

six_L

#3
hi,jj2007
tested again, the cDialogHook_2.exe can extract 32 and 64 bit dll or exe ICO.
attachment: there are some icons in win explorer.exe file.
Say you, Say me, Say the codes together for ever.

ragdog

Hi Six_L

I use OFN_EXPLORER for Vista look and Placesbar (listview) left side with Desktop ,Network etc.



But if i use a hook  mov   ofn.Flags,OFN_EXPLORER or OFN_ENABLEHOOK have  i the old style.

six_L

hi,ragdog
this was an old question. (http://www.masmforum.com/board/index.php?topic=14214.0).
x_OPENFILENAME STRUCT
lStructSize DWORD ?
hwndOwner HWND ?
hInstance HINSTANCE ?
lpstrFilter LPSTR ?
lpstrCustomFilter LPSTR ?
nMaxCustFilter DWORD ?
nFilterIndex DWORD ?
lpstrFile LPSTR ?
nMaxFile DWORD ?
lpstrFileTitle LPSTR ?
nMaxFileTitle DWORD ?
lpstrInitialDir LPSTR ?
lpstrTitle LPSTR ?
Flags DWORD ?
nFileOffset WORD ?
nFileExtension WORD ?
lpstrDefExt LPSTR ?
lCustData LPARAM ?
lpfnHook LPOFNHOOKPROC ?
lpTemplateName LPSTR ?
pvReserved DWORD ?
dwReserved DWORD ?
FlagsEx DWORD ?
x_OPENFILENAME ENDS

QuoteFlagsEx
Type: DWORD

A set of bit flags you can use to initialize the dialog box. Currently, this member can be zero or the following flag.

Value   Meaning
OFN_EX_NOPLACESBAR
0x00000001
If this flag is set, the places bar is not displayed. If this flag is not set, Explorer-style dialog boxes include a places bar containing icons for commonly-used folders, such as Favorites and Desktop.

Remarks
For compatibility reasons, the Places Bar is hidden if Flags is set to OFN_ENABLEHOOK and lStructSize is OPENFILENAME_SIZE_VERSION_400.

i used the x_OPENFILENAME STRUCT, my testing codes was either crashed or noactive.
i'll try to test again.
Say you, Say me, Say the codes together for ever.

ragdog

Thank you Sixl

I forgot my old question

Here is a working code


_WIN32_WINNT equ  0500h

OPENFILENAME_ struct
lStructSize DWORD ?
hwndOwner HWND ?
hInstance HINSTANCE ?
lpstrFilter LPSTR ?
lpstrCustomFilter LPSTR ?
nMaxCustFilter DWORD ?
nFilterIndex DWORD ?
lpstrFile LPSTR ?
nMaxFile DWORD ?
lpstrFileTitle LPSTR ?
nMaxFileTitle DWORD ?
lpstrInitialDir LPSTR ?
lpstrTitle LPSTR ?
Flags DWORD ?
nFileOffset WORD ?
nFileExtension WORD ?
lpstrDefExt LPSTR ?
lCustData LPARAM ?
lpfnHook LPOFNHOOKPROC ?
lpTemplateName LPSTR ?
ifdef _MAC
lpEditInfo LPEDITMENU ?
lpstrPrompt LPSTR ?
endif
if (_WIN32_WINNT ge 0500h)
pvReserved DWORD ?
dwReserved DWORD ?
FlagsEx         DWORD ?
endif
OPENFILENAME_ ends



invoke RtlZeroMemory,addr ofn,sizeof ofn
mov ofn.lStructSize,sizeof OPENFILENAME_
m2m ofn.hwndOwner,hWnd
m2m ofn.hInstance,hInstance
mov ofn.lpfnHook,offset DlgHook
mov ofn.lpstrTitle,chr$ ("  Select a file ...")
mov ofn.lpstrFilter, offset szFilter
mov ofn.lpstrFile, offset buffer
mov ofn.nMaxFile, sizeof buffer
if (_WIN32_WINNT ge 0500h)
mov ofn.pvReserved,NULL;
mov ofn.dwReserved, 0;
mov ofn.FlagsEx, 0;
endif
mov ofn.Flags,  OFN_EXPLORER or OFN_ENABLEHOOK
invoke GetOpenFileName,addr ofn   
.if (!eax)
;not selected
ret
.endif


Callback


DlgHook proc uses esi edi ebx hWin:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM
    mov eax,uMsg
    .if eax==WM_INITDIALOG

   .elseif eax == WM_NOTIFY

    .elseif eax==WM_CLOSE
        invoke  DestroyWindow, hWin
    .else
            mov eax, FALSE
            ret
    .endif
    mov eax, TRUE
    ret

DlgHook endp


But is not original Vista dialog, Is there any solution for this??


six_L

hi,ragdog
ofn.FlagsEx can't work rightly. tested again and again, no any result of displaying.
sorry, i can't help you a bit.
Say you, Say me, Say the codes together for ever.

ragdog

Hello six_L

After i have many trouble with my x64 template can i post a solution with ofn hook.

Many thanks to Fearless,John and Jochen  :biggrin:

Regards

six_L

hello,ragdog
your example works fine.
thanks you.

in my example, there is no Placesbar (listview) left side with Desktop ,Network etc.
can you make my example of the following Attachment?
Say you, Say me, Say the codes together for ever.

ragdog

Hello Six

have you forgot the filebuffer?

And by your  includes set  Winver xxx

WINVER equ 0501h

include \jwasm\include\windows.inc
include \jwasm\include\CommCtrl.inc
include \jwasm\include\commdlg.INC
includelib user32.lib
includelib kernel32.lib
includelib comctl32.lib
includelib comdlg32.lib



BrowseFilename  db  MAX_PATH dup (?)

   lea rax, BrowseFilename
   mov ofn.lpstrFile, rax


I think this is it?

But i use not a Dlg template for browse, like Gunners example

Greets,