Search in sources :

Example 86 with INaviFunction

use of com.google.security.zynamics.binnavi.disassembly.INaviFunction in project binnavi by google.

the class CCrossReferencesPanel method processRemovedNode.

/**
   * Processes a removed node and updates the references list accordingly.
   *
   * @param node The node to remove.
   *
   * @return True, if the removed node was the last node with its parent function in the graph.
   */
private boolean processRemovedNode(final INaviViewNode node) {
    if (node instanceof INaviCodeNode) {
        final INaviCodeNode cnode = (INaviCodeNode) node;
        try {
            final INaviFunction targetFunction = cnode.getParentFunction();
            if (m_nodeCounter.containsKey(targetFunction)) {
                final int newCounter = m_nodeCounter.get(targetFunction) - 1;
                if (newCounter == 0) {
                    m_nodeCounter.remove(targetFunction);
                    final Set<CCrossReference> toDelete = new HashSet<CCrossReference>();
                    for (final CCrossReference reference : m_crossReferences) {
                        if (reference.getCalledFunction() == targetFunction) {
                            toDelete.add(reference);
                        }
                    }
                    m_crossReferences.removeAll(toDelete);
                    return true;
                } else {
                    m_nodeCounter.put(targetFunction, newCounter);
                }
            }
        // else
        // {
        // TODO: How is this even possible?
        // }
        } catch (final MaybeNullException exception) {
        // Code nodes that do not have a parent function can obviously not be called.
        }
    }
    return false;
}
Also used : INaviCodeNode(com.google.security.zynamics.binnavi.disassembly.INaviCodeNode) MaybeNullException(com.google.security.zynamics.binnavi.Exceptions.MaybeNullException) INaviFunction(com.google.security.zynamics.binnavi.disassembly.INaviFunction) HashSet(java.util.HashSet)

Example 87 with INaviFunction

use of com.google.security.zynamics.binnavi.disassembly.INaviFunction in project binnavi by google.

the class CViewsTableRenderer method getTableCellRendererComponent.

@Override
public Component getTableCellRendererComponent(final JTable table, final Object value, final boolean isSelected, final boolean hasFocus, final int row, final int column) {
    final INaviView view = this.table.getUnsortedView(row);
    if (view == null) {
        return new JLabel("No cross references");
    }
    final INaviFunction function = container.getFunction(view);
    if ((column == 0) && (function != null)) {
        final IDebugger debugger = container.getDebuggerProvider().getDebugger(function.getModule());
        if (debugger != null) {
            return new CAddressLabel(table, view, debugger, function, getBackgroundColor(this.table, isSelected, function.getType(), view.getGraphType()), null);
        }
    }
    return new ViewLabel(value, isSelected, row, column, null);
}
Also used : INaviView(com.google.security.zynamics.binnavi.disassembly.views.INaviView) JLabel(javax.swing.JLabel) INaviFunction(com.google.security.zynamics.binnavi.disassembly.INaviFunction) IDebugger(com.google.security.zynamics.binnavi.debug.debugger.interfaces.IDebugger)

Example 88 with INaviFunction

use of com.google.security.zynamics.binnavi.disassembly.INaviFunction in project binnavi by google.

the class CFunctionViewsModel method getValueAt.

@Override
public final Object getValueAt(final int row, final int col) {
    final List<INaviView> views = m_cachedValues == null ? getViews() : m_cachedValues;
    final INaviView view = views.get(row);
    final INaviFunction function = m_module.getContent().getViewContainer().getFunction(view);
    Preconditions.checkNotNull(function, "IE01189: View without known function");
    switch(col) {
        case ADDRESS_COLUM:
            return function.getAddress().toHexString();
        case FUNCTIONNAME_COLUM:
            return new CFunctionNameTypePair(view.getName(), function.getType());
        case DESCRIPTION_COLUMN:
            return view.getConfiguration().getDescription();
        case MODULE_COLUMN:
            return function.getOriginalModulename();
        case FORWARDER_COLUMN:
            return getForwarderColumnText(function);
        case BASICBLOCK_COUNT_COLUMN:
            return getNodeCount(view, function);
        case EDGE_COUNT_COLUMN:
            return getEdgeCount(view, function);
        case INCOMING_CALLS_COUNT_COLUMN:
            return function.getIndegree();
        case OUTGOING_CALLS_COUNT_COLUMN:
            return function.getOutdegree();
        default:
            throw new IllegalStateException("IE02245: Unknown column");
    }
}
Also used : INaviView(com.google.security.zynamics.binnavi.disassembly.views.INaviView) INaviFunction(com.google.security.zynamics.binnavi.disassembly.INaviFunction)

Example 89 with INaviFunction

use of com.google.security.zynamics.binnavi.disassembly.INaviFunction in project binnavi by google.

the class CFunctionViewsModel method delete.

@Override
public void delete() {
    m_module.removeListener(m_moduleListener);
    if (m_activeDebugger != null) {
        final BreakpointManager manager = m_activeDebugger.getBreakpointManager();
        manager.removeListener(m_breakpointManagerListener);
    }
    if (m_module.isLoaded()) {
        for (final IFlowgraphView view : m_module.getContent().getViewContainer().getNativeFlowgraphViews()) {
            view.removeListener(m_viewListener);
        }
        for (final INaviFunction function : m_module.getContent().getFunctionContainer().getFunctions()) {
            function.removeListener(m_viewListener);
        }
    }
}
Also used : IFlowgraphView(com.google.security.zynamics.binnavi.disassembly.IFlowgraphView) BreakpointManager(com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointManager) INaviFunction(com.google.security.zynamics.binnavi.disassembly.INaviFunction)

Example 90 with INaviFunction

use of com.google.security.zynamics.binnavi.disassembly.INaviFunction in project binnavi by google.

the class CFunctionViewsModel method getForwarderColumnText.

/**
   * Calculates the content of the forwarder column for a given function.
   * 
   * @param function The function to check.
   * 
   * @return The text shown in the table for the forwarder column of the given function.
   */
private String getForwarderColumnText(final INaviFunction function) {
    final IAddress address = function.getForwardedFunctionAddress();
    if (address == null) {
        return "-";
    }
    final int moduleId = function.getForwardedFunctionModuleId();
    final INaviModule forwardedModule = m_database.getContent().getModule(moduleId);
    if (forwardedModule == null) {
        return "INVALID";
    } else if (!forwardedModule.isLoaded()) {
        return String.format("%s:%s", forwardedModule.getConfiguration().getName(), address.toHexString());
    }
    final INaviFunction forwardedFunction = forwardedModule.getContent().getFunctionContainer().getFunction(address);
    if (forwardedFunction == null) {
        return "INVALID";
    } else {
        return String.format("%s:%s", forwardedModule.getConfiguration().getName(), forwardedFunction.getName());
    }
}
Also used : INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) INaviFunction(com.google.security.zynamics.binnavi.disassembly.INaviFunction) IAddress(com.google.security.zynamics.zylib.disassembly.IAddress) Breakpoint(com.google.security.zynamics.binnavi.debug.models.breakpoints.Breakpoint)

Aggregations

INaviFunction (com.google.security.zynamics.binnavi.disassembly.INaviFunction)94 INaviModule (com.google.security.zynamics.binnavi.disassembly.INaviModule)39 Test (org.junit.Test)38 INaviView (com.google.security.zynamics.binnavi.disassembly.views.INaviView)26 INaviInstruction (com.google.security.zynamics.binnavi.disassembly.INaviInstruction)20 ExpensiveBaseTest (com.google.security.zynamics.binnavi.disassembly.types.ExpensiveBaseTest)16 IAddress (com.google.security.zynamics.zylib.disassembly.IAddress)16 INaviCodeNode (com.google.security.zynamics.binnavi.disassembly.INaviCodeNode)14 CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)14 CTag (com.google.security.zynamics.binnavi.Tagging.CTag)12 INaviViewNode (com.google.security.zynamics.binnavi.disassembly.INaviViewNode)12 ArrayList (java.util.ArrayList)12 MaybeNullException (com.google.security.zynamics.binnavi.Exceptions.MaybeNullException)11 MockView (com.google.security.zynamics.binnavi.disassembly.MockView)10 CCodeNode (com.google.security.zynamics.binnavi.disassembly.CCodeNode)9 FilledList (com.google.security.zynamics.zylib.types.lists.FilledList)9 HashMap (java.util.HashMap)9 CFunctionNode (com.google.security.zynamics.binnavi.disassembly.CFunctionNode)8 COperandTree (com.google.security.zynamics.binnavi.disassembly.COperandTree)8 INaviEdge (com.google.security.zynamics.binnavi.disassembly.INaviEdge)8