News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

FindFirstFileEx problem - undefined symbols

Started by morgot, March 21, 2014, 06:19:23 AM

Previous topic - Next topic

morgot

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?
Sorry for the bad English

ragdog

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

qWord

Unless the values are explicit assigned, enumerations start with zero:

FindExInfoStandard       equ 0
FindExInfoBasic          equ 1
FindExInfoMaxInfoLevel   equ 2
MREAL macros - when you need floating point arithmetic while assembling!

ragdog


GoneFishing

 qWord is right :

P.S.: I love Snipping Tool & MSPAINT  :biggrin:

ragdog

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


TWell

QuoteBy default, the first enumeration-constant is associated with the value 0.
Look here

MichaelW

FINDEX_INFO_LEVELS enumeration

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.



Well Microsoft, here's another nice mess you've gotten us into.

jj2007

#8
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:
      ; 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 :(

morgot

Thank you!
I do not know anything about enumerations.
Sorry for the bad English

morgot

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
Sorry for the bad English

dedndave

ENUM seems to be a MASM reserved word
we just don't know how to use it - lol

jj2007


MichaelW

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

Well Microsoft, here's another nice mess you've gotten us into.

jj2007

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