Masm bug? Macro not working when called as first instruction after Start:

Started by jj2007, June 17, 2008, 01:24:09 PM

Previous topic - Next topic

jj2007

Just made a strange discovery. The code below works perfectly. However, try...

start: .if EXIST(addr FindMe)

... instead of ...

start:
.if EXIST(addr FindMe)


Is this a known bug?

.nolist
include \masm32\include\masm32rt.inc

EXIST MACRO fname:REQ, DiscardHandle:=<1>
invoke FindFirstFile, reparg(<fname>), addr wfd
.if eax==INVALID_HANDLE_VALUE
xor eax, eax
.elseif DiscardHandle
invoke FindClose, eax
.endif
EXITM <eax>
ENDM

.data?
wfd WIN32_FIND_DATA <?>

.data
FindMe db "\masm32\OllyDbg\OLLYDBG.EXE", 0
FileEx db "The file exists:", 0
NoFile db "The file does NOT exist:", 0

.code
start:
.if EXIST(addr FindMe)
invoke MessageBox, 0, addr FindMe, addr FileEx, MB_OK
.else
invoke MessageBox, 0, addr FindMe, addr NoFile, MB_OK
.endif
invoke ExitProcess, 0
end start

[attachment deleted by admin]

qWord

hi,

i don't think this is a bug. The code in EXIST()-macro will be created before the entrypoint. The reason for this is that masm expand macros before the current line.

regards qword

FPU in a trice: SmplMath
It's that simple!