@@ -439,7 +439,7 @@ def __is_compliant() -> bool:
439
439
440
440
return (uc_maj , uc_min ) == (bnd_maj , bnd_min )
441
441
442
- def __new__ (cls , arch : int , mode : int ):
442
+ def __new__ (cls , arch : int , mode : int , cpu : Optional [ int ] = None ):
443
443
# verify version compatibility with the core before doing anything
444
444
if not Uc .__is_compliant ():
445
445
raise UcError (uc .UC_ERR_VERSION )
@@ -479,12 +479,13 @@ def __uc_generic():
479
479
# return the appropriate unicorn subclass type
480
480
return super (Uc , cls ).__new__ (subclass )
481
481
482
- def __init__ (self , arch : int , mode : int ) -> None :
482
+ def __init__ (self , arch : int , mode : int , cpu : Optional [ int ] = None ) -> None :
483
483
"""Initialize a Unicorn engine instance.
484
484
485
485
Args:
486
486
arch: emulated architecture identifier (see UC_ARCH_* constants)
487
487
mode: emulated processor mode (see UC_MODE_* constants)
488
+ cpu: emulated cpu model (see UC_CPU_* constants) [optional]
488
489
"""
489
490
490
491
self ._arch = arch
@@ -498,6 +499,9 @@ def __init__(self, arch: int, mode: int) -> None:
498
499
self ._uch = None
499
500
raise UcError (status )
500
501
502
+ if cpu is not None :
503
+ self .ctl_set_cpu_model (cpu )
504
+
501
505
# we have to keep a reference to the callbacks so they do not get gc-ed
502
506
# see: https://docs.python.org/3/library/ctypes.html#callback-functions
503
507
self ._callbacks : MutableMapping [int , ctypes ._FuncPointer ] = {}
0 commit comments