| 
                  
                  
                   I wrote a function to create a file with specified flags:
 
 
format PE GUI
 
 
include 'win32ax.inc'
 
 
OPEN_READWRITE                =0x00000002
 
OPEN_CREATE              =0x00000004
 
OPEN_DELETEONCLOSE       =0x00000008
 
OPEN_SHARE_WRITE         =0x00000100
 
 
proc testproc filename, flags
 
    locals
 
              dwDesiredAccess dw 0    
 
            dwCreationDisposition dw 0 
 
         dwShareMode dw 0
 
            dwFlagsAndAttributes dw 0
 
   endl
 
                
 
    ;Flags And Attributes
 
       xor eax, eax
 
        mov eax, [flags]
 
    and eax, OPEN_DELETEONCLOSE
 
 .if eax=OPEN_DELETEONCLOSE
 
          mov dword [dwFlagsAndAttributes], FILE_ATTRIBUTE_NORMAL or FILE_FLAG_DELETE_ON_CLOSE
 
        .else
 
               mov dword [dwFlagsAndAttributes], FILE_ATTRIBUTE_NORMAL
 
     .endif
 
      
 
    ;Desired Access 
 
    xor eax, eax
 
        mov eax, [flags]
 
    and eax, OPEN_READWRITE
 
     .if eax=OPEN_READWRITE
 
              mov dword [dwDesiredAccess], GENERIC_READ or GENERIC_WRITE
 
  .else
 
               mov dword [dwDesiredAccess], GENERIC_READ
 
   .endif
 
      
 
    ;Creation Disposition
 
       xor eax, eax
 
        mov eax, [flags]
 
    and eax, OPEN_CREATE
 
        .if eax=OPEN_CREATE
 
         mov dword [dwCreationDisposition], OPEN_ALWAYS
 
      .else
 
               mov dword [dwCreationDisposition], OPEN_EXISTING
 
    .endif
 
      
 
    ;Share Mode
 
 xor eax, eax
 
        mov eax, [flags]
 
    and eax, OPEN_SHARE_WRITE
 
   .if eax=OPEN_SHARE_WRITE
 
            mov dword [dwShareMode], FILE_SHARE_READ or FILE_SHARE_WRITE
 
        .else
 
               mov dword [dwShareMode], FILE_SHARE_READ
 
    .endif  
 
            
 
    
 
    invoke CreateFileA,[filename],dword [dwDesiredAccess],dword [dwShareMode],0,dword [dwCreationDisposition],dword [dwFlagsAndAttributes],0
 
    ret
 
endp     
 
 
section '.code' code readable executable 
 
start:
 
       stdcall testproc, "d:\test1.txt",OPEN_READWRITE or OPEN_CREATE
 
   invoke  ExitProcess,0
 
.end start
 
 
 
 
it does not work, but if I change the local variable's order:
 
 
locals
 
             dwShareMode dw 0
 
            dwDesiredAccess dw 0    
 
            dwCreationDisposition dw 0 
 
         dwFlagsAndAttributes dw 0
 
endl
 
 
 
it work well, why? also why I can not check [flags] directly like:.if [flags] and OPEN_SHARE_WRITE ? 
                  
                 |