Skip to content

Commit 534f410

Browse files
xusheng6withzombies
authored andcommitted
Only collect ILs if when are available
1 parent 6c34afa commit 534f410

File tree

1 file changed

+36
-29
lines changed

1 file changed

+36
-29
lines changed

__init__.py

Lines changed: 36 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -231,49 +231,56 @@ def graph_ils(bv, g, head, func, addr):
231231
def collect_ils(bv, func):
232232
lookup = defaultdict(lambda: defaultdict(list))
233233

234-
llil = func.low_level_il
235-
mlil = func.medium_level_il
236-
hlil = func.high_level_il
234+
llil = func.llil_if_available
235+
mlil = func.mlil_if_available
236+
hlil = func.hlil_if_available
237237
show_common = Settings().get_bool("bnil-graph.showCommon")
238238
show_mapped = Settings().get_bool("bnil-graph.showMapped")
239239
show_ssa = Settings().get_bool("bnil-graph.showSSA")
240240

241241
if show_common:
242-
for block in llil:
243-
for il in block:
244-
lookup["LowLevelIL"][il.address].append(il)
242+
if llil is not None:
243+
for block in llil:
244+
for il in block:
245+
lookup["LowLevelIL"][il.address].append(il)
245246

246-
for block in mlil:
247-
for mil in block:
248-
lookup["MediumLevelIL"][mil.address].append(mil)
247+
if mlil is not None:
248+
for block in mlil:
249+
for mil in block:
250+
lookup["MediumLevelIL"][mil.address].append(mil)
249251

250-
for block in hlil:
251-
for hil in block:
252-
lookup["HighLevelIL"][hil.address].append(hil)
252+
if hlil is not None:
253+
for block in hlil:
254+
for hil in block:
255+
lookup["HighLevelIL"][hil.address].append(hil)
253256

254257
if show_ssa:
255-
for block in llil.ssa_form:
256-
for il in block:
257-
lookup["LowLevelILSSA"][il.address].append(il)
258+
if llil is not None and llil.ssa_form is not None:
259+
for block in llil.ssa_form:
260+
for il in block:
261+
lookup["LowLevelILSSA"][il.address].append(il)
258262

259-
for block in mlil.ssa_form:
260-
for mil in block:
261-
lookup["MediumLevelILSSA"][mil.address].append(mil)
263+
if mlil is not None and mlil.ssa_form is not None:
264+
for block in mlil.ssa_form:
265+
for mil in block:
266+
lookup["MediumLevelILSSA"][mil.address].append(mil)
262267

263-
for block in hlil.ssa_form:
264-
for hil in block:
265-
lookup["HighLevelILSSA"][hil.address].append(hil)
268+
if hlil is not None and hlil.ssa_form is not None:
269+
for block in hlil.ssa_form:
270+
for hil in block:
271+
lookup["HighLevelILSSA"][hil.address].append(hil)
266272

267273
if show_mapped:
268-
mmlil = llil.mapped_medium_level_il
269-
for block in mmlil:
270-
for mil in block:
271-
lookup["MappedMediumLevelIL"][mil.address].append(mil)
272-
273-
if show_ssa:
274-
for block in mmlil.ssa_form:
274+
if llil is not None and llil.mapped_medium_level_il is not None:
275+
mmlil = llil.mapped_medium_level_il
276+
for block in mmlil:
275277
for mil in block:
276-
lookup["MappedMediumLevelILSSA"][mil.address].append(mil)
278+
lookup["MappedMediumLevelIL"][mil.address].append(mil)
279+
280+
if show_ssa:
281+
for block in mmlil.ssa_form:
282+
for mil in block:
283+
lookup["MappedMediumLevelILSSA"][mil.address].append(mil)
277284

278285
return lookup
279286

0 commit comments

Comments
 (0)