forked from dantmnf/NCSIOverride
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshim_nasm.asm
51 lines (44 loc) · 847 Bytes
/
shim_nasm.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
%ifidn __OUTPUT_FORMAT__, win64
bits 64
%define mangle(x) x
%macro declare 1
extern mangle(p%1)
section .text
global mangle(Shim%1)
mangle(Shim%1):
call shim_prepare2
jmp [rel mangle(p%1)]
%endmacro
section .text
shim_prepare2:
cmp dword [rel mangle(shim_prepared)], 0
jz _continue
ret
_continue:
push r9
push r8
push rdx
push rcx
call mangle(shim_prepare)
pop rcx
pop rdx
pop r8
pop r9
ret
%elifidn __OUTPUT_FORMAT__, win32
bits 32
%define mangle(x) _ %+ x
%macro declare 1
extern mangle(p%1)
section .text
global mangle(Shim%1)
mangle(Shim%1):
call shim_prepare
jmp [mangle(p%1)]
%endmacro
%endif
section .text
align 8
extern mangle(shim_prepare)
extern mangle(shim_prepared)
%include "shim_declare.inc"