Search in sources :

Example 31 with INaviView

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

the class ViewTest method setUp.

@SuppressWarnings("deprecation")
@Before
public void setUp() throws LoadCancelledException, com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException, FileReadException, CouldntLoadDataException {
    ConfigManager.instance().read();
    final TagManager tagManager = new TagManager(new MockTagManager(TagType.NODE_TAG));
    final CTagManager internalTagManager = new CTagManager(new Tree<CTag>(new TreeNode<CTag>(new CTag(1, "", "", TagType.VIEW_TAG, m_provider))), TagType.VIEW_TAG, m_provider);
    m_viewTagManager = new TagManager(internalTagManager);
    final Database database = new Database(new MockDatabase());
    internalModule = new CModule(1, "", "", new Date(), new Date(), "00000000000000000000000000000000", "0000000000000000000000000000000000000000", 0, 0, new CAddress(0), new CAddress(0), null, null, Integer.MAX_VALUE, false, m_provider);
    internalModule.load();
    module = new Module(database, internalModule, tagManager, m_viewTagManager);
    final Calendar cal = Calendar.getInstance();
    cal.setTime(module.getModificationDate());
    cal.add(Calendar.DATE, 1);
    m_modificationDate = cal.getTime();
    m_creationDate = new Date();
    final ITreeNode<CTag> tag = internalTagManager.addTag(internalTagManager.getRootTag(), "foo");
    final CModuleViewGenerator generator = new CModuleViewGenerator(m_provider, internalModule);
    final INaviView internalView = generator.generate(1, "My View", "My View Description", com.google.security.zynamics.zylib.disassembly.ViewType.NonNative, GraphType.MIXED_GRAPH, m_creationDate, m_modificationDate, 1, 2, Sets.newHashSet(tag.getObject()), new HashSet<CTag>(), false);
    m_view = new View(module, internalView, tagManager, m_viewTagManager);
}
Also used : CModuleViewGenerator(com.google.security.zynamics.binnavi.Database.CModuleViewGenerator) Calendar(java.util.Calendar) CTag(com.google.security.zynamics.binnavi.Tagging.CTag) CTagManager(com.google.security.zynamics.binnavi.Tagging.CTagManager) MockTagManager(com.google.security.zynamics.binnavi.Tagging.MockTagManager) CView(com.google.security.zynamics.binnavi.disassembly.views.CView) INaviView(com.google.security.zynamics.binnavi.disassembly.views.INaviView) MockView(com.google.security.zynamics.binnavi.disassembly.MockView) Date(java.util.Date) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) CTagManager(com.google.security.zynamics.binnavi.Tagging.CTagManager) MockTagManager(com.google.security.zynamics.binnavi.Tagging.MockTagManager) INaviView(com.google.security.zynamics.binnavi.disassembly.views.INaviView) ITreeNode(com.google.security.zynamics.zylib.types.trees.ITreeNode) TreeNode(com.google.security.zynamics.zylib.types.trees.TreeNode) MockDatabase(com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase) MockDatabase(com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase) CModule(com.google.security.zynamics.binnavi.disassembly.Modules.CModule) CModule(com.google.security.zynamics.binnavi.disassembly.Modules.CModule) Before(org.junit.Before)

Example 32 with INaviView

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

the class PostgreSQLViewNotificationParser method informProjectNotification.

/**
   * The inform function for notifications from the bn_project_views table. This function is used
   * when a project view is created or deleted.
   *
   * @param projectNotificationContainer The {@link ViewNotificationContainer} to use as data
   *        source.
   * @param provider The {@link SQLProvider} to access the database.
   * @throws CouldntLoadDataException if the information could not be loaded from the database.
   */
private void informProjectNotification(final ViewNotificationContainer projectNotificationContainer, final SQLProvider provider) throws CouldntLoadDataException {
    if (projectNotificationContainer.getDatabaseOperation().equals("INSERT")) {
        final INaviProject project = projectNotificationContainer.getNotificationProject().get();
        if (!project.isLoaded()) {
            return;
        }
        final Integer viewId = projectNotificationContainer.getViewId();
        final ImmutableNaviViewConfiguration databaseViewConfiguration = provider.loadFlowGraphInformation(project, viewId);
        final CProjectViewGenerator generator = new CProjectViewGenerator(provider, project);
        final INaviView view = generator.generate(databaseViewConfiguration);
        project.getContent().addView(view);
    }
    if (projectNotificationContainer.getDatabaseOperation().equals("UPDATE")) {
        // updates will not happen as this is only a mapping of id to id.
        return;
    }
    if (projectNotificationContainer.getDatabaseOperation().equals("DELETE")) {
        final INaviProject project = projectNotificationContainer.getNotificationProject().get();
        if (!project.isLoaded()) {
            return;
        }
        final Integer viewId = projectNotificationContainer.getViewId();
        final INaviView view = ViewManager.get(provider).getView(viewId);
        project.getContent().deleteViewInternal(view);
    }
}
Also used : ImmutableNaviViewConfiguration(com.google.security.zynamics.binnavi.disassembly.views.ImmutableNaviViewConfiguration) INaviProject(com.google.security.zynamics.binnavi.disassembly.INaviProject) INaviView(com.google.security.zynamics.binnavi.disassembly.views.INaviView) CProjectViewGenerator(com.google.security.zynamics.binnavi.Database.CProjectViewGenerator)

Example 33 with INaviView

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

the class PostgreSQLViewNotificationParser method parseModuleViewNotification.

/**
   * Parser for a bn_module_views notification. The function uses the moduleViewNotificationPattern
   * to parse the incoming {@link PGNotification} into a {@link ViewNotificationContainer}.
   *
   * @param notification The {@link PGNotification} to parse.
   * @param provider The {@link SQLProvider} to access the database.
   *
   * @return A {@link ViewNotificationContainer} with the parsed information.
   */
private ViewNotificationContainer parseModuleViewNotification(final PGNotification notification, final SQLProvider provider) {
    final Matcher matcher = moduleViewNotificationPattern.matcher(notification.getParameter());
    if (!matcher.find()) {
        throw new IllegalStateException("IE02743: compiled pattern: " + moduleViewNotificationPattern.toString() + " did not match notification: " + notification.getParameter());
    }
    final Integer viewId = Integer.parseInt(matcher.group(3));
    final Optional<INaviView> view = Optional.fromNullable(ViewManager.get(provider).getView(viewId));
    final Optional<Integer> moduleId = Optional.fromNullable(Integer.parseInt(matcher.group(4)));
    final Optional<INaviModule> module = Optional.fromNullable(provider.findModule(moduleId.get()));
    final String databaseOperation = matcher.group(2);
    return new ViewNotificationContainer(viewId, view, moduleId, module, Optional.<INaviProject>absent(), databaseOperation);
}
Also used : INaviView(com.google.security.zynamics.binnavi.disassembly.views.INaviView) INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) Matcher(java.util.regex.Matcher) ViewNotificationContainer(com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.containers.ViewNotificationContainer)

Example 34 with INaviView

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

the class PostgreSQLViewNotificationParser method parseViewNotification.

/**
   * Parser for a bn_views notification. The function uses the viewNotificationPattern to parse the
   * incoming {@link PGNotification} into a {@link ViewNotificationContainer}.
   *
   * @param notification The {@link PGNotification} to parse.
   * @param provider The {@link SQLProvider} to access the database.
   *
   * @return A {@link ViewNotificationContainer} with the parsed information.
   */
private ViewNotificationContainer parseViewNotification(final PGNotification notification, final SQLProvider provider) {
    final Matcher matcher = viewNotificationPattern.matcher(notification.getParameter());
    if (!matcher.find()) {
        throw new IllegalStateException("IE02742: compiled pattern: " + viewNotificationPattern.toString() + " did not match notification: " + notification.getParameter());
    }
    final Integer viewId = Integer.parseInt(matcher.group(3));
    final Optional<INaviView> view = Optional.fromNullable(ViewManager.get(provider).getView(viewId));
    final String databaseOperation = matcher.group(2);
    return new ViewNotificationContainer(viewId, view, Optional.<Integer>absent(), Optional.<INaviModule>absent(), Optional.<INaviProject>absent(), databaseOperation);
}
Also used : INaviView(com.google.security.zynamics.binnavi.disassembly.views.INaviView) Matcher(java.util.regex.Matcher) ViewNotificationContainer(com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.containers.ViewNotificationContainer)

Example 35 with INaviView

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

the class CCodeNodeMenu method addFunctionOperandMenu.

private void addFunctionOperandMenu(final CGraphModel model, final INaviReplacement replacement) {
    final INaviFunction function = ((CFunctionReplacement) replacement).getFunction();
    final INaviView view = function.getModule().getContent().getViewContainer().getView(function);
    add(new CChangeFunctionNameAction(model.getParent(), view));
    addSeparator();
}
Also used : CChangeFunctionNameAction(com.google.security.zynamics.binnavi.ZyGraph.Menus.Actions.CChangeFunctionNameAction) CFunctionReplacement(com.google.security.zynamics.binnavi.disassembly.CFunctionReplacement) INaviView(com.google.security.zynamics.binnavi.disassembly.views.INaviView) INaviFunction(com.google.security.zynamics.binnavi.disassembly.INaviFunction)

Aggregations

INaviView (com.google.security.zynamics.binnavi.disassembly.views.INaviView)121 Test (org.junit.Test)54 INaviModule (com.google.security.zynamics.binnavi.disassembly.INaviModule)29 INaviFunction (com.google.security.zynamics.binnavi.disassembly.INaviFunction)26 ExpensiveBaseTest (com.google.security.zynamics.binnavi.disassembly.types.ExpensiveBaseTest)18 CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)14 INaviViewNode (com.google.security.zynamics.binnavi.disassembly.INaviViewNode)13 CTag (com.google.security.zynamics.binnavi.Tagging.CTag)11 INaviInstruction (com.google.security.zynamics.binnavi.disassembly.INaviInstruction)10 CView (com.google.security.zynamics.binnavi.disassembly.views.CView)10 ArrayList (java.util.ArrayList)10 CouldntLoadDataException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException)9 CouldntSaveDataException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException)8 HashMap (java.util.HashMap)8 MockSqlProvider (com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider)7 IComment (com.google.security.zynamics.binnavi.Gui.GraphWindows.CommentDialogs.Interfaces.IComment)7 CProjectContainer (com.google.security.zynamics.binnavi.disassembly.CProjectContainer)7 IAddress (com.google.security.zynamics.zylib.disassembly.IAddress)7 FilledList (com.google.security.zynamics.zylib.types.lists.FilledList)7 MockTagManager (com.google.security.zynamics.binnavi.Tagging.MockTagManager)6