本文整理汇总了Python中keystone.KS_MODE_32属性的典型用法代码示例。如果您正苦于以下问题:Python keystone.KS_MODE_32属性的具体用法?Python keystone.KS_MODE_32怎么用?Python keystone.KS_MODE_32使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类keystone
的用法示例。
在下文中一共展示了keystone.KS_MODE_32属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: assemble
# 需要导入模块: import keystone [as 别名]
# 或者: from keystone import KS_MODE_32 [as 别名]
def assemble(code, addr = 0, mode = keystone.KS_MODE_32):
"""
assemble asm code for inline hook
"""
ks = keystone.Ks(keystone.KS_ARCH_X86, mode)
encoding, count = ks.asm(code, addr)
buf = ''.join(chr(c) for c in encoding)
return buf, count
示例2: patch_code
# 需要导入模块: import keystone [as 别名]
# 或者: from keystone import KS_MODE_32 [as 别名]
def patch_code(self, instructions='ret;',va=0):
""" put instruction(s), at the end of the basic block specified"""
#TODO: get capstone instruction at the end of the basic_block
try:
k = ks.Ks(ks.KS_ARCH_X86, ks.KS_MODE_32)
encoding, count = k.asm(instructions, va+self.OPTIONAL_HEADER.ImageBase)
except ks.KsError as e:
l.error("Error! %s", e)
raise
if not self.set_bytes_at_rva(va, ''.join(map(chr, encoding))):
raise Exception('Cannot patch bytes at %x!', va)