Search in sources :

Example 46 with INaviView

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

the class Project method createView.

// ! Creates a copy of a view.
/**
   * Creates a new view by copying an existing view.
   *
   * @param view The view to copy.
   * @param name The name of the new view.
   * @param description The description of the new view.
   *
   * @return The created view.
   *
   * @throws CouldntSaveDataException Thrown if the view could not be created.
   */
public View createView(final View view, final String name, final String description) throws CouldntSaveDataException {
    if (!isLoaded()) {
        throw new IllegalStateException("Error: The project has not yet been loaded");
    }
    Preconditions.checkNotNull(view, "Error: View argument can't be null");
    final INaviView newView = m_project.getContent().createView(view.getNative(), name, description);
    return ObjectFinders.getObject(newView, m_views);
}
Also used : INaviView(com.google.security.zynamics.binnavi.disassembly.views.INaviView)

Example 47 with INaviView

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

the class CNativeCallgraphsViewsModel method setValueAt.

@Override
public void setValueAt(final Object value, final int row, final int column) {
    if (column == DESCRIPTION_COLUMN) {
        final INaviView view = m_module.getContent().getViewContainer().getNativeCallgraphView();
        try {
            view.getConfiguration().setDescription((String) value);
            fireTableDataChanged();
        } catch (final CouldntSaveDataException e) {
            // TODO: Improve this
            CUtilityFunctions.logException(e);
        }
    }
}
Also used : INaviView(com.google.security.zynamics.binnavi.disassembly.views.INaviView) CouldntSaveDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException)

Example 48 with INaviView

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

the class CReilViewCreator method create.

/**
   * Creates a REIL view object from a REIL graph.
   * 
   * @param container The container in which the new REIL view is created.
   * @param graph The graph that contains the REIL code to be shown in the view.
   * 
   * @return The created REIL code view.
   */
public static INaviView create(final INaviModule container, final ReilGraph graph) {
    Preconditions.checkNotNull(container, "IE01809: Container argument can not be null");
    Preconditions.checkNotNull(graph, "IE01815: Graph argument can not be null");
    final INaviView view = container.getContent().getViewContainer().createView("REIL View", "");
    final Map<ReilBlock, CCodeNode> nodeMap = new HashMap<ReilBlock, CCodeNode>();
    for (final ReilBlock block : graph) {
        final List<INaviInstruction> instructions = new ArrayList<INaviInstruction>();
        for (final ReilInstruction reilInstruction : block) {
            final List<COperandTree> operands = new ArrayList<COperandTree>();
            if (reilInstruction.getFirstOperand().getType() == OperandType.EMPTY) {
                operands.add(getEmptyOperand(container));
            } else {
                operands.add(convert(container, reilInstruction.getFirstOperand()));
            }
            if (reilInstruction.getSecondOperand().getType() == OperandType.EMPTY) {
                operands.add(getEmptyOperand(container));
            } else {
                operands.add(convert(container, reilInstruction.getSecondOperand()));
            }
            if (reilInstruction.getThirdOperand().getType() == OperandType.EMPTY) {
                operands.add(getEmptyOperand(container));
            } else {
                operands.add(convert(container, reilInstruction.getThirdOperand()));
            }
            final INaviInstruction convertedInstruction = container.createInstruction(reilInstruction.getAddress(), reilInstruction.getMnemonic(), operands, new byte[0], "REIL");
            instructions.add(convertedInstruction);
        }
        final CCodeNode node = view.getContent().createCodeNode(null, instructions);
        node.setColor(ConfigManager.instance().getColorSettings().getBasicBlocksColor());
        nodeMap.put(block, node);
    }
    for (final ReilEdge edge : graph.getEdges()) {
        final CNaviViewEdge reilEdge = view.getContent().createEdge(nodeMap.get(edge.getSource()), nodeMap.get(edge.getTarget()), edge.getType());
        EdgeInitializer.adjustColor(reilEdge);
    }
    return view;
}
Also used : ReilInstruction(com.google.security.zynamics.reil.ReilInstruction) HashMap(java.util.HashMap) ReilEdge(com.google.security.zynamics.reil.ReilEdge) ReilBlock(com.google.security.zynamics.reil.ReilBlock) ArrayList(java.util.ArrayList) CNaviViewEdge(com.google.security.zynamics.binnavi.disassembly.CNaviViewEdge) INaviView(com.google.security.zynamics.binnavi.disassembly.views.INaviView) CCodeNode(com.google.security.zynamics.binnavi.disassembly.CCodeNode) COperandTree(com.google.security.zynamics.binnavi.disassembly.COperandTree) INaviInstruction(com.google.security.zynamics.binnavi.disassembly.INaviInstruction)

Example 49 with INaviView

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

the class CFunctionViewsModel method setValueAt.

@Override
public final void setValueAt(final Object value, final int row, final int column) {
    final INaviView view = getViews().get(row);
    if (column == DESCRIPTION_COLUMN) {
        try {
            view.getConfiguration().setDescription((String) value);
        } catch (final Exception e) {
            CUtilityFunctions.logException(e);
            final String innerMessage = "E00188: " + "View name could not be changed";
            final String innerDescription = CUtilityFunctions.createDescription(String.format("The view name of view '%s' could not be changed.", view.getName()), new String[] { "There was a problem with the database connection." }, new String[] { "The view was not updated and the new view name is lost." });
            NaviErrorDialog.show(null, innerMessage, innerDescription, e);
        }
    } else if (column == FUNCTIONNAME_COLUM) {
        try {
            view.getConfiguration().setName((String) value);
        } catch (final Exception e) {
            CUtilityFunctions.logException(e);
            final String innerMessage = "E00189: " + "View description could not be changed";
            final String innerDescription = CUtilityFunctions.createDescription(String.format("The view description of view '%s' could not be changed.", view.getName()), new String[] { "There was a problem with the database connection." }, new String[] { "The view was not updated and the new view description is lost." });
            NaviErrorDialog.show(null, innerMessage, innerDescription, e);
        }
    }
}
Also used : INaviView(com.google.security.zynamics.binnavi.disassembly.views.INaviView)

Example 50 with INaviView

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

the class CViewPruner method prune.

/**
   * Creates a new view from the results of an operand tracking operation.
   *
   * @param container Container where the new view is created.
   * @param view Input view that provides the data.
   * @param keptInstructions Instructions to add to the new view.
   *
   * @return The new view.
   */
public static INaviView prune(final IViewContainer container, final INaviView view, final List<INaviInstruction> keptInstructions) {
    final INaviView prunedView = container.createView("Pruned View", "");
    final Map<INaviViewNode, INaviViewNode> nodeMap = convertNodes(view, prunedView, keptInstructions);
    convertEdges(view, prunedView, nodeMap);
    return prunedView;
}
Also used : INaviView(com.google.security.zynamics.binnavi.disassembly.views.INaviView) INaviViewNode(com.google.security.zynamics.binnavi.disassembly.INaviViewNode)

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