Completed AMD64 compatibility
This commit is contained in:
parent
583b67dbb1
commit
0086b58f39
|
@ -19,11 +19,7 @@ global amxx_DynaInit, _amxx_DynaInit
|
||||||
;void amxx_DynaInit(void *ptr);
|
;void amxx_DynaInit(void *ptr);
|
||||||
amxx_DynaInit:
|
amxx_DynaInit:
|
||||||
_amxx_DynaInit:
|
_amxx_DynaInit:
|
||||||
mov rax, rdi ;get pointer, first param is in rdi
|
mov [GLOBAL_GATE wrt rip], rdi
|
||||||
lea rdi, [GLOBAL_GATE wrt rip]
|
|
||||||
mov [rdi], rax ;store
|
|
||||||
|
|
||||||
mov rax, 1
|
|
||||||
ret
|
ret
|
||||||
|
|
||||||
;;Assembles the gateway function
|
;;Assembles the gateway function
|
||||||
|
@ -45,10 +41,14 @@ _amxx_DynaMake:
|
||||||
pop rdi ;get buffer as destination
|
pop rdi ;get buffer as destination
|
||||||
pop rax ;get id
|
pop rax ;get id
|
||||||
;align us to mov rsi, 1234... - on x86-64 this is 2 bytes after the differential
|
;align us to mov rsi, 1234... - on x86-64 this is 2 bytes after the differential
|
||||||
add rdi, (_amxx_DynaMoveOffset-_amxx_DynaFuncStart) + 2
|
add rdi, (_amxx_DynaFuncStart.move-_amxx_DynaFuncStart) + 2
|
||||||
mov [rdi], qword rax
|
mov [rdi], qword rax
|
||||||
|
;align rdi to the call
|
||||||
|
add rdi, (_amxx_DynaFuncStart.call-_amxx_DynaFuncStart.move)
|
||||||
|
mov rax, qword [GLOBAL_GATE wrt rip]
|
||||||
|
;copy the real address
|
||||||
|
mov [rdi], rax
|
||||||
|
|
||||||
mov rax, 1
|
|
||||||
ret
|
ret
|
||||||
|
|
||||||
;;The gateway function we will re-assemble
|
;;The gateway function we will re-assemble
|
||||||
|
@ -66,9 +66,11 @@ _amxx_DynaFuncStart:
|
||||||
mov rdx, rsi ;move 2nd param to 3rd
|
mov rdx, rsi ;move 2nd param to 3rd
|
||||||
mov rsi, rdi ;move 1st param to 2nd
|
mov rsi, rdi ;move 1st param to 2nd
|
||||||
;this old trick, we'll move in the real pointer in a bit.
|
;this old trick, we'll move in the real pointer in a bit.
|
||||||
_amxx_DynaMoveOffset:
|
.move:
|
||||||
mov rsi, qword 1234567812345678h
|
mov rdi, qword 1234567812345678h
|
||||||
call [GLOBAL_GATE wrt rip] ;pass through teh global gateway.
|
.call:
|
||||||
|
mov rcx, qword 1234567812345678h
|
||||||
|
call rcx
|
||||||
|
|
||||||
pop rbp
|
pop rbp
|
||||||
ret
|
ret
|
||||||
|
@ -83,5 +85,7 @@ _amxx_DynaCodesize:
|
||||||
mov rax, _amxx_DynaFuncEnd - _amxx_DynaFuncStart
|
mov rax, _amxx_DynaFuncEnd - _amxx_DynaFuncStart
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
section .data
|
||||||
|
|
||||||
GLOBAL_GATE DQ 0
|
GLOBAL_GATE DQ 0
|
||||||
|
|
||||||
|
|
|
@ -334,7 +334,7 @@ static cell AMX_NATIVE_CALL register_native(AMX *amx, cell *params)
|
||||||
pNative->pfn = new char[size + 10];
|
pNative->pfn = new char[size + 10];
|
||||||
VirtualProtect(pNative->pfn, size+10, PAGE_EXECUTE_READWRITE, &temp);
|
VirtualProtect(pNative->pfn, size+10, PAGE_EXECUTE_READWRITE, &temp);
|
||||||
#else
|
#else
|
||||||
pNative->pfn = (char *)memalign(sysconf(_SC_PAGESIZE), amx->code_size);
|
pNative->pfn = (char *)memalign(sysconf(_SC_PAGESIZE), size+10);
|
||||||
mprotect((void *)pNative->pfn, size+10, PROT_READ|PROT_WRITE|PROT_EXEC);
|
mprotect((void *)pNative->pfn, size+10, PROT_READ|PROT_WRITE|PROT_EXEC);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user