Search in sources :

Example 6 with IFilledList

use of com.google.security.zynamics.zylib.types.lists.IFilledList in project binnavi by google.

the class PostgreSQLHelpers method getViewsWithAddress.

/**
   * Searches for the views with a given address.
   *
   * @param connection Connection to a SQL database.
   * @param query SQL query to issue for the search.
   * @param columnName Name of the column from which the container ID is read.
   * @param finder Finder object that is used to find the view object from a view ID.
   *
   * @return A list of views that was found by the query.
   *
   * @throws CouldntLoadDataException Thrown if the search failed with an error.
   */
// TODO (timkornau): find out if there is a better way to have the sql query build in here rather
// then in the caller.
// It just seems to be wrong like this.
public static IFilledList<INaviView> getViewsWithAddress(final CConnection connection, final String query, final String columnName, final ContainerFinder finder) throws CouldntLoadDataException {
    Preconditions.checkNotNull(finder, "IE00607: Finder argument can not be null");
    Preconditions.checkNotNull(columnName, "IE00608: Column name argument can not be null");
    Preconditions.checkNotNull(query, "IE00627: Query argument can not be null");
    Preconditions.checkNotNull(connection, "IE00628: Connection argument can not be null");
    final IFilledList<INaviView> views = new FilledList<INaviView>();
    try (ResultSet resultSet = connection.executeQuery(query, true)) {
        while (resultSet.next()) {
            final int containerId = resultSet.getInt(columnName);
            final int viewId = resultSet.getInt("view_id");
            final INaviView view = finder.findView(containerId, viewId);
            views.add(view);
        }
        return views;
    } catch (final SQLException exception) {
        throw new CouldntLoadDataException(exception);
    }
}
Also used : INaviView(com.google.security.zynamics.binnavi.disassembly.views.INaviView) FilledList(com.google.security.zynamics.zylib.types.lists.FilledList) IFilledList(com.google.security.zynamics.zylib.types.lists.IFilledList) SQLException(java.sql.SQLException) CouldntLoadDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException) ResultSet(java.sql.ResultSet)

Example 7 with IFilledList

use of com.google.security.zynamics.zylib.types.lists.IFilledList in project binnavi by google.

the class PostgreSQLModuleCallgraphsLoader method loadModuleCallgraphs.

/**
   * Loads the call graph views of a module. Depending on the view type argument, this function can
   * load the native call graph view or non-native call graph views.
   * 
   * The arguments module, viewTagManager, and nodeTagManager must belong to the database connected
   * to by the provider argument.
   * 
   * @param provider The connection to the database.
   * @param module The module whose call graph views are loaded.
   * @param viewTagManager The tag manager responsible for tagging the views.
   * @param nodeTagManager The tag manager responsible for tagging view nodes.
   * @param viewType The type of the views to load.
   * 
   * @return The loaded views.
   * 
   * @throws CouldntLoadDataException Thrown if the views could not be loaded.
   */
private static IFilledList<ICallgraphView> loadModuleCallgraphs(final AbstractSQLProvider provider, final CModule module, final CTagManager viewTagManager, final ITagManager nodeTagManager, final ViewType viewType) throws CouldntLoadDataException {
    PostgreSQLViewsLoader.checkArguments(provider, module, viewTagManager);
    final String query = "SELECT * FROM load_module_call_graphs(?, ?)";
    try {
        final CConnection connection = provider.getConnection();
        final PreparedStatement statement = connection.getConnection().prepareStatement(query);
        statement.setInt(1, module.getConfiguration().getId());
        statement.setObject(2, viewType == ViewType.Native ? "native" : "non-native", Types.OTHER);
        final ResultSet resultSet = statement.executeQuery();
        final Map<Integer, Set<CTag>> tags = PostgreSQLModuleViewsLoader.loadTags(connection, module, viewTagManager);
        return new FilledList<ICallgraphView>(processQueryResults(resultSet, module, tags, nodeTagManager, provider, new ArrayList<CView>(), viewType, GraphType.CALLGRAPH));
    } 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) FilledList(com.google.security.zynamics.zylib.types.lists.FilledList) IFilledList(com.google.security.zynamics.zylib.types.lists.IFilledList) 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 8 with IFilledList

use of com.google.security.zynamics.zylib.types.lists.IFilledList in project binnavi by google.

the class PostgreSQLModuleMixedGraphsLoader method loadMixedgraphs.

/**
   * Loads the mixed-graph views of a module. These mixed graph views are necessarily non-native
   * because there are no native mixed graph views.
   * 
   * The module, 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 module The module 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 IFilledList<INaviView> loadMixedgraphs(final AbstractSQLProvider provider, final CModule module, final CTagManager viewTagManager, final CTagManager nodeTagManager) throws CouldntLoadDataException {
    checkArguments(provider, module, 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, module.getConfiguration().getId());
        final ResultSet resultSet = statement.executeQuery();
        final Map<Integer, Set<CTag>> tags = loadTags(connection, module, viewTagManager);
        return new FilledList<INaviView>(processQueryResults(resultSet, module, 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) FilledList(com.google.security.zynamics.zylib.types.lists.FilledList) IFilledList(com.google.security.zynamics.zylib.types.lists.IFilledList) 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 9 with IFilledList

use of com.google.security.zynamics.zylib.types.lists.IFilledList in project binnavi by google.

the class CDebugBottomPanel method getPanels.

/**
   * Creates the panels that are shown in the panel.
   *
   * @param model Provides the data needed by the components in the panel.
   * @param debugPerspectiveModel Describes the debug perspective.
   *
   * @return The created panels.
   */
private static IFilledList<IResultsPanel> getPanels(final CGraphModel model, final CDebugPerspectiveModel debugPerspectiveModel) {
    final IFilledList<IResultsPanel> debugPanels = new FilledList<IResultsPanel>();
    debugPanels.add(new CCombinedMemoryPanel(model.getParent(), debugPerspectiveModel));
    debugPanels.add(new CModulesPanel(debugPerspectiveModel));
    debugPanels.add(new CThreadInformationPanel(debugPerspectiveModel));
    debugPanels.add(new CBreakpointPanel(model.getParent(), model.getDebuggerProvider(), model.getGraph(), model.getViewContainer()));
    debugPanels.add(new CTracesPanel(debugPerspectiveModel, model.getGraph(), model.getViewContainer().getTraceProvider(), model.getGraphPanel()));
    debugPanels.add(new CBookmarkPanel(model.getDebuggerProvider()));
    debugPanels.add(new CDebuggerHistoryPanel(debugPerspectiveModel));
    return debugPanels;
}
Also used : IResultsPanel(com.google.security.zynamics.binnavi.Gui.GraphWindows.BottomPanel.IResultsPanel) CModulesPanel(com.google.security.zynamics.binnavi.Gui.Debug.ModulesPanel.CModulesPanel) CThreadInformationPanel(com.google.security.zynamics.binnavi.Gui.Debug.ThreadInformationPanel.CThreadInformationPanel) CDebuggerHistoryPanel(com.google.security.zynamics.binnavi.Gui.Debug.History.CDebuggerHistoryPanel) CTracesPanel(com.google.security.zynamics.binnavi.Gui.Debug.EventLists.CTracesPanel) FilledList(com.google.security.zynamics.zylib.types.lists.FilledList) IFilledList(com.google.security.zynamics.zylib.types.lists.IFilledList) CCombinedMemoryPanel(com.google.security.zynamics.binnavi.Gui.Debug.CombinedMemoryPanel.CCombinedMemoryPanel) CBookmarkPanel(com.google.security.zynamics.binnavi.Gui.Debug.Bookmarks.CBookmarkPanel) CBreakpointPanel(com.google.security.zynamics.binnavi.Gui.Debug.BreakpointTable.CBreakpointPanel)

Example 10 with IFilledList

use of com.google.security.zynamics.zylib.types.lists.IFilledList in project binnavi by google.

the class PostgreSQLProviderTest method testCModuleFunctionsgetViewsWithAddresses1.

@Test
public void testCModuleFunctionsgetViewsWithAddresses1() throws CouldntLoadDataException, LoadCancelledException {
    final INaviModule module = getProvider().loadModules().get(0);
    module.load();
    final IFilledList<UnrelocatedAddress> addresses = new FilledList<UnrelocatedAddress>();
    List<INaviView> views = PostgreSQLModuleFunctions.getViewsWithAddresses((AbstractSQLProvider) getProvider(), module, addresses, true);
    assertEquals(0, views.size());
    addresses.add(new UnrelocatedAddress(new CAddress(0x10033DCL)));
    views = PostgreSQLModuleFunctions.getViewsWithAddresses((AbstractSQLProvider) getProvider(), module, addresses, true);
    assertEquals(1, views.size());
    addresses.add(new UnrelocatedAddress(new CAddress(0x1003429)));
    views = PostgreSQLModuleFunctions.getViewsWithAddresses((AbstractSQLProvider) getProvider(), module, addresses, true);
    assertEquals(0, views.size());
    views = PostgreSQLModuleFunctions.getViewsWithAddresses((AbstractSQLProvider) getProvider(), module, addresses, false);
    assertEquals(2, views.size());
}
Also used : AbstractSQLProvider(com.google.security.zynamics.binnavi.Database.AbstractSQLProvider) INaviView(com.google.security.zynamics.binnavi.disassembly.views.INaviView) INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) IFilledList(com.google.security.zynamics.zylib.types.lists.IFilledList) FilledList(com.google.security.zynamics.zylib.types.lists.FilledList) UnrelocatedAddress(com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) ExpensiveBaseTest(com.google.security.zynamics.binnavi.disassembly.types.ExpensiveBaseTest) Test(org.junit.Test)

Aggregations

FilledList (com.google.security.zynamics.zylib.types.lists.FilledList)15 IFilledList (com.google.security.zynamics.zylib.types.lists.IFilledList)15 INaviView (com.google.security.zynamics.binnavi.disassembly.views.INaviView)7 Test (org.junit.Test)7 UnrelocatedAddress (com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress)6 CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)5 CouldntLoadDataException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException)4 INaviFunction (com.google.security.zynamics.binnavi.disassembly.INaviFunction)4 INaviModule (com.google.security.zynamics.binnavi.disassembly.INaviModule)4 ResultSet (java.sql.ResultSet)4 SQLException (java.sql.SQLException)4 CConnection (com.google.security.zynamics.binnavi.Database.CConnection)3 ExpensiveBaseTest (com.google.security.zynamics.binnavi.disassembly.types.ExpensiveBaseTest)3 Pair (com.google.security.zynamics.zylib.general.Pair)3 ArrayList (java.util.ArrayList)3 AbstractSQLProvider (com.google.security.zynamics.binnavi.Database.AbstractSQLProvider)2 MockDebugger (com.google.security.zynamics.binnavi.Debug.Debugger.MockDebugger)2 CBreakpointTableModel (com.google.security.zynamics.binnavi.Gui.Debug.BreakpointTable.CBreakpointTableModel)2 DebugTargetSettings (com.google.security.zynamics.binnavi.debug.debugger.DebugTargetSettings)2 DebuggerProvider (com.google.security.zynamics.binnavi.debug.debugger.DebuggerProvider)2