News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

GetOpenFileName crash, why?

Started by Farabi, February 06, 2008, 07:58:00 AM

Previous topic - Next topic

Farabi

I dont know what is wrong, thanks for point me my mistake. I dont know why but it is working befor.



GetFileName proc uses esi hParent:DWORD,lpTitle:DWORD,lpFilter:DWORD
LOCAL ofn         :  OPENFILENAME ; structure

   mov ofn.lStructSize,        sizeof OPENFILENAME
   push 0
   pop ofn.hWndOwner
   push 0
   pop ofn.hInstance
   push lpFilter
   pop ofn.lpstrFilter
   push offset szFileName
   pop ofn.lpstrFile
   mov ofn.nMaxFile,           sizeof szFileName
   push lpTitle
   pop ofn.lpstrTitle
   mov ofn.Flags,              OFN_EXPLORER or OFN_FILEMUSTEXIST or \
                               OFN_LONGNAMES

   invoke GetOpenFileName,ADDR ofn
   ret

GetFileName endp

fOpenFileDialog proc hWnd:dword,lpszTitleO:dword,lpszFilterO:dword

   
           invoke memfill,ADDR szFileName,length szFileName,0
           invoke GetFileName,hWnd, lpszTitleO, lpszFilterO
           
           .if eax!=0
           lea eax,szFileName
           .endif
ret
fOpenFileDialog endp


I call it like this


.elseif uMsg==WM_COMMAND

.if wParam==101
invoke fOpenFileDialog,0,CADD("Pilih berkas gambar:"),addr filt
cmp eax,0
jz @F
invoke FaceDetect,eax
@@:
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

ToutEnMasm

Hello,
Without many search (parameters of the function are not shown),I see that the structure is in the stack (local variables).
Common mistake is to forget the initialisation at zero of all the structure before full it with useful data.
a RtlZeroMemory of all the structure seem needed

Quote
OPENFILENAMEA   STRUCT
   lStructSize DWORD ?
   hwndOwner DWORD ?
   hInstance DWORD ?
   lpstrFilter DWORD ?
   lpstrCustomFilter DWORD ?
   nMaxCustFilter DWORD ?
   nFilterIndex DWORD ?
   lpstrFile DWORD ?
   nMaxFile DWORD ?
   lpstrFileTitle DWORD ?
   nMaxFileTitle DWORD ?
   lpstrInitialDir DWORD ?
   lpstrTitle DWORD ?
   Flags DWORD ?
   nFileOffset WORD ?
   nFileExtension WORD ?
   lpstrDefExt DWORD ?
   lCustData DWORD ?
   lpfnHook DWORD ?
   lpTemplateName DWORD ?
IFDEF _MAC
   lpEditInfo DWORD ?
   lpstrPrompt DWORD ?
ENDIF
IF COMPARE(_WIN32_WINNT,GE,00500h)
   pvReserved DWORD ?
   dwReserved DWORD ?
   FlagsEx DWORD ?
ENDIF ; (_WIN32_WINNT >= 0x0500)
OPENFILENAMEA      ENDS