• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef INT_SYSCALL_HOOKS_H
17 #define INT_SYSCALL_HOOKS_H
18 
19 #include <features.h>
20 #include <stddef.h>
21 
22 extern hidden volatile const char *g_syscall_hooks_table __attribute__((aligned(8)));
23 extern hidden volatile void *g_syscall_hooks_entry __attribute__((aligned(8)));
24 
is_syscall_hooked(long n)25 static inline int is_syscall_hooked(long n)
26 {
27 	return g_syscall_hooks_table != NULL && g_syscall_hooks_table[n] != 0;
28 }
29 
__syscall_hooks_entry0(long n)30 static inline long __syscall_hooks_entry0(long n)
31 {
32 	return ((long (*)(long))g_syscall_hooks_entry)(n);
33 }
34 
__syscall_hooks_entry1(long n,long a)35 static inline long __syscall_hooks_entry1(long n, long a)
36 {
37 	return ((long (*)(long, long))g_syscall_hooks_entry)(n, a);
38 }
39 
__syscall_hooks_entry2(long n,long a,long b)40 static inline long __syscall_hooks_entry2(long n, long a, long b)
41 {
42 	return ((long (*)(long, long, long))g_syscall_hooks_entry)(n, a, b);
43 }
44 
__syscall_hooks_entry3(long n,long a,long b,long c)45 static inline long __syscall_hooks_entry3(long n, long a, long b, long c)
46 {
47 	return ((long (*)(long, long, long, long))g_syscall_hooks_entry)(n, a, b, c);
48 }
49 
__syscall_hooks_entry4(long n,long a,long b,long c,long d)50 static inline long __syscall_hooks_entry4(long n, long a, long b, long c, long d)
51 {
52 	return ((long (*)(long, long, long, long, long))g_syscall_hooks_entry)(n, a, b, c, d);
53 }
54 
__syscall_hooks_entry5(long n,long a,long b,long c,long d,long e)55 static inline long __syscall_hooks_entry5(long n, long a, long b, long c, long d, long e)
56 {
57 	return ((long (*)(long, long, long, long, long, long))g_syscall_hooks_entry)(n, a, b, c, d, e);
58 }
59 
__syscall_hooks_entry6(long n,long a,long b,long c,long d,long e,long f)60 static inline long __syscall_hooks_entry6(long n, long a, long b, long c, long d, long e, long f)
61 {
62 	return ((long (*)(long, long, long, long, long, long, long))g_syscall_hooks_entry)(n, a, b, c, d, e, f);
63 }
64 #endif