1 | ; $Id: VBoxREMWrapperA.asm 1 1970-01-01 00:00:00Z vboxsync $
|
---|
2 | ;; @file
|
---|
3 | ;
|
---|
4 | ; VBoxREM Wrapper, Assembly routines and wrapper Templates.
|
---|
5 | ;
|
---|
6 | ; InnoTek Systemberatung GmbH confidential
|
---|
7 | ;
|
---|
8 | ; Copyright (c) 2006 InnoTek Systemberatung GmbH
|
---|
9 | ;
|
---|
10 | ; Author: knut st. osmundsen <bird@innotek.de>
|
---|
11 | ;
|
---|
12 | ; All Rights Reserved
|
---|
13 | ;
|
---|
14 | ;
|
---|
15 |
|
---|
16 |
|
---|
17 |
|
---|
18 |
|
---|
19 | ;*******************************************************************************
|
---|
20 | ;* Header Files *
|
---|
21 | ;*******************************************************************************
|
---|
22 | %include "iprt/asmdefs.mac"
|
---|
23 |
|
---|
24 |
|
---|
25 |
|
---|
26 | BEGINCODE
|
---|
27 |
|
---|
28 | %ifdef __WIN64__
|
---|
29 |
|
---|
30 |
|
---|
31 | BEGINPROC WrapGCC2MSC0Int
|
---|
32 | jmp $+5+0deadbeefh
|
---|
33 | ENDPROC WrapGCC2MSC0Int
|
---|
34 |
|
---|
35 |
|
---|
36 | BEGINPROC WrapGCC2MSC1Int
|
---|
37 | push rbp
|
---|
38 | mov rbp, rsp
|
---|
39 | sub rsp, 10h
|
---|
40 |
|
---|
41 | mov rcx, rdi
|
---|
42 | call $+5+0deadbeefh
|
---|
43 |
|
---|
44 | leave
|
---|
45 | ret
|
---|
46 | ENDPROC WrapGCC2MSC1Int
|
---|
47 |
|
---|
48 |
|
---|
49 | BEGINPROC WrapGCC2MSC2Int
|
---|
50 | push rbp
|
---|
51 | mov rbp, rsp
|
---|
52 | sub rsp, 10h
|
---|
53 |
|
---|
54 | mov rdx, rsi
|
---|
55 | mov rcx, rdi
|
---|
56 | call $+5+0deadbeefh
|
---|
57 |
|
---|
58 | leave
|
---|
59 | ret
|
---|
60 | ENDPROC WrapGCC2MSC2Int
|
---|
61 |
|
---|
62 |
|
---|
63 | BEGINPROC WrapGCC2MSC3Int
|
---|
64 | push rbp
|
---|
65 | mov rbp, rsp
|
---|
66 | sub rsp, 20h
|
---|
67 |
|
---|
68 | mov r8, rdx
|
---|
69 | mov rdx, rsi
|
---|
70 | mov rcx, rdi
|
---|
71 | call $+5+0deadbeefh
|
---|
72 |
|
---|
73 | leave
|
---|
74 | ret
|
---|
75 | ENDPROC WrapGCC2MSC3Int
|
---|
76 |
|
---|
77 |
|
---|
78 | BEGINPROC WrapGCC2MSC4Int
|
---|
79 | push rbp
|
---|
80 | mov rbp, rsp
|
---|
81 | sub rsp, 20h
|
---|
82 |
|
---|
83 | mov r9, rcx
|
---|
84 | mov r8, rdx
|
---|
85 | mov rdx, rsi
|
---|
86 | mov rcx, rdi
|
---|
87 | call $+5+0deadbeefh
|
---|
88 |
|
---|
89 | leave
|
---|
90 | ret
|
---|
91 | ENDPROC WrapGCC2MSC4Int
|
---|
92 |
|
---|
93 |
|
---|
94 | BEGINPROC WrapGCC2MSC5Int
|
---|
95 | push rbp
|
---|
96 | mov rbp, rsp
|
---|
97 | sub rsp, 30h
|
---|
98 |
|
---|
99 | mov [rsp + 20h], r8
|
---|
100 | mov r9, rcx
|
---|
101 | mov r8, rdx
|
---|
102 | mov rdx, rsi
|
---|
103 | mov rcx, rdi
|
---|
104 | call $+5+0deadbeefh
|
---|
105 |
|
---|
106 | leave
|
---|
107 | ret
|
---|
108 | ENDPROC WrapGCC2MSC5Int
|
---|
109 |
|
---|
110 |
|
---|
111 | BEGINPROC WrapGCC2MSC6Int
|
---|
112 | push rbp
|
---|
113 | mov rbp, rsp
|
---|
114 | sub rsp, 30h
|
---|
115 |
|
---|
116 | mov [rsp + 28h], r9
|
---|
117 | mov [rsp + 20h], r8
|
---|
118 | mov r9, rcx
|
---|
119 | mov r8, rdx
|
---|
120 | mov rdx, rsi
|
---|
121 | mov rcx, rdi
|
---|
122 | call $+5+0deadbeefh
|
---|
123 |
|
---|
124 | leave
|
---|
125 | ret
|
---|
126 | ENDPROC WrapGCC2MSC6Int
|
---|
127 |
|
---|
128 |
|
---|
129 | BEGINPROC WrapGCC2MSC7Int
|
---|
130 | push rbp
|
---|
131 | mov rbp, rsp
|
---|
132 | sub rsp, 40h
|
---|
133 |
|
---|
134 | mov r11, [ebp + 10h]
|
---|
135 | mov [rsp + 30h], r11
|
---|
136 | mov [rsp + 28h], r9
|
---|
137 | mov [rsp + 20h], r8
|
---|
138 | mov r9, rcx
|
---|
139 | mov r8, rdx
|
---|
140 | mov rdx, rsi
|
---|
141 | mov rcx, rdi
|
---|
142 | call $+5+0deadbeefh
|
---|
143 |
|
---|
144 | leave
|
---|
145 | ret
|
---|
146 | ENDPROC WrapGCC2MSC7Int
|
---|
147 |
|
---|
148 |
|
---|
149 | BEGINPROC WrapGCC2MSC8Int
|
---|
150 | push rbp
|
---|
151 | mov rbp, rsp
|
---|
152 | sub rsp, 40h
|
---|
153 |
|
---|
154 | mov r10, [ebp + 18h]
|
---|
155 | mov [rsp + 38h], r10
|
---|
156 | mov r11, [ebp + 10h]
|
---|
157 | mov [rsp + 30h], r11
|
---|
158 | mov [rsp + 28h], r9
|
---|
159 | mov [rsp + 20h], r8
|
---|
160 | mov r9, rcx
|
---|
161 | mov r8, rdx
|
---|
162 | mov rdx, rsi
|
---|
163 | mov rcx, rdi
|
---|
164 | call $+5+0deadbeefh
|
---|
165 |
|
---|
166 | leave
|
---|
167 | ret
|
---|
168 | ENDPROC WrapGCC2MSC8Int
|
---|
169 |
|
---|
170 |
|
---|
171 | BEGINPROC WrapGCC2MSC9Int
|
---|
172 | push rbp
|
---|
173 | mov rbp, rsp
|
---|
174 | sub rsp, 50h
|
---|
175 |
|
---|
176 | mov rax, [ebp + 20h]
|
---|
177 | mov [rsp + 40h], rax
|
---|
178 | mov r10, [ebp + 18h]
|
---|
179 | mov [rsp + 38h], r10
|
---|
180 | mov r11, [ebp + 10h]
|
---|
181 | mov [rsp + 30h], r11
|
---|
182 | mov [rsp + 28h], r9
|
---|
183 | mov [rsp + 20h], r8
|
---|
184 | mov r9, rcx
|
---|
185 | mov r8, rdx
|
---|
186 | mov rdx, rsi
|
---|
187 | mov rcx, rdi
|
---|
188 | call $+5+0deadbeefh
|
---|
189 |
|
---|
190 | leave
|
---|
191 | ret
|
---|
192 | ENDPROC WrapGCC2MSC9Int
|
---|
193 |
|
---|
194 |
|
---|
195 | BEGINPROC WrapGCC2MSC10Int
|
---|
196 | push rbp
|
---|
197 | mov rbp, rsp
|
---|
198 | sub rsp, 50h
|
---|
199 |
|
---|
200 | mov r11, [ebp + 28h]
|
---|
201 | mov [rsp + 48h], r11
|
---|
202 | mov rax, [ebp + 20h]
|
---|
203 | mov [rsp + 40h], rax
|
---|
204 | mov r10, [ebp + 18h]
|
---|
205 | mov [rsp + 38h], r10
|
---|
206 | mov r11, [ebp + 10h]
|
---|
207 | mov [rsp + 30h], r11
|
---|
208 | mov [rsp + 28h], r9
|
---|
209 | mov [rsp + 20h], r8
|
---|
210 | mov r9, rcx
|
---|
211 | mov r8, rdx
|
---|
212 | mov rdx, rsi
|
---|
213 | mov rcx, rdi
|
---|
214 | call $+5+0deadbeefh
|
---|
215 |
|
---|
216 | leave
|
---|
217 | ret
|
---|
218 | ENDPROC WrapGCC2MSC10Int
|
---|
219 |
|
---|
220 |
|
---|
221 | BEGINPROC WrapGCC2MSC11Int
|
---|
222 | push rbp
|
---|
223 | mov rbp, rsp
|
---|
224 | sub rsp, 60h
|
---|
225 |
|
---|
226 | mov r10, [ebp + 30h]
|
---|
227 | mov [rsp + 50h], r10
|
---|
228 | mov r11, [ebp + 28h]
|
---|
229 | mov [rsp + 48h], r11
|
---|
230 | mov rax, [ebp + 20h]
|
---|
231 | mov [rsp + 40h], rax
|
---|
232 | mov r10, [ebp + 18h]
|
---|
233 | mov [rsp + 38h], r10
|
---|
234 | mov r11, [ebp + 10h]
|
---|
235 | mov [rsp + 30h], r11
|
---|
236 | mov [rsp + 28h], r9
|
---|
237 | mov [rsp + 20h], r8
|
---|
238 | mov r9, rcx
|
---|
239 | mov r8, rdx
|
---|
240 | mov rdx, rsi
|
---|
241 | mov rcx, rdi
|
---|
242 | call $+5+0deadbeefh
|
---|
243 |
|
---|
244 | leave
|
---|
245 | ret
|
---|
246 | ENDPROC WrapGCC2MSC11Int
|
---|
247 |
|
---|
248 |
|
---|
249 | BEGINPROC WrapGCC2MSC12Int
|
---|
250 | push rbp
|
---|
251 | mov rbp, rsp
|
---|
252 | sub rsp, 60h
|
---|
253 |
|
---|
254 | mov rax, [ebp + 28h]
|
---|
255 | mov [rsp + 48h], rax
|
---|
256 | mov r10, [ebp + 30h]
|
---|
257 | mov [rsp + 50h], r10
|
---|
258 | mov r11, [ebp + 28h]
|
---|
259 | mov [rsp + 48h], r11
|
---|
260 | mov rax, [ebp + 20h]
|
---|
261 | mov [rsp + 40h], rax
|
---|
262 | mov r10, [ebp + 18h]
|
---|
263 | mov [rsp + 38h], r10
|
---|
264 | mov r11, [ebp + 10h]
|
---|
265 | mov [rsp + 30h], r11
|
---|
266 | mov [rsp + 28h], r9
|
---|
267 | mov [rsp + 20h], r8
|
---|
268 | mov r9, rcx
|
---|
269 | mov r8, rdx
|
---|
270 | mov rdx, rsi
|
---|
271 | mov rcx, rdi
|
---|
272 | call $+5+0deadbeefh
|
---|
273 |
|
---|
274 | leave
|
---|
275 | ret
|
---|
276 | ENDPROC WrapGCC2MSC12Int
|
---|
277 |
|
---|
278 |
|
---|
279 |
|
---|
280 | BEGINPROC WrapGCC2MSCVariadictInt
|
---|
281 | %ifdef DEBUG
|
---|
282 | ; check that there are NO floting point arguments in XMM registers!
|
---|
283 | or rax, rax
|
---|
284 | jz .ok
|
---|
285 | int3
|
---|
286 | .ok:
|
---|
287 | %endif
|
---|
288 | sub rsp, 28h
|
---|
289 | mov r11, [rsp + 28h] ; r11 = return address.
|
---|
290 | mov [rsp + 28h], r9
|
---|
291 | mov [rsp + 20h], r8
|
---|
292 | mov r9, rcx
|
---|
293 | mov [rsp + 18h], r9 ; (*)
|
---|
294 | mov r8, rdx
|
---|
295 | mov [rsp + 14h], r8 ; (*)
|
---|
296 | mov rdx, rsi
|
---|
297 | mov [rsp + 8h], rdx ; (*)
|
---|
298 | mov rcx, rdi
|
---|
299 | mov [rsp], rcx ; (*)
|
---|
300 | mov rsi, r11 ; rsi is preserved by the callee.
|
---|
301 | call $+5+0deadbeefh
|
---|
302 | add rsp, 30h
|
---|
303 | jmp rsi
|
---|
304 | ; (*) unconditionally spill the registers, just in case '...' implies weird stuff on MSC. Check this out!
|
---|
305 | ENDPROC WrapGCC2MSCVariadictInt
|
---|
306 |
|
---|
307 |
|
---|
308 |
|
---|
309 | ;
|
---|
310 | ; The other way around:
|
---|
311 | ;
|
---|
312 |
|
---|
313 |
|
---|
314 | BEGINPROC WrapMSC2GCC0Int
|
---|
315 | push rbp
|
---|
316 | mov rbp, rsp
|
---|
317 | sub rsp, 10h
|
---|
318 | mov [ebp - 10h], rsi
|
---|
319 | mov [ebp - 18h], rdi
|
---|
320 |
|
---|
321 | call $+5+0deadbeefh
|
---|
322 |
|
---|
323 | mov rdi, [ebp - 18h]
|
---|
324 | mov rsi, [ebp - 10h]
|
---|
325 | leave
|
---|
326 | ret
|
---|
327 | ENDPROC WrapMSC2GCC0Int
|
---|
328 |
|
---|
329 |
|
---|
330 | BEGINPROC WrapMSC2GCC1Int
|
---|
331 | push rbp
|
---|
332 | mov rbp, rsp
|
---|
333 | sub rsp, 20h
|
---|
334 | mov [ebp - 10h], rsi
|
---|
335 | mov [ebp - 18h], rdi
|
---|
336 |
|
---|
337 | mov rdi, rcx
|
---|
338 | call $+5+0deadbeefh
|
---|
339 |
|
---|
340 | mov rdi, [ebp - 18h]
|
---|
341 | mov rsi, [ebp - 10h]
|
---|
342 | leave
|
---|
343 | ret
|
---|
344 | ENDPROC WrapMSC2GCC1Int
|
---|
345 |
|
---|
346 |
|
---|
347 | BEGINPROC WrapMSC2GCC2Int
|
---|
348 | push rbp
|
---|
349 | mov rbp, rsp
|
---|
350 | sub rsp, 20h
|
---|
351 | mov [ebp - 10h], rsi
|
---|
352 | mov [ebp - 18h], rdi
|
---|
353 |
|
---|
354 | mov rdi, rcx
|
---|
355 | mov rsi, rdx
|
---|
356 | call $+5+0deadbeefh
|
---|
357 |
|
---|
358 | mov rdi, [ebp - 18h]
|
---|
359 | mov rsi, [ebp - 10h]
|
---|
360 | leave
|
---|
361 | ret
|
---|
362 | ENDPROC WrapMSC2GCC2Int
|
---|
363 |
|
---|
364 |
|
---|
365 | BEGINPROC WrapMSC2GCC3Int
|
---|
366 | push rbp
|
---|
367 | mov rbp, rsp
|
---|
368 | sub rsp, 20h
|
---|
369 | mov [ebp - 10h], rsi
|
---|
370 | mov [ebp - 18h], rdi
|
---|
371 |
|
---|
372 | mov rdi, rcx
|
---|
373 | mov rsi, rdx
|
---|
374 | mov rdx, r8
|
---|
375 | call $+5+0deadbeefh
|
---|
376 |
|
---|
377 | mov rdi, [ebp - 18h]
|
---|
378 | mov rsi, [ebp - 10h]
|
---|
379 | leave
|
---|
380 | ret
|
---|
381 | ENDPROC WrapMSC2GCC3Int
|
---|
382 |
|
---|
383 |
|
---|
384 | BEGINPROC WrapMSC2GCC4Int
|
---|
385 | push rbp
|
---|
386 | mov rbp, rsp
|
---|
387 | sub rsp, 20h
|
---|
388 | mov [ebp - 10h], rsi
|
---|
389 | mov [ebp - 18h], rdi
|
---|
390 |
|
---|
391 | mov rdi, rcx
|
---|
392 | mov rsi, rdx
|
---|
393 | mov rdx, r8
|
---|
394 | mov rcx, r9
|
---|
395 | call $+5+0deadbeefh
|
---|
396 |
|
---|
397 | mov rdi, [ebp - 18h]
|
---|
398 | mov rsi, [ebp - 10h]
|
---|
399 | leave
|
---|
400 | ret
|
---|
401 | ENDPROC WrapMSC2GCC4Int
|
---|
402 |
|
---|
403 |
|
---|
404 | BEGINPROC WrapMSC2GCC5Int
|
---|
405 | push rbp
|
---|
406 | mov rbp, rsp
|
---|
407 | sub rsp, 20h
|
---|
408 | mov [ebp - 10h], rsi
|
---|
409 | mov [ebp - 18h], rdi
|
---|
410 |
|
---|
411 | mov rdi, rcx
|
---|
412 | mov rsi, rdx
|
---|
413 | mov rdx, r8
|
---|
414 | mov rcx, r9
|
---|
415 | mov r8, [ebp + 30h]
|
---|
416 | call $+5+0deadbeefh
|
---|
417 |
|
---|
418 | mov rdi, [ebp - 18h]
|
---|
419 | mov rsi, [ebp - 10h]
|
---|
420 | leave
|
---|
421 | ret
|
---|
422 | ENDPROC WrapMSC2GCC5Int
|
---|
423 |
|
---|
424 |
|
---|
425 | BEGINPROC WrapMSC2GCC6Int
|
---|
426 | push rbp
|
---|
427 | mov rbp, rsp
|
---|
428 | sub rsp, 20h
|
---|
429 | mov [ebp - 10h], rsi
|
---|
430 | mov [ebp - 18h], rdi
|
---|
431 |
|
---|
432 | mov rdi, rcx
|
---|
433 | mov rsi, rdx
|
---|
434 | mov rdx, r8
|
---|
435 | mov rcx, r9
|
---|
436 | mov r8, [ebp + 30h]
|
---|
437 | mov r9, [ebp + 38h]
|
---|
438 | call $+5+0deadbeefh
|
---|
439 |
|
---|
440 | mov rdi, [ebp - 18h]
|
---|
441 | mov rsi, [ebp - 10h]
|
---|
442 | leave
|
---|
443 | ret
|
---|
444 | ENDPROC WrapMSC2GCC6Int
|
---|
445 |
|
---|
446 |
|
---|
447 | BEGINPROC WrapMSC2GCC7Int
|
---|
448 | push rbp
|
---|
449 | mov rbp, rsp
|
---|
450 | sub rsp, 30h
|
---|
451 | mov [ebp - 10h], rsi
|
---|
452 | mov [ebp - 18h], rdi
|
---|
453 |
|
---|
454 | mov rdi, rcx
|
---|
455 | mov rsi, rdx
|
---|
456 | mov rdx, r8
|
---|
457 | mov rcx, r9
|
---|
458 | mov r8, [ebp + 30h]
|
---|
459 | mov r9, [ebp + 38h]
|
---|
460 | mov r10, [ebp + 40h]
|
---|
461 | mov [esp], r10
|
---|
462 | call $+5+0deadbeefh
|
---|
463 |
|
---|
464 | mov rdi, [ebp - 18h]
|
---|
465 | mov rsi, [ebp - 10h]
|
---|
466 | leave
|
---|
467 | ret
|
---|
468 | ENDPROC WrapMSC2GCC7Int
|
---|
469 |
|
---|
470 |
|
---|
471 | BEGINPROC WrapMSC2GCC8Int
|
---|
472 | push rbp
|
---|
473 | mov rbp, rsp
|
---|
474 | sub rsp, 30h
|
---|
475 | mov [ebp - 10h], rsi
|
---|
476 | mov [ebp - 18h], rdi
|
---|
477 |
|
---|
478 | mov rdi, rcx
|
---|
479 | mov rsi, rdx
|
---|
480 | mov rdx, r8
|
---|
481 | mov rcx, r9
|
---|
482 | mov r8, [ebp + 30h]
|
---|
483 | mov r9, [ebp + 38h]
|
---|
484 | mov r10, [ebp + 40h]
|
---|
485 | mov [esp], r10
|
---|
486 | mov r11, [ebp + 48h]
|
---|
487 | mov [esp + 8], r11
|
---|
488 | call $+5+0deadbeefh
|
---|
489 |
|
---|
490 | mov rdi, [ebp - 18h]
|
---|
491 | mov rsi, [ebp - 10h]
|
---|
492 | leave
|
---|
493 | ret
|
---|
494 | ENDPROC WrapMSC2GCC8Int
|
---|
495 |
|
---|
496 |
|
---|
497 | BEGINPROC WrapMSC2GCC9Int
|
---|
498 | push rbp
|
---|
499 | mov rbp, rsp
|
---|
500 | sub rsp, 40h
|
---|
501 | mov [ebp - 10h], rsi
|
---|
502 | mov [ebp - 18h], rdi
|
---|
503 |
|
---|
504 | mov rdi, rcx
|
---|
505 | mov rsi, rdx
|
---|
506 | mov rdx, r8
|
---|
507 | mov rcx, r9
|
---|
508 | mov r8, [ebp + 30h]
|
---|
509 | mov r9, [ebp + 38h]
|
---|
510 | mov r10, [ebp + 40h]
|
---|
511 | mov [esp], r10
|
---|
512 | mov r11, [ebp + 48h]
|
---|
513 | mov [esp + 8], r11
|
---|
514 | mov rax, [ebp + 50h]
|
---|
515 | mov [esp + 10h], rax
|
---|
516 | call $+5+0deadbeefh
|
---|
517 |
|
---|
518 | mov rdi, [ebp - 18h]
|
---|
519 | mov rsi, [ebp - 10h]
|
---|
520 | leave
|
---|
521 | ret
|
---|
522 | ENDPROC WrapMSC2GCC9Int
|
---|
523 |
|
---|
524 | %endif ; __WIN64__
|
---|