This commit continues the PR #111
- Allow to register handler separately for invalid memory access - Add new memory events for hooking: - UC_MEM_READ_INVALID, UC_MEM_WRITE_INVALID, UC_MEM_FETCH_INVALID - UC_HOOK_MEM_READ_PROT, UC_HOOK_MEM_WRITE_PROT, UC_HOOK_MEM_FETCH_PROT - Rename UC_ERR_EXEC_PROT to UC_ERR_FETCH_PROT - Change API uc_hook_add() so event type @type can be combined from hooking types
This commit is contained in:
@ -272,11 +272,13 @@ class Uc(object):
|
||||
cb = ctypes.cast(UC_HOOK_CODE_CB(self._hookcode_cb), UC_HOOK_CODE_CB)
|
||||
status = _uc.uc_hook_add(self._uch, ctypes.byref(_h2), htype, cb, \
|
||||
ctypes.cast(self._callback_count, ctypes.c_void_p), begin, end)
|
||||
elif htype == UC_HOOK_MEM_INVALID:
|
||||
elif htype & UC_HOOK_MEM_READ_INVALID or htype & UC_HOOK_MEM_WRITE_INVALID or \
|
||||
htype & UC_HOOK_MEM_FETCH_INVALID or htype & UC_HOOK_MEM_READ_PROT or \
|
||||
htype & UC_HOOK_MEM_WRITE_PROT or htype & UC_HOOK_MEM_FETCH_PROT:
|
||||
cb = ctypes.cast(UC_HOOK_MEM_INVALID_CB(self._hook_mem_invalid_cb), UC_HOOK_MEM_INVALID_CB)
|
||||
status = _uc.uc_hook_add(self._uch, ctypes.byref(_h2), htype, \
|
||||
cb, ctypes.cast(self._callback_count, ctypes.c_void_p))
|
||||
elif htype in (UC_HOOK_MEM_READ, UC_HOOK_MEM_WRITE, UC_HOOK_MEM_READ_WRITE):
|
||||
elif htype in (UC_HOOK_MEM_READ, UC_HOOK_MEM_WRITE, UC_HOOK_MEM_READ | UC_HOOK_MEM_WRITE):
|
||||
cb = ctypes.cast(UC_HOOK_MEM_ACCESS_CB(self._hook_mem_access_cb), UC_HOOK_MEM_ACCESS_CB)
|
||||
status = _uc.uc_hook_add(self._uch, ctypes.byref(_h2), htype, \
|
||||
cb, ctypes.cast(self._callback_count, ctypes.c_void_p))
|
||||
|
@ -46,7 +46,7 @@ UC_ERR_INSN_INVALID = 11
|
||||
UC_ERR_MAP = 12
|
||||
UC_ERR_WRITE_PROT = 13
|
||||
UC_ERR_READ_PROT = 14
|
||||
UC_ERR_EXEC_PROT = 15
|
||||
UC_ERR_FETCH_PROT = 15
|
||||
UC_ERR_ARG = 16
|
||||
UC_ERR_READ_UNALIGNED = 17
|
||||
UC_ERR_WRITE_UNALIGNED = 18
|
||||
@ -54,19 +54,25 @@ UC_ERR_FETCH_UNALIGNED = 19
|
||||
UC_MEM_READ = 16
|
||||
UC_MEM_WRITE = 17
|
||||
UC_MEM_FETCH = 18
|
||||
UC_MEM_WRITE_PROT = 19
|
||||
UC_MEM_READ_PROT = 20
|
||||
UC_MEM_FETCH_PROT = 21
|
||||
UC_HOOK_INTR = 32
|
||||
UC_HOOK_INSN = 33
|
||||
UC_HOOK_CODE = 34
|
||||
UC_HOOK_BLOCK = 35
|
||||
UC_HOOK_MEM_INVALID_READ = 36
|
||||
UC_HOOK_MEM_INVALID_WRITE = 37
|
||||
UC_HOOK_MEM_INVALID_FETCH = 38
|
||||
UC_HOOK_MEM_READ = 39
|
||||
UC_HOOK_MEM_WRITE = 40
|
||||
UC_HOOK_MEM_FETCH = 41
|
||||
UC_MEM_READ_INVALID = 19
|
||||
UC_MEM_WRITE_INVALID = 20
|
||||
UC_MEM_FETCH_INVALID = 21
|
||||
UC_MEM_WRITE_PROT = 22
|
||||
UC_MEM_READ_PROT = 23
|
||||
UC_MEM_FETCH_PROT = 24
|
||||
UC_HOOK_INTR = 1
|
||||
UC_HOOK_INSN = 2
|
||||
UC_HOOK_CODE = 4
|
||||
UC_HOOK_BLOCK = 8
|
||||
UC_HOOK_MEM_READ_INVALID = 16
|
||||
UC_HOOK_MEM_WRITE_INVALID = 32
|
||||
UC_HOOK_MEM_FETCH_INVALID = 64
|
||||
UC_HOOK_MEM_READ_PROT = 128
|
||||
UC_HOOK_MEM_WRITE_PROT = 256
|
||||
UC_HOOK_MEM_FETCH_PROT = 512
|
||||
UC_HOOK_MEM_READ = 1024
|
||||
UC_HOOK_MEM_WRITE = 2048
|
||||
UC_HOOK_MEM_FETCH = 4096
|
||||
|
||||
UC_PROT_NONE = 0
|
||||
UC_PROT_READ = 1
|
||||
|
Reference in New Issue
Block a user