-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwin64wx.inc
204 lines (187 loc) · 4.2 KB
/
win64wx.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
; Extended Win64 programming headers (WideChar)
include 'win64w.inc'
include 'macro/if.inc'
macro allow_nesting
{ macro invoke proc,[arg]
\{ \common fastcall [proc],arg \}
macro fastcall proc,[arg]
\{ \common \local list,counter,flags,outer_frame,nested_frame,..close_nest
match =current@frame,current@frame \\{
frame
define outer_frame \\}
define counter
define list
flags = 0
\forward \local param,nested,isfloat,..next
match any,counter \\{ list equ list, \\}
counter equ counter+1
define param arg
define nested
isfloat = 0
match =invoke statement,param \\{
nested equ param
define param \\}
match =fastcall statement,param \\{
nested equ param
define param \\}
match =float =invoke statement,param \\{
define nested invoke statement
define param
isfloat = 1 \\}
match =float =fastcall statement,param \\{
define nested fastcall statement
define param
isfloat = 1 \\}
match statement,nested \\{
match =nested_frame,nested_frame \\\{
frame
define nested_frame \\\}
allow_nesting
statement
purge invoke_fastcall
if counter > 4
if isfloat
movq [rsp+size@frame+(counter-1)*8],xmm0
else
mov [rsp+size@frame+(counter-1)*8],rax
end if
else
flags = flags or 1 shl (counter-1)
if isfloat
flags = flags or 1 shl (4+counter-1)
end if
if ..close_nest > ..next
if float
movq [rsp+size@frame+(counter-1)*8],xmm0
else
mov [rsp+size@frame+(counter-1)*8],rax
end if
else
flags = flags or 1 shl (8+counter-1)
end if
end if
..next: \\}
list equ list <param>
\common ..close_nest:
match ,nested_frame \\{ endf \\}
if flags and 1
if flags and 1 shl 4
if ~ flags and 1 shl 8
movq xmm0,[rsp]
end if
else
if flags and 1 shl 8
mov rcx,rax
else
mov rcx,[rsp]
end if
end if
end if
if flags and 1 shl 1
if flags and 1 shl (4+1)
if flags and 1 shl (8+1)
movq xmm1,xmm0
else
movq xmm1,[rsp+8]
end if
else
if flags and 1 shl (8+1)
mov rdx,rax
else
mov rdx,[rsp+8]
end if
end if
end if
if flags and 1 shl 2
if flags and 1 shl (4+2)
if flags and 1 shl (8+2)
movq xmm2,xmm0
else
movq xmm2,[rsp+2*8]
end if
else
if flags and 1 shl (8+2)
mov r8,rax
else
mov r8,[rsp+2*8]
end if
end if
end if
if flags and 1 shl 3
if flags and 1 shl (4+3)
if flags and 1 shl (8+3)
movq xmm3,xmm0
else
movq xmm3,[rsp+3*8]
end if
else
if flags and 1 shl (8+3)
mov r9,rax
else
mov r9,[rsp+3*8]
end if
end if
end if
match args,list \\{ fastcall proc,args \\}
match ,list \\{ fastcall proc \\}
match ,outer_frame \\{ endf \\} \} }
allow_nesting
macro import lib,[functions]
{ common macro import_#lib \{ import lib,functions \} }
macro api [functions]
{ common macro all_api \{ all_api
api functions \} }
macro all_api {}
include 'api/kernel32.inc'
include 'api/user32.inc'
include 'api/gdi32.inc'
include 'api/advapi32.inc'
include 'api/comctl32.inc'
include 'api/comdlg32.inc'
include 'api/shell32.inc'
include 'api/wsock32.inc'
purge import,api
macro .data { section '.data' data readable writeable }
macro .code {
section '.text' code readable executable
entry $
sub rsp,8
local main,code
entry equ main
if main <> code
jmp main
end if
code: }
macro .end value
{
label entry at value
section '.idata' import data readable writeable
library kernel32,'KERNEL32.DLL',\
user32,'USER32.DLL',\
gdi32,'GDI32.DLL',\
advapi32,'ADVAPI32.DLL',\
comctl32,'COMCTL32.DLL',\
comdlg32,'COMDLG32.DLL',\
shell32,'SHELL32.DLL',\
wsock32,'WSOCK32.DLL'
import_kernel32
import_user32
import_gdi32
import_advapi32
import_comctl32
import_comdlg32
import_shell32
import_wsock32
all_api
}
virtual at 0
inc ax
if $=1
detected_16bit = 1
else
detected_16bit = 0
end if
end virtual
if detected_16bit
format PE64 GUI 5.0
end if