Skip to content

Commit

Permalink
Fix TLB fill hook (#2042)
Browse files Browse the repository at this point in the history
* Fix the TLB fill hook

* Add missing annotations
  • Loading branch information
elicn authored Oct 25, 2024
1 parent 16916b2 commit 957df0e
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions bindings/python/unicorn/unicorn_py3/unicorn.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,)
Expand All @@ -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,)
Expand Down Expand Up @@ -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)
Expand All @@ -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,)

Expand Down

0 comments on commit 957df0e

Please sign in to comment.