MCPcopy Create free account
hub / github.com/Vector35/binaryninja-api / render_svg

Function render_svg

python/examples/export_svg.py:114–346  ·  view source on GitHub ↗
(function, offset, mode, form, showOpcodes, showAddresses, origname)

Source from the content-addressed store, hash-verified

112 return f"rgb({r}, {g}, {b})"
113
114def render_svg(function, offset, mode, form, showOpcodes, showAddresses, origname):
115 settings = DisassemblySettings()
116 if showOpcodes:
117 settings.set_option(DisassemblyOption.ShowOpcode, True)
118 if showAddresses:
119 settings.set_option(DisassemblyOption.ShowAddress, True)
120 if form == "LLIL":
121 graph_type = FunctionGraphType.LowLevelILFunctionGraph
122 elif form == "LLIL SSA":
123 graph_type = FunctionGraphType.LowLevelILSSAFormFunctionGraph
124 elif form == "Lifted IL":
125 graph_type = FunctionGraphType.LiftedILFunctionGraph
126 elif form == "Mapped Medium":
127 graph_type = FunctionGraphType.MappedMediumLevelILFunctionGraph
128 elif form == "Mapped Medium SSA":
129 graph_type = FunctionGraphType.MappedMediumLevelILSSAFormFunctionGraph
130 elif form == "MLIL":
131 graph_type = FunctionGraphType.MediumLevelILFunctionGraph
132 elif form == "MLIL SSA":
133 graph_type = FunctionGraphType.MediumLevelILSSAFormFunctionGraph
134 elif form == "HLIL":
135 graph_type = FunctionGraphType.HighLevelILFunctionGraph
136 elif form == "HLIL SSA":
137 graph_type = FunctionGraphType.HighLevelILSSAFormFunctionGraph
138 else:
139 graph_type = FunctionGraphType.NormalFunctionGraph
140 graph = function.create_graph(graph_type=graph_type, settings=settings)
141 graph.layout_and_wait()
142 heightconst = 15
143 ratio = 0.48
144 widthconst = heightconst * ratio
145
146 output = f''&#x27;<html>
147 <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="{graph.width * widthconst + 20}" height="{graph.height * heightconst + 20}">
148 <style type="text/css">
149 @import url(https://fonts.googleapis.com/css?family=Source+Code+Pro);
150 body {{
151 /* These colors are only for the bottom section, can tweak later */
152 background-color: rgb(42, 42, 42);
153 color: rgb(220, 220, 220);
154 font-family: "Source Code Pro", "Lucida Console", "Consolas", monospace;
155 }}
156 a, a:visited {{
157 color: rgb(200, 200, 200);
158 font-weight: bold;
159 }}
160 svg {{
161 background-color: {rgbStr('GraphBackgroundDarkColor')};
162 display: block;
163 margin: 0 auto;
164 }}
165 .basicblock {{
166 stroke: {rgbStr('GraphNodeOutlineColor')};
167 fill: {rgbStr('GraphNodeDarkColor')};
168 }}
169 .edge {{
170 fill: none;
171 stroke-width: 1px;

Callers 1

save_svgFunction · 0.85

Calls 9

set_optionMethod · 0.95
DisassemblySettingsClass · 0.90
rgbStrFunction · 0.85
instruction_data_flowFunction · 0.85
escapeFunction · 0.85
BranchTypeEnum · 0.85
layout_and_waitMethod · 0.80
create_graphMethod · 0.45

Tested by

no test coverage detected