本文整理汇总了Python中unicorn.UC_MODE_THUMB属性的典型用法代码示例。如果您正苦于以下问题:Python unicorn.UC_MODE_THUMB属性的具体用法?Python unicorn.UC_MODE_THUMB怎么用?Python unicorn.UC_MODE_THUMB使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类unicorn
的用法示例。
在下文中一共展示了unicorn.UC_MODE_THUMB属性的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import unicorn [as 别名]
# 或者: from unicorn import UC_MODE_THUMB [as 别名]
def __init__(self, trace=True, sca_mode=False, local_vars={}):
super().__init__(trace, sca_mode)
self.emu = uc.Uc(uc.UC_ARCH_ARM, uc.UC_MODE_THUMB | uc.UC_MODE_MCLASS)
self.disasm = cs.Cs(cs.CS_ARCH_ARM, cs.CS_MODE_THUMB | cs.CS_MODE_MCLASS)
self.disasm.detail = True
self.word_size = 4
self.endianness = "little"
self.page_size = self.emu.query(uc.UC_QUERY_PAGE_SIZE)
self.page_shift = self.page_size.bit_length() - 1
self.pc = uc.arm_const.UC_ARM_REG_PC
known_regs = [i[len('UC_ARM_REG_'):] for i in dir(uc.arm_const) if '_REG' in i]
self.reg_map = {r.lower(): getattr(uc.arm_const, 'UC_ARM_REG_'+r) for r in known_regs}
self.stubbed_functions = local_vars
self.setup(sca_mode)
self.reset_stack()
# Force mapping of those addresses so that
# exception returns can be caught in the base
# block hook rather than a code fetch hook
self.map_space(0xfffffff0, 0xffffffff)
self.emu.hook_add(uc.UC_HOOK_INTR, self.intr_hook)
示例2: _fixup_thumb_pc
# 需要导入模块: import unicorn [as 别名]
# 或者: from unicorn import UC_MODE_THUMB [as 别名]
def _fixup_thumb_pc(self, pc):
"""Fix the PC for emu_start to take ARM Thumb mode into account."""
# If the arch mode is UC_MODE_THUMB, force Thumb.
# Otherwise, check Thumb bit in CPSR.
if self._protocol.arch.unicorn_arch == unicorn.UC_ARCH_ARM and \
(self._protocol.arch.unicorn_mode == unicorn.UC_MODE_THUMB or
self._protocol.read_register(self._protocol.arch.sr_name) & 0x20):
pc |= 1
return pc
示例3: test_thumb_mode_emulation
# 需要导入模块: import unicorn [as 别名]
# 或者: from unicorn import UC_MODE_THUMB [as 别名]
def test_thumb_mode_emulation(self):
asm = "add r0, r1, r2"
self._setupCpu(asm, mode=CS_MODE_THUMB)
self.rf.write("R0", 0)
self.rf.write("R1", 0x1234)
self.rf.write("R2", 0x5678)
emu = emulate_next(self.cpu)
self.assertEqual(self.rf.read("R0"), 0x1234 + 0x5678)
self.assertEqual(emu._emu.query(UC_QUERY_MODE), UC_MODE_THUMB)
示例4: hook_mem_unmapped
# 需要导入模块: import unicorn [as 别名]
# 或者: from unicorn import UC_MODE_THUMB [as 别名]
def hook_mem_unmapped(self, uc, access, address, size, value, user_data):
if self.report:
self.write_to_session('%sreading to an unmapped memory region at '
'<span style="color: #C36969">0x%x</span>' % (self.apix, address))
uc.emu_stop()
map_len = self.map_region_by_addr(address)
if map_len > 0:
start_addr = self.current_address
if self.cli.context_manager.get_arch().get_unicorn_mode() == unicorn.UC_MODE_THUMB:
start_addr += 1
uc.emu_start(start_addr, start_addr + self.cli.context_manager.get_pointer_size())
示例5: unicorn_thumb
# 需要导入模块: import unicorn [as 别名]
# 或者: from unicorn import UC_MODE_THUMB [as 别名]
def unicorn_thumb(self):
if _unicorn is None:
l.warning("Unicorn is not installed!")
return None
return _unicorn.Uc(self.uc_arch, self.uc_mode + _unicorn.UC_MODE_THUMB)
示例6: __init__
# 需要导入模块: import unicorn [as 别名]
# 或者: from unicorn import UC_MODE_THUMB [as 别名]
def __init__(self, controller, r, stage):
# controller.gdb_print("creating longwrite break\n")
self.emptywrite = {'start': None,
'end': None,
'pc': None}
self.writeinfo = self.emptywrite
self.breakaddr = r['breakaddr']
self.contaddr = r['contaddr']
self.writeaddr = r['writeaddr']
self.thumb = r['thumb']
r2.gets(stage.elf, "s 0x%x" % self.writeaddr)
if self.thumb:
self.emu = unicorn.Uc(unicorn.UC_ARCH_ARM, unicorn.UC_MODE_THUMB)
r2.gets(stage.elf, "ahb 16")
r2.gets(stage.elf, "e asm.bits=16")
self.cs = capstone.Cs(capstone.CS_ARCH_ARM, capstone.CS_MODE_THUMB)
else:
self.emu = unicorn.Uc(unicorn.UC_ARCH_ARM, unicorn.UC_MODE_ARM)
r2.gets(stage.elf, "ahb 32")
r2.gets(stage.elf, "e asm.bits=32")
self.cs = capstone.Cs(capstone.CS_ARCH_ARM, capstone.CS_MODE_ARM)
r2.get(stage.elf, "pdj 1")
self.cs.detail = True
self.info = staticanalysis.LongWriteInfo(stage.elf, r['start'],
r['end'], self.thumb)
self.inss = []
self.regs = set()
self.bytes = b""
self.dst_addrs = []
self.write_size = r['writesize']
for i in self.info.bbs:
self.inss.append(i)
bs = i["bytes"].decode("hex")
self.bytes += b"%s" % bs
ci = next(self.cs.disasm(bs, i["offset"], 1))
if i["offset"] == self.writeaddr:
self.write_ins = ci
(read, write) = ci.regs_access()
for rs in (read, write):
self.regs.update([ci.reg_name(rn).encode('ascii') for rn in rs])
self.emu.mem_map(0, 0xFFFFFFFF + 1, unicorn.UC_PROT_ALL)
self.emu.mem_write(self.inss[0]["offset"], self.bytes)
self.emu.hook_add(unicorn.UC_HOOK_MEM_WRITE, self.write_hook)
self.spec = "*(0x%x)" % r['breakaddr']
TargetBreak.__init__(self, self.spec, controller, True, stage, r=r)