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

Function make_code

python/examples/make_code.py:31–47  ·  view source on GitHub ↗
(bv: BinaryView, start: int, end: int)

Source from the content-addressed store, hash-verified

29 pass
30
31def make_code(bv: BinaryView, start: int, end: int) -> None:
32 if bv.get_basic_blocks_at(start):
33 return
34 if end - start <= 1:
35 # find the next basic block, data variable, or segment/section end
36 data_var = bv.get_next_data_var_after(start)
37 if data_var is not None:
38 end = data_var.address
39 else:
40 end = bv.end
41 end = min(bv.get_next_basic_block_start_after(start), end)
42 seg = bv.get_segment_at(start)
43 if seg is not None:
44 end = min(seg.end, end)
45 section_ends = [s.end for s in bv.get_sections_at(start)]
46 end = min(*section_ends, end)
47 bv.define_user_data_var(start, Type.array(Type.int(1, False), end-start), f"CODE_{start:08x}")
48
49def make_code_helper(ctx: UIActionContext):
50 make_code(ctx.binaryView, ctx.address, ctx.address + ctx.length)

Callers 1

make_code_helperFunction · 0.85

Calls 8

get_basic_blocks_atMethod · 0.80
get_segment_atMethod · 0.80
get_sections_atMethod · 0.80
define_user_data_varMethod · 0.45
arrayMethod · 0.45
intMethod · 0.45

Tested by

no test coverage detected