Search in sources :

Example 61 with CouldntLoadDataException

use of com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException in project binnavi by google.

the class CGraphGrouper method groupNodes.

/**
   * Creates a new group node from a list of nodes.
   * 
   * @param graph The graph where the group node is created.
   * @param nodes The nodes to be grouped.
   */
private static void groupNodes(final ZyGraph graph, final List<NaviNode> nodes) {
    final StringBuilder stringBuilder = new StringBuilder();
    final List<INaviViewNode> rawNodes = new ArrayList<INaviViewNode>();
    // ATTENTION: DO NOT MOVE THIS LINE BELOW THE REMOVEELEMENT LINE
    final INaviGroupNode commonParent = getCommonParent(nodes);
    for (final NaviNode node : nodes) {
        if (node.getRawNode().getParentGroup() != null) {
            node.getRawNode().getParentGroup().removeElement(node.getRawNode());
        }
        rawNodes.add(node.getRawNode());
        stringBuilder.append(determineNodeText(node));
        stringBuilder.append('\n');
    }
    final CGroupNode groupNode = graph.getRawView().getContent().createGroupNode(rawNodes);
    if (commonParent != null) {
        commonParent.addElement(groupNode);
    }
    try {
        groupNode.appendComment(stringBuilder.toString());
    } catch (CouldntSaveDataException | CouldntLoadDataException exception) {
        CUtilityFunctions.logException(exception);
    }
}
Also used : CouldntSaveDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException) CouldntLoadDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException) ArrayList(java.util.ArrayList) NaviNode(com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode) INaviViewNode(com.google.security.zynamics.binnavi.disassembly.INaviViewNode) INaviGroupNode(com.google.security.zynamics.binnavi.disassembly.INaviGroupNode) CGroupNode(com.google.security.zynamics.binnavi.disassembly.CGroupNode)

Example 62 with CouldntLoadDataException

use of com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException in project binnavi by google.

the class CGraphInliner method getFunctionToInline.

/**
   * Determines the function to inline with consideration of function forwarding.
   * 
   * @param parent Parent window used for dialogs.
   * @param viewContainer Contains the function to inline.
   * @param function The function to be inlined.
   * @param forwarderModuleId Module ID of the module the function is forwarded to.
   * @param forwarderAddress Address of the function the function is forwarded to. This argument can
   *        be null.
   * 
   * @return The function to be inlined.
   */
private static INaviFunction getFunctionToInline(final JFrame parent, final IViewContainer viewContainer, final INaviFunction function, final int forwarderModuleId, final IAddress forwarderAddress) {
    if (forwarderAddress == null) {
        return function;
    } else {
        final IDatabase database = viewContainer.getDatabase();
        final INaviModule module = database.getContent().getModule(forwarderModuleId);
        if (!viewContainer.containsModule(module)) {
            CMessageBox.showInformation(parent, String.format("You are trying to inline an external function into a module view. " + "This is not possible.\n" + "To inline external functions it is necessary to create projects."));
            return null;
        }
        if (!module.isLoaded()) {
            try {
                module.load();
            } catch (final CouldntLoadDataException | LoadCancelledException e) {
                CUtilityFunctions.logException(e);
                return null;
            }
        }
        return module.getContent().getFunctionContainer().getFunction(forwarderAddress);
    }
}
Also used : IDatabase(com.google.security.zynamics.binnavi.Database.Interfaces.IDatabase) INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) CouldntLoadDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException) LoadCancelledException(com.google.security.zynamics.binnavi.Database.Exceptions.LoadCancelledException)

Example 63 with CouldntLoadDataException

use of com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException in project binnavi by google.

the class CProject method load.

@Override
public void load() throws CouldntLoadDataException, LoadCancelledException {
    synchronized (m_loadReporter) {
        if (isLoaded()) {
            return;
        }
        m_isLoading = true;
        try {
            if (!m_loadReporter.report(ProjectLoadEvents.Starting)) {
                throw new LoadCancelledException();
            }
            if (!m_loadReporter.report(ProjectLoadEvents.LoadingAddressSpaces)) {
                throw new LoadCancelledException();
            }
            final List<CAddressSpace> addressSpaces = m_provider.loadAddressSpaces(this);
            for (final CAddressSpace space : addressSpaces) {
                space.load();
            }
            if (!m_loadReporter.report(ProjectLoadEvents.LoadingCallgraphViews)) {
                throw new LoadCancelledException();
            }
            final List<ICallgraphView> userCallgraphs = m_provider.loadCallgraphViews(this);
            if (!m_loadReporter.report(ProjectLoadEvents.LoadingFlowgraphViews)) {
                throw new LoadCancelledException();
            }
            final List<IFlowgraphView> userFlowgraphs = m_provider.loadFlowgraphs(this);
            if (!m_loadReporter.report(ProjectLoadEvents.LoadingMixedgraphViews)) {
                throw new LoadCancelledException();
            }
            final List<INaviView> userMixedgraphs = m_provider.loadMixedgraphs(this);
            if (!m_loadReporter.report(ProjectLoadEvents.LoadingTraces)) {
                throw new LoadCancelledException();
            }
            final List<TraceList> traces = m_provider.loadTraces(this);
            final ArrayList<INaviView> views = new ArrayList<INaviView>(userCallgraphs);
            views.addAll(userFlowgraphs);
            views.addAll(userMixedgraphs);
            m_content = new CProjectContent(this, m_listeners, m_provider, addressSpaces, views, new FilledList<TraceList>(traces));
        } catch (CouldntLoadDataException | LoadCancelledException e) {
            m_isLoading = false;
            throw e;
        } finally {
            m_loadReporter.report(ProjectLoadEvents.Finished);
        }
        for (final IProjectListener listener : m_listeners) {
            try {
                listener.loadedProject(this);
            } catch (final Exception exception) {
                CUtilityFunctions.logException(exception);
            }
        }
        m_isLoading = false;
    }
}
Also used : FilledList(com.google.security.zynamics.zylib.types.lists.FilledList) CouldntLoadDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException) ArrayList(java.util.ArrayList) 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) INaviView(com.google.security.zynamics.binnavi.disassembly.views.INaviView) TraceList(com.google.security.zynamics.binnavi.debug.models.trace.TraceList) LoadCancelledException(com.google.security.zynamics.binnavi.Database.Exceptions.LoadCancelledException) CAddressSpace(com.google.security.zynamics.binnavi.disassembly.AddressSpaces.CAddressSpace)

Example 64 with CouldntLoadDataException

use of com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException in project binnavi by google.

the class CViewLoader method load.

/**
   * Loads a view and shows an error message if the view can not be loaded.
   *
   * @param parent Parent window used for error dialogs.
   * @param container Context in which the view is loaded.
   * @param view View to be loaded.
   */
public static void load(final JFrame parent, final IViewContainer container, final INaviView view) {
    Preconditions.checkNotNull(parent, "IE00011: Parent argument can not be null");
    Preconditions.checkNotNull(container, "IE00012: Container argument can not be null");
    Preconditions.checkNotNull(view, "IE00013: View argument can not be null");
    if (view.isLoaded()) {
        return;
    }
    final ViewLoaderThread thread = new ViewLoaderThread(view);
    CProgressDialog.showEndless(parent, String.format("Loading view '%s'", view.getName()), thread);
    final Exception exception = thread.getException();
    if (exception != null) {
        if (exception instanceof CouldntLoadDataException) {
            CUtilityFunctions.logException(exception);
            final String message = "E00050: Could not load view";
            final String description = CUtilityFunctions.createDescription(String.format("The view '%s' could not be loaded.", view.getName()), new String[] { "There were problems with the database connection.", "Malformed data was found in the database." }, new String[] { "The view was not loaded." });
            NaviErrorDialog.show(parent, message, description, exception);
        } else if (exception instanceof CPartialLoadException) {
            CUtilityFunctions.logException(exception);
            final String moduleName = ((CPartialLoadException) exception).getModule().getConfiguration().getName();
            final String message = "E00051: Could not load view";
            final String description = CUtilityFunctions.createDescription(String.format("The view '%s' could not be loaded because it " + "depends on the unloaded module '%s'.", view.getName(), moduleName), new String[] { String.format("Module '%s' is not loaded.", moduleName) }, new String[] { String.format("The view can not be loaded before the module '%s' is loaded.", moduleName) });
            NaviErrorDialog.show(parent, message, description, exception);
        }
    }
}
Also used : CPartialLoadException(com.google.security.zynamics.binnavi.Database.Exceptions.CPartialLoadException) CouldntLoadDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException) CouldntLoadDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException) CPartialLoadException(com.google.security.zynamics.binnavi.Database.Exceptions.CPartialLoadException)

Example 65 with CouldntLoadDataException

use of com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException in project binnavi by google.

the class CModuleLoader method loadModuleInternal.

/**
   * Loads a module inside a thread.
   * 
   * @param parent Parent window used for dialogs.
   * @param module Module to load.
   * @param projectTree Project tree to expand on module loading. This argument can be null.
   */
private static void loadModuleInternal(final Window parent, final INaviModule module, final JTree projectTree) {
    final CModuleLoaderOperation operation = new CModuleLoaderOperation(module);
    boolean success = false;
    try {
        if (projectTree != null) {
            // Make sure the lazy UI components responsible for displaying data etc.
            // are properly initialized. Order is important - this has to happen
            // BEFORE module.load() is called, so that all the listeners in the UI
            // component already exist and can hence be filled by the module loading.
            CNodeExpander.findNode(projectTree, module).getComponent();
        }
        module.load();
        success = true;
        if (projectTree != null) {
            new SwingInvoker() {

                @Override
                protected void operation() {
                    CNodeExpander.expandNode(projectTree, module);
                    operation.stop();
                }
            }.invokeLater();
        }
    } catch (final CouldntLoadDataException exception) {
        CUtilityFunctions.logException(exception);
        final String message = "E00177: " + "Module data could not be loaded";
        final String description = CUtilityFunctions.createDescription(String.format("BinNavi could not load the module '%s'.", module.getConfiguration().getName()), new String[] { "The connection dropped while the data was loaded." }, new String[] { "BinNavi can not open the module. To fix this situation try " + "to load the module again. Restart BinNavi if necessary and contact " + "the BinNavi support if the problem persists." });
        NaviErrorDialog.show(parent, message, description, exception);
    } catch (final LoadCancelledException e) {
    // Don't show the user that he cancelled the operation.
    } finally {
        if (!success) {
            operation.stop();
        }
    }
}
Also used : CouldntLoadDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException) SwingInvoker(com.google.security.zynamics.zylib.gui.SwingInvoker) LoadCancelledException(com.google.security.zynamics.binnavi.Database.Exceptions.LoadCancelledException)

Aggregations

CouldntLoadDataException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException)85 SQLException (java.sql.SQLException)53 ResultSet (java.sql.ResultSet)47 ArrayList (java.util.ArrayList)30 PreparedStatement (java.sql.PreparedStatement)27 CConnection (com.google.security.zynamics.binnavi.Database.CConnection)20 LoadCancelledException (com.google.security.zynamics.binnavi.Database.Exceptions.LoadCancelledException)17 CouldntSaveDataException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException)16 HashMap (java.util.HashMap)12 IAddress (com.google.security.zynamics.zylib.disassembly.IAddress)10 BigInteger (java.math.BigInteger)9 CPartialLoadException (com.google.security.zynamics.binnavi.Database.Exceptions.CPartialLoadException)8 IComment (com.google.security.zynamics.binnavi.Gui.GraphWindows.CommentDialogs.Interfaces.IComment)8 CTag (com.google.security.zynamics.binnavi.Tagging.CTag)8 INaviModule (com.google.security.zynamics.binnavi.disassembly.INaviModule)8 CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)7 INaviView (com.google.security.zynamics.binnavi.disassembly.views.INaviView)6 Set (java.util.Set)6 CouldntDeleteException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntDeleteException)5 CDefaultProgressOperation (com.google.security.zynamics.binnavi.Gui.Progress.CDefaultProgressOperation)5