diff --git a/include/libafl/hooks/tcg/jmp.h b/include/libafl/hooks/tcg/jmp.h index 765f636d15..8c66833a1e 100644 --- a/include/libafl/hooks/tcg/jmp.h +++ b/include/libafl/hooks/tcg/jmp.h @@ -9,9 +9,12 @@ #include "libafl/exit.h" #include "libafl/hook.h" +typedef uint64_t (*libafl_jmp_gen_cb)(uint64_t data, target_ulong src, target_ulong dst); +typedef void (*libafl_jmp_exec_cb)(uint64_t data, target_ulong src, target_ulong dst, uint64_t id); + struct libafl_jmp_hook { - uint64_t (*gen)(uint64_t data, target_ulong src, target_ulong dst); - void (*exec)(uint64_t data, target_ulong src, target_ulong dst, uint64_t id); + libafl_jmp_gen_cb gen_cb; + libafl_jmp_exec_cb exec_cb; uint64_t data; size_t num; TCGHelperInfo helper_info; @@ -20,8 +23,8 @@ struct libafl_jmp_hook { extern struct libafl_jmp_hook* libafl_jmp_hooks; -size_t libafl_add_jmp_hook(uint64_t (*gen)(uint64_t data, target_ulong src, target_ulong dst), - void (*exec)(uint64_t data, target_ulong src, target_ulong dst, uint64_t id), +size_t libafl_add_jmp_hook(uint64_t (*gen_cb)(uint64_t data, target_ulong src, target_ulong dst), + void (*exec_cb)(uint64_t data, target_ulong src, target_ulong dst, uint64_t id), uint64_t data); void libafl_gen_jmp(target_ulong src, target_ulong dst); diff --git a/libafl/hooks/tcg/jmp.c b/libafl/hooks/tcg/jmp.c index 84fd42dea0..05b1f8ec1d 100644 --- a/libafl/hooks/tcg/jmp.c +++ b/libafl/hooks/tcg/jmp.c @@ -11,20 +11,20 @@ static TCGHelperInfo libafl_exec_jmp_hook_info = { struct libafl_jmp_hook* libafl_jmp_hooks; size_t libafl_jmp_hooks_num = 0; -size_t libafl_add_jmp_hook(uint64_t (*gen)(uint64_t data, target_ulong src, target_ulong dst), - void (*exec)(uint64_t data, target_ulong src, target_ulong dst, uint64_t id), +size_t libafl_add_jmp_hook(uint64_t (*gen_cb)(uint64_t data, target_ulong src, target_ulong dst), + void (*exec_cb)(uint64_t data, target_ulong src, target_ulong dst, uint64_t id), uint64_t data) { struct libafl_jmp_hook* hook = calloc(sizeof(struct libafl_jmp_hook), 1); - hook->gen = gen; - hook->exec = exec; + hook->gen_cb = gen_cb; + hook->exec_cb = exec_cb; hook->num = libafl_jmp_hooks_num++; hook->data = data; hook->next = libafl_jmp_hooks; libafl_jmp_hooks = hook; memcpy(&hook->helper_info, &libafl_exec_jmp_hook_info, sizeof(TCGHelperInfo)); - hook->helper_info.func = exec; + hook->helper_info.func = exec_cb; return hook->num; } @@ -34,9 +34,9 @@ void libafl_gen_jmp(target_ulong src, target_ulong dst) struct libafl_jmp_hook* hook = libafl_jmp_hooks; while (hook) { uint64_t cur_id = 0; - if (hook->gen) - cur_id = hook->gen(hook->data, src, dst); - if (cur_id != (uint64_t)-1 && hook->exec) { + if (hook->gen_cb) + cur_id = hook->gen_cb(hook->data, src, dst); + if (cur_id != (uint64_t)-1 && hook->exec_cb) { TCGv_i64 tmp0 = tcg_constant_i64(hook->data); TCGv_i64 tmp1 = tcg_constant_i64(src); TCGv_i64 tmp2 = tcg_constant_i64(dst); @@ -57,9 +57,9 @@ void libafl_gen_jmp_dynamic(target_ulong src, TCGv_i32 dst) struct libafl_jmp_hook* hook = libafl_jmp_hooks; while (hook) { uint64_t cur_id = 0; - if (hook->gen) - cur_id = hook->gen(hook->data, src, 0); // target is not statically known, signal with 0 - if (cur_id != (uint64_t)-1 && hook->exec) { + if (hook->gen_cb) + cur_id = hook->gen_cb(hook->data, src, 0); // target is not statically known, signal with 0 + if (cur_id != (uint64_t)-1 && hook->exec_cb) { TCGv_i64 tmp0 = tcg_constant_i64(hook->data); TCGv_i64 tmp1 = tcg_constant_i64(src); // TCGv_i32 tmp2 = dst;