📄 linux_syscall_support.h
字号:
int, b, int, p) LSS_INLINE _syscall3(int, setresgid, gid_t, r, gid_t, e, gid_t, s) LSS_INLINE _syscall3(int, setresuid, uid_t, r, uid_t, e, uid_t, s) LSS_INLINE _syscall2(int, setrlimit, int, r, const struct rlimit*, l) LSS_INLINE _syscall2(int, sigaltstack, const stack_t*, s, const stack_t*, o) LSS_INLINE _syscall2(int, stat, const char*, f, struct stat*, b) LSS_INLINE _syscall3(ssize_t, write, int, f, const void *, b, size_t, c) LSS_INLINE _syscall3(ssize_t, writev, int, f, const struct iovec *, v, size_t, c) #if defined(__x86_64__) LSS_INLINE _syscall6(void*, mmap, void*, s, size_t, l, int, p, int, f, int, d, __off64_t, o) LSS_INLINE _syscall4(int, newfstatat, int, d, const char *, p, struct stat *, b, int, f) LSS_INLINE _syscall3(int, recvmsg, int, s, struct msghdr*, m, int, f) LSS_INLINE _syscall3(int, sendmsg, int, s, const struct msghdr*, m, int, f) LSS_INLINE _syscall6(int, sendto, int, s, const void*, m, size_t, l, int, f, const struct sockaddr*, a, int, t) LSS_INLINE _syscall2(int, shutdown, int, s, int, h) LSS_INLINE _syscall4(int, rt_sigaction, int, s, const struct sigaction*, a, struct sigaction*, o, int, c) LSS_INLINE _syscall2(int, rt_sigpending, sigset_t*, s, int, c) LSS_INLINE _syscall4(int, rt_sigprocmask, int, h, const sigset_t*, s, sigset_t*, o, int, c); LSS_INLINE _syscall3(int, socket, int, d, int, t, int, p) LSS_INLINE _syscall4(int, socketpair, int, d, int, t, int, p, int*, s) LSS_INLINE int LSS_NAME(setfsgid32)(gid_t gid) { return LSS_NAME(setfsgid)(gid); } LSS_INLINE int LSS_NAME(setfsuid32)(uid_t uid) { return LSS_NAME(setfsuid)(uid); } LSS_INLINE int LSS_NAME(setresgid32)(gid_t rgid, gid_t egid, gid_t sgid) { return LSS_NAME(setresgid)(rgid, egid, sgid); } LSS_INLINE int LSS_NAME(setresuid32)(uid_t ruid, uid_t euid, uid_t suid) { return LSS_NAME(setresuid)(ruid, euid, suid); } LSS_INLINE int LSS_NAME(sigaction)(int signum, const struct sigaction *act, struct sigaction *oldact) { return LSS_NAME(rt_sigaction)(signum, act, oldact, (_NSIG+6)/8); } LSS_INLINE int LSS_NAME(sigpending)(sigset_t *set) { return LSS_NAME(rt_sigpending)(set, (_NSIG+6)/8); } LSS_INLINE int LSS_NAME(sigprocmask)(int how, const sigset_t *set, sigset_t *oldset) { return LSS_NAME(rt_sigprocmask)(how, set, oldset, (_NSIG+6)/8); } #endif #if defined(__x86_64__) || defined(__ARM_ARCH_3__) LSS_INLINE _syscall4(pid_t, wait4, pid_t, p, int*, s, int, o, struct rusage*, r) LSS_INLINE pid_t LSS_NAME(waitpid)(pid_t pid, int *status, int options){ return LSS_NAME(wait4)(pid, status, options, 0); } #endif #if defined(__i386__) || defined(__x86_64__) LSS_INLINE _syscall4(int, openat, int, d, const char *, p, int, f, int, m) LSS_INLINE _syscall3(int, unlinkat, int, d, const char *, p, int, f) #endif #if defined(__i386__) || defined(__ARM_ARCH_3__) #define __NR__setfsgid32 __NR_setfsgid32 #define __NR__setfsuid32 __NR_setfsuid32 #define __NR__setresgid32 __NR_setresgid32 #define __NR__setresuid32 __NR_setresuid32 #define __NR__socketcall __NR_socketcall LSS_INLINE _syscall5(int, _llseek, uint, fd, ulong, hi, ulong, lo, loff_t *, res, uint, wh) LSS_INLINE _syscall2(int, ugetrlimit, int, r,struct rlimit*,l) LSS_INLINE _syscall1(void*, mmap, void*, a) LSS_INLINE _syscall6(void*, mmap2, void*, s, size_t, l, int, p, int, f, int, d, __off64_t, o) LSS_INLINE _syscall1(int, _setfsgid32, gid_t, f) LSS_INLINE _syscall1(int, _setfsuid32, uid_t, f) LSS_INLINE _syscall3(int, _setresgid32, gid_t, r, gid_t, e, gid_t, s) LSS_INLINE _syscall3(int, _setresuid32, uid_t, r, uid_t, e, uid_t, s) LSS_INLINE _syscall3(int, sigaction, int, s, const struct sigaction*, a, struct sigaction*, o) LSS_INLINE _syscall1(int, sigpending, sigset_t*, s) LSS_INLINE _syscall3(int, sigprocmask, int, h, const sigset_t*, s, sigset_t*, o) LSS_INLINE _syscall2(int, _socketcall, int, c, va_list, a) LSS_INLINE int LSS_NAME(setfsgid32)(gid_t gid) { int rc; if ((rc = LSS_NAME(_setfsgid32)(gid)) < 0 && LSS_ERRNO == ENOSYS) { if ((unsigned int)gid & ~0xFFFFu) { rc = EINVAL; } else { rc = LSS_NAME(setfsgid)(gid); } } return rc; } LSS_INLINE int LSS_NAME(setfsuid32)(uid_t uid) { int rc; if ((rc = LSS_NAME(_setfsuid32)(uid)) < 0 && LSS_ERRNO == ENOSYS) { if ((unsigned int)uid & ~0xFFFFu) { rc = EINVAL; } else { rc = LSS_NAME(setfsuid)(uid); } } return rc; } LSS_INLINE int LSS_NAME(setresgid32)(gid_t rgid, gid_t egid, gid_t sgid) { int rc; if ((rc = LSS_NAME(_setresgid32)(rgid, egid, sgid)) < 0 && LSS_ERRNO == ENOSYS) { if ((unsigned int)rgid & ~0xFFFFu || (unsigned int)egid & ~0xFFFFu || (unsigned int)sgid & ~0xFFFFu) { rc = EINVAL; } else { rc = LSS_NAME(setresgid)(rgid, egid, sgid); } } return rc; } LSS_INLINE int LSS_NAME(setresuid32)(uid_t ruid, uid_t euid, uid_t suid) { int rc; if ((rc = LSS_NAME(_setresuid32)(ruid, euid, suid)) < 0 && LSS_ERRNO == ENOSYS) { if ((unsigned int)ruid & ~0xFFFFu || (unsigned int)euid & ~0xFFFFu || (unsigned int)suid & ~0xFFFFu) { rc = EINVAL; } else { rc = LSS_NAME(setresuid)(ruid, euid, suid); } } return rc; } LSS_INLINE int LSS_NAME(socketcall)(int op, ...) { int rc; va_list ap; va_start(ap, op); rc = LSS_NAME(_socketcall)(op, ap); va_end(ap); return rc; } LSS_INLINE ssize_t LSS_NAME(recvmsg)(int s,struct msghdr*msg,int flags){ return (ssize_t)LSS_NAME(socketcall)(17, s, msg, flags); } LSS_INLINE ssize_t LSS_NAME(sendmsg)(int s, const struct msghdr *msg, int flags) { return (ssize_t)LSS_NAME(socketcall)(16, s, msg, flags); } LSS_INLINE ssize_t LSS_NAME(sendto)(int s, const void *buf, size_t len, int flags, const struct sockaddr*to, unsigned int tolen) { return (ssize_t)LSS_NAME(socketcall)(11, s, buf, len, flags, to, tolen); } LSS_INLINE int LSS_NAME(shutdown)(int s, int how) { return LSS_NAME(socketcall)(13, s, how); } LSS_INLINE int LSS_NAME(socket)(int domain, int type, int protocol) { return LSS_NAME(socketcall)(1, domain, type, protocol); } LSS_INLINE int LSS_NAME(socketpair)(int d, int type, int protocol, int sv[2]) { return LSS_NAME(socketcall)(8, d, type, protocol, sv); } #endif #if defined(__i386__) LSS_INLINE _syscall4(int, fstatat64, int, d, const char *, p, struct stat64 *, b, int, f) LSS_INLINE _syscall3(pid_t, waitpid, pid_t, p, int*, s, int, o) #endif LSS_INLINE int LSS_NAME(execv)(const char *path, const char * const argv[]) { extern char **environ; return LSS_NAME(execve)(path, argv, (const char * const *)environ); } LSS_INLINE pid_t LSS_NAME(gettid)() { pid_t tid = LSS_NAME(_gettid)(); if (tid != -1) { return tid; } return LSS_NAME(getpid)(); } LSS_INLINE int LSS_NAME(ptrace_detach)(pid_t pid) { /* PTRACE_DETACH can sometimes forget to wake up the tracee and it * then sends job control signals to the real parent, rather than to * the tracer. We reduce the risk of this happening by starting a * whole new time slice, and then quickly sending a SIGCONT signal * right after detaching from the tracee. */ int rc, err; LSS_NAME(sched_yield)(); rc = LSS_NAME(ptrace)(PTRACE_DETACH, pid, (void *)0, (void *)0); err = LSS_ERRNO; LSS_NAME(kill)(pid, SIGCONT); LSS_ERRNO = err; return rc; } LSS_INLINE int LSS_NAME(raise)(int sig) { return LSS_NAME(kill)(LSS_NAME(getpid)(), sig); } LSS_INLINE int LSS_NAME(setpgrp)() { return LSS_NAME(setpgid)(0, 0); } LSS_INLINE int LSS_NAME(sysconf)(int name) { extern int __getpagesize(void); switch (name) { case _SC_OPEN_MAX: { unsigned long limit[2]; return LSS_NAME(getrlimit)(RLIMIT_NOFILE, (struct rlimit *)limit)<0 ? 8192 : limit[0]; } case _SC_PAGESIZE: return __getpagesize(); default: errno = ENOSYS; return -1; } }#endif#if defined(__cplusplus) && !defined(SYS_CPLUSPLUS)}#endif#endif#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -