Search in sources :

Example 11 with LoadCancelledException

use of com.google.security.zynamics.binnavi.Database.Exceptions.LoadCancelledException 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 12 with LoadCancelledException

use of com.google.security.zynamics.binnavi.Database.Exceptions.LoadCancelledException 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 13 with LoadCancelledException

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

the class CDatabase method connect.

@Override
public void connect() throws CouldntLoadDriverException, CouldntConnectException, InvalidDatabaseException, CouldntInitializeDatabaseException, InvalidExporterDatabaseFormatException, LoadCancelledException {
    loadReporter.start();
    isConnecting = true;
    try {
        final Pair<CConnection, SQLProvider> connectionData = CDatabaseConnection.connect(description, loadReporter);
        provider = connectionData.second();
    } catch (final CouldntLoadDriverException exception) {
        loadReporter.report(LoadEvents.LOADING_FINISHED);
        throw exception;
    } catch (final CouldntConnectException exception) {
        loadReporter.report(LoadEvents.LOADING_FINISHED);
        throw exception;
    } catch (final CouldntInitializeDatabaseException exception) {
        loadReporter.report(LoadEvents.LOADING_FINISHED);
        throw exception;
    } catch (final InvalidDatabaseException exception) {
        loadReporter.report(LoadEvents.LOADING_FINISHED);
        throw exception;
    } catch (final InvalidExporterDatabaseFormatException exception) {
        loadReporter.report(LoadEvents.LOADING_FINISHED);
        throw exception;
    } catch (final LoadCancelledException exception) {
        loadReporter.report(LoadEvents.LOADING_FINISHED);
        throw exception;
    } finally {
        isConnecting = false;
    }
    for (final IDatabaseListener listener : listeners) {
        try {
            listener.openedDatabase(this);
        } catch (final Exception exception) {
            CUtilityFunctions.logException(exception);
        }
    }
    try {
        final PostgreSQLNotificationProvider notificationProvider = PostgreSQLNotificationProvider.initialize(provider, description);
        notificationProvider.listen(NotificationChannel.all());
        notificationProvider.startPolling();
    } catch (final SQLException exception) {
        NaviLogger.severe("Error: Could not establish a channel for receiving notifications from the database %s", exception);
    }
}
Also used : SQLException(java.sql.SQLException) CouldntInitializeDatabaseException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntInitializeDatabaseException) InvalidExporterDatabaseFormatException(com.google.security.zynamics.binnavi.Database.Exceptions.InvalidExporterDatabaseFormatException) SQLProvider(com.google.security.zynamics.binnavi.Database.Interfaces.SQLProvider) IDatabaseListener(com.google.security.zynamics.binnavi.Database.Interfaces.IDatabaseListener) LoadCancelledException(com.google.security.zynamics.binnavi.Database.Exceptions.LoadCancelledException) CouldntInitializeDatabaseException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntInitializeDatabaseException) CouldntLoadDriverException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDriverException) InvalidExporterDatabaseFormatException(com.google.security.zynamics.binnavi.Database.Exceptions.InvalidExporterDatabaseFormatException) SQLException(java.sql.SQLException) InvalidDatabaseException(com.google.security.zynamics.binnavi.Database.Exceptions.InvalidDatabaseException) CouldntConnectException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntConnectException) CouldntSaveDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException) CouldntLoadDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException) CouldntUpdateDatabaseException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntUpdateDatabaseException) InvalidDatabaseVersionException(com.google.security.zynamics.binnavi.Database.Exceptions.InvalidDatabaseVersionException) CouldntLoadDriverException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDriverException) PostgreSQLNotificationProvider(com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.PostgreSQLNotificationProvider) InvalidDatabaseException(com.google.security.zynamics.binnavi.Database.Exceptions.InvalidDatabaseException) CouldntConnectException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntConnectException) LoadCancelledException(com.google.security.zynamics.binnavi.Database.Exceptions.LoadCancelledException)

Example 14 with LoadCancelledException

use of com.google.security.zynamics.binnavi.Database.Exceptions.LoadCancelledException 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)

Example 15 with LoadCancelledException

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

the class CModuleFunctions method copyView.

/**
   * Copies a view into a module view.
   * 
   * @param parent Parent window used for dialogs.
   * @param module Module where the copied view is stored.
   * @param view The view to copy.
   */
public static void copyView(final JFrame parent, final INaviModule module, final INaviView view) {
    Preconditions.checkNotNull(parent, "IE01832: Parent argument can not be null");
    Preconditions.checkNotNull(module, "IE01833: Module argument can not be null");
    Preconditions.checkNotNull(view, "IE01834: View argument can not be null");
    if (module.getContent().getViewContainer().hasView(view)) {
        if (!view.isLoaded()) {
            try {
                view.load();
            } catch (final CouldntLoadDataException e) {
                CUtilityFunctions.logException(e);
                final String innerMessage = "E00133: View could not be copied";
                final String innerDescription = CUtilityFunctions.createDescription(String.format("The view '%s' could not be copied because it could not be loaded.", view.getName()), new String[] { "There was a problem with the database connection." }, new String[] { "The new view was not created." });
                NaviErrorDialog.show(parent, innerMessage, innerDescription, e);
                return;
            } catch (CPartialLoadException | LoadCancelledException e) {
                CUtilityFunctions.logException(e);
                return;
            }
        }
        final CView newView = module.getContent().getViewContainer().createView(String.format("Copy of %s", view.getName()), null);
        CViewInserter.insertView(view, newView);
    }
}
Also used : CView(com.google.security.zynamics.binnavi.disassembly.views.CView) CPartialLoadException(com.google.security.zynamics.binnavi.Database.Exceptions.CPartialLoadException) CouldntLoadDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException) LoadCancelledException(com.google.security.zynamics.binnavi.Database.Exceptions.LoadCancelledException)

Aggregations

LoadCancelledException (com.google.security.zynamics.binnavi.Database.Exceptions.LoadCancelledException)19 CouldntLoadDataException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException)18 CouldntSaveDataException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException)8 CPartialLoadException (com.google.security.zynamics.binnavi.Database.Exceptions.CPartialLoadException)6 CTag (com.google.security.zynamics.binnavi.Tagging.CTag)5 CouldntConnectException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntConnectException)4 CouldntInitializeDatabaseException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntInitializeDatabaseException)4 CouldntLoadDriverException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDriverException)4 InvalidDatabaseException (com.google.security.zynamics.binnavi.Database.Exceptions.InvalidDatabaseException)4 InvalidDatabaseVersionException (com.google.security.zynamics.binnavi.Database.Exceptions.InvalidDatabaseVersionException)4 InvalidExporterDatabaseFormatException (com.google.security.zynamics.binnavi.Database.Exceptions.InvalidExporterDatabaseFormatException)4 CDefaultProgressOperation (com.google.security.zynamics.binnavi.Gui.Progress.CDefaultProgressOperation)4 INaviModule (com.google.security.zynamics.binnavi.disassembly.INaviModule)4 CouldntUpdateDatabaseException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntUpdateDatabaseException)3 TraceList (com.google.security.zynamics.binnavi.debug.models.trace.TraceList)3 CAddressSpace (com.google.security.zynamics.binnavi.disassembly.AddressSpaces.CAddressSpace)3 INaviFunction (com.google.security.zynamics.binnavi.disassembly.INaviFunction)3 INaviView (com.google.security.zynamics.binnavi.disassembly.views.INaviView)3 ArrayList (java.util.ArrayList)3 CouldntDeleteException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntDeleteException)2