Search in sources :

Example 1 with BookmarkManager

use of com.google.security.zynamics.binnavi.models.Bookmarks.memory.BookmarkManager 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 BookmarkManager

use of com.google.security.zynamics.binnavi.models.Bookmarks.memory.BookmarkManager in project binnavi by google.

the class CBookmarksTableModelTest method test2getValueAt.

@Test
public void test2getValueAt() {
    final DebugTargetSettings target = new ModuleTargetSettings(CommonTestObjects.MODULE);
    final DebuggerProvider debuggerProvider = new DebuggerProvider(target);
    final CBookmarkTableModel model = new CBookmarkTableModel(debuggerProvider);
    final IAddress address = new MockAddress();
    final CBookmark bookmark = new CBookmark(address, "foo");
    final MockDebugger debugger = new MockDebugger(new ModuleTargetSettings(CommonTestObjects.MODULE));
    debugger.getBreakpointManager().addBreakpoints(BreakpointType.REGULAR, CommonTestObjects.BP_ADDRESS_0_SET);
    debuggerProvider.addDebugger(debugger);
    final BookmarkManager bookmarkManager = debugger.getBookmarkManager();
    bookmarkManager.addBookmark(bookmark);
    assertEquals(1, bookmarkManager.getNumberOfBookmarks());
    assertEquals("foo", model.getValueAt(0, 2));
    assertEquals(address.toHexString(), model.getValueAt(0, 1));
    assertEquals(debugger.getPrintableString(), model.getValueAt(0, 0));
    final int[] rows = { 0 };
    CBookmarkFunctions.deleteBookmarks(debuggerProvider, rows);
    assertEquals(0, bookmarkManager.getNumberOfBookmarks());
    model.dispose();
}
Also used : MockDebugger(com.google.security.zynamics.binnavi.Debug.Debugger.MockDebugger) CBookmark(com.google.security.zynamics.binnavi.models.Bookmarks.memory.CBookmark) DebuggerProvider(com.google.security.zynamics.binnavi.debug.debugger.DebuggerProvider) CBookmarkTableModel(com.google.security.zynamics.binnavi.Gui.Debug.Bookmarks.CBookmarkTableModel) DebugTargetSettings(com.google.security.zynamics.binnavi.debug.debugger.DebugTargetSettings) ModuleTargetSettings(com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings) MockAddress(com.google.security.zynamics.zylib.disassembly.MockAddress) IAddress(com.google.security.zynamics.zylib.disassembly.IAddress) BookmarkManager(com.google.security.zynamics.binnavi.models.Bookmarks.memory.BookmarkManager) Test(org.junit.Test)

Example 3 with BookmarkManager

use of com.google.security.zynamics.binnavi.models.Bookmarks.memory.BookmarkManager in project binnavi by google.

the class CBoookmarkFunctionsTest method test2DeleteBookmarks.

@Test
public void test2DeleteBookmarks() {
    final DebugTargetSettings target = new ModuleTargetSettings(CommonTestObjects.MODULE);
    final DebuggerProvider debuggerProvider = new DebuggerProvider(target);
    final CBookmarkTableModel model = new CBookmarkTableModel(debuggerProvider);
    final CBookmark bookmark = new CBookmark(new MockAddress(), "foo");
    final MockDebugger debugger = new MockDebugger(new ModuleTargetSettings(CommonTestObjects.MODULE));
    debugger.getBreakpointManager().addBreakpoints(BreakpointType.REGULAR, CommonTestObjects.BP_ADDRESS_0_SET);
    debuggerProvider.addDebugger(debugger);
    final BookmarkManager bookmarkManager = debugger.getBookmarkManager();
    bookmarkManager.addBookmark(bookmark);
    assertEquals(1, bookmarkManager.getNumberOfBookmarks());
    final int[] rows = { 0 };
    CBookmarkFunctions.deleteBookmarks(debuggerProvider, rows);
    assertEquals(0, bookmarkManager.getNumberOfBookmarks());
    model.dispose();
}
Also used : MockDebugger(com.google.security.zynamics.binnavi.Debug.Debugger.MockDebugger) CBookmark(com.google.security.zynamics.binnavi.models.Bookmarks.memory.CBookmark) DebuggerProvider(com.google.security.zynamics.binnavi.debug.debugger.DebuggerProvider) CBookmarkTableModel(com.google.security.zynamics.binnavi.Gui.Debug.Bookmarks.CBookmarkTableModel) DebugTargetSettings(com.google.security.zynamics.binnavi.debug.debugger.DebugTargetSettings) ModuleTargetSettings(com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings) MockAddress(com.google.security.zynamics.zylib.disassembly.MockAddress) BookmarkManager(com.google.security.zynamics.binnavi.models.Bookmarks.memory.BookmarkManager) Test(org.junit.Test)

Example 4 with BookmarkManager

use of com.google.security.zynamics.binnavi.models.Bookmarks.memory.BookmarkManager in project binnavi by google.

the class CBookmarkTableModel method getBookmarkAddress.

/**
   * Finds the bookmark address of the bookmark that is displayed in a given row of the table.
   *
   * @param row The table row where the bookmark is displayed.
   *
   * @return The bookmark address of the bookmark in the given row.
   */
private String getBookmarkAddress(final int row) {
    final Triple<IDebugger, BookmarkManager, Integer> bookmarkTriple = CBookmarkTableHelpers.findBookmark(m_debuggerProvider, row);
    final BookmarkManager manager = bookmarkTriple.second();
    final int index = bookmarkTriple.third();
    return manager.getBookmark(index).getAddress().toHexString();
}
Also used : IDebugger(com.google.security.zynamics.binnavi.debug.debugger.interfaces.IDebugger) BookmarkManager(com.google.security.zynamics.binnavi.models.Bookmarks.memory.BookmarkManager)

Example 5 with BookmarkManager

use of com.google.security.zynamics.binnavi.models.Bookmarks.memory.BookmarkManager in project binnavi by google.

the class CBookmarkTableModel method setBookmarkDescription.

/**
   * Modifies the bookmark description of the bookmark displayed in the given row.
   *
   * @param row The row of the bookmark.
   * @param description The new description of the bookmark.
   */
private void setBookmarkDescription(final int row, final String description) {
    final Triple<IDebugger, BookmarkManager, Integer> bookmarkTriple = CBookmarkTableHelpers.findBookmark(m_debuggerProvider, row);
    final BookmarkManager manager = bookmarkTriple.second();
    final int index = bookmarkTriple.third();
    manager.getBookmark(index).setDescription(description);
}
Also used : IDebugger(com.google.security.zynamics.binnavi.debug.debugger.interfaces.IDebugger) BookmarkManager(com.google.security.zynamics.binnavi.models.Bookmarks.memory.BookmarkManager)

Aggregations

BookmarkManager (com.google.security.zynamics.binnavi.models.Bookmarks.memory.BookmarkManager)8 IDebugger (com.google.security.zynamics.binnavi.debug.debugger.interfaces.IDebugger)5 CBookmark (com.google.security.zynamics.binnavi.models.Bookmarks.memory.CBookmark)5 Test (org.junit.Test)3 MockDebugger (com.google.security.zynamics.binnavi.Debug.Debugger.MockDebugger)2 CBookmarkTableModel (com.google.security.zynamics.binnavi.Gui.Debug.Bookmarks.CBookmarkTableModel)2 DebugTargetSettings (com.google.security.zynamics.binnavi.debug.debugger.DebugTargetSettings)2 DebuggerProvider (com.google.security.zynamics.binnavi.debug.debugger.DebuggerProvider)2 ModuleTargetSettings (com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings)2 CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)2 IAddress (com.google.security.zynamics.zylib.disassembly.IAddress)2 MockAddress (com.google.security.zynamics.zylib.disassembly.MockAddress)2 CCreateBookmarkAction (com.google.security.zynamics.binnavi.Gui.Debug.MemoryPanel.Actions.CCreateBookmarkAction)1 CDeleteBookmarkAction (com.google.security.zynamics.binnavi.Gui.Debug.MemoryPanel.Actions.CDeleteBookmarkAction)1 CDumpMemoryRangeAction (com.google.security.zynamics.binnavi.Gui.Debug.MemoryPanel.Actions.CDumpMemoryRangeAction)1 CFollowDumpAction (com.google.security.zynamics.binnavi.Gui.Debug.MemoryPanel.Actions.CFollowDumpAction)1 CGotoAction (com.google.security.zynamics.binnavi.Gui.Debug.MemoryPanel.Actions.CGotoAction)1 CGotoBookmarkAction (com.google.security.zynamics.binnavi.Gui.Debug.MemoryPanel.Actions.CGotoBookmarkAction)1 CLoadAllAction (com.google.security.zynamics.binnavi.Gui.Debug.MemoryPanel.Actions.CLoadAllAction)1 CSearchAction (com.google.security.zynamics.binnavi.Gui.Debug.MemoryPanel.Actions.CSearchAction)1