def paint_nodes(self, nodes_coverage): """ Paint node level coverage defined by the current database mappings. """ # create a node info object as our vehicle for setting the node color node_info = idaapi.node_info_t() # # loop through every node that we have coverage data for, painting them # in the IDA graph view as applicable. # for node_coverage in nodes_coverage: node_metadata = node_coverage._database._metadata.nodes[ node_coverage.address] # assign the background color we would like to paint to this node node_info.bg_color = node_coverage.coverage_color # do the *actual* painting of a single node instance idaapi.set_node_info2(node_metadata.function.address, node_metadata.id, node_info, idaapi.NIF_BG_COLOR | idaapi.NIF_FRAME_COLOR) self._painted_nodes.add(node_metadata.address)
def set_color(self, color=None): for line in self.lines: line.color = color node_info = idaapi.node_info_t() node_info.bg_color = color idaapi.set_node_info2(self.startEA, self.id, node_info, idaapi.NIF_BG_COLOR)
def paint_node_coverage(nodes_metadata, nodes_coverage): """ Paint function graph nodes using the given node coverages. """ # create a node info object as our vehicle for setting the node color node_info = idaapi.node_info_t() # # loop through every node that we have coverage data for, painting them # in the IDA graph view as applicable. # for node_coverage in nodes_coverage.itervalues(): node_metadata = nodes_metadata[node_coverage.address] # assign the background color we would like to paint to this node node_info.bg_color = node_coverage.coverage_color # # remember, nodes may technically be 'shared' between functions, # so we need to paint the node in every function flowchart that # has a reference to it. # for function_address, node_id in node_metadata.ids.iteritems(): # do the *actual* painting of a single node instance idaapi.set_node_info2(function_address, node_id, node_info, idaapi.NIF_BG_COLOR | idaapi.NIF_FRAME_COLOR)
def unpaint_node_coverage(nodes_metadata, nodes_coverage): """ Unpaint function graph nodes using the given node coverages. """ # create a node info object as our vehicle for resetting the node color node_info = idaapi.node_info_t() node_info.bg_color = idc.DEFCOLOR # # loop through every node that we have coverage data for, clearing # their paint (color) in the IDA graph view as applicable. # for node_coverage in nodes_coverage.itervalues(): node_metadata = nodes_metadata[node_coverage.address] # # remember, nodes may technically be 'shared' between functions, # so we need to clear the node's paint in every function flowchart # that has a reference to it. # for function_address, node_id in node_metadata.ids.iteritems(): # do the *actual* painting of a single node instance idaapi.set_node_info2(function_address, node_id, node_info, idaapi.NIF_BG_COLOR | idaapi.NIF_FRAME_COLOR)
def set_color(self, color=None): for line in self.lines: line.color = color if color is None: idaapi.clr_node_info2(self._fc._q.bounds.startEA, self.id, idaapi.NIF_BG_COLOR) else: node_info = idaapi.node_info_t() node_info.bg_color = color idaapi.set_node_info2(self._fc._q.bounds.startEA, self.id, node_info, idaapi.NIF_BG_COLOR)
def color_block(ea=None, color=0x55ff7f): """http://reverseengineering.stackexchange.com/questions/10662/change-block-node-color-with-idapython and WanderingGlitch for the tip of refresh_idaview_anyway()""" func_top = fn.top() f = idaapi.get_func(ea) g = idaapi.FlowChart(f, flags=idaapi.FC_PREDS) bb_id = get_bb_id(g, ea) p = idaapi.node_info_t() p.bg_color = color idaapi.set_node_info2(func_top, bb_id, p, idaapi.NIF_BG_COLOR | idaapi.NIF_FRAME_COLOR) idaapi.refresh_idaview_anyway()
def color_nodes(function_address, nodes, color): """ Color a list of nodes within the function graph at function_address. """ # create node info object with specified color node_info = idaapi.node_info_t() node_info.bg_color = color # paint the specified nodes for node in nodes: idaapi.set_node_info2( function_address, node.id, node_info, idaapi.NIF_BG_COLOR | idaapi.NIF_FRAME_COLOR )
def SetBbColor(self, ea=None, color=0x55ff7f): ''' SetBbColor(ea, color) => None Set Color for selected base block (default color = green) Example: ida SetBbColor 0x456789 [0xFFFFFF] ''' def get_bb(graph, ea): for block in graph: if block.startEA <= ea and block.endEA > ea: return block f = idaapi.get_func(ea) g = idaapi.FlowChart(f, flags=idaapi.FC_PREDS) bb = get_bb(g, ea) # create color node p = idaapi.node_info_t() p.bg_color = color # Set Color idaapi.set_node_info2(f.start_ea, bb.id, p, idaapi.NIF_BG_COLOR | idaapi.NIF_FRAME_COLOR) idaapi.refresh_idaview_anyway() return None
def clear_nodes(self, nodes_metadata): """ Clear paint from the given graph nodes. """ # create a node info object as our vehicle for resetting the node color node_info = idaapi.node_info_t() node_info.bg_color = idc.DEFCOLOR # # loop through every node that we have metadata data for, clearing # their paint (color) in the IDA graph view as applicable. # for node_metadata in nodes_metadata: # do the *actual* painting of a single node instance idaapi.set_node_info2(node_metadata.function.address, node_metadata.id, node_info, idaapi.NIF_BG_COLOR | idaapi.NIF_FRAME_COLOR) self._painted_nodes.discard(node_metadata.address)