Search in sources :

Example 26 with CouldntLoadDataException

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

the class CGraphInliner method inlineFunction.

/**
   * Replaces a function node with the basic blocks of a function.
   * 
   * @param parent Parent window that is used to display error messages.
   * @param graph Graph where the inlining operation happens.
   * @param node The function node that is replaced by the basic blocks of the corresponding
   *        function.
   */
public static void inlineFunction(final JFrame parent, final ZyGraph graph, final INaviFunctionNode node) {
    Preconditions.checkNotNull(parent, "IE01743: Parent argument can not be null");
    Preconditions.checkNotNull(graph, "IE01744: Graph argument can not be null");
    Preconditions.checkNotNull(node, "IE01745: Node argument can not be null");
    final INaviView view = graph.getRawView();
    final INaviFunction function = node.getFunction();
    try {
        if (!function.isLoaded()) {
            function.load();
        }
        CInliningHelper.inlineFunctionNode(view, node);
        if (graph.getSettings().getLayoutSettings().getAutomaticLayouting()) {
            CGraphLayouter.refreshLayout(parent, graph);
        }
    } catch (final CouldntLoadDataException e) {
        exceptionDialog(parent, function, e);
    }
}
Also used : INaviView(com.google.security.zynamics.binnavi.disassembly.views.INaviView) CouldntLoadDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException) INaviFunction(com.google.security.zynamics.binnavi.disassembly.INaviFunction)

Example 27 with CouldntLoadDataException

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

the class CAddressSpaceFunctions method loadAddressSpaces.

/**
   * Loads one or more address spaces.
   * 
   * @param projectTree Project tree of the main window.
   * @param addressSpaces The address spaces to load.
   */
public static void loadAddressSpaces(final JTree projectTree, final INaviAddressSpace[] addressSpaces) {
    new Thread() {

        @Override
        public void run() {
            final CDefaultProgressOperation operation = new CDefaultProgressOperation("Loading address spaces", false, true);
            operation.getProgressPanel().setMaximum(addressSpaces.length);
            for (final INaviAddressSpace addressSpace : addressSpaces) {
                operation.getProgressPanel().setText("Loading address spaces" + ": '" + addressSpace.getConfiguration().getName() + "'");
                try {
                    addressSpace.load();
                    new SwingInvoker() {

                        @Override
                        protected void operation() {
                            CNodeExpander.expandNode(projectTree, addressSpace);
                        }
                    }.invokeLater();
                } catch (final CouldntLoadDataException exception) {
                    CUtilityFunctions.logException(exception);
                    final String message = "E00109: " + "Address space could not be loaded";
                    final String description = CUtilityFunctions.createDescription(String.format("The address space '%s' could not be loaded. Try loading the address space again. If the problem persists, disconnect from and reconnect to the database, restart com.google.security.zynamics.binnavi, or contact the BinNavi support.", addressSpace.getConfiguration().getName()), new String[] { "Database connection problems." }, new String[] { "The address space was not loaded." });
                    NaviErrorDialog.show(SwingUtilities.getWindowAncestor(projectTree), message, description, exception);
                } catch (final LoadCancelledException e) {
                // Do nothing
                } finally {
                    operation.getProgressPanel().next();
                }
            }
            operation.stop();
        }
    }.start();
}
Also used : CDefaultProgressOperation(com.google.security.zynamics.binnavi.Gui.Progress.CDefaultProgressOperation) 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) INaviAddressSpace(com.google.security.zynamics.binnavi.disassembly.INaviAddressSpace)

Example 28 with CouldntLoadDataException

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

the class PostgreSQLProjectFlowgraphsLoader method loadFlowGraphInformation.

public static ImmutableNaviViewConfiguration loadFlowGraphInformation(final SQLProvider provider, final INaviProject project, final Integer viewId) throws CouldntLoadDataException {
    Preconditions.checkNotNull(provider, "IE02618: provider argument can not be null");
    Preconditions.checkNotNull(project, "IE02619: project argument can not be null");
    Preconditions.checkNotNull(viewId, "IE02620: viewId argument can not be null");
    final CConnection connection = provider.getConnection();
    final String query = " SELECT * FROM load_project_flowGraph(?,?) ";
    try {
        final PreparedStatement statement = connection.getConnection().prepareStatement(query);
        statement.setInt(1, project.getConfiguration().getId());
        statement.setInt(2, viewId);
        final ResultSet resultSet = statement.executeQuery();
        while (resultSet.next()) {
            final int databaseViewId = resultSet.getInt("view_id");
            final String name = PostgreSQLHelpers.readString(resultSet, "name");
            final String description = PostgreSQLHelpers.readString(resultSet, "description");
            final ViewType viewType = resultSet.getString("type").equalsIgnoreCase("native") ? ViewType.Native : ViewType.NonNative;
            final Timestamp creationDate = resultSet.getTimestamp("creation_date");
            final Timestamp modificationDate = resultSet.getTimestamp("modification_date");
            final boolean isStared = resultSet.getBoolean("stared");
            final int nodeCount = resultSet.getInt("bbcount");
            final int edgeCount = resultSet.getInt("edgecount");
            final ImmutableNaviViewConfiguration viewConfiguration = new ImmutableNaviViewConfiguration(databaseViewId, name, description, viewType, creationDate, modificationDate, isStared, nodeCount, edgeCount);
            return viewConfiguration;
        }
        return null;
    } catch (final SQLException exception) {
        throw new CouldntLoadDataException(exception);
    }
}
Also used : CConnection(com.google.security.zynamics.binnavi.Database.CConnection) ImmutableNaviViewConfiguration(com.google.security.zynamics.binnavi.disassembly.views.ImmutableNaviViewConfiguration) SQLException(java.sql.SQLException) CouldntLoadDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException) ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement) Timestamp(java.sql.Timestamp) ViewType(com.google.security.zynamics.zylib.disassembly.ViewType)

Example 29 with CouldntLoadDataException

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

the class PostgreSQLProjectFlowgraphsLoader method loadFlowgraphs.

/**
   * Loads the flow graph views of a project.
   * 
   * @param provider The connection to the database.
   * @param project The project whose flow graph views are loaded.
   * @param viewTagManager Tag manager responsible for tagging the loaded views.
   * @param nodeTagManager The tag manager responsible for tagging view nodes.
   * 
   * @return The loaded flow graph views.
   * 
   * @throws CouldntLoadDataException Thrown if the flow graph views could not be loaded.
   */
public static List<IFlowgraphView> loadFlowgraphs(final SQLProvider provider, final INaviProject project, final CTagManager viewTagManager, final CTagManager nodeTagManager) throws CouldntLoadDataException {
    checkArguments(provider, project, viewTagManager);
    final CConnection connection = provider.getConnection();
    final String query = " SELECT * FROM load_project_flow_graphs(?, ?) ";
    try {
        final PreparedStatement statement = connection.getConnection().prepareStatement(query);
        statement.setInt(1, project.getConfiguration().getId());
        statement.setObject(2, "non-native", Types.OTHER);
        final ResultSet resultSet = statement.executeQuery();
        final Map<Integer, Set<CTag>> tags = loadTags(connection, project, viewTagManager);
        return new ArrayList<IFlowgraphView>(processQueryResults(resultSet, project, tags, nodeTagManager, provider, new ArrayList<CView>(), ViewType.NonNative, GraphType.FLOWGRAPH));
    } catch (final SQLException exception) {
        throw new CouldntLoadDataException(exception);
    }
}
Also used : CConnection(com.google.security.zynamics.binnavi.Database.CConnection) Set(java.util.Set) ResultSet(java.sql.ResultSet) SQLException(java.sql.SQLException) CouldntLoadDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException) ResultSet(java.sql.ResultSet) ArrayList(java.util.ArrayList) PreparedStatement(java.sql.PreparedStatement)

Example 30 with CouldntLoadDataException

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

the class PostgreSQLProjectMixedGraphsLoader method loadMixedgraphs.

/**
   * Loads the non-native mixed-graph views of a project.
   * 
   * The project, the view tag manager, and the node tag manager must be stored in the database
   * connected to by the provider argument.
   * 
   * @param provider The SQL provider that provides the connection.
   * @param project The project from where the views are loaded.
   * @param viewTagManager View tag manager that contains all view tags of the database.
   * @param nodeTagManager The tag manager responsible for tagging view nodes.
   * 
   * @return A list of non-native mixed-graph views.
   * 
   * @throws CouldntLoadDataException Thrown if the views could not be loaded.
   */
public static List<INaviView> loadMixedgraphs(final AbstractSQLProvider provider, final CProject project, final CTagManager viewTagManager, final CTagManager nodeTagManager) throws CouldntLoadDataException {
    checkArguments(provider, project, viewTagManager);
    final String query = "SELECT * FROM load_module_mixed_graph(?)";
    try {
        final CConnection connection = provider.getConnection();
        final PreparedStatement statement = connection.getConnection().prepareStatement(query);
        statement.setInt(1, project.getConfiguration().getId());
        final ResultSet resultSet = statement.executeQuery();
        final Map<Integer, Set<CTag>> tags = loadTags(connection, project, viewTagManager);
        return new ArrayList<INaviView>(processQueryResults(resultSet, project, tags, nodeTagManager, provider, new ArrayList<CView>(), ViewType.NonNative, GraphType.MIXED_GRAPH));
    } catch (final SQLException exception) {
        throw new CouldntLoadDataException(exception);
    }
}
Also used : CConnection(com.google.security.zynamics.binnavi.Database.CConnection) Set(java.util.Set) ResultSet(java.sql.ResultSet) SQLException(java.sql.SQLException) CouldntLoadDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException) ResultSet(java.sql.ResultSet) ArrayList(java.util.ArrayList) PreparedStatement(java.sql.PreparedStatement)

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