Search in sources :

Example 1 with ZyGraph

use of com.google.security.zynamics.binnavi.yfileswrap.zygraph.ZyGraph in project binnavi by google.

the class CGraphBuilder method buildGraph.

/**
   * Builds a displayable graph from a view.
   *
   * @param view The view to be turned into a graph.
   *
   * @return The generated graph.
   * @throws LoadCancelledException Thrown if loading the graph was canceled.
   */
public static ZyGraph buildGraph(final INaviView view) throws LoadCancelledException {
    Preconditions.checkNotNull(view, "IE01763: View argument can't be null");
    final Pair<Map<String, String>, ZyGraphViewSettings> viewSettings = loadSettings(view);
    final Map<String, String> rawSettings = viewSettings.first();
    final ZyGraphViewSettings graphSettings = viewSettings.second();
    graphSettings.rawSettings = rawSettings;
    final ZyGraphBuilder builder = new ZyGraphBuilder();
    ZyGraphBuilderManager.instance().setBuilder(view, builder);
    final Graph2D graph = builder.convert(view.getGraph().getNodes(), view.getGraph().getEdges(), graphSettings, view.getType() == ViewType.Native);
    final ZyGraph2DView graphView = new ZyGraph2DView(graph);
    final ZyGraph zyGraph = new ZyGraph(view, builder.getNodeMap(), builder.getEdgeMap(), graphSettings, graphView);
    zyGraph.getView().setCenter(CViewSettingsGenerator.createDoubleSetting(rawSettings, "view_center_x", 0), CViewSettingsGenerator.createDoubleSetting(rawSettings, "view_center_y", 0));
    zyGraph.getView().setWorldRect(CViewSettingsGenerator.createIntegerSetting(rawSettings, "world_rect_x", 0), CViewSettingsGenerator.createIntegerSetting(rawSettings, "world_rect_y", 0), CViewSettingsGenerator.createIntegerSetting(rawSettings, "world_rect_width", 800), CViewSettingsGenerator.createIntegerSetting(rawSettings, "world_rect_height", 600));
    zyGraph.getView().setZoom(CViewSettingsGenerator.createDoubleSetting(rawSettings, "zoom", 1));
    ZyGraphBuilderManager.instance().removeBuilder(view);
    return zyGraph;
}
Also used : ZyGraphBuilder(com.google.security.zynamics.binnavi.yfileswrap.zygraph.Builders.ZyGraphBuilder) ZyGraphViewSettings(com.google.security.zynamics.binnavi.ZyGraph.ZyGraphViewSettings) ZyGraph(com.google.security.zynamics.binnavi.yfileswrap.zygraph.ZyGraph) ZyGraph2DView(com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.ZyGraph2DView) HashMap(java.util.HashMap) Map(java.util.Map) Graph2D(y.view.Graph2D)

Example 2 with ZyGraph

use of com.google.security.zynamics.binnavi.yfileswrap.zygraph.ZyGraph in project binnavi by google.

the class CGraphBuilder method buildDnDGraph.

/**
   * Builds a graph that supports drag and drop operations from the type editor onto operand tree
   * nodes in order to assign type substitutions.
   *
   * @param view The view to build the graph from.
   * @param typeManager THe type manager for the module that contains the given view.
   * @return Returns a new instance of the created graph.
   * @throws LoadCancelledException
   */
public static ZyGraph buildDnDGraph(final INaviView view, final TypeManager typeManager) throws LoadCancelledException {
    final ZyGraph graph = buildGraph(view);
    final ZyGraphDragAndDropSupport dndSupport = new ZyGraphDragAndDropSupport(graph, new BaseTypeTransferHandler(typeManager, new DragAndDropSupportWrapper(graph)));
    dndSupport.enableDndSupport();
    return graph;
}
Also used : BaseTypeTransferHandler(com.google.security.zynamics.binnavi.Gui.GraphWindows.types.BaseTypeTransferHandler) ZyGraph(com.google.security.zynamics.binnavi.yfileswrap.zygraph.ZyGraph) DragAndDropSupportWrapper(com.google.security.zynamics.binnavi.yfileswrap.Gui.GraphWindows.types.DragAndDropSupportWrapper) ZyGraphDragAndDropSupport(com.google.security.zynamics.binnavi.yfileswrap.zygraph.ZyGraphDragAndDropSupport)

Example 3 with ZyGraph

use of com.google.security.zynamics.binnavi.yfileswrap.zygraph.ZyGraph 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 4 with ZyGraph

use of com.google.security.zynamics.binnavi.yfileswrap.zygraph.ZyGraph in project binnavi by google.

the class OpenInLastWindowAndZoomToAddressAction method actionPerformed.

@Override
public void actionPerformed(final ActionEvent event) {
    final FutureCallback<Boolean> callBack = new FutureCallback<Boolean>() {

        @Override
        public void onFailure(final Throwable t) {
            CUtilityFunctions.logException(t);
        }

        @Override
        public void onSuccess(final Boolean result) {
            ZyGraph graph = null;
            final List<CGraphWindow> windows = CWindowManager.instance().getOpenWindows();
            for (final CGraphWindow graphContainer : windows) {
                for (final IGraphPanel window : graphContainer) {
                    if (reference.getView().equals(window.getModel().getGraph().getRawView())) {
                        graph = window.getModel().getGraph();
                    }
                }
            }
            for (final NaviNode node : graph.getNodes()) {
                if (node.getRawNode() instanceof INaviCodeNode) {
                    final INaviCodeNode codeNode = (INaviCodeNode) node.getRawNode();
                    for (final INaviInstruction instruction : codeNode.getInstructions()) {
                        if (instruction.getAddress().equals(reference.getAddress())) {
                            ZyZoomHelpers.zoomToAddress(graph, reference.getAddress());
                            CrossReferencePainter.paintCrossReference(node, codeNode, reference, instruction);
                        }
                    }
                }
            }
        }
    };
    CShowViewFunctions.showViewsAndPerformCallBack(m_parent, m_container, m_views, CWindowManager.instance().getLastWindow(), callBack);
}
Also used : CGraphWindow(com.google.security.zynamics.binnavi.Gui.GraphWindows.CGraphWindow) INaviCodeNode(com.google.security.zynamics.binnavi.disassembly.INaviCodeNode) ZyGraph(com.google.security.zynamics.binnavi.yfileswrap.zygraph.ZyGraph) IGraphPanel(com.google.security.zynamics.binnavi.Gui.GraphWindows.IGraphPanel) NaviNode(com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode) FutureCallback(com.google.common.util.concurrent.FutureCallback) INaviInstruction(com.google.security.zynamics.binnavi.disassembly.INaviInstruction)

Example 5 with ZyGraph

use of com.google.security.zynamics.binnavi.yfileswrap.zygraph.ZyGraph in project binnavi by google.

the class CGraphWindow method addGraph.

@Override
public void addGraph(final IGraphPanel panel) {
    if (panel.getPanel() == null) {
        throw new IllegalStateException("IE01145: Invalid panel object returned");
    }
    final ZyGraph graph = panel.getModel().getGraph();
    graph.addListener(m_graphListener);
    final INaviView rawView = graph.getRawView();
    if (!alreadyListening(rawView)) {
        // We need one listener per view to update the window title and
        // other stuff that depends on the view.
        rawView.addListener(m_viewListener);
    }
    m_tabbedPane.addTab(CNameShortener.shorten(rawView), panel.getPanel());
}
Also used : INaviView(com.google.security.zynamics.binnavi.disassembly.views.INaviView) ZyGraph(com.google.security.zynamics.binnavi.yfileswrap.zygraph.ZyGraph)

Aggregations

ZyGraph (com.google.security.zynamics.binnavi.yfileswrap.zygraph.ZyGraph)23 NaviNode (com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode)9 Test (org.junit.Test)9 CModuleContainer (com.google.security.zynamics.binnavi.disassembly.Modules.CModuleContainer)5 CCodeNode (com.google.security.zynamics.binnavi.disassembly.CCodeNode)4 INaviInstruction (com.google.security.zynamics.binnavi.disassembly.INaviInstruction)4 INaviModule (com.google.security.zynamics.binnavi.disassembly.INaviModule)4 MockSqlProvider (com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider)3 ZyGraphViewSettings (com.google.security.zynamics.binnavi.ZyGraph.ZyGraphViewSettings)3 INaviCodeNode (com.google.security.zynamics.binnavi.disassembly.INaviCodeNode)3 INaviFunction (com.google.security.zynamics.binnavi.disassembly.INaviFunction)3 INaviViewNode (com.google.security.zynamics.binnavi.disassembly.INaviViewNode)3 INaviView (com.google.security.zynamics.binnavi.disassembly.views.INaviView)3 ZyGraph2DView (com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.ZyGraph2DView)3 MockDatabase (com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase)2 MockDebuggerProvider (com.google.security.zynamics.binnavi.Debug.Debugger.MockDebuggerProvider)2 CGraphWindow (com.google.security.zynamics.binnavi.Gui.GraphWindows.CGraphWindow)2 CComment (com.google.security.zynamics.binnavi.Gui.GraphWindows.CommentDialogs.CComment)2 CTag (com.google.security.zynamics.binnavi.Tagging.CTag)2 CCodeNodeUpdater (com.google.security.zynamics.binnavi.ZyGraph.Updaters.CodeNodes.CCodeNodeUpdater)2