Search in sources :

Example 1 with CView

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

the class PostgreSQLModuleFlowgraphsLoader method loadModuleFlowgraphs.

/**
   * Loads the flow graphs of a module.
   * 
   * @param provider The connection to the database.
   * @param module The module whose flow 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 ImmutableList<IFlowgraphView> loadModuleFlowgraphs(final AbstractSQLProvider provider, final CModule module, final CTagManager viewTagManager, final CTagManager nodeTagManager, final ViewType viewType) throws CouldntLoadDataException {
    checkArguments(provider, module, viewTagManager);
    final String query = " SELECT * FROM load_module_flow_graphs(?, ?) ";
    final CConnection connection = provider.getConnection();
    try {
        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 = loadTags(connection, module, viewTagManager);
        return new ImmutableList.Builder<IFlowgraphView>().addAll(processQueryResults(resultSet, module, tags, nodeTagManager, provider, new ArrayList<CView>(), viewType, GraphType.FLOWGRAPH)).build();
    } catch (final SQLException exception) {
        throw new CouldntLoadDataException(exception);
    }
}
Also used : CConnection(com.google.security.zynamics.binnavi.Database.CConnection) CView(com.google.security.zynamics.binnavi.disassembly.views.CView) 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) PreparedStatement(java.sql.PreparedStatement)

Example 2 with CView

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

the class CProjectContent method createView.

/**
   * Creates a new empty view with the given name and description in the project. The new view is
   * not stored in the database until INaviView::save is called.
   * 
   * @param name The name of the new view.
   * @param description The description of the new view.
   * 
   * @return The new view that was created in the project.
   */
public INaviView createView(final String name, final String description) {
    final Date date = new Date();
    final CProjectViewGenerator generator = new CProjectViewGenerator(m_provider, m_project);
    final CView view = generator.generate(-1, name, description, ViewType.NonNative, GraphType.MIXED_GRAPH, date, date, 0, 0, new HashSet<CTag>(), new HashSet<CTag>(), false);
    try {
        view.load();
    } catch (CouldntLoadDataException | CPartialLoadException | LoadCancelledException e) {
        // This can not happen; new views with ID -1 do not access the database
        // when they are loaded.
        CUtilityFunctions.logException(e);
    }
    addView(view);
    return view;
}
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) CTag(com.google.security.zynamics.binnavi.Tagging.CTag) LoadCancelledException(com.google.security.zynamics.binnavi.Database.Exceptions.LoadCancelledException) CProjectViewGenerator(com.google.security.zynamics.binnavi.Database.CProjectViewGenerator) Date(java.util.Date)

Example 3 with CView

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

the class CProjectContent method createView.

/**
   * Creates a new view with the given name and description in the project by copying an existing
   * view. The new view is not stored in the database until INaviView::save is called.
   * 
   * @param view The view that is copied.
   * @param name The name of the new view.
   * @param description The description of the new view.
   * 
   * @return The new view that was created in the project.
   */
public INaviView createView(final INaviView view, final String name, final String description) {
    Preconditions.checkNotNull(view, "IE02228: view argument can not be null");
    Preconditions.checkArgument(view.inSameDatabase(m_provider), "IE02229: View and project Content are not in the same database");
    Preconditions.checkNotNull(name, "IE02230: name argument can not be null");
    Preconditions.checkNotNull(description, "IE02231: description argument can not be null");
    final CView newView = CView.createUnsavedProjectView(m_project, view, name, description, m_provider);
    addView(newView);
    return newView;
}
Also used : CView(com.google.security.zynamics.binnavi.disassembly.views.CView)

Example 4 with CView

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

the class CViewContainer method createView.

/**
   * Creates a new empty view in the module.
   *
   * @param name The name of the new view.
   * @param description The description of the new view.
   *
   * @return The new view.
   */
public CView createView(final String name, final String description) {
    Preconditions.checkNotNull(name, "IE00164: Name argument can not be null");
    Preconditions.checkNotNull(description, "IE00165: Name description can not be null");
    final Date date = new Date();
    final CModuleViewGenerator generator = new CModuleViewGenerator(m_provider, m_module);
    final CView view = generator.generate(-1, name, description, ViewType.NonNative, GraphType.MIXED_GRAPH, date, date, 0, 0, new HashSet<CTag>(), new HashSet<CTag>(), false);
    try {
        view.load();
    } catch (CouldntLoadDataException | CPartialLoadException | LoadCancelledException e) {
        CUtilityFunctions.logException(e);
    }
    addView(view);
    return view;
}
Also used : CView(com.google.security.zynamics.binnavi.disassembly.views.CView) CModuleViewGenerator(com.google.security.zynamics.binnavi.Database.CModuleViewGenerator) CPartialLoadException(com.google.security.zynamics.binnavi.Database.Exceptions.CPartialLoadException) CouldntLoadDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException) CTag(com.google.security.zynamics.binnavi.Tagging.CTag) LoadCancelledException(com.google.security.zynamics.binnavi.Database.Exceptions.LoadCancelledException) Date(java.util.Date)

Example 5 with CView

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

the class PostgreSQLProviderTest method testCViewFunctionsUntagView2.

@Test(expected = NullPointerException.class)
public void testCViewFunctionsUntagView2() throws CouldntSaveDataException, CouldntLoadDataException {
    final INaviModule module = getProvider().loadModules().get(0);
    final CView view = (CView) module.getContent().getViewContainer().getViews().get(224);
    getProvider().removeTag(view, null);
}
Also used : CView(com.google.security.zynamics.binnavi.disassembly.views.CView) INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) ExpensiveBaseTest(com.google.security.zynamics.binnavi.disassembly.types.ExpensiveBaseTest) Test(org.junit.Test)

Aggregations

CView (com.google.security.zynamics.binnavi.disassembly.views.CView)45 Test (org.junit.Test)36 CTag (com.google.security.zynamics.binnavi.Tagging.CTag)16 ExpensiveBaseTest (com.google.security.zynamics.binnavi.disassembly.types.ExpensiveBaseTest)15 INaviModule (com.google.security.zynamics.binnavi.disassembly.INaviModule)13 Date (java.util.Date)13 MockSqlProvider (com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider)12 INaviView (com.google.security.zynamics.binnavi.disassembly.views.INaviView)9 IComment (com.google.security.zynamics.binnavi.Gui.GraphWindows.CommentDialogs.Interfaces.IComment)8 CTagManager (com.google.security.zynamics.binnavi.Tagging.CTagManager)7 INaviViewNode (com.google.security.zynamics.binnavi.disassembly.INaviViewNode)7 CModule (com.google.security.zynamics.binnavi.disassembly.Modules.CModule)6 ArrayList (java.util.ArrayList)6 CFunction (com.google.security.zynamics.binnavi.disassembly.CFunction)5 CFunctionNode (com.google.security.zynamics.binnavi.disassembly.CFunctionNode)5 CouldntLoadDataException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException)4 MockDatabase (com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase)4 CCodeNode (com.google.security.zynamics.binnavi.disassembly.CCodeNode)4 BigInteger (java.math.BigInteger)4 CModuleViewGenerator (com.google.security.zynamics.binnavi.Database.CModuleViewGenerator)3