Skip to content

Instantly share code, notes, and snippets.

@Unam3dd
Created May 30, 2023 16:39
Show Gist options
  • Save Unam3dd/60d6c1692e502f42a9abda6c8245988e to your computer and use it in GitHub Desktop.
Save Unam3dd/60d6c1692e502f42a9abda6c8245988e to your computer and use it in GitHub Desktop.
Syscall Template assembly x86
.intel_syntax noprefix
.global vs_syscall
.section .text
vs_syscall:
endbr64
mov rax, rdi
mov rdi, rsi
mov rsi, rdx
mov rdx, rcx
mov r10, r8
mov r8, r9
mov r9, qword [rsp+0x8]
syscall
cmp rax, 0xfffffffffffff001
jae .L_ret_errno
ret
.L_ret_errno:
neg eax
mov ebx, eax
call __errno_location
mov dword ptr [rax], ebx
xor ebx, eax
xor eax, ebx
xor ebx, eax
or rax, 0xffffffffffffffff
ret
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment