def find_bbls(function_ea):
'''
yields all basic blocks that belong to the
given function. The blocks are returned in
a 2-tuple like:
(start_address, end_address)
Both start and end address are RELATIVE offsets
from the image base.
'''
# get image base from IDA
image_base = idaapi.get_imagebase()
function_ea += image_base
# get flow chart from IDA
flow_chart = idaapi.FlowChart(
idaapi.get_func(function_ea),
flags=idaapi.FC_PREDS
)
# iterate through all basic blocks in
# the current routine
for block in flow_chart:
start_addr = block.startEA - image_base
end_addr = block.endEA - image_base
if start_addr != end_addr:
yield start_addr, end_addr
评论列表
文章目录