Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def translate(code_bytes, base_address, thumb=False):
done = False
if thumb:
ctx = ThumbTranslationContext()
else:
ctx = ArmTranslationContext()
for i in ctx.disassembler.disasm(code_bytes, base_address):
if done:
raise StopIteration()
mnemonic = '{} {}'.format(i.mnemonic, i.op_str)
yield native.Instruction(
i.address, mnemonic, _translate(ctx, i),
ends_basic_block(i), i.size)
if ends_basic_block(i):
done = True
ctx = _x86_64_ctx
else:
ctx = _x86_64_rip_ctx
else:
if threadsafe:
ctx = X86TranslationContext()
else:
ctx = _x86_ctx
for i in ctx.disassembler.disasm(code_bytes, base_address):
if done:
raise StopIteration()
mnemonic = '{} {}'.format(i.mnemonic, i.op_str)
yield native.Instruction(
i.address, mnemonic, _translate(ctx, i),
ends_basic_block(i), i.size)
if ends_basic_block(i):
done = True
def translate(code_bytes, base_address):
done = False
ctx = Arm64TranslationContext()
for i in ctx.disassembler.disasm(code_bytes, base_address):
if done:
raise StopIteration()
mnemonic = '{} {}'.format(i.mnemonic, i.op_str)
yield native.Instruction(
i.address, mnemonic, _translate(ctx, i),
ends_basic_block(i), i.size)
if ends_basic_block(i):
done = True