Search in sources :

Example 1 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 2 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 3 with INaviView

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

the class CDataflowViewCreator method create.

/**
 * Creates a new dataflow view.
 *
 * @param container The container in which the dataflow view is created.
 * @param view The normal view that provides the control-flow information.
 *
 * @return The created dataflow view.
 *
 * @throws InternalTranslationException Thrown if the input view could not be translated to REIL.
 */
public static INaviView create(final IViewContainer container, final INaviView view) throws InternalTranslationException {
    Preconditions.checkNotNull(container, "IE00411: Module argument can not be null");
    Preconditions.checkNotNull(view, "IE00414: View argument can not be null");
    final Map<IAddress, INaviInstruction> instructions = new HashMap<IAddress, INaviInstruction>();
    for (final CCodeNode codeNode : view.getBasicBlocks()) {
        for (final INaviInstruction instruction : codeNode.getInstructions()) {
            instructions.put(instruction.getAddress(), instruction);
        }
    }
    final ReilFunction function = view.getContent().getReilCode();
    final OperandGraph operandGraph = OperandGraph.create(function.getGraph());
    final INaviView dfView = container.createView(String.format("Data flow view of '%s'", view.getName()), "");
    final Map<OperandGraphNode, INaviCodeNode> nodeMap = new HashMap<OperandGraphNode, INaviCodeNode>();
    final Map<INaviInstruction, CCodeNode> instructionMap = new HashMap<INaviInstruction, CCodeNode>();
    for (final OperandGraphNode operandGraphNode : operandGraph) {
        final ReilInstruction reilInstruction = operandGraphNode.getInstruction();
        final INaviInstruction instruction = instructions.get(ReilHelpers.toNativeAddress(reilInstruction.getAddress()));
        if (instructionMap.containsKey(instruction)) {
            nodeMap.put(operandGraphNode, instructionMap.get(instruction));
            continue;
        }
        final CCodeNode codeNode = dfView.getContent().createCodeNode(null, Lists.newArrayList(instruction));
        codeNode.setColor(ConfigManager.instance().getColorSettings().getBasicBlocksColor());
        nodeMap.put(operandGraphNode, codeNode);
        instructionMap.put(instruction, codeNode);
    }
    for (final OperandGraphEdge edge : operandGraph.getEdges()) {
        final INaviCodeNode source = nodeMap.get(edge.getSource());
        final INaviCodeNode target = nodeMap.get(edge.getTarget());
        if (source.equals(target)) {
            continue;
        }
        dfView.getContent().createEdge(source, target, EdgeType.JUMP_UNCONDITIONAL);
    }
    return dfView;
}
Also used : ReilInstruction(com.google.security.zynamics.reil.ReilInstruction) HashMap(java.util.HashMap) ReilFunction(com.google.security.zynamics.reil.ReilFunction) IAddress(com.google.security.zynamics.zylib.disassembly.IAddress) OperandGraph(com.google.security.zynamics.reil.algorithms.mono.OperandGraph) INaviCodeNode(com.google.security.zynamics.binnavi.disassembly.INaviCodeNode) INaviView(com.google.security.zynamics.binnavi.disassembly.views.INaviView) OperandGraphEdge(com.google.security.zynamics.reil.algorithms.mono.OperandGraphEdge) CCodeNode(com.google.security.zynamics.binnavi.disassembly.CCodeNode) OperandGraphNode(com.google.security.zynamics.reil.algorithms.mono.OperandGraphNode) INaviInstruction(com.google.security.zynamics.binnavi.disassembly.INaviInstruction)

Example 4 with INaviView

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

the class TypeInstanceContainerBackend method loadTypeInstanceReference.

/**
 * Load a single type instance reference from the database.
 *
 * @param typeInstanceId the id of the {@link TypeInstanceReference reference}.
 * @param address The address of the {@link INaviInstruction instruction} where the
 *        {@link TypeInstanceReference reference} is associated.
 * @param position The {@link OperandTree operand tree} position in the {@link INaviInstruction
 *        instruction} the {@link TypeInstanceReference reference} is associated to.
 * @param expressionId The {@link OperandTreeNode operand tree node} id within the
 *        {@link OperandTree operand tree}.
 *
 * @return The {@link TypeInstanceReference} loaded from the database.
 * @throws CouldntLoadDataException
 */
public TypeInstanceReference loadTypeInstanceReference(final Integer typeInstanceId, final BigInteger address, final Integer position, final Integer expressionId) throws CouldntLoadDataException {
    Preconditions.checkNotNull(typeInstanceId, "Error: typeInstanceId argument can not be null");
    Preconditions.checkNotNull(address, "Error: address argument can not be null");
    Preconditions.checkNotNull(position, "Error: position argument can not be null");
    Preconditions.checkNotNull(expressionId, "Error: expressionId argument can not be null");
    final RawTypeInstanceReference rawReference = provider.loadTypeInstanceReference(module, typeInstanceId, address, position, expressionId);
    final TypeInstance typeInstance = instancesById.get(rawReference.getTypeInstanceId());
    final INaviView view = module.getContent().getViewContainer().getView(rawReference.getViewId());
    final TypeInstanceReference reference = new TypeInstanceReference(new CAddress(address), position, Optional.<INaviOperandTreeNode>absent(), typeInstance, view);
    referenceLookup.put(new InstanceReferenceLookup(new CAddress(address), position, expressionId), reference);
    return reference;
}
Also used : INaviView(com.google.security.zynamics.binnavi.disassembly.views.INaviView) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress)

Example 5 with INaviView

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

the class CViewContainer method delete.

private void delete(final INaviView view) {
    final INaviView currentStoredView = m_customViews.get(m_customViews.indexOf(view));
    m_customViews.remove(currentStoredView);
    viewIdView.remove(view.getConfiguration().getId());
    currentStoredView.removeListener(m_viewListener);
    for (final IModuleListener listener : m_listeners) {
        try {
            listener.deletedView(m_module, currentStoredView);
        } catch (final Exception exception) {
            CUtilityFunctions.logException(exception);
        }
    }
}
Also used : INaviView(com.google.security.zynamics.binnavi.disassembly.views.INaviView) LoadCancelledException(com.google.security.zynamics.binnavi.Database.Exceptions.LoadCancelledException) CouldntSaveDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException) CouldntLoadDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException) CPartialLoadException(com.google.security.zynamics.binnavi.Database.Exceptions.CPartialLoadException) CouldntDeleteException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntDeleteException)

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