@@ -103,7 +103,7 @@ def _load_lib(path, lib_name):
103
103
for _path in _path_list :
104
104
if _path is None :
105
105
continue
106
-
106
+
107
107
_uc = _load_lib (_path , "libunicorn.so" )
108
108
if _uc is not None :
109
109
# In this case, show a warning for users
@@ -153,16 +153,16 @@ class uc_tb(ctypes.Structure):
153
153
_setup_prototype (_uc , "uc_errno" , ucerr , uc_engine )
154
154
_setup_prototype (_uc , "uc_reg_read" , ucerr , uc_engine , ctypes .c_int , ctypes .c_void_p )
155
155
_setup_prototype (_uc , "uc_reg_write" , ucerr , uc_engine , ctypes .c_int , ctypes .c_void_p )
156
- _setup_prototype (_uc , "uc_mem_read" , ucerr , uc_engine , ctypes .c_uint64 , ctypes .POINTER (ctypes .c_char ), ctypes .c_size_t )
157
- _setup_prototype (_uc , "uc_mem_write" , ucerr , uc_engine , ctypes .c_uint64 , ctypes .POINTER (ctypes .c_char ), ctypes .c_size_t )
156
+ _setup_prototype (_uc , "uc_mem_read" , ucerr , uc_engine , ctypes .c_uint64 , ctypes .POINTER (ctypes .c_char ), ctypes .c_uint64 )
157
+ _setup_prototype (_uc , "uc_mem_write" , ucerr , uc_engine , ctypes .c_uint64 , ctypes .POINTER (ctypes .c_char ), ctypes .c_uint64 )
158
158
_setup_prototype (_uc , "uc_emu_start" , ucerr , uc_engine , ctypes .c_uint64 , ctypes .c_uint64 , ctypes .c_uint64 , ctypes .c_size_t )
159
159
_setup_prototype (_uc , "uc_emu_stop" , ucerr , uc_engine )
160
160
_setup_prototype (_uc , "uc_hook_del" , ucerr , uc_engine , uc_hook_h )
161
- _setup_prototype (_uc , "uc_mmio_map" , ucerr , uc_engine , ctypes .c_uint64 , ctypes .c_size_t , ctypes .c_void_p , ctypes .c_void_p , ctypes .c_void_p , ctypes .c_void_p )
162
- _setup_prototype (_uc , "uc_mem_map" , ucerr , uc_engine , ctypes .c_uint64 , ctypes .c_size_t , ctypes .c_uint32 )
163
- _setup_prototype (_uc , "uc_mem_map_ptr" , ucerr , uc_engine , ctypes .c_uint64 , ctypes .c_size_t , ctypes .c_uint32 , ctypes .c_void_p )
164
- _setup_prototype (_uc , "uc_mem_unmap" , ucerr , uc_engine , ctypes .c_uint64 , ctypes .c_size_t )
165
- _setup_prototype (_uc , "uc_mem_protect" , ucerr , uc_engine , ctypes .c_uint64 , ctypes .c_size_t , ctypes .c_uint32 )
161
+ _setup_prototype (_uc , "uc_mmio_map" , ucerr , uc_engine , ctypes .c_uint64 , ctypes .c_uint64 , ctypes .c_void_p , ctypes .c_void_p , ctypes .c_void_p , ctypes .c_void_p )
162
+ _setup_prototype (_uc , "uc_mem_map" , ucerr , uc_engine , ctypes .c_uint64 , ctypes .c_uint64 , ctypes .c_uint32 )
163
+ _setup_prototype (_uc , "uc_mem_map_ptr" , ucerr , uc_engine , ctypes .c_uint64 , ctypes .c_uint64 , ctypes .c_uint32 , ctypes .c_void_p )
164
+ _setup_prototype (_uc , "uc_mem_unmap" , ucerr , uc_engine , ctypes .c_uint64 , ctypes .c_uint64 )
165
+ _setup_prototype (_uc , "uc_mem_protect" , ucerr , uc_engine , ctypes .c_uint64 , ctypes .c_uint64 , ctypes .c_uint32 )
166
166
_setup_prototype (_uc , "uc_query" , ucerr , uc_engine , ctypes .c_uint32 , ctypes .POINTER (ctypes .c_size_t ))
167
167
_setup_prototype (_uc , "uc_context_alloc" , ucerr , uc_engine , ctypes .POINTER (uc_context ))
168
168
_setup_prototype (_uc , "uc_free" , ucerr , ctypes .c_void_p )
@@ -593,7 +593,7 @@ def _mmio_map_write_cb(self, handle, offset, size, value, user_data):
593
593
(cb , data ) = self ._callbacks [user_data ]
594
594
cb (self , offset , size , value , data )
595
595
596
- def mmio_map (self , address : int , size : int ,
596
+ def mmio_map (self , address : int , size : int ,
597
597
read_cb : UC_MMIO_READ_TYPE , user_data_read : Any ,
598
598
write_cb : UC_MMIO_WRITE_TYPE , user_data_write : Any ):
599
599
internal_read_cb = ctypes .cast (UC_MMIO_READ_CB (self ._mmio_map_read_cb ), UC_MMIO_READ_CB )
@@ -609,7 +609,7 @@ def mmio_map(self, address: int, size: int,
609
609
status = _uc .uc_mmio_map (self ._uch , address , size , internal_read_cb , read_count , internal_write_cb , write_count )
610
610
if status != uc .UC_ERR_OK :
611
611
raise UcError (status )
612
-
612
+
613
613
# https://docs.python.org/3/library/ctypes.html#callback-functions
614
614
self ._ctype_cbs .append (internal_read_cb )
615
615
self ._ctype_cbs .append (internal_write_cb )
@@ -731,12 +731,12 @@ def __ctl(self, ctl, nr, rw):
731
731
732
732
def __ctl_r (self , ctl , nr ):
733
733
return self .__ctl (ctl , nr , uc .UC_CTL_IO_READ )
734
-
734
+
735
735
def __ctl_w (self , ctl , nr ):
736
736
return self .__ctl (ctl , nr , uc .UC_CTL_IO_WRITE )
737
-
737
+
738
738
def __ctl_rw (self , ctl , nr ):
739
- return self .__ctl (ctl , nr , uc .UC_CTL_IO_READ_WRITE )
739
+ return self .__ctl (ctl , nr , uc .UC_CTL_IO_READ_WRITE )
740
740
741
741
def __ctl_r_1_arg (self , ctl , ctp ):
742
742
arg = ctp ()
@@ -746,7 +746,7 @@ def __ctl_r_1_arg(self, ctl, ctp):
746
746
def __ctl_w_1_arg (self , ctl , val , ctp ):
747
747
arg = ctp (val )
748
748
self .ctl (self .__ctl_w (ctl , 1 ), arg )
749
-
749
+
750
750
def __ctl_w_2_arg (self , ctl , val1 , val2 , ctp1 , ctp2 ):
751
751
arg1 = ctp1 (val1 )
752
752
arg2 = ctp2 (val2 )
@@ -763,7 +763,7 @@ def ctl_get_mode(self):
763
763
764
764
def ctl_get_page_size (self ):
765
765
return self .__ctl_r_1_arg (uc .UC_CTL_UC_PAGE_SIZE , ctypes .c_uint32 )
766
-
766
+
767
767
def ctl_set_page_size (self , val : int ):
768
768
self .__ctl_w_1_arg (uc .UC_CTL_UC_PAGE_SIZE , val , ctypes .c_uint32 )
769
769
@@ -772,10 +772,10 @@ def ctl_get_arch(self):
772
772
773
773
def ctl_get_timeout (self ):
774
774
return self .__ctl_r_1_arg (uc .UC_CTL_UC_TIMEOUT , ctypes .c_uint64 )
775
-
775
+
776
776
def ctl_exits_enabled (self , val : bool ):
777
777
self .__ctl_w_1_arg (uc .UC_CTL_UC_USE_EXITS , val , ctypes .c_int )
778
-
778
+
779
779
def ctl_get_exits_cnt (self ):
780
780
return self .__ctl_r_1_arg (uc .UC_CTL_UC_EXITS_CNT , ctypes .c_size_t )
781
781
@@ -793,7 +793,7 @@ def ctl_set_exits(self, exits: List[int]):
793
793
794
794
def ctl_get_cpu_model (self ):
795
795
return self .__ctl_r_1_arg (uc .UC_CTL_CPU_MODEL , ctypes .c_int )
796
-
796
+
797
797
def ctl_set_cpu_model (self , val : int ):
798
798
self .__ctl_w_1_arg (uc .UC_CTL_CPU_MODEL , val , ctypes .c_int )
799
799
@@ -802,7 +802,7 @@ def ctl_remove_cache(self, addr: int, end: int):
802
802
803
803
def ctl_request_cache (self , addr : int ):
804
804
return self .__ctl_rw_1_1_arg (uc .UC_CTL_TB_REQUEST_CACHE , addr , ctypes .c_uint64 , uc_tb )
805
-
805
+
806
806
def ctl_flush_tb (self ):
807
807
self .ctl (self .__ctl_w (uc .UC_CTL_TB_FLUSH , 0 ))
808
808
@@ -963,7 +963,7 @@ def size(self):
963
963
@property
964
964
def arch (self ):
965
965
return self ._arch
966
-
966
+
967
967
@property
968
968
def mode (self ):
969
969
return self ._mode
@@ -1012,11 +1012,11 @@ def __del__(self):
1012
1012
UC_HOOK_TCG_OPCODE_TYPE = Callable [[Uc , int , int , int , Any ], None ]
1013
1013
1014
1014
UC_HOOK_CALLBACK_TYPE = Union [
1015
- UC_HOOK_CODE_TYPE ,
1016
- UC_HOOK_INSN_INVALID_TYPE ,
1017
- UC_HOOK_MEM_INVALID_TYPE ,
1018
- UC_HOOK_MEM_ACCESS_TYPE ,
1019
- UC_HOOK_INSN_IN_TYPE ,
1015
+ UC_HOOK_CODE_TYPE ,
1016
+ UC_HOOK_INSN_INVALID_TYPE ,
1017
+ UC_HOOK_MEM_INVALID_TYPE ,
1018
+ UC_HOOK_MEM_ACCESS_TYPE ,
1019
+ UC_HOOK_INSN_IN_TYPE ,
1020
1020
UC_HOOK_INSN_OUT_TYPE ,
1021
1021
UC_HOOK_INSN_SYSCALL_TYPE ,
1022
1022
UC_HOOK_INSN_SYS_TYPE ,
0 commit comments