Search in sources :

Example 26 with INaviView

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

the class CEventTableMenu method addOpenFunction.

/**
   * Adds a menu item to open the selected trace.
   *
   * @param parent Parent window of the menu.
   * @param traces The selected traces.
   */
private void addOpenFunction(final Window parent, final List<ITraceEvent> traces) {
    if (traces.size() == 1) {
        final ITraceEvent trace = traces.get(0);
        final INaviModule module = trace.getOffset().getModule();
        if (module.isLoaded()) {
            final INaviFunction function = module.getContent().getFunctionContainer().getFunction(trace.getOffset().getAddress().getAddress());
            if (function != null) {
                final IViewContainer container = graphModel.getViewContainer();
                final INaviView view = container.getView(function);
                if (view != null) {
                    add(new JMenuItem(CActionProxy.proxy(new COpenInLastWindowAction(parent, container, new INaviView[] { view }))));
                    addSeparator();
                }
            }
        }
    }
}
Also used : IViewContainer(com.google.security.zynamics.binnavi.disassembly.views.IViewContainer) INaviView(com.google.security.zynamics.binnavi.disassembly.views.INaviView) INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) COpenInLastWindowAction(com.google.security.zynamics.binnavi.Gui.MainWindow.ProjectTree.Nodes.Views.Component.Actions.COpenInLastWindowAction) JMenuItem(javax.swing.JMenuItem) INaviFunction(com.google.security.zynamics.binnavi.disassembly.INaviFunction) ITraceEvent(com.google.security.zynamics.binnavi.debug.models.trace.interfaces.ITraceEvent)

Example 27 with INaviView

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

the class ZyGraph method saveAs.

/**
   * Creates a copy of the current native view and transfers the copied native view into the graph
   * object. That means that the graph object changes its underlying raw view when this function is
   * called.
   *
   * @param container The view container where the view is copied to.
   * @param name The new name of the raw view.
   * @param description The new description of the raw view.
   *
   * @return The new raw view.
   *
   * @throws CouldntSaveDataException Thrown if the view could not be saved.
   */
public INaviView saveAs(final IViewContainer container, final String name, final String description) throws CouldntSaveDataException {
    Preconditions.checkNotNull(container, "IE00871: Container argument can not be null");
    Preconditions.checkNotNull(name, "IE00872: Name argument can not be null");
    Preconditions.checkNotNull(description, "IE00899: Description argument can not be null");
    final INaviView oldView = m_rawView;
    final INaviView newView = container.createView(name, description);
    CViewInserter.insertView(oldView, newView);
    final List<INaviViewNode> oldNodes = oldView.getGraph().getNodes();
    final List<INaviViewNode> newNodes = newView.getGraph().getNodes();
    for (int i = 0; i < oldNodes.size(); i++) {
        final INaviViewNode newNode = newNodes.get(i);
        final NaviNode oldNode = getMappings().getNode(oldNodes.get(i));
        getMappings().setNode(newNode, oldNode);
        oldNode.setRawNode(newNode);
        for (final INaviGraphListener listener : m_listeners) {
            try {
                listener.changedModel(this, oldNode);
            } catch (final Exception exception) {
                CUtilityFunctions.logException(exception);
            }
        }
    }
    final List<INaviEdge> oldEdges = oldView.getGraph().getEdges();
    final List<INaviEdge> newEdges = newView.getGraph().getEdges();
    for (int i = 0; i < oldEdges.size(); i++) {
        final INaviEdge newEdge = newEdges.get(i);
        final NaviEdge oldEdge = getMappings().getEdge(oldEdges.get(i));
        assert oldEdge != null;
        getMappings().setEdge(newEdge, oldEdge);
        final ZyEdgeRealizer<NaviEdge> realizer = oldEdge.getRealizer();
        realizer.setUpdater(new CEdgeUpdater(newEdge));
        oldEdge.setRawEdge(newEdge);
    }
    removeListeners();
    newView.save();
    CSettingsFunctions.saveSettings(newView, getView(), m_settings);
    m_rawView = newView;
    initializeListeners();
    m_synchronizer.reset();
    for (final INaviGraphListener listener : m_listeners) {
        // ESCA-JAVA0166: Catch Exception here because we are calling a listener function.
        try {
            listener.changedView(oldView, newView);
        } catch (final Exception exception) {
            CUtilityFunctions.logException(exception);
        }
    }
    oldView.close();
    return m_rawView;
}
Also used : INaviView(com.google.security.zynamics.binnavi.disassembly.views.INaviView) CEdgeUpdater(com.google.security.zynamics.binnavi.ZyGraph.Updaters.CEdgeUpdater) INaviViewNode(com.google.security.zynamics.binnavi.disassembly.INaviViewNode) INaviGraphListener(com.google.security.zynamics.binnavi.ZyGraph.INaviGraphListener) INaviEdge(com.google.security.zynamics.binnavi.disassembly.INaviEdge) CouldntSaveDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException) INaviEdge(com.google.security.zynamics.binnavi.disassembly.INaviEdge)

Example 28 with INaviView

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

the class CViewsToTagHandler method drop.

@SuppressWarnings("unchecked")
@Override
public void drop(final DefaultMutableTreeNode parentNode, final Object data) {
    final List<INaviView> views = (List<INaviView>) data;
    final CTag tag = ((CTagNode) parentNode).getObject().getObject();
    for (final INaviView view : views) {
        CViewFunctions.tagView(m_parent, view, tag);
    }
}
Also used : INaviView(com.google.security.zynamics.binnavi.disassembly.views.INaviView) CTag(com.google.security.zynamics.binnavi.Tagging.CTag) List(java.util.List)

Example 29 with INaviView

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

the class CViewsToTagHandler method canHandle.

@SuppressWarnings("unchecked")
@Override
public boolean canHandle(final DefaultMutableTreeNode parentNode, final Object data) {
    if (parentNode instanceof CTagNode) {
        final List<INaviView> views = (List<INaviView>) data;
        final CTag tag = ((CTagNode) parentNode).getObject().getObject();
        for (final INaviView view : views) {
            if (!view.getConfiguration().isTagged(tag) && view.inSameDatabase(tag)) {
                return true;
            }
        }
        return false;
    }
    return false;
}
Also used : INaviView(com.google.security.zynamics.binnavi.disassembly.views.INaviView) CTag(com.google.security.zynamics.binnavi.Tagging.CTag) CTagNode(com.google.security.zynamics.binnavi.Gui.MainWindow.ProjectTree.Nodes.Tag.CTagNode) List(java.util.List)

Example 30 with INaviView

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

the class CNameListGenerators method getNameList.

/**
   * Generates a name list from the names of the given views.
   * 
   * @param views The views that provide the names.
   * 
   * @return The generated name list.
   */
public static String getNameList(final INaviView[] views) {
    int count = 0;
    final StringBuilder list = new StringBuilder();
    for (final INaviView view : views) {
        list.append("- ");
        list.append(view.getName());
        list.append('\n');
        count++;
        if ((count == MAX_LIST_LENGTH) && (views.length != MAX_LIST_LENGTH)) {
            list.append("\n... ");
            list.append(String.format("%d others ...", views.length - count));
            break;
        }
    }
    return list.toString();
}
Also used : INaviView(com.google.security.zynamics.binnavi.disassembly.views.INaviView)

Aggregations

INaviView (com.google.security.zynamics.binnavi.disassembly.views.INaviView)121 Test (org.junit.Test)54 INaviModule (com.google.security.zynamics.binnavi.disassembly.INaviModule)29 INaviFunction (com.google.security.zynamics.binnavi.disassembly.INaviFunction)26 ExpensiveBaseTest (com.google.security.zynamics.binnavi.disassembly.types.ExpensiveBaseTest)18 CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)14 INaviViewNode (com.google.security.zynamics.binnavi.disassembly.INaviViewNode)13 CTag (com.google.security.zynamics.binnavi.Tagging.CTag)11 INaviInstruction (com.google.security.zynamics.binnavi.disassembly.INaviInstruction)10 CView (com.google.security.zynamics.binnavi.disassembly.views.CView)10 ArrayList (java.util.ArrayList)10 CouldntLoadDataException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException)9 CouldntSaveDataException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException)8 HashMap (java.util.HashMap)8 MockSqlProvider (com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider)7 IComment (com.google.security.zynamics.binnavi.Gui.GraphWindows.CommentDialogs.Interfaces.IComment)7 CProjectContainer (com.google.security.zynamics.binnavi.disassembly.CProjectContainer)7 IAddress (com.google.security.zynamics.zylib.disassembly.IAddress)7 FilledList (com.google.security.zynamics.zylib.types.lists.FilledList)7 MockTagManager (com.google.security.zynamics.binnavi.Tagging.MockTagManager)6