Search in sources :

Example 1 with CModuleContainer

use of com.google.security.zynamics.binnavi.disassembly.Modules.CModuleContainer in project binnavi by google.

the class View2DTest method setUp.

@Before
public void setUp() throws CouldntLoadDataException, LoadCancelledException, FileReadException {
    ConfigManager.instance().read();
    final MockDatabase database = new MockDatabase();
    final CModule module = new CModule(1, "", "", new Date(), new Date(), "00000000000000000000000000000000", "0000000000000000000000000000000000000000", 0, 0, new CAddress(0), new CAddress(0), null, null, Integer.MAX_VALUE, false, new MockSqlProvider());
    database.getContent().addModule(module);
    manager.addDatabase(database);
    module.load();
    m_view = module.getContent().getViewContainer().createView("name", "description");
    final ZyGraphViewSettings settings = new ZyGraphViewSettings(new CallGraphSettingsConfigItem());
    settings.getLayoutSettings().setDefaultGraphLayout(LayoutStyle.CIRCULAR);
    final ZyGraph2DView g2dView = new ZyGraph2DView();
    final LinkedHashMap<Node, NaviNode> nodeMap = new LinkedHashMap<Node, NaviNode>();
    final LinkedHashMap<Edge, NaviEdge> edgeMap = new LinkedHashMap<Edge, NaviEdge>();
    final Node node1 = g2dView.getGraph2D().createNode();
    final CTextNode rawNode1 = m_view.getContent().createTextNode(Lists.<IComment>newArrayList(new CComment(null, CommonTestObjects.TEST_USER_1, null, " TEXT NODE ")));
    nodeMap.put(node1, new NaviNode(node1, new ZyNormalNodeRealizer<NaviNode>(new ZyLabelContent(null)), rawNode1));
    final Node node2 = g2dView.getGraph2D().createNode();
    final CTextNode rawNode2 = m_view.getContent().createTextNode(Lists.<IComment>newArrayList(new CComment(null, CommonTestObjects.TEST_USER_1, null, " TEXT COMMENT ")));
    nodeMap.put(node2, new NaviNode(node2, new ZyNormalNodeRealizer<NaviNode>(new ZyLabelContent(null)), rawNode2));
    final Edge edge = g2dView.getGraph2D().createEdge(node1, node2);
    final INaviEdge rawEdge = m_view.getContent().createEdge(rawNode1, rawNode2, com.google.security.zynamics.zylib.gui.zygraph.edges.EdgeType.JUMP_CONDITIONAL_FALSE);
    edgeMap.put(edge, new NaviEdge(nodeMap.get(node1), nodeMap.get(node2), edge, new ZyEdgeRealizer<NaviEdge>(new ZyLabelContent(null), null), rawEdge));
    final ZyGraph graph = new ZyGraph(m_view, nodeMap, edgeMap, settings, g2dView);
    m_view2d = new View2D(database, new CModuleContainer(database, module), graph, pluginInterface);
}
Also used : ZyGraphViewSettings(com.google.security.zynamics.binnavi.ZyGraph.ZyGraphViewSettings) CallGraphSettingsConfigItem(com.google.security.zynamics.binnavi.config.CallGraphSettingsConfigItem) ZyGraph(com.google.security.zynamics.binnavi.yfileswrap.zygraph.ZyGraph) CTextNode(com.google.security.zynamics.binnavi.disassembly.CTextNode) Node(y.base.Node) NaviNode(com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode) NaviNode(com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode) INaviEdge(com.google.security.zynamics.binnavi.disassembly.INaviEdge) CModuleContainer(com.google.security.zynamics.binnavi.disassembly.Modules.CModuleContainer) Date(java.util.Date) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) LinkedHashMap(java.util.LinkedHashMap) View2D(com.google.security.zynamics.binnavi.yfileswrap.API.disassembly.View2D) CComment(com.google.security.zynamics.binnavi.Gui.GraphWindows.CommentDialogs.CComment) ZyEdgeRealizer(com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.realizers.ZyEdgeRealizer) ZyLabelContent(com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLabelContent) MockSqlProvider(com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider) ZyNormalNodeRealizer(com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.realizers.ZyNormalNodeRealizer) MockDatabase(com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase) ZyGraph2DView(com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.ZyGraph2DView) CTextNode(com.google.security.zynamics.binnavi.disassembly.CTextNode) CModule(com.google.security.zynamics.binnavi.disassembly.Modules.CModule) NaviEdge(com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviEdge) Edge(y.base.Edge) INaviEdge(com.google.security.zynamics.binnavi.disassembly.INaviEdge) NaviEdge(com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviEdge) INaviEdge(com.google.security.zynamics.binnavi.disassembly.INaviEdge) Before(org.junit.Before)

Example 2 with CModuleContainer

use of com.google.security.zynamics.binnavi.disassembly.Modules.CModuleContainer in project binnavi by google.

the class PluginInterface method showInWindow.

/**
   * Shows a view in a given window.
   *
   * @param window The window where the view is shown.
   * @param view The view to show.
   *
   * @return The view2d object that is shown.
   */
public View2D showInWindow(final GraphWindow window, final View view) {
    Preconditions.checkNotNull(view, "Error: View argument can not be null");
    final ViewContainer container = view.getContainer();
    if (container instanceof Module) {
        final Module module = (Module) container;
        return show(window.getNative(), view, new CModuleContainer(container.getDatabase().getNative(), module.getNative()));
    } else {
        final Project project = (Project) container;
        return show(window.getNative(), view, new CProjectContainer(container.getDatabase().getNative(), project.getNative()));
    }
}
Also used : Project(com.google.security.zynamics.binnavi.API.disassembly.Project) CProjectContainer(com.google.security.zynamics.binnavi.disassembly.CProjectContainer) Module(com.google.security.zynamics.binnavi.API.disassembly.Module) CModuleContainer(com.google.security.zynamics.binnavi.disassembly.Modules.CModuleContainer) IViewContainer(com.google.security.zynamics.binnavi.disassembly.views.IViewContainer) ViewContainer(com.google.security.zynamics.binnavi.API.disassembly.ViewContainer)

Example 3 with CModuleContainer

use of com.google.security.zynamics.binnavi.disassembly.Modules.CModuleContainer in project binnavi by google.

the class PostgreSQLGroupNodeCommentTests method setupGroupNode.

private INaviGroupNode setupGroupNode() throws CouldntLoadDataException, LoadCancelledException, MaybeNullException, CPartialLoadException, CouldntSaveDataException {
    final INaviModule module = getProvider().loadModules().get(0);
    module.load();
    final INaviFunction function = module.getContent().getFunctionContainer().getFunction("sub_1004565");
    final INaviView view = module.getContent().getViewContainer().getView(function);
    view.load();
    assertEquals(42, view.getNodeCount());
    final INaviViewNode node1 = view.getContent().getBasicBlocks().get(1);
    final INaviViewNode node2 = view.getContent().getBasicBlocks().get(2);
    view.getContent().createGroupNode(Lists.newArrayList(node1, node2));
    final ZyGraph graph = CGraphBuilder.buildGraph(view);
    final INaviView nonNativeView = graph.saveAs(new CModuleContainer(getDatabase(), module), " TEST GROUP NODE COMMENTS ", " TESTING GROUP NODE COMMENTS ");
    INaviGroupNode savedGroupNode = null;
    for (final INaviViewNode node : nonNativeView.getGraph().getNodes()) {
        if (node instanceof INaviGroupNode) {
            savedGroupNode = (INaviGroupNode) node;
        }
    }
    return savedGroupNode;
}
Also used : INaviView(com.google.security.zynamics.binnavi.disassembly.views.INaviView) INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) ZyGraph(com.google.security.zynamics.binnavi.yfileswrap.zygraph.ZyGraph) INaviViewNode(com.google.security.zynamics.binnavi.disassembly.INaviViewNode) CModuleContainer(com.google.security.zynamics.binnavi.disassembly.Modules.CModuleContainer) INaviGroupNode(com.google.security.zynamics.binnavi.disassembly.INaviGroupNode) INaviFunction(com.google.security.zynamics.binnavi.disassembly.INaviFunction)

Example 4 with CModuleContainer

use of com.google.security.zynamics.binnavi.disassembly.Modules.CModuleContainer in project binnavi by google.

the class PostgreSQLTextNodeCommentTests method setupTextNode.

private INaviTextNode setupTextNode() throws CouldntLoadDataException, LoadCancelledException, MaybeNullException, CPartialLoadException, CouldntSaveDataException {
    final INaviModule module = getProvider().loadModules().get(1);
    module.load();
    final INaviFunction function = module.getContent().getFunctionContainer().getFunction("SetCommState");
    final INaviView view = module.getContent().getViewContainer().getView(function);
    view.load();
    final INaviCodeNode codeNode = view.getContent().getBasicBlocks().get(5);
    final INaviTextNode textNode = view.getContent().createTextNode(null);
    view.getContent().createEdge(codeNode, textNode, EdgeType.TEXTNODE_EDGE);
    final ZyGraph graph = CGraphBuilder.buildGraph(view);
    globalView = graph.saveAs(new CModuleContainer(getDatabase(), module), " TEST TEXT NODE COMMENTS ", " TESTING TEXT NODE COMMENTS ");
    INaviTextNode savedTextNode = null;
    for (final INaviViewNode node : globalView.getGraph().getNodes()) {
        if (node instanceof INaviTextNode) {
            savedTextNode = (INaviTextNode) node;
        }
    }
    return savedTextNode;
}
Also used : INaviCodeNode(com.google.security.zynamics.binnavi.disassembly.INaviCodeNode) INaviView(com.google.security.zynamics.binnavi.disassembly.views.INaviView) INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) ZyGraph(com.google.security.zynamics.binnavi.yfileswrap.zygraph.ZyGraph) INaviTextNode(com.google.security.zynamics.binnavi.disassembly.INaviTextNode) INaviViewNode(com.google.security.zynamics.binnavi.disassembly.INaviViewNode) CModuleContainer(com.google.security.zynamics.binnavi.disassembly.Modules.CModuleContainer) INaviFunction(com.google.security.zynamics.binnavi.disassembly.INaviFunction)

Example 5 with CModuleContainer

use of com.google.security.zynamics.binnavi.disassembly.Modules.CModuleContainer in project binnavi by google.

the class CPostgreSQLZyGraphTest2 method testSave.

@Test
public void testSave() throws CouldntSaveDataException, CouldntLoadDriverException, CouldntConnectException, InvalidDatabaseException, CouldntInitializeDatabaseException, CouldntLoadDataException, InvalidExporterDatabaseFormatException, InvalidDatabaseVersionException, CPartialLoadException, LoadCancelledException {
    m_view.getGraph().getNodes().get(0).setSelected(true);
    m_view.getGraph().getNodes().get(1).setColor(new Color(123));
    m_view.getGraph().getNodes().get(2).setX(456);
    m_view.getGraph().getNodes().get(3).setY(789);
    final INaviView newView = m_graph.saveAs(new CModuleContainer(m_database, m_module), "New View", "New View Description");
    m_database2.connect();
    m_database2.load();
    final INaviModule module = m_database2.getContent().getModules().get(0);
    module.load();
    final Iterable<INaviView> views = CViewFilter.getFlowgraphViews(module.getContent().getViewContainer().getViews());
    final INaviView loadedNewView = Iterables.getLast(views);
    loadedNewView.load();
    assertEquals(loadedNewView.getNodeCount(), newView.getNodeCount());
    assertEquals(true, loadedNewView.getGraph().getNodes().get(0).isSelected());
    assertEquals(0xFF00007B, loadedNewView.getGraph().getNodes().get(1).getColor().getRGB());
    assertEquals(456, loadedNewView.getGraph().getNodes().get(2).getX(), 0);
    assertEquals(789, loadedNewView.getGraph().getNodes().get(3).getY(), 0);
    m_database2.close();
}
Also used : INaviView(com.google.security.zynamics.binnavi.disassembly.views.INaviView) INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) Color(java.awt.Color) CModuleContainer(com.google.security.zynamics.binnavi.disassembly.Modules.CModuleContainer) Test(org.junit.Test)

Aggregations

CModuleContainer (com.google.security.zynamics.binnavi.disassembly.Modules.CModuleContainer)16 Test (org.junit.Test)7 CModuleNode (com.google.security.zynamics.binnavi.Gui.MainWindow.ProjectTree.Nodes.Module.CModuleNode)5 INaviModule (com.google.security.zynamics.binnavi.disassembly.INaviModule)5 INaviView (com.google.security.zynamics.binnavi.disassembly.views.INaviView)5 ZyGraph (com.google.security.zynamics.binnavi.yfileswrap.zygraph.ZyGraph)5 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)5 INaviFunction (com.google.security.zynamics.binnavi.disassembly.INaviFunction)4 Module (com.google.security.zynamics.binnavi.API.disassembly.Module)3 Project (com.google.security.zynamics.binnavi.API.disassembly.Project)3 ViewContainer (com.google.security.zynamics.binnavi.API.disassembly.ViewContainer)3 CProjectContainer (com.google.security.zynamics.binnavi.disassembly.CProjectContainer)3 INaviViewNode (com.google.security.zynamics.binnavi.disassembly.INaviViewNode)3 CView (com.google.security.zynamics.binnavi.disassembly.views.CView)3 IViewContainer (com.google.security.zynamics.binnavi.disassembly.views.IViewContainer)3 MockDatabase (com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase)2 CComment (com.google.security.zynamics.binnavi.Gui.GraphWindows.CommentDialogs.CComment)2 CModule (com.google.security.zynamics.binnavi.disassembly.Modules.CModule)2 CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)2 Date (java.util.Date)2