10
10
#include "libafl/exit.h"
11
11
#include "libafl/hook.h"
12
12
13
- struct syshook_ret {
14
- target_ulong retval ;
15
- bool skip_syscall ;
13
+ enum libafl_syshook_ret_tag {
14
+ LIBAFL_SYSHOOK_RUN ,
15
+ LIBAFL_SYSHOOK_SKIP ,
16
16
};
17
17
18
+ // Representation of a pre-syscall hook result.
19
+ // It is associated with the LibAFL enum `SyscallHookResult`.
20
+ // Any change made here should be also propagated to the Rust enum.
21
+ struct libafl_syshook_ret {
22
+ enum libafl_syshook_ret_tag tag ;
23
+ union {
24
+ target_ulong syshook_skip_retval ;
25
+ };
26
+ };
27
+
28
+ typedef struct libafl_syshook_ret (* libafl_pre_syscall_cb )(
29
+ uint64_t data , int sys_num , target_ulong arg0 , target_ulong arg1 ,
30
+ target_ulong arg2 , target_ulong arg3 , target_ulong arg4 , target_ulong arg5 ,
31
+ target_ulong arg6 , target_ulong arg7 );
32
+
33
+ typedef target_ulong (* libafl_post_syscall_cb )(
34
+ uint64_t data , target_ulong ret , int sys_num , target_ulong arg0 ,
35
+ target_ulong arg1 , target_ulong arg2 , target_ulong arg3 , target_ulong arg4 ,
36
+ target_ulong arg5 , target_ulong arg6 , target_ulong arg7 );
37
+
18
38
struct libafl_pre_syscall_hook {
19
39
// functions
20
- struct syshook_ret (* callback )(uint64_t data , int sys_num ,
21
- target_ulong arg0 , target_ulong arg1 ,
22
- target_ulong arg2 , target_ulong arg3 ,
23
- target_ulong arg4 , target_ulong arg5 ,
24
- target_ulong arg6 , target_ulong arg7 );
40
+ libafl_pre_syscall_cb callback ;
25
41
26
42
// data
27
43
uint64_t data ;
@@ -33,11 +49,7 @@ struct libafl_pre_syscall_hook {
33
49
34
50
struct libafl_post_syscall_hook {
35
51
// functions
36
- target_ulong (* callback )(uint64_t data , target_ulong ret , int sys_num ,
37
- target_ulong arg0 , target_ulong arg1 ,
38
- target_ulong arg2 , target_ulong arg3 ,
39
- target_ulong arg4 , target_ulong arg5 ,
40
- target_ulong arg6 , target_ulong arg7 );
52
+ libafl_post_syscall_cb callback ;
41
53
42
54
// data
43
55
uint64_t data ;
@@ -47,20 +59,10 @@ struct libafl_post_syscall_hook {
47
59
struct libafl_post_syscall_hook * next ;
48
60
};
49
61
50
- size_t libafl_add_pre_syscall_hook (
51
- struct syshook_ret (* callback )(uint64_t data , int sys_num ,
52
- target_ulong arg0 , target_ulong arg1 ,
53
- target_ulong arg2 , target_ulong arg3 ,
54
- target_ulong arg4 , target_ulong arg5 ,
55
- target_ulong arg6 , target_ulong arg7 ),
56
- uint64_t data );
57
- size_t libafl_add_post_syscall_hook (
58
- target_ulong (* callback )(uint64_t data , target_ulong ret , int sys_num ,
59
- target_ulong arg0 , target_ulong arg1 ,
60
- target_ulong arg2 , target_ulong arg3 ,
61
- target_ulong arg4 , target_ulong arg5 ,
62
- target_ulong arg6 , target_ulong arg7 ),
63
- uint64_t data );
62
+ size_t libafl_add_pre_syscall_hook (libafl_pre_syscall_cb callback ,
63
+ uint64_t data );
64
+ size_t libafl_add_post_syscall_hook (libafl_post_syscall_cb callback ,
65
+ uint64_t data );
64
66
65
67
int libafl_qemu_remove_pre_syscall_hook (size_t num );
66
68
int libafl_qemu_remove_post_syscall_hook (size_t num );
0 commit comments