64 bit System API
Posted: Sun Jul 12, 2020 1:02 pm
Hello,
I am working on a 64 bit system API dispatcher, but the function throws an invalid opcode when called. Here is the function
I have read through the ABI as well.
Thanks for your help,
nexos
I am working on a 64 bit system API dispatcher, but the function throws an invalid opcode when called. Here is the function
Code: Select all
VOID SchedApiDispatch(REGS* r)
{
if(r->rax > MAXSYSCALL)
{
r->rax = 0;
return;
}
VOID* location = syscalls[r->rax];
QWORD ret = 0;
asm volatile (" \
mov %1, %%rdi; \
mov %2, %%rsi; \
mov %3, %%rdx; \
mov %4, %%rcx; \
mov %5, %%r8; \
mov %6, %%r9; \
call *%7; \
add $48, %%esp; \
" : "=a" (ret) : "r" (r->rdi), "r" (r->rsi), "r" (r->rdx), "r" (r->rcx), "r" (r->r8), "r" (r->r9), "r" (location));
r->rax = ret;
}
Thanks for your help,
nexos