Skip to content

Commit 8028591

Browse files
author
Ryan Stortz
committed
Initial HLIL support
1 parent 6492b2f commit 8028591

File tree

2 files changed

+24
-5
lines changed

2 files changed

+24
-5
lines changed

__init__.py

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def graph_il_insn(g, head, il, label=None):
8282
]
8383
)
8484

85-
if isinstance(il, (MediumLevelILInstruction, LowLevelILInstruction)):
85+
if isinstance(il, (HighLevelILInstruction, MediumLevelILInstruction, LowLevelILInstruction)):
8686

8787
tokens.append(
8888
InstructionTextToken(
@@ -157,7 +157,7 @@ def graph_il(g, head, type, il):
157157

158158
il_desc = binaryninja.FlowGraphNode(g)
159159

160-
il_desc.lines = [
160+
lines = [
161161
"{}".format(type),
162162
"",
163163
DisassemblyTextLine(
@@ -177,9 +177,17 @@ def graph_il(g, head, type, il):
177177
),
178178
]
179179
),
180-
il.tokens,
181180
]
182181

182+
183+
if hasattr(il, 'lines'):
184+
for line in il.lines:
185+
lines.append(line.tokens)
186+
else:
187+
lines.append(il.tokens)
188+
189+
il_desc.lines = lines
190+
183191
graph_il_insn(g, il_desc, il, "operation")
184192
g.append(il_desc)
185193

@@ -200,6 +208,7 @@ def collect_ils(bv, func):
200208

201209
llil = func.low_level_il
202210
mlil = func.medium_level_il
211+
hlil = func.high_level_il
203212
show_common = Settings().get_bool("bnil-graph.showCommon")
204213
show_mapped = Settings().get_bool("bnil-graph.showMapped")
205214
show_ssa = Settings().get_bool("bnil-graph.showSSA")
@@ -213,6 +222,10 @@ def collect_ils(bv, func):
213222
for mil in block:
214223
lookup["MediumLevelIL"][mil.address].append(mil)
215224

225+
for block in hlil:
226+
for hil in block:
227+
lookup["HighLevelIL"][hil.address].append(hil)
228+
216229
if show_ssa:
217230
for block in llil.ssa_form:
218231
for il in block:
@@ -222,6 +235,10 @@ def collect_ils(bv, func):
222235
for mil in block:
223236
lookup["MediumLevelILSSA"][mil.address].append(mil)
224237

238+
for block in hlil.ssa_form:
239+
for hil in block:
240+
lookup["HighLevelILSSA"][hil.address].append(hil)
241+
225242
if show_mapped:
226243
mmlil = llil.mapped_medium_level_il
227244
for block in mmlil:
@@ -257,11 +274,13 @@ def graph_bnil(bv, addr):
257274
def match_condition(name, o):
258275
match = []
259276

260-
if isinstance(o, (LowLevelILInstruction, MediumLevelILInstruction)):
277+
if isinstance(o, (LowLevelILInstruction, MediumLevelILInstruction, HighLevelILInstruction)):
261278
if isinstance(o, LowLevelILInstruction):
262279
operation_class = "LowLevelILOperation"
263280
elif isinstance(o, MediumLevelILInstruction):
264281
operation_class = "MediumLevelILOperation"
282+
elif isinstance(o, HighLevelILInstruction):
283+
operation_class = "HighLevelILOperation"
265284

266285
match += ["# {}".format(str(o))]
267286
match += [

plugin.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@
2525
"Windows": "",
2626
"Linux": ""
2727
},
28-
"version": "1.2.2",
28+
"version": "1.3.0",
2929
"minimumbinaryninjaversion": 0
3030
}

0 commit comments

Comments
 (0)