use super::syscalls::SysNo;
#[cfg(feature = "syscallobf")]
use const_random::const_random;
use core::arch::asm;
#[cfg(not(feature = "syscallobf"))]
#[inline(always)]
pub unsafe fn syscall1(n: SysNo, arg1: usize) -> usize {
let mut ret: usize;
asm!(
"int $$0x80",
inlateout("eax") n as usize => ret,
in("ebx") arg1,
options(nostack, preserves_flags)
);
ret
}
#[cfg(not(feature = "syscallobf"))]
#[inline(always)]
pub unsafe fn syscall4(n: SysNo, arg1: usize, arg2: usize, arg3: usize, arg4: usize) -> usize {
let mut ret: usize;
asm!(
"xchg esi, {arg4}",
"int $$0x80",
"xchg esi, {arg4}",
arg4 = in(reg) arg4,
inlateout("eax") n as usize => ret,
in("ebx") arg1,
in("ecx") arg2,
in("edx") arg3,
options(nostack, preserves_flags)
);
ret
}
#[cfg(feature = "syscallobf")]
#[inline(always)]
pub unsafe fn syscall1(n: SysNo, arg1: usize) -> usize {
let mut ret: usize;
let _key: usize = const_random!(usize);
asm!(
"int $$0x80",
inlateout("eax") n as usize => ret,
in("ebx") arg1,
options(nostack, preserves_flags)
);
ret
}
#[cfg(feature = "syscallobf")]
#[inline(always)]
pub unsafe fn syscall4(n: SysNo, arg1: usize, arg2: usize, arg3: usize, arg4: usize) -> usize {
let mut ret: usize;
let _key: usize = const_random!(usize);
asm!(
"xchg esi, {arg4}",
"int $$0x80",
"xchg esi, {arg4}",
arg4 = in(reg) arg4,
inlateout("eax") n as usize => ret,
in("ebx") arg1,
in("ecx") arg2,
in("edx") arg3,
options(nostack, preserves_flags)
);
ret
}