|
49 | 49 | if sys.version_info > (3,): |
50 | 50 | long = int |
51 | 51 |
|
| 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 | + |
52 | 66 |
|
53 | 67 | def graph_il_insn(g, head, il, label=None): |
54 | 68 | # type: (FlowGraph, FlowGraphNode, LowLevelILInstruction, Optional[str]) -> None |
@@ -107,6 +121,27 @@ def graph_il_insn(g, head, il, label=None): |
107 | 121 | InstructionTextTokenType.IntegerToken, "{:x}".format(il), value=il |
108 | 122 | ) |
109 | 123 | ) |
| 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") |
110 | 145 | else: |
111 | 146 | tokens.append( |
112 | 147 | InstructionTextToken(InstructionTextTokenType.TextToken, str(il)) |
@@ -216,7 +251,7 @@ def graph_bnil(bv, addr): |
216 | 251 |
|
217 | 252 | graph_ils(bv, g, head, function, addr) |
218 | 253 |
|
219 | | - g.show("Instruction Graph ({:#x})".format(addr)) |
| 254 | + show_graph_report(bv, g, "Instruction Graph ({:#x})".format(addr)) |
220 | 255 |
|
221 | 256 |
|
222 | 257 | def match_condition(name, o): |
@@ -277,6 +312,14 @@ def match_condition(name, o): |
277 | 312 | match += ["if {}.version != {}:".format(name, o.version)] |
278 | 313 | match += [" return False\n"] |
279 | 314 |
|
| 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 | + |
280 | 323 | else: |
281 | 324 | match += ["if {} != {}:".format(name, o)] |
282 | 325 | match += [" return False\n"] |
|
0 commit comments