flat assembler
Message board for the users of flat assembler.
Index
> Windows > How to optimize GetSave/OpenFileName |
Author |
|
shoorick 04 Apr 2006, 05:42
you can write such macro:
macro FillOpenFileNameStruct _Parent,... { push 0 ; lpTemplateName push _DefExt ... push _Parent push sizeof.OPENFILENAME } - it will create this filled structure in stack. pointer to it - esp if you plan to push some after it you have to preserve pointer in another register or check offset by yourself. after calling function you can free it with add esp,[esp] anyway if you will use stdcall you will do some pushes, also call/ret will cost some. regards!
|
|||||||||||
04 Apr 2006, 05:42 |
|
shoorick 04 Apr 2006, 07:10
walking your source:
you can use such subroutine, but: 1. if you pass pointer to your structure you have to get it into register, eg. edx and use offset with it: mov edx,[pofn] mov [edx + OPENFILENAME.lStructSize],sizeof.OPENFILENAME ... 2. to get pointer to the local variable you have explicitlely load it, eg.: lea ecx,[ofn] 3.invoke will do "call [proc]", but you need "call proc" - this available via "stdcall" (fasm is not masm), eg.: lea ecx,[ofn] stdcall SET_OPENFILENAME,0,[hWnd],pFile,...,ecx regards! |
|||
04 Apr 2006, 07:10 |
|
Vasilev Vjacheslav 04 Apr 2006, 14:49
my code:
Code: szFilter db "Executable Files",0,"*.exe",0,0 szTitle db "Select file",0 proc _openfile uses ebx esi edi, lpWnd,lpTargetPath,lpFilter,lpTitle local ofn:OPENFILENAME lea edi,[ofn] mov ecx,sizeof.OPENFILENAME xor al,al rep stosb lea edi,[ofn] mov [edi+OPENFILENAME.lStructSize],sizeof.OPENFILENAME m2m [edi+OPENFILENAME.hwndOwner],[lpWnd] m2m [edi+OPENFILENAME.hInstance],[hInstance] m2m [edi+OPENFILENAME.lpstrFilter],[lpFilter] mov [edi+OPENFILENAME.nFilterIndex],1 m2m [edi+OPENFILENAME.lpstrFile],[lpTargetPath] mov [edi+OPENFILENAME.nMaxFile],MAX_PATH m2m [edi+OPENFILENAME.lpstrTitle],[lpTitle] mov [edi+OPENFILENAME.Flags],OFN_EXPLORER+OFN_FILEMUSTEXIST+OFN_HIDEREADONLY invoke GetOpenFileName,edi ret endp proc _opensave uses ebx esi edi, lpWnd,lpTargetPath,lpFilter,lpTitle local ofn:OPENFILENAME lea edi,[ofn] mov ecx,sizeof.OPENFILENAME xor al,al rep stosb lea edi,[ofn] mov [edi+OPENFILENAME.lStructSize],sizeof.OPENFILENAME m2m [edi+OPENFILENAME.hwndOwner],[lpWnd] m2m [edi+OPENFILENAME.hInstance],[hInstance] m2m [edi+OPENFILENAME.lpstrFilter],[lpFilter] mov [edi+OPENFILENAME.nFilterIndex],1 m2m [edi+OPENFILENAME.lpstrFile],[lpTargetPath] mov [edi+OPENFILENAME.nMaxFile],MAX_PATH m2m [edi+OPENFILENAME.lpstrTitle],[lpTitle] mov [edi+OPENFILENAME.Flags],OFN_FILEMUSTEXIST+OFN_PATHMUSTEXIST+OFN_LONGNAMES+OFN_EXPLORER+OFN_HIDEREADONLY invoke GetSaveFileName,edi ret endp |
|||
04 Apr 2006, 14:49 |
|
AsmER 07 Apr 2006, 10:25
Hehe,
I just started looking, if it is possible to do thing like: Code: lea reg, structre mov [reg+structure.element_of_the_structure], value in FASM (I knowed I can do it in MASM) and you sent answer to me(MASM 1:1 FASM). You can't know how much you helped Right, this post can be treated as closed |
|||
07 Apr 2006, 10:25 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.