• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #include "syscall_hooks.h"
2 
3 #define __SYSCALL_LL_E(x) (x)
4 #define __SYSCALL_LL_O(x) (x)
5 
6 #define __asm_syscall(...) do { \
7 	__asm__ __volatile__ ( "svc 0" \
8 	: "=r"(x0) : __VA_ARGS__ : "memory", "cc"); \
9 	return x0; \
10 	} while (0)
11 
__syscall0(long n)12 static inline long __syscall0(long n)
13 {
14 	if (is_syscall_hooked(n)) {
15 		return __syscall_hooks_entry0(n);
16 	}
17 	register long x8 __asm__("x8") = n;
18 	register long x0 __asm__("x0");
19 	__asm_syscall("r"(x8));
20 }
21 
__syscall1(long n,long a)22 static inline long __syscall1(long n, long a)
23 {
24 	if (is_syscall_hooked(n)) {
25 		return __syscall_hooks_entry1(n, a);
26 	}
27 	register long x8 __asm__("x8") = n;
28 	register long x0 __asm__("x0") = a;
29 	__asm_syscall("r"(x8), "0"(x0));
30 }
31 
__syscall2(long n,long a,long b)32 static inline long __syscall2(long n, long a, long b)
33 {
34 	if (is_syscall_hooked(n)) {
35 		return __syscall_hooks_entry2(n, a, b);
36 	}
37 	register long x8 __asm__("x8") = n;
38 	register long x0 __asm__("x0") = a;
39 	register long x1 __asm__("x1") = b;
40 	__asm_syscall("r"(x8), "0"(x0), "r"(x1));
41 }
42 
__syscall3(long n,long a,long b,long c)43 static inline long __syscall3(long n, long a, long b, long c)
44 {
45 	if (is_syscall_hooked(n)) {
46 		return __syscall_hooks_entry3(n, a, b, c);
47 	}
48 	register long x8 __asm__("x8") = n;
49 	register long x0 __asm__("x0") = a;
50 	register long x1 __asm__("x1") = b;
51 	register long x2 __asm__("x2") = c;
52 	__asm_syscall("r"(x8), "0"(x0), "r"(x1), "r"(x2));
53 }
54 
__syscall4(long n,long a,long b,long c,long d)55 static inline long __syscall4(long n, long a, long b, long c, long d)
56 {
57 	if (is_syscall_hooked(n)) {
58 		return __syscall_hooks_entry4(n, a, b, c, d);
59 	}
60 	register long x8 __asm__("x8") = n;
61 	register long x0 __asm__("x0") = a;
62 	register long x1 __asm__("x1") = b;
63 	register long x2 __asm__("x2") = c;
64 	register long x3 __asm__("x3") = d;
65 	__asm_syscall("r"(x8), "0"(x0), "r"(x1), "r"(x2), "r"(x3));
66 }
67 
__syscall5(long n,long a,long b,long c,long d,long e)68 static inline long __syscall5(long n, long a, long b, long c, long d, long e)
69 {
70 	if (is_syscall_hooked(n)) {
71 		return __syscall_hooks_entry5(n, a, b, c, d, e);
72 	}
73 	register long x8 __asm__("x8") = n;
74 	register long x0 __asm__("x0") = a;
75 	register long x1 __asm__("x1") = b;
76 	register long x2 __asm__("x2") = c;
77 	register long x3 __asm__("x3") = d;
78 	register long x4 __asm__("x4") = e;
79 	__asm_syscall("r"(x8), "0"(x0), "r"(x1), "r"(x2), "r"(x3), "r"(x4));
80 }
81 
__syscall6(long n,long a,long b,long c,long d,long e,long f)82 static inline long __syscall6(long n, long a, long b, long c, long d, long e, long f)
83 {
84 	if (is_syscall_hooked(n)) {
85 		return __syscall_hooks_entry6(n, a, b, c, d, e, f);
86 	}
87 	register long x8 __asm__("x8") = n;
88 	register long x0 __asm__("x0") = a;
89 	register long x1 __asm__("x1") = b;
90 	register long x2 __asm__("x2") = c;
91 	register long x3 __asm__("x3") = d;
92 	register long x4 __asm__("x4") = e;
93 	register long x5 __asm__("x5") = f;
94 	__asm_syscall("r"(x8), "0"(x0), "r"(x1), "r"(x2), "r"(x3), "r"(x4), "r"(x5));
95 }
96 
97 #define VDSO_USEFUL
98 #define VDSO_CGT_SYM "__kernel_clock_gettime"
99 #define VDSO_CGT_VER "LINUX_2.6.39"
100 #define VDSO_CGR_SYM "__kernel_clock_getres"
101 #define VDSO_CGR_VER "LINUX_2.6.39"
102 #define VDSO_GTD_SYM "__kernel_gettimeofday"
103 #define VDSO_GTD_VER "LINUX_2.6.39"
104 
105 #define IPC_64 0
106