Search in sources :

Example 11 with ZyGraph

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

the class CVariableHighlighterTest method test1Simple.

@Test
public void test1Simple() throws FileReadException, CouldntLoadDataException, LoadCancelledException, CouldntSaveDataException {
    final ZyGraph graph = ZyGraphFactory.generateTestGraph();
    final List<INaviInstruction> mockInstructions = new ArrayList<INaviInstruction>();
    final CCodeNode node = graph.getRawView().getBasicBlocks().get(0);
    final NaviNode naviNode = graph.getNode(node);
    mockInstructions.add(Iterables.get(node.getInstructions(), 0));
    final BackEndDebuggerProvider provider = new MockDebuggerProvider();
    @SuppressWarnings("unused") final CCodeNodeUpdater updater = new CCodeNodeUpdater(graph, naviNode, node, provider);
    assertFalse(naviNode.getRealizer().getNodeContent().getLineContent(0).hasHighlighting(CHighlightLayers.VARIABLE_LAYER));
    CVariableHighlighter.highlightInstructions(graph, mockInstructions);
    assertTrue(naviNode.getRealizer().getNodeContent().getLineContent(0).hasHighlighting(CHighlightLayers.VARIABLE_LAYER));
}
Also used : ZyGraph(com.google.security.zynamics.binnavi.yfileswrap.zygraph.ZyGraph) CCodeNode(com.google.security.zynamics.binnavi.disassembly.CCodeNode) CCodeNodeUpdater(com.google.security.zynamics.binnavi.ZyGraph.Updaters.CodeNodes.CCodeNodeUpdater) ArrayList(java.util.ArrayList) NaviNode(com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode) BackEndDebuggerProvider(com.google.security.zynamics.binnavi.debug.debugger.BackEndDebuggerProvider) MockDebuggerProvider(com.google.security.zynamics.binnavi.Debug.Debugger.MockDebuggerProvider) INaviInstruction(com.google.security.zynamics.binnavi.disassembly.INaviInstruction) Test(org.junit.Test)

Example 12 with ZyGraph

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

the class CTaggedGraphNodeNodeTest method test1Simple.

@Test
public void test1Simple() throws FileReadException, CouldntLoadDataException, LoadCancelledException, CouldntSaveDataException {
    final ZyGraph graph = ZyGraphFactory.generateTestGraph();
    final CCodeNode node = graph.getRawView().getBasicBlocks().get(0);
    final NaviNode naviNode = graph.getNode(node);
    @SuppressWarnings("unused") final CTaggedGraphNodeNode taggedNode = new CTaggedGraphNodeNode(graph, naviNode);
}
Also used : ZyGraph(com.google.security.zynamics.binnavi.yfileswrap.zygraph.ZyGraph) CCodeNode(com.google.security.zynamics.binnavi.disassembly.CCodeNode) NaviNode(com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode) Test(org.junit.Test)

Example 13 with ZyGraph

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

the class CActionSave method actionPerformed.

@Override
public void actionPerformed(final ActionEvent event) {
    final ZyGraph graph = m_graph.get();
    final JFrame parent = m_parent.get();
    if ((graph != null) && (parent != null)) {
        CGraphSaver.save(parent, graph);
    }
}
Also used : JFrame(javax.swing.JFrame) ZyGraph(com.google.security.zynamics.binnavi.yfileswrap.zygraph.ZyGraph)

Example 14 with ZyGraph

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

the class CViewLoader method load.

/**
   * Loads a view.
   *
   * @throws LoadCancelledException Thrown if the user canceled the load operation.
   * @throws CPartialLoadException Thrown if not all required modules are loaded.
   * @throws CouldntLoadDataException Thrown if the view data could not be loaded from the database.
   */
public void load() throws CouldntLoadDataException, CPartialLoadException, LoadCancelledException {
    if (!view.isLoaded()) {
        view.load();
    }
    // Convert the data from the raw view into a graph that can be displayed.
    final ZyGraph graph = container instanceof CModuleContainer ? CGraphBuilder.buildDnDGraph(view, container.getModules().get(0).getTypeManager()) : CGraphBuilder.buildGraph(view);
    CRegisterHotKeys.register(graph);
    if (window == null) {
        // If the parent window of the graph is null, a new graph window is created.
        final CGraphWindow navi = new CGraphWindow();
        final CGraphModel model = new CGraphModel(navi, container.getDatabase(), container, graph);
        CNodeUpdaterInitializer.addUpdaters(model);
        final CGraphPanel panel = new CGraphPanel(model);
        navi.addGraph(panel);
        CWindowManager.instance().register(navi);
        // Part of the workaround you can find in WorkaroundListener in CGraphWindow
        navi.setSize(Toolkit.getDefaultToolkit().getScreenSize());
        navi.setVisible(true);
        GuiHelper.applyWindowFix(navi);
        navi.setExtendedState(Frame.MAXIMIZED_BOTH);
        workArounds(panel);
        graphModel = model;
    } else {
        final CGraphModel model = new CGraphModel(window, container.getDatabase(), container, graph);
        CNodeUpdaterInitializer.addUpdaters(model);
        final CGraphPanel panel = new CGraphPanel(model);
        // If a parent window is given, the graph is added to this window.
        window.addGraph(panel);
        workArounds(panel);
        window.toFront();
        graphModel = model;
    }
}
Also used : CGraphWindow(com.google.security.zynamics.binnavi.Gui.GraphWindows.CGraphWindow) CGraphPanel(com.google.security.zynamics.binnavi.Gui.GraphWindows.CGraphPanel) ZyGraph(com.google.security.zynamics.binnavi.yfileswrap.zygraph.ZyGraph) CGraphModel(com.google.security.zynamics.binnavi.Gui.GraphWindows.CGraphModel) CModuleContainer(com.google.security.zynamics.binnavi.disassembly.Modules.CModuleContainer)

Example 15 with ZyGraph

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

the class CPanelCloser method saveNativeGraph.

/**
   * Saves a native graph.
   *
   * @param parent The parent window of the panel.
   * @param panel The panel to be closed.
   */
private static void saveNativeGraph(final JFrame parent, final IGraphPanel panel) {
    final ZyGraph graph = panel.getModel().getGraph();
    final CSaveProgress progress = CGraphSaver.saveAs(parent, graph, panel.getModel().getViewContainer());
    while (!progress.isDone()) {
        try {
            Thread.sleep(100);
        } catch (final InterruptedException e) {
            // restore the interrupted status of the thread.
            // http://www.ibm.com/developerworks/java/library/j-jtp05236/index.html
            java.lang.Thread.currentThread().interrupt();
        }
    }
}
Also used : ZyGraph(com.google.security.zynamics.binnavi.yfileswrap.zygraph.ZyGraph) CSaveProgress(com.google.security.zynamics.binnavi.Gui.GraphWindows.Implementations.CSaveProgress)

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