Search in sources :

Example 81 with CAddress

use of com.google.security.zynamics.zylib.disassembly.CAddress in project binnavi by google.

the class FunctionEdgeTest method testConstructor.

@Test
public void testConstructor() {
    final MockSqlProvider provider = new MockSqlProvider();
    final CModule internalModule = new CModule(1, "", "", new Date(), new Date(), "00000000000000000000000000000000", "0000000000000000000000000000000000000000", 0, 0, new CAddress(0), new CAddress(0), null, null, Integer.MAX_VALUE, false, provider);
    final CFunction parentFunction = new CFunction(internalModule, new MockView(), new CAddress(0x123), "Mock Function", "Mock Function", "Mock Description", 0, 0, 0, 0, FunctionType.NORMAL, "", 0, null, null, null, provider);
    final Function function = new Function(ModuleFactory.get(), parentFunction);
    final FunctionBlock block = new FunctionBlock(function);
    final FunctionBlock childBlock = new FunctionBlock(function);
    final FunctionEdge edge = new FunctionEdge(block, childBlock);
    assertEquals("Function Edge [Mock Function -> Mock Function]", edge.toString());
    assertEquals(block, edge.getSource());
    assertEquals(childBlock, edge.getTarget());
    assertEquals(0, block.getParents().size());
    assertEquals(1, block.getChildren().size());
    assertEquals(childBlock, block.getChildren().get(0));
    assertEquals(0, childBlock.getChildren().size());
    assertEquals(1, childBlock.getParents().size());
    assertEquals(block, childBlock.getParents().get(0));
}
Also used : CFunction(com.google.security.zynamics.binnavi.disassembly.CFunction) MockView(com.google.security.zynamics.binnavi.disassembly.MockView) MockSqlProvider(com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider) CFunction(com.google.security.zynamics.binnavi.disassembly.CFunction) CModule(com.google.security.zynamics.binnavi.disassembly.Modules.CModule) Date(java.util.Date) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) Test(org.junit.Test)

Example 82 with CAddress

use of com.google.security.zynamics.zylib.disassembly.CAddress in project binnavi by google.

the class BookmarkManager method addBookmark.

// ! Creates a new bookmark.
/**
   * Creates a new bookmark with an address and a description.
   *
   * @param address The address of the new bookmark.
   * @param description The description of the new bookmark.
   */
public void addBookmark(final Address address, final String description) {
    Preconditions.checkNotNull(address, "Error: Bookmark addresses can't be null");
    m_bookmarkManager.addBookmark(new CBookmark(new CAddress(address.toLong()), description));
}
Also used : CBookmark(com.google.security.zynamics.binnavi.models.Bookmarks.memory.CBookmark) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress)

Example 83 with CAddress

use of com.google.security.zynamics.zylib.disassembly.CAddress in project binnavi by google.

the class CGotoAddressField method buildAddressSelectionPopUp.

/**
   * In the case of multiple modules zoom to address does not work therefore the user must select in
   * which module to search.
   */
private void buildAddressSelectionPopUp() {
    final CAddressSelectionDialog dlg = new CAddressSelectionDialog(m_parent, m_modules);
    dlg.setVisible(true);
    final INaviModule result = dlg.getSelectionResult();
    final IAddress address = new CAddress(Long.parseLong(getText(), 16));
    ZyZoomHelpers.zoomToAddress(m_graph, address, result, true);
}
Also used : INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) IAddress(com.google.security.zynamics.zylib.disassembly.IAddress) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress)

Example 84 with CAddress

use of com.google.security.zynamics.zylib.disassembly.CAddress in project binnavi by google.

the class CGotoAddressField method zoomToAddress.

/**
   * Zooms to the current address.
   */
private void zoomToAddress() {
    if (!"".equals(getText())) {
        add(getText());
        final IAddress address = new CAddress(Long.parseLong(getText(), 16));
        m_textField.setSuccessful(ZyZoomHelpers.zoomToAddress(m_graph, address, m_modules.get(0), true));
    }
}
Also used : IAddress(com.google.security.zynamics.zylib.disassembly.IAddress) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress)

Example 85 with CAddress

use of com.google.security.zynamics.zylib.disassembly.CAddress 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)

Aggregations

CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)315 Test (org.junit.Test)221 UnrelocatedAddress (com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress)60 MockSqlProvider (com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider)55 ModuleTargetSettings (com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings)51 BreakpointAddress (com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress)48 MockDebugger (com.google.security.zynamics.binnavi.Debug.Debugger.MockDebugger)47 CModule (com.google.security.zynamics.binnavi.disassembly.Modules.CModule)47 ArrayList (java.util.ArrayList)46 Date (java.util.Date)46 MockModule (com.google.security.zynamics.binnavi.disassembly.Modules.MockModule)45 INaviModule (com.google.security.zynamics.binnavi.disassembly.INaviModule)40 MemorySection (com.google.security.zynamics.binnavi.debug.models.processmanager.MemorySection)32 MemoryMap (com.google.security.zynamics.binnavi.debug.models.processmanager.MemoryMap)29 MockView (com.google.security.zynamics.binnavi.disassembly.MockView)28 TargetProcessThread (com.google.security.zynamics.binnavi.debug.models.processmanager.TargetProcessThread)27 RelocatedAddress (com.google.security.zynamics.binnavi.disassembly.RelocatedAddress)27 CFunction (com.google.security.zynamics.binnavi.disassembly.CFunction)26 MockDatabase (com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase)24 CTag (com.google.security.zynamics.binnavi.Tagging.CTag)24