(function, offset, mode, form, showOpcodes, showAddresses, origname)
| 112 | return f"rgb({r}, {g}, {b})" |
| 113 | |
| 114 | def 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'''<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; |
no test coverage detected