-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathx64Def.asm
85 lines (66 loc) · 1.22 KB
/
x64Def.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
;//
;// Created by Anonymous275 on 9/9/2021.
;//
;External C functions used by _penter and _pexit
extern FuncEntry:Proc
extern FuncExit:Proc
.code
_penter proc
; Store the volatile registers
push r11
push r10
push r9
push r8
push rax
push rdx
push rcx
; reserve space for 4 registers [ rcx,rdx,r8 and r9 ] 32 bytes
sub rsp,20h
; Get the return address of the function
mov rcx,rsp
mov rcx,qword ptr[rcx+58h]
sub rcx,5
;call the function to get the name of the callee and caller
call FuncEntry
;Release the space reserved for the registersk by adding 32 bytes
add rsp,20h
;Restore the registers back by poping out
pop rcx
pop rdx
pop rax
pop r8
pop r9
pop r10
pop r11
;return
ret
_penter endp
_pexit proc
; Store the volatile registers
push r11
push r10
push r9
push r8
push rax
push rdx
push rcx
; reserve space for 4 registers [ rcx,rdx,r8 and r9 ] 32 bytes
sub rsp,20h
; Get the return address of the function
mov rcx,rsp
mov rcx,qword ptr[rcx+58h]
call FuncExit
;Release the space reserved for the registersk by adding 32 bytes
add rsp,20h
;Restore the registers back by poping out
pop rcx
pop rdx
pop rax
pop r8
pop r9
pop r10
pop r11
;return
ret
_pexit endp
end