From 957df0ec3a9ef85b15f9a54d4a13a17095884b55 Mon Sep 17 00:00:00 2001 From: Eli Date: Fri, 25 Oct 2024 15:22:53 +0300 Subject: [PATCH] Fix TLB fill hook (#2042) * Fix the TLB fill hook * Add missing annotations --- bindings/python/unicorn/unicorn_py3/unicorn.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/bindings/python/unicorn/unicorn_py3/unicorn.py b/bindings/python/unicorn/unicorn_py3/unicorn.py index 9b5f8e0cb5..e2d844cda4 100644 --- a/bindings/python/unicorn/unicorn_py3/unicorn.py +++ b/bindings/python/unicorn/unicorn_py3/unicorn.py @@ -1048,7 +1048,7 @@ def hook_add(self, htype: int, callback: Callable, user_data: Any = None, begin: def __hook_intr(): @uccallback(self, HOOK_INTR_CFUNC) - def __hook_intr_cb(uc: Uc, intno: int, key: int): + def __hook_intr_cb(uc: Uc, intno: int, key: int) -> None: callback(uc, intno, user_data) return (__hook_intr_cb,) @@ -1061,7 +1061,7 @@ def __hook_insn(): def __hook_code(): @uccallback(self, HOOK_CODE_CFUNC) - def __hook_code_cb(uc: Uc, address: int, size: int, key: int): + def __hook_code_cb(uc: Uc, address: int, size: int, key: int) -> None: callback(uc, address, size, user_data) return (__hook_code_cb,) @@ -1089,14 +1089,14 @@ def __hook_insn_invalid_cb(uc: Uc, key: int) -> bool: def __hook_edge_gen(): @uccallback(self, HOOK_EDGE_GEN_CFUNC) - def __hook_edge_gen_cb(uc: Uc, cur: ctypes._Pointer[uc_tb], prev: ctypes._Pointer[uc_tb], key: int): + def __hook_edge_gen_cb(uc: Uc, cur: ctypes._Pointer[uc_tb], prev: ctypes._Pointer[uc_tb], key: int) -> None: callback(uc, cur.contents, prev.contents, user_data) return (__hook_edge_gen_cb,) def __hook_tcg_opcode(): @uccallback(self, HOOK_TCG_OPCODE_CFUNC) - def __hook_tcg_op_cb(uc: Uc, address: int, arg1: int, arg2: int, size: int, key: int): + def __hook_tcg_op_cb(uc: Uc, address: int, arg1: int, arg2: int, size: int, key: int) -> None: callback(uc, address, arg1, arg2, size, user_data) opcode = ctypes.c_uint64(aux1) @@ -1106,8 +1106,8 @@ def __hook_tcg_op_cb(uc: Uc, address: int, arg1: int, arg2: int, size: int, key: def __hook_tlb_fill(): @uccallback(self, HOOK_TLB_FILL_CFUNC) - def __hook_tlb_fill_cb(uc: Uc, vaddr: int, access: int, entry: ctypes._Pointer[uc_tlb_entry], key: int): - callback(uc, vaddr, access, entry.contents, user_data) + def __hook_tlb_fill_cb(uc: Uc, vaddr: int, access: int, entry: ctypes._Pointer[uc_tlb_entry], key: int) -> bool: + return callback(uc, vaddr, access, entry.contents, user_data) return (__hook_tlb_fill_cb,)