It was easier than I thought :t
It will be implemented in macrolib.c
Have look at this example, with these two macros DEFINE and UNDEF both version can be assembled at ones.
Here is the source:
.386
.model Flat, C
DEFINE MACRO a:req
a = 1
ENDM
UNDEF MACRO a:req
a = 0
ENDM
DEFINE USELITERALS
IF USELITERALS
OPTION LITERALS:ON ; Allow string literals use in INVOKE
printf PROTO :PTR, :PTR
ELSE
printf PROTO :PTR, :vararg
ENDIF
TRUE equ 1
includelib \masm32\lib\ntdll.lib
RtlCompareString PROTO STDCALL :ptr,:ptr,:BYTE
RtlInitAnsiString PROTO STDCALL :ptr, :ptr
includelib \masm32\lib\msvcrt.lib
includelib \masm32\lib\kernel32.lib
ExitProcess proto STDCALL :dword
_STRING struct
_Length word ?
_Maximumlength word ?
_Buffer dword ?
_STRING ends
.data
format db 'result: %d',13,10,0
s1 db "someStr",0 ;
s2 db "anotherStr",0 ;
.code
main proc
LOCAL str1 : _STRING
LOCAL str2 : _STRING
IF USELITERALS
INVOKE RtlInitAnsiString, addr str1, "someStr"
INVOKE RtlInitAnsiString, addr str2, "anotherStr"
INVOKE RtlCompareString, addr str1, addr str2, TRUE
INVOKE printf, "result: %d", eax
ENDIF
UNDEF USELITERALS
IF USELITERALS EQ 0
INVOKE RtlInitAnsiString, addr str1, addr s1
INVOKE RtlInitAnsiString, addr str2, addr s2
INVOKE RtlCompareString, addr str1, addr str2, TRUE
INVOKE printf, addr format, eax
ENDIF
INVOKE ExitProcess,0
main endp
end main
and here is disassembly:
1: .386
2: .model Flat, C
3:
4: DEFINE MACRO a:req
5: a = 1
6: ENDM
7:
8: UNDEF MACRO a:req
9: a = 0
10: ENDM
11:
12:
13: DEFINE USELITERALS
14: IF USELITERALS
15: OPTION LITERALS:ON ; Allow string literals use in INVOKE
16: printf PROTO :PTR, :PTR
17: ELSE
18: printf PROTO :PTR, :vararg
19: ENDIF
20:
21:
22: TRUE equ 1
23:
24: includelib \masm32\lib\ntdll.lib
25: RtlCompareString PROTO STDCALL :ptr,:ptr,:BYTE
26: RtlInitAnsiString PROTO STDCALL :ptr, :ptr
27:
28: includelib \masm32\lib\msvcrt.lib
29:
30: includelib \masm32\lib\kernel32.lib
31: ExitProcess proto STDCALL :dword
32:
33: _STRING struct
34: _Length word ?
35: _Maximumlength word ?
36: _Buffer dword ?
37: _STRING ends
38:
39: .data
40: format db 'result: %d',13,10,0
41: s1 db "someStr",0 ;
42: s2 db "anotherStr",0 ;
43:
44: .code
45:
46: main proc
009E107C 55 push ebp
009E107D 8B EC mov ebp,esp
009E107F 83 EC 10 sub esp,10h
47: LOCAL str1 : _STRING
48: LOCAL str2 : _STRING
49:
50: IF USELITERALS
51: INVOKE RtlInitAnsiString, addr str1, "someStr"
009E1082 68 20 50 9E 00 push 9E5020h
009E1087 8D 45 F8 lea eax,[str1]
009E108A 50 push eax
009E108B E8 DE FF FF FF call _RtlInitAnsiString@8 (09E106Eh)
52: INVOKE RtlInitAnsiString, addr str2, "anotherStr"
009E1090 68 28 50 9E 00 push 9E5028h
009E1095 8D 45 F0 lea eax,[str2]
009E1098 50 push eax
009E1099 E8 D0 FF FF FF call _RtlInitAnsiString@8 (09E106Eh)
53: INVOKE RtlCompareString, addr str1, addr str2, TRUE
009E109E 6A 01 push 1
009E10A0 8D 45 F0 lea eax,[str2]
009E10A3 50 push eax
009E10A4 8D 45 F8 lea eax,[str1]
009E10A7 50 push eax
009E10A8 E8 BB FF FF FF call _RtlCompareString@12 (09E1068h)
54: INVOKE printf, "result: %d", eax
009E10AD 50 push eax
009E10AE 68 3E 50 9E 00 push 9E503Eh
009E10B3 E8 BC FF FF FF call _printf (09E1074h)
009E10B8 83 C4 08 add esp,8
55: ENDIF
56: UNDEF USELITERALS
57: IF USELITERALS EQ 0
58: INVOKE RtlInitAnsiString, addr str1, addr s1
009E10BB 68 0D 50 9E 00 push 9E500Dh
009E10C0 8D 45 F8 lea eax,[str1]
009E10C3 50 push eax
009E10C4 E8 A5 FF FF FF call _RtlInitAnsiString@8 (09E106Eh)
59: INVOKE RtlInitAnsiString, addr str2, addr s2
009E10C9 68 15 50 9E 00 push 9E5015h
009E10CE 8D 45 F0 lea eax,[str2]
009E10D1 50 push eax
009E10D2 E8 97 FF FF FF call _RtlInitAnsiString@8 (09E106Eh)
60: INVOKE RtlCompareString, addr str1, addr str2, TRUE
009E10D7 6A 01 push 1
60: INVOKE RtlCompareString, addr str1, addr str2, TRUE
009E10D9 8D 45 F0 lea eax,[str2]
009E10DC 50 push eax
009E10DD 8D 45 F8 lea eax,[str1]
009E10E0 50 push eax
009E10E1 E8 82 FF FF FF call _RtlCompareString@12 (09E1068h)
61: INVOKE printf, addr format, eax
009E10E6 50 push eax
009E10E7 68 00 50 9E 00 push 9E5000h
009E10EC E8 83 FF FF FF call _printf (09E1074h)
009E10F1 83 C4 08 add esp,8
62: ENDIF
63:
64: INVOKE ExitProcess,0
009E10F4 6A 00 push 0
009E10F6 E8 83 0F 00 00 call _ExitProcess@4 (09E207Eh)