This repository has been archived by the owner on Sep 20, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 71
/
macro.inc
253 lines (217 loc) · 3.82 KB
/
macro.inc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
;; ==================================================================================================== ;;
GetBaseDelta macro reg
local @delta
call @delta
@delta:
pop reg
sub reg, @delta
endm
m2m macro arg1, arg2
push arg2
pop arg1
endm
jmpz macro reg, lbl
test reg, reg
jz lbl
endm
jmpnz macro reg, lbl
test reg, reg
jnz lbl
endm
jmps macro reg, lbl
test reg, reg
js lbl
endm
jmpns macro reg, lbl
test reg, reg
jns lbl
endm
jmple macro reg, lbl
test reg, reg
jle lbl
endm
;; ==================================================================================================== ;;
DEBUG macro arg1, arg2, arg3
ifdef DEBUGMODE
pushad
GetBaseDelta ebx
mov esi, arg2
invokx _RtlGetLastWin32Error[ebx]
mov edi, eax
invokx &Debug[ebx], arg1, esi, arg3
invokx _RtlSetLastWin32Error[ebx], edi
popad
endif
endm
;; ==================================================================================================== ;;
NOPS macro
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
endm
;; ==================================================================================================== ;;
;; Âûçûâàåòñÿ òàê:
;; vxinvoke õõõ[ebx],var1[ebx],1,&var1[ebx],17
;; ãäå õõõ - ïåðåìåííàÿ ñîäåðæàùàÿ àäðåñ âûçûâàåìîé ôóíêöèè
;; [ebx] - äåëüòà(èëè ëþáîé äðóãîé, èëè âîîáùå áåç ðåãèñòðà)
;; var1[ebx] -  êà÷åñòâå ïàðàìåòðà ïåðåäà¸òñÿ çíà÷åíèå ïåðåìåííîé var1
;; &var1[ebx] -  êà÷åñòâå ïàðàìåòðà ïåðåäà¸òñÿ àäðåñ ïåðåìåííîé var1
;;
;;
;;
;;
;; íåáîëüøîå îáíîâëåíèå
;; Òåïåððü ìîæíî äåëàòü òàê:
;; vxinvoke õõõ[ebx],'some text',"other text",1,&var1[ebx],17
;;
;; êîä ñãåíåðèðóåòñÿ òàêîé:
;; call label1
;; db 'some text'
;; db 0
;; label1:
;;
;; è òåïåðü ìîæíî ïåðåäàâàòü ïàðàìåòð â åàõ â ëþáîì ìåñòå. Êîáàíäû &var1[ebx]ãåíåðèðóþò òàêîé êîä:
;; push eax
;; lea eax,var1[ebx]
;; xchg [esp],eax
;; è ñëåäîâàòåëüíî íå ïîðòÿò åàõ
;;
;;
;;
;;
;; vxinvoke &xxx[ebx] - vizov polzovatelskoi proceduri
;;
;;
;; ==================================================================================================== ;;
vxpush macro arg1, useeax
local label1, label2
fSym substr <arg1>,1,1
ifidn fSym,<&>
var1 substr <arg1>,2
if useeax eq 0
lea eax, var1
push eax
else
push eax
lea eax, var1
xchg eax, [esp]
endif
elseifidn fSym,<'>
call label1
db arg1
db 0
label1:
elseifidn fSym,<">
call label2
flag1 = 0
forc char, <arg1>
ifdif <char>, <">
if flag1 eq 1
flag1 = 0
ifidn <char>,<r>
db 13
elseifidn <char>,<n>
db 10
else
db "\"
ifidn <char>,<\>
flag1 = 1
else
db "&char"
endif
endif
elseifidn <char>,<\> ;; trap the escape character and set the flag
flag1 = 1
else
db "&char"
endif
endif
endm
if flag1 eq 1
db "\"
endif
db 0
label2:
else
push arg1
endif
endm
invokx macro fName, arglist : vararg
useeax = 0
count = 0
for arg, <arglist>
count=count+1
ifidn <arg>, <eax>
useeax=useeax+1
endif
endm
Len sizestr <fName>
baseIn substr <fName>,Len-3,3
ifidn baseIn, <eax>
useeax=useeax+1
endif
while count
index = 0
for arg, <arglist>
index=index+1
if count eq index
vxpush arg, useeax
ifidn <arg>, <eax>
useeax=useeax-1
endif
endif
endm
count=count-1
endm
firstSymb substr <fName>,1,1
;; User proc call
ifidn firstSymb, <&>
funcName substr <fName>,2,Len-1
lea eax, funcName
call eax
;; Call proc addr in var
else
call fName
endif
endm