Search in sources :

Example 1 with IGraphPanel

use of com.google.security.zynamics.binnavi.Gui.GraphWindows.IGraphPanel in project binnavi by google.

the class CDebugEventNotifier method activateWindow.

/**
 * Activates the window of this debugger.
 *
 * @return The window of this debugger.
 */
private JFrame activateWindow() {
    for (final IGraphContainerWindow window : CWindowManager.instance().getOpenWindows()) {
        for (final IGraphPanel graphPanel : window) {
            final BackEndDebuggerProvider debuggerProvider = graphPanel.getModel().getDebuggerProvider();
            for (final IDebugger d : debuggerProvider) {
                if (d == m_debugger) {
                    window.activate(graphPanel);
                    window.show();
                    return window.getFrame();
                }
            }
        }
    }
    return null;
}
Also used : IGraphContainerWindow(com.google.security.zynamics.binnavi.Gui.GraphWindows.IGraphContainerWindow) IGraphPanel(com.google.security.zynamics.binnavi.Gui.GraphWindows.IGraphPanel) BackEndDebuggerProvider(com.google.security.zynamics.binnavi.debug.debugger.BackEndDebuggerProvider) IDebugger(com.google.security.zynamics.binnavi.debug.debugger.interfaces.IDebugger)

Example 2 with IGraphPanel

use of com.google.security.zynamics.binnavi.Gui.GraphWindows.IGraphPanel 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 3 with IGraphPanel

use of com.google.security.zynamics.binnavi.Gui.GraphWindows.IGraphPanel in project binnavi by google.

the class PluginInterface method show.

/**
 * Shows a view in a given graph window.
 *
 * @param graphWindow The window in which the view is shown. This argument can be null.
 * @param view The view to show.
 * @param container Context in which the view is opened.
 *
 * @return Describes the open view.
 */
private View2D show(final CGraphWindow graphWindow, final View view, final IViewContainer container) {
    for (final CGraphWindow window : CWindowManager.instance()) {
        for (final IGraphPanel panel : window) {
            if (panel.getModel().getGraph().getRawView() == view.getNative()) {
                return panel.getModel().getView2D();
            }
        }
    }
    final WindowWaiter waiter = new WindowWaiter(view.getNative());
    CWindowManager.instance().addListener(waiter);
    final List<CGraphWindow> openBefore = CWindowManager.instance().getOpenWindows();
    for (final CGraphWindow window : openBefore) {
        window.addListener(waiter);
    }
    CViewOpener.showView(mainWindow.getFrame(), container, view.getNative(), graphWindow);
    while (waiter.getModel() == null) {
        try {
            Thread.sleep(1000);
        } catch (final InterruptedException exception) {
            CUtilityFunctions.logException(exception);
            // restore the interrupted status of the thread.
            // http://www.ibm.com/developerworks/java/library/j-jtp05236/index.html
            java.lang.Thread.currentThread().interrupt();
        }
    }
    final CGraphModel model = waiter.getModel();
    CWindowManager.instance().removeListener(waiter);
    for (final CGraphWindow window : openBefore) {
        window.removeListener(waiter);
    }
    return model.getView2D();
}
Also used : CGraphWindow(com.google.security.zynamics.binnavi.Gui.GraphWindows.CGraphWindow) IGraphPanel(com.google.security.zynamics.binnavi.Gui.GraphWindows.IGraphPanel) CGraphModel(com.google.security.zynamics.binnavi.Gui.GraphWindows.CGraphModel)

Example 4 with IGraphPanel

use of com.google.security.zynamics.binnavi.Gui.GraphWindows.IGraphPanel in project binnavi by google.

the class CBreakpointFunctions method zoomToBreakpoint.

/**
 * Zooms to a given breakpoint.
 *
 * @param parent Parent window for dialogs.
 * @param graph Graph shown in the window of the breakpoint table.
 * @param container View container of the graph.
 * @param address Address to zoom to.
 */
public static void zoomToBreakpoint(final Window parent, final ZyGraph graph, final IViewContainer container, final BreakpointAddress address) {
    final IAddress addr = address.getAddress().getAddress();
    if (!ZyZoomHelpers.zoomToAddress(graph, addr, address.getModule(), true)) {
        for (final CGraphWindow window : CWindowManager.instance()) {
            for (final IGraphPanel graphPanel : window) {
                if (ZyZoomHelpers.zoomToAddress(graphPanel.getModel().getGraph(), addr, address.getModule(), true)) {
                    window.activate(graphPanel);
                    window.toFront();
                    return;
                }
            }
        }
        CViewSearcher.searchView(parent, container, addr);
    }
}
Also used : CGraphWindow(com.google.security.zynamics.binnavi.Gui.GraphWindows.CGraphWindow) IGraphPanel(com.google.security.zynamics.binnavi.Gui.GraphWindows.IGraphPanel) IAddress(com.google.security.zynamics.zylib.disassembly.IAddress)

Example 5 with IGraphPanel

use of com.google.security.zynamics.binnavi.Gui.GraphWindows.IGraphPanel in project binnavi by google.

the class CPanelFinder method getPanelWithAddress.

/**
 * Returns the graph panel that contains a given address.
 *
 * @param debugger The active debugger.
 * @param address The address to search for.
 *
 * @return The graph panel that contains the address or null if there is no such graph panel.
 */
public static IGraphPanel getPanelWithAddress(final IDebugger debugger, final UnrelocatedAddress address) {
    final List<IGraphPanel> panels = collectPanelsWithAddress(debugger, address);
    if (panels.isEmpty()) {
        return null;
    } else {
        final List<IGraphPanel> activeWindowPanels = new ArrayList<IGraphPanel>();
        final List<IGraphPanel> inactiveWindowPanels = new ArrayList<IGraphPanel>();
        for (final IGraphPanel panel : panels) {
            final CGraphWindow parent = panel.getModel().getParent();
            if (parent.isActive() && parent.isActiveGraph(panel)) {
                return panel;
            } else if (parent.isActive()) {
                activeWindowPanels.add(panel);
            } else {
                inactiveWindowPanels.add(panel);
            }
        }
        if (activeWindowPanels.isEmpty()) {
            // Arbitrarily choose a panel from a non-active window
            return inactiveWindowPanels.get(0);
        } else {
            // Arbitrarily choose a panel from the active window
            return activeWindowPanels.get(0);
        }
    }
}
Also used : CGraphWindow(com.google.security.zynamics.binnavi.Gui.GraphWindows.CGraphWindow) IGraphPanel(com.google.security.zynamics.binnavi.Gui.GraphWindows.IGraphPanel) ArrayList(java.util.ArrayList)

Aggregations

IGraphPanel (com.google.security.zynamics.binnavi.Gui.GraphWindows.IGraphPanel)7 CGraphWindow (com.google.security.zynamics.binnavi.Gui.GraphWindows.CGraphWindow)5 FutureCallback (com.google.common.util.concurrent.FutureCallback)1 CGraphModel (com.google.security.zynamics.binnavi.Gui.GraphWindows.CGraphModel)1 IGraphContainerWindow (com.google.security.zynamics.binnavi.Gui.GraphWindows.IGraphContainerWindow)1 BackEndDebuggerProvider (com.google.security.zynamics.binnavi.debug.debugger.BackEndDebuggerProvider)1 IDebugger (com.google.security.zynamics.binnavi.debug.debugger.interfaces.IDebugger)1 INaviCodeNode (com.google.security.zynamics.binnavi.disassembly.INaviCodeNode)1 INaviInstruction (com.google.security.zynamics.binnavi.disassembly.INaviInstruction)1 NaviNode (com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode)1 ZyGraph (com.google.security.zynamics.binnavi.yfileswrap.zygraph.ZyGraph)1 IAddress (com.google.security.zynamics.zylib.disassembly.IAddress)1 ArrayList (java.util.ArrayList)1