The MASM Forum

General => The Campus => Topic started by: morgot on March 21, 2014, 06:19:23 AM

Title: FindFirstFileEx problem - undefined symbols
Post by: morgot on March 21, 2014, 06:19:23 AM
Hello.
How i can to invoke this function? Masm don't know some symbols, such as FindExInfoStandard and other from here
http://msdn.microsoft.com/en-us/library/windows/desktop/aa364415(v=vs.85).aspx
http://msdn.microsoft.com/en-us/library/windows/desktop/aa364416(v=vs.85).aspx

Where can I get these values? Usually, I would take them out of the C source files, but now I do not know what to do.

typedef enum _FINDEX_INFO_LEVELS {
    FindExInfoStandard,
    FindExInfoMaxInfoLevel
} FINDEX_INFO_LEVELS;


How to "translate" this into Masm?
Title: Re: FindFirstFileEx problem - undefined symbols
Post by: ragdog on March 21, 2014, 07:02:42 AM
FINDEX_INFO_LEVELS   
   FindExInfoStandard    equ  1
   FindExInfoBasic   equ 2
   FindExInfoMaxInfoLevel   equ 3
FINDEX_INFO_LEVELS      ENDS

I have not test it

But i have read this cpp example

hFind = FindFirstFileEx(argv[1], FindExInfoStandard, &FindFileData,
             FindExSearchNameMatch, NULL, 0);


And think this is not declared without a struct

FindExInfoStandard    equ  1
FindExInfoBasic   equ 2
FindExInfoMaxInfoLevel   equ 3
Title: Re: FindFirstFileEx problem - undefined symbols
Post by: qWord on March 21, 2014, 07:12:34 AM
Unless the values are explicit assigned, enumerations start with zero:

FindExInfoStandard       equ 0
FindExInfoBasic          equ 1
FindExInfoMaxInfoLevel   equ 2
Title: Re: FindFirstFileEx problem - undefined symbols
Post by: ragdog on March 21, 2014, 07:13:50 AM
Sure qWord?

Ok i have not test it
Title: Re: FindFirstFileEx problem - undefined symbols
Post by: GoneFishing on March 21, 2014, 07:17:10 AM
 qWord is right :

P.S.: I love Snipping Tool & MSPAINT  :biggrin:
Title: Re: FindFirstFileEx problem - undefined symbols
Post by: ragdog on March 21, 2014, 07:19:27 AM
Ok i have build a exe and see it you're right qWord

hFind = FindFirstFileEx(argv[1], FindExInfoStandard, &FindFileData,
             FindExSearchNameMatch, NULL, 0);

..
...
push    ecx             ; lpFindFileData
push    0               ; fInfoLevelId                  ;<<<<<<<<<<<<<<<
mov     edx, [ebp+argv]
mov     eax, [edx+4]
push    eax             ; lpFileName
call    ds:__imp__FindFirstFileExA@24

Title: Re: FindFirstFileEx problem - undefined symbols
Post by: TWell on March 21, 2014, 07:28:43 AM
QuoteBy default, the first enumeration-constant is associated with the value 0.
Look here (http://msdn.microsoft.com/en-us/library/whbyts4t.aspx)
Title: Re: FindFirstFileEx problem - undefined symbols
Post by: MichaelW on March 21, 2014, 01:32:36 PM
 FINDEX_INFO_LEVELS enumeration (http://msdn.microsoft.com/en-us/library/windows/desktop/aa364415(v=vs.85).aspx)

Interesting, the enumeration from my 2003 PSDK WinBase.h is different from the current:

typedef enum _FINDEX_INFO_LEVELS {
    FindExInfoStandard,
    FindExInfoMaxInfoLevel
} FINDEX_INFO_LEVELS;


So the value of FindExInfoMaxInfoLevel has changed, and now it's for validation only. I thought Microsoft generally tries to avoid this.



Title: Re: FindFirstFileEx problem - undefined symbols
Post by: jj2007 on March 21, 2014, 05:32:05 PM
Quote from: MichaelW on March 21, 2014, 01:32:36 PMow it's for validation only

What do you mean with "validation only"?

I use this to speed up GetFiles (http://www.webalice.it/jj2006/MasmBasicQuickReference.htm#Mb1056):
      ; perform a dummy search to find out if the OS supports the fast flags:
      FindExInfoBasic=1
      invoke FindFirstFileEx, chr$("C:\NoFFx.Yet"),
      FindExInfoBasic, offset wfd, 0, 0, FIND_FIRST_EX_LARGE_FETCH
      invoke GetLastError
      .if eax!=ERROR_INVALID_PARAMETER
            ... set a flag saying it's allowed to use FindExInfoBasic ...

... and of course, now I wonder if it works on XP and Win7 alike 8)

EDIT: I got it...:
Quotetypedef enum _FINDEX_INFO_LEVELS {
  FindExInfoStandard,
  FindExInfoBasic,
  FindExInfoMaxInfoLevel
} FINDEX_INFO_LEVELS;
...
FindExInfoMaxInfoLevel
    This value is used for validation. Supported values are less than this value.
Which means that if FindExInfoMaxInfoLevel=1, the enumeration above has only one member, i.e. FindExInfoBasic is not defined. Odd and clumsy, and in the end you'll have to do runtime testing as in my code posted above :(
Title: Re: FindFirstFileEx problem - undefined symbols
Post by: morgot on March 21, 2014, 08:53:24 PM
Thank you!
I do not know anything about enumerations.
Title: Re: FindFirstFileEx problem - undefined symbols
Post by: morgot on April 13, 2014, 02:17:22 AM
Hello, can you say me, what value is FSCTL_SET_REPARSE_POINT ? How to use this constant in my masm code?
http://msdn.microsoft.com/en-us/library/windows/desktop/aa364595(v=vs.85).aspx
Title: Re: FindFirstFileEx problem - undefined symbols
Post by: dedndave on April 13, 2014, 03:37:04 AM
ENUM seems to be a MASM reserved word
we just don't know how to use it - lol
Title: Re: FindFirstFileEx problem - undefined symbols
Post by: jj2007 on April 13, 2014, 03:45:07 AM
Enum (http://www.webalice.it/jj2006/MasmBasicQuickReference.htm#Mb1016) is reserved but not by Masm ;-)
Title: Re: FindFirstFileEx problem - undefined symbols
Post by: MichaelW on April 13, 2014, 08:31:49 AM
FWIW drizz posted an Enum macro that does the essentials on the old forum:

http://www.masmforum.com/board/index.php?topic=9038.msg65478#msg65478


Enum macro __EnumStart:=<0>,__EnumArgs:vararg
LOCAL i,arg
i = __EnumStart
for arg,<__EnumArgs>
ifnb <arg>
&arg equ i
endif
i = i + 1
endm
endm

;typedef enum _FINDEX_INFO_LEVELS {
;  FindExInfoStandard,
;  FindExInfoBasic,
;  FindExInfoMaxInfoLevel
;} FINDEX_INFO_LEVELS;

include \masm32\include\masm32rt.inc
.data
.code
start:

    Enum ,FindExInfoStandard,FindExInfoBasic,FindExInfoMaxInfoLevel

    printf("FindExInfoStandard     %d\n", FindExInfoStandard)
    printf("FindExInfoBasic        %d\n", FindExInfoBasic)
    printf("FindExInfoMaxInfoLevel %d\n\n", FindExInfoMaxInfoLevel)

    inkey
    exit
end start


FindExInfoStandard     0
FindExInfoBasic        1
FindExInfoMaxInfoLevel 2

Title: Re: FindFirstFileEx problem - undefined symbols
Post by: jj2007 on April 13, 2014, 08:43:09 AM
The MasmBasic version is very similar but default start is 10:

EnuCt=10   ; IDOK ... IDHELP=1...9

Enum MACRO args:VARARG
LOCAL arg, is, arg2
  for arg, <args>
   is INSTR <arg>, <:>
   if is
      EnuCt=@SubStr(<arg>, 1, is-1)
      arg2 SUBSTR <arg>, is+1
      arg2=EnuCt
   else
      arg=EnuCt
   endif
   EnuCt=EnuCt+1
  ENDM
ENDM


Usage:
  Enum 0:FindExInfoStandard, FindExInfoBasic, FindExInfoMaxInfoLevel  ; force start at 0
  Enum IdMenuNew, IdMenuSave, IdMenuCopy, IdTimer ; continued, IdMenuNew=3
  Enum 20:IdEdit, IdButton1, 30:IdButton2, IdStatic, IdFind, IdFindStatic