MCPcopy Create free account
hub / github.com/Vector35/binaryninja-api / lift

Function lift

arch/arm64/arm64test.py:12799–12837  ·  view source on GitHub ↗
(data, disasm=False)

Source from the content-addressed store, hash-verified

12797
12798# TODO: make this less hacky
12799def lift(data, disasm=False):
12800 EPILOG = b'\xa0\xd5\x9b\xd2' + b'\xc0\x03\x5f\xd6' # mov x0, 0xDEAD; return
12801
12802 platform = binaryninja.Platform['linux-aarch64']
12803 # make a pretend function that returns
12804 bv = binaryview.BinaryView.new(data + EPILOG)
12805 bv.add_function(0, plat=platform)
12806 assert len(bv.functions) == 1
12807
12808 asm = []
12809
12810 tokens = []
12811 attributes = set()
12812 #for block in bv.functions[0].low_level_il:
12813 for block in bv.functions[0].lifted_il:
12814 for il in block:
12815 attributes = attributes.union(il.attributes)
12816 tokens.append(il2str(il))
12817 if disasm:
12818 info = block.arch.get_instruction_info(bv[il.address:il.address+block.arch._get_max_instruction_length(None)], il.address)
12819 if info:
12820 asm.append(''.join(map(str, block.arch.get_instruction_text(bv[il.address:il.address + info.length], il.address)[0])))
12821 else:
12822 asm.append(''.join(map(str, block.arch.get_instruction_text(bv[il.address:il.address+4], il.address)[0])))
12823 il_str = '; '.join(tokens)
12824
12825 i = len(il_str)
12826 try:
12827 i = il_str.rindex('; LLIL_SET_REG.q(x0,LLIL_CONST.q(0xDEAD))')
12828 except:
12829 # ValueError: substring not found
12830 pass
12831 il_str = il_str[0:i]
12832 asm = asm[0:1]
12833
12834 if disasm:
12835 return il_str, attributes, asm
12836 else:
12837 return il_str, attributes
12838
12839def il_str_to_tree(ilstr):
12840 result = ''

Callers 10

print_caseFunction · 0.90
test_all_liftsFunction · 0.85
instruction_llilMethod · 0.85
liftMethod · 0.85
lift_with_sizeMethod · 0.85
expressionMethod · 0.85
if_exprMethod · 0.85
loadMethod · 0.85
storeMethod · 0.85
intrinsicMethod · 0.85

Calls 9

joinMethod · 0.80
il2strFunction · 0.70
newMethod · 0.45
add_functionMethod · 0.45
unionMethod · 0.45
appendMethod · 0.45
get_instruction_infoMethod · 0.45
get_instruction_textMethod · 0.45

Tested by

no test coverage detected