Search in sources :

Example 1 with IDebugger

use of com.google.security.zynamics.binnavi.debug.debugger.interfaces.IDebugger in project binnavi by google.

the class CMemoryMenu method createMenu.

/**
 * Creates the context menu of a memory viewer component.
 *
 * @param offset The memory offset where the context menu will be shown.
 *
 * @return The context menu for the specified address.
 */
@Override
public JPopupMenu createMenu(final long offset) {
    final JPopupMenu menu = new JPopupMenu();
    final IDebugger debugger = m_debugger.getCurrentSelectedDebugger();
    if (debugger == null) {
        return null;
    }
    menu.add(CActionProxy.proxy(new CSearchAction(m_parent, m_debugger, m_memoryView)));
    menu.add(CActionProxy.proxy(new CGotoAction(m_parent, m_memoryView, m_debugger)));
    if (canReadDword(debugger.getProcessManager().getMemoryMap(), offset)) {
        final byte[] data = debugger.getProcessManager().getMemory().getData(offset, 4);
        final IAddress dword = new CAddress(ByteHelpers.readDwordLittleEndian(data, 0));
        if (canReadDword(debugger.getProcessManager().getMemoryMap(), dword.toLong())) {
            menu.add(CActionProxy.proxy(new CFollowDumpAction(m_debugger, dword)));
        }
    }
    menu.addSeparator();
    final long firstOffset = m_memoryView.getHexView().getBaseAddress();
    final int size = m_memoryView.getHexView().getData().getDataLength();
    menu.add(new CLoadAllAction(m_parent, debugger, new CAddress(firstOffset), size));
    // Offer the option to dump memory
    final JMenu dumpMenu = new JMenu("Dump to file");
    dumpMenu.add(CActionProxy.proxy(new CDumpMemoryRangeAction(m_parent, debugger, m_memoryView.getHexView().getData(), new CAddress(firstOffset), size)));
    menu.add(dumpMenu);
    menu.addSeparator();
    final BookmarkManager manager = debugger.getBookmarkManager();
    // At first offer the option to add or remove a bookmark
    // at the specified position.
    final CBookmark bookmark = manager.getBookmark(new CAddress(offset));
    if (bookmark == null) {
        menu.add(new JMenuItem(CActionProxy.proxy(new CCreateBookmarkAction(manager, new CAddress(offset)))));
    } else {
        menu.add(new JMenuItem(CActionProxy.proxy(new CDeleteBookmarkAction(manager, bookmark))));
    }
    if (manager.getNumberOfBookmarks() != 0) {
        // Afterwards list all currently active bookmarks.
        menu.addSeparator();
        final JMenu bookmarksItem = new JMenu("Bookmarks");
        for (int i = 0; i < manager.getNumberOfBookmarks(); i++) {
            bookmarksItem.add(CActionProxy.proxy(new CGotoBookmarkAction(m_debugger, manager.getBookmark(i))));
        }
        menu.add(bookmarksItem);
    }
    menu.addSeparator();
    menu.add(HexViewOptionsMenu.createHexViewOptionsMenu(m_memoryView.getHexView()));
    return menu;
}
Also used : CDeleteBookmarkAction(com.google.security.zynamics.binnavi.Gui.Debug.MemoryPanel.Actions.CDeleteBookmarkAction) CFollowDumpAction(com.google.security.zynamics.binnavi.Gui.Debug.MemoryPanel.Actions.CFollowDumpAction) CGotoBookmarkAction(com.google.security.zynamics.binnavi.Gui.Debug.MemoryPanel.Actions.CGotoBookmarkAction) CGotoAction(com.google.security.zynamics.binnavi.Gui.Debug.MemoryPanel.Actions.CGotoAction) CLoadAllAction(com.google.security.zynamics.binnavi.Gui.Debug.MemoryPanel.Actions.CLoadAllAction) JPopupMenu(javax.swing.JPopupMenu) IDebugger(com.google.security.zynamics.binnavi.debug.debugger.interfaces.IDebugger) IAddress(com.google.security.zynamics.zylib.disassembly.IAddress) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) BookmarkManager(com.google.security.zynamics.binnavi.models.Bookmarks.memory.BookmarkManager) CCreateBookmarkAction(com.google.security.zynamics.binnavi.Gui.Debug.MemoryPanel.Actions.CCreateBookmarkAction) CBookmark(com.google.security.zynamics.binnavi.models.Bookmarks.memory.CBookmark) CSearchAction(com.google.security.zynamics.binnavi.Gui.Debug.MemoryPanel.Actions.CSearchAction) CDumpMemoryRangeAction(com.google.security.zynamics.binnavi.Gui.Debug.MemoryPanel.Actions.CDumpMemoryRangeAction) JMenuItem(javax.swing.JMenuItem) JMenu(javax.swing.JMenu)

Example 2 with IDebugger

use of com.google.security.zynamics.binnavi.debug.debugger.interfaces.IDebugger in project binnavi by google.

the class CMemoryFunctions method gotoOffset.

/**
 * Shows the Goto Offset dialog and sets the caret of a hex control to the entered offset.
 *
 * @param parent Parent window used for dialogs.
 * @param view Hex view to focus after the Goto operation.
 * @param model Model that contains the memory viewer where the offset is changed.
 */
public static void gotoOffset(final JFrame parent, final CMemoryViewer view, final CDebugPerspectiveModel model) {
    final IDebugger debugger = model.getCurrentSelectedDebugger();
    if (debugger == null) {
        return;
    }
    final TargetProcessThread activeThread = debugger.getProcessManager().getActiveThread();
    final Memory memory = debugger.getProcessManager().getMemory();
    final CDefaultMemoryExpressionBinding binding = new CDefaultMemoryExpressionBinding(activeThread, memory);
    final CGotoDialog dlg = new CGotoDialog(parent, model.getCurrentSelectedDebugger().getProcessManager().getMemoryMap(), binding, model.getGotoAddress());
    dlg.setVisible(true);
    final IAddress value = dlg.getValue();
    if (value != null) {
        model.setGotoAddress(value);
        model.setActiveMemoryAddress(value, true);
        view.requestFocusInWindow();
    }
}
Also used : TargetProcessThread(com.google.security.zynamics.binnavi.debug.models.processmanager.TargetProcessThread) Memory(com.google.security.zynamics.zylib.general.memmanager.Memory) IDebugger(com.google.security.zynamics.binnavi.debug.debugger.interfaces.IDebugger) CGotoDialog(com.google.security.zynamics.binnavi.Gui.Debug.Goto.CGotoDialog) IAddress(com.google.security.zynamics.zylib.disassembly.IAddress)

Example 3 with IDebugger

use of com.google.security.zynamics.binnavi.debug.debugger.interfaces.IDebugger in project binnavi by google.

the class CMemoryRefreshButtonSynchronizer method updateGui.

/**
 * Updates the button according to the currently available information about the target process.
 */
private void updateGui() {
    final IDebugger debugger = m_debugPerspectiveModel.getCurrentSelectedDebugger();
    final TargetProcessThread thread = debugger == null ? null : debugger.getProcessManager().getActiveThread();
    final boolean connected = debugger != null && debugger.isConnected();
    final boolean suspended = connected && thread != null;
    m_refreshButton.setEnabled(suspended);
}
Also used : TargetProcessThread(com.google.security.zynamics.binnavi.debug.models.processmanager.TargetProcessThread) IDebugger(com.google.security.zynamics.binnavi.debug.debugger.interfaces.IDebugger)

Example 4 with IDebugger

use of com.google.security.zynamics.binnavi.debug.debugger.interfaces.IDebugger 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 5 with IDebugger

use of com.google.security.zynamics.binnavi.debug.debugger.interfaces.IDebugger in project binnavi by google.

the class CMemorySectionPanelSynchronizer method updateGui.

/**
 * Updates the GUI of the synchronized memory section box depending on the current state of the
 * debug GUI perspective and the active debugger.
 */
private void updateGui() {
    final IDebugger activeDebugger = debugPerspectiveModel.getCurrentSelectedDebugger();
    final TargetProcessThread activeThread = activeDebugger == null ? null : activeDebugger.getProcessManager().getActiveThread();
    final boolean enable = (activeThread != null) && (activeDebugger != null) && activeDebugger.isConnected() && (activeDebugger.getProcessManager().getTargetInformation() != null) && activeDebugger.getProcessManager().getTargetInformation().getDebuggerOptions().canMemmap() && (memorySectionBox.getItemCount() != 0);
    new SwingInvoker() {

        @Override
        protected void operation() {
            memorySectionBox.setEnabled(enable);
        }
    }.invokeAndWait();
}
Also used : TargetProcessThread(com.google.security.zynamics.binnavi.debug.models.processmanager.TargetProcessThread) SwingInvoker(com.google.security.zynamics.zylib.gui.SwingInvoker) IDebugger(com.google.security.zynamics.binnavi.debug.debugger.interfaces.IDebugger)

Aggregations

IDebugger (com.google.security.zynamics.binnavi.debug.debugger.interfaces.IDebugger)62 BreakpointManager (com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointManager)16 TargetProcessThread (com.google.security.zynamics.binnavi.debug.models.processmanager.TargetProcessThread)16 MockDebugger (com.google.security.zynamics.binnavi.Debug.Debugger.MockDebugger)6 ModuleTargetSettings (com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings)6 Breakpoint (com.google.security.zynamics.binnavi.debug.models.breakpoints.Breakpoint)6 BreakpointAddress (com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress)6 CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)6 Test (org.junit.Test)6 MemorySection (com.google.security.zynamics.binnavi.debug.models.processmanager.MemorySection)5 INaviModule (com.google.security.zynamics.binnavi.disassembly.INaviModule)5 UnrelocatedAddress (com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress)5 CDebugPerspectiveModel (com.google.security.zynamics.binnavi.Gui.GraphWindows.Panels.CDebugPerspectiveModel)4 INaviFunction (com.google.security.zynamics.binnavi.disassembly.INaviFunction)4 INaviInstruction (com.google.security.zynamics.binnavi.disassembly.INaviInstruction)4 BookmarkManager (com.google.security.zynamics.binnavi.models.Bookmarks.memory.BookmarkManager)4 IAddress (com.google.security.zynamics.zylib.disassembly.IAddress)4 Pair (com.google.security.zynamics.zylib.general.Pair)4 ArrayList (java.util.ArrayList)4 IGraphModel (com.google.security.zynamics.binnavi.Gui.GraphWindows.IGraphModel)3