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
|
PUBLIC microprofile_tramp_enter
PUBLIC microprofile_tramp_leave
PUBLIC microprofile_tramp_code_begin
PUBLIC microprofile_tramp_code_end
PUBLIC microprofile_tramp_end
PUBLIC microprofile_tramp_exit
PUBLIC microprofile_tramp_intercept0
PUBLIC microprofile_tramp_enter_patch
;PUBLIC microprofile_tramp_get_rsp_loc
PUBLIC microprofile_tramp_arg0
;PUBLIC microprofile_tramp_arg1
PUBLIC microprofile_tramp_call_patch_pop
PUBLIC microprofile_tramp_call_patch_push
PUBLIC microprofile_tramp_trunk
.data
.code
;RCX, RDX, R8, R9, XMM0-XMM3, YMM0-YMM3, ZMM0-ZMM
;RAX, ST(0), XMM0, YMM0, ZMM0 RAX
microprofile_tramp_enter:
mov r11, [rsp]
push rcx
push rdx
push r8
push r9
;sub $88h, %rsp
sub rsp, 68h
movdqu [rsp + 050h], xmm3
movdqu [rsp + 040h], xmm2
movdqu [rsp + 030h], xmm1
movdqu [rsp + 020h], xmm0
mov rcx, r11
microprofile_tramp_call_patch_push:
mov rax, 0102030405060708h
call rax
test rax, rax
jz microprofile_tramp_fail ;if push fails, skip to call code, and dont patch return adress.
microprofile_tramp_enter_patch:
; PATCH 1 TRAMP EXIT
mov rax, 0102030405060708h ;patch to tramp_code_end
mov [rsp+088h], rax
microprofile_tramp_arg0:
mov rcx, 42
microprofile_tramp_intercept0:
;PATCH 2 INTERCEPT0
mov rax, 0102030405060708h
call rax
microprofile_tramp_fail:
movdqu xmm3, [rsp + 050h]
movdqu xmm2, [rsp + 040h]
movdqu xmm1, [rsp + 030h]
movdqu xmm0, [rsp + 020h]
add rsp, 68h
pop r9
pop r8
pop rdx
pop rcx
microprofile_tramp_code_begin:
;;insert code here
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
microprofile_tramp_code_end:
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
microprofile_tramp_exit:
mov rcx, 117
push rax
sub rsp, 30h
movdqu [rsp + 020h], xmm0
microprofile_tramp_leave:
;PATCH 3 INTERCEPT1
mov rax, 0102030405060708h
call rax ;jump to proxy
microprofile_tramp_call_patch_pop:
mov rax, 0102030405060708h
call rax
mov r11, rax
movdqu xmm0, [rsp + 020h]
add rsp, 30h
pop rax
jmp r11
int 3
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
int 3
microprofile_tramp_trunk: ;: #used for moved constants.
; todo: move it to the beginning so it can be aligned by default.
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
microprofile_tramp_end:
end
|