Esempio n. 1
0
 def uc_reg_const(self, reg_name: str) -> int:
     """
     Gets the reg const for the current arch
     :param reg_name: the reg name
     :return: UC_ const for the register of this name
     """
     return uc_reg_const(self.arch, reg_name)
Esempio n. 2
0
 def uc_write_pc(self, uc, val) -> int:
     """
     Sets the program counter of a unicorn instance
     :param uc: Unicorn instance
     :param arch: the architecture to use
     :param val: the value to write
     """
     return uc.reg_write(uc_reg_const(self.arch, self.arch.pc_name), val)
Esempio n. 3
0
 def uc_read_pc(self, uc) -> int:
     """
     Gets the current pc from unicorn for this arch
     :param uc: the unicorn instance
     :return: value of the pc
     """
     # noinspection PyUnresolvedReferences
     return uc.reg_read(uc_reg_const(self.arch, self.arch.pc_name))
Esempio n. 4
0
 def uc_load_registers(self, uc: Uc) -> None:
     """
     Loads all registers to unicorn, called in the harness.
     """
     regs = self.fetch_all_regs()
     for key, value in regs.items():
         if key in self.arch.ignored_regs:
             # print("[d] Ignoring reg: {} (Ignored)".format(r))
             continue
         try:
             uc.reg_write(uc_reg_const(self.arch, key), value)
         except Exception as ex:
             print("[d] Faild to load reg: {} ({})".format(key, ex))
             pass