本文整理匯總了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)