1010#include "libafl/exit.h"
1111#include "libafl/hook.h"
1212
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 ,
1616};
1717
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+
1838struct libafl_pre_syscall_hook {
1939 // 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 ;
2541
2642 // data
2743 uint64_t data ;
@@ -33,11 +49,7 @@ struct libafl_pre_syscall_hook {
3349
3450struct libafl_post_syscall_hook {
3551 // 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 ;
4153
4254 // data
4355 uint64_t data ;
@@ -47,20 +59,10 @@ struct libafl_post_syscall_hook {
4759 struct libafl_post_syscall_hook * next ;
4860};
4961
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 );
6466
6567int libafl_qemu_remove_pre_syscall_hook (size_t num );
6668int libafl_qemu_remove_post_syscall_hook (size_t num );
0 commit comments