-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMyMacros.asm
155 lines (126 loc) · 2.15 KB
/
MyMacros.asm
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
literal MACRO quoted_text:VARARG
LOCAL local_text
.data
local_text db quoted_text,0
align 4
.code
EXITM <local_text>
ENDM
SADD MACRO quoted_text:VARARG
EXITM <ADDR literal(quoted_text)>
ENDM
szText MACRO Name, Text:VARARG
LOCAL lbl
jmp lbl
Name db Text,0
lbl:
ENDM
m2m MACRO M1, M2
push M2
pop M1
ENDM
FUNC MACRO parameters:VARARG
invoke parameters
EXITM <eax>
ENDM
return MACRO arg
mov eax, arg
ret
ENDM
RGB MACRO red, green, blue
xor eax, eax
mov ah, blue ; blue
mov al, green ; green
rol eax, 8
mov al, red ; red
ENDM
chr$ MACRO any_text:VARARG
LOCAL txtname
.data
txtname db any_text,0
.code
EXITM <OFFSET txtname>
ENDM
dsText MACRO Name, Text:VARARG
.data
Name db Text,0
align 4
.code
ENDM
FF MACRO dta,dtb,dtc,dtd,x,s,t ; a = b + ((a + F(b,c,d) + x + t) << s )
mov eax,dtb
mov ebx,dtc
mov ecx,dtd
; F(x,y,z) = (x and y) or ((not x) and z)
and ebx,eax
not eax
and eax,ecx
or eax,ebx
add eax,dta
add eax,x
add eax,t
mov cl,s
rol eax,cl
add eax,dtb
mov dta,eax
ENDM
GG MACRO dta,dtb,dtc,dtd,x,s,t ; a = b + ((a + G(b,c,d) + x + t) << s)
mov eax,dtb
mov ebx,dtc
mov ecx,dtd
; G(x,y,z) = (x and z) or (y and (not z))
and eax,ecx
not ecx
and ecx,ebx
or eax,ecx
add eax,dta
add eax,x
add eax,t
mov cl,s
rol eax,cl
add eax,dtb
mov dta,eax
ENDM
HH MACRO dta,dtb,dtc,dtd,x,s,t ; a = b + ((a + H(b,c,d) + x + t) << s)
mov eax,dtb
mov ebx,dtc
mov ecx,dtd
; H(x,y,z) = x xor y xor z
xor eax,ebx
xor eax,ecx
add eax,dta
add eax,x
add eax,t
mov cl,s
rol eax,cl
add eax,dtb
mov dta,eax
ENDM
II MACRO dta,dtb,dtc,dtd,x,s,t ; a = b + ((a + I(b,c,d) + x + t) << s)
mov eax,dtb
mov ebx,dtc
mov ecx,dtd
; I(x,y,z) = y xor (x or (not z))
not ecx
or eax,ecx
xor eax,ebx
add eax,dta
add eax,x
add eax,t
mov cl,s
rol eax,cl
add eax,dtb
mov dta,eax
ENDM
AllowSingleInstance MACRO lpTitle
invoke FindWindow,NULL,lpTitle
cmp eax, 0
je @F
push eax
invoke ShowWindow,eax,SW_RESTORE
pop eax
invoke SetForegroundWindow,eax
mov eax, 0
ret
@@:
ENDM