Skip to content

Commit 6492b2f

Browse files
author
Ryan Stortz
committed
SSA Variables and new graph api
* Support SSARegisters, SSAVariables, and Variables in the grapher * Support SSAVariables in the match generator * Update to use newly fixed graph display api
1 parent 058a071 commit 6492b2f

File tree

2 files changed

+45
-2
lines changed

2 files changed

+45
-2
lines changed

__init__.py

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,20 @@
4949
if sys.version_info > (3,):
5050
long = int
5151

52+
def show_graph_report(bv, g, name):
53+
54+
# 1.3.2086-dev
55+
major, minor, patch = binaryninja.core_version().split('.')
56+
major = int(major)
57+
minor = int(minor)
58+
patch = int(patch.split('-')[0])
59+
60+
if major == 1 and minor <= 3 and patch < 2086:
61+
g.show(name)
62+
return
63+
64+
bv.show_graph_report(name, g)
65+
5266

5367
def graph_il_insn(g, head, il, label=None):
5468
# type: (FlowGraph, FlowGraphNode, LowLevelILInstruction, Optional[str]) -> None
@@ -107,6 +121,27 @@ def graph_il_insn(g, head, il, label=None):
107121
InstructionTextTokenType.IntegerToken, "{:x}".format(il), value=il
108122
)
109123
)
124+
elif isinstance(il, lowlevelil.SSARegister):
125+
tokens.append(
126+
InstructionTextToken(InstructionTextTokenType.TextToken, "<SSARegister>")
127+
)
128+
129+
graph_il_insn(g, record, il.reg, "reg")
130+
graph_il_insn(g, record, il.version, "version")
131+
elif isinstance(il, mediumlevelil.SSAVariable):
132+
tokens.append(
133+
InstructionTextToken(InstructionTextTokenType.TextToken, "<SSAVariable>")
134+
)
135+
136+
graph_il_insn(g, record, il.var, "var")
137+
graph_il_insn(g, record, il.version, "version")
138+
elif isinstance(il, function.Variable):
139+
tokens.append(
140+
InstructionTextToken(InstructionTextTokenType.TextToken, "<Variable>")
141+
)
142+
143+
graph_il_insn(g, record, il.name, "name")
144+
graph_il_insn(g, record, il.type, "type")
110145
else:
111146
tokens.append(
112147
InstructionTextToken(InstructionTextTokenType.TextToken, str(il))
@@ -216,7 +251,7 @@ def graph_bnil(bv, addr):
216251

217252
graph_ils(bv, g, head, function, addr)
218253

219-
g.show("Instruction Graph ({:#x})".format(addr))
254+
show_graph_report(bv, g, "Instruction Graph ({:#x})".format(addr))
220255

221256

222257
def match_condition(name, o):
@@ -277,6 +312,14 @@ def match_condition(name, o):
277312
match += ["if {}.version != {}:".format(name, o.version)]
278313
match += [" return False\n"]
279314

315+
elif isinstance(o, SSAVariable):
316+
match += ["if {}.var.name != '{}':".format(name, o.var.name)]
317+
match += [" return False\n"]
318+
319+
match += ["if {}.version != {}:".format(name, o.version)]
320+
match += [" return False\n"]
321+
322+
280323
else:
281324
match += ["if {} != {}:".format(name, o)]
282325
match += [" return False\n"]

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.1",
28+
"version": "1.2.2",
2929
"minimumbinaryninjaversion": 0
3030
}

0 commit comments

Comments
 (0)