Search in sources :

Example 16 with MemorySection

use of com.google.security.zynamics.binnavi.debug.models.processmanager.MemorySection in project binnavi by google.

the class CDebuggerSynchronizerTest method testMemmap.

@Test
public void testMemmap() {
    final IFilledList<MemorySection> sections = new FilledList<MemorySection>();
    sections.add(new MemorySection(new CAddress(100), new CAddress(200)));
    sections.add(new MemorySection(new CAddress(300), new CAddress(400)));
    debuggerSynchronizer.receivedEvent(new MemoryMapReply(0, 0, new MemoryMap(sections)));
    assertEquals(0, listener.exception);
    assertEquals(2, mockDebugger.getProcessManager().getMemoryMap().getNumberOfSections());
}
Also used : MemoryMap(com.google.security.zynamics.binnavi.debug.models.processmanager.MemoryMap) MemorySection(com.google.security.zynamics.binnavi.debug.models.processmanager.MemorySection) IFilledList(com.google.security.zynamics.zylib.types.lists.IFilledList) FilledList(com.google.security.zynamics.zylib.types.lists.FilledList) MemoryMapReply(com.google.security.zynamics.binnavi.debug.connection.packets.replies.MemoryMapReply) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) Test(org.junit.Test)

Example 17 with MemorySection

use of com.google.security.zynamics.binnavi.debug.models.processmanager.MemorySection in project binnavi by google.

the class CRegisterMenuProvider method getRegisterMenu.

@Override
public JPopupMenu getRegisterMenu(final int registerNumber) {
    final IDebugger debugger = m_debugPerspectiveModel.getCurrentSelectedDebugger();
    if (debugger == null) {
        return null;
    }
    final JPopupMenu menu = new JPopupMenu();
    final BigInteger value = m_dataProvider.getRegisterInformation(registerNumber).getValue();
    menu.add(CActionProxy.proxy(new CCopyRegisterValueAction(value.toString(16).toUpperCase())));
    final MemorySection section = ProcessHelpers.getSectionWith(debugger.getProcessManager().getMemoryMap(), new CAddress(value));
    final JMenuItem gotoAddress = menu.add(CActionProxy.proxy(new CGotoOffsetAction(m_debugPerspectiveModel, new CAddress(value))));
    gotoAddress.setEnabled(section != null);
    if (containsAddress(m_debugPerspectiveModel.getGraphModel().getGraph().getRawView(), value.longValue())) {
        menu.add(CActionProxy.proxy(new CZoomToAddressAction(m_debugPerspectiveModel.getGraphModel().getGraph(), new CAddress(value), debugger.getModule(new RelocatedAddress(new CAddress(value))))));
    } else {
        final IViewContainer container = m_debugPerspectiveModel.getGraphModel().getViewContainer();
        menu.add(CActionProxy.proxy(new CSearchAction(m_debugPerspectiveModel.getGraphModel().getParent(), container, new CAddress(value))));
    }
    return menu;
}
Also used : CZoomToAddressAction(com.google.security.zynamics.binnavi.Gui.Debug.RegisterPanel.Actions.CZoomToAddressAction) CCopyRegisterValueAction(com.google.security.zynamics.binnavi.Gui.Debug.RegisterPanel.Actions.CCopyRegisterValueAction) IViewContainer(com.google.security.zynamics.binnavi.disassembly.views.IViewContainer) MemorySection(com.google.security.zynamics.binnavi.debug.models.processmanager.MemorySection) CGotoOffsetAction(com.google.security.zynamics.binnavi.Gui.Debug.RegisterPanel.Actions.CGotoOffsetAction) RelocatedAddress(com.google.security.zynamics.binnavi.disassembly.RelocatedAddress) BigInteger(java.math.BigInteger) CSearchAction(com.google.security.zynamics.binnavi.Gui.MainWindow.ProjectTree.Actions.CSearchAction) JMenuItem(javax.swing.JMenuItem) IDebugger(com.google.security.zynamics.binnavi.debug.debugger.interfaces.IDebugger) JPopupMenu(javax.swing.JPopupMenu) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress)

Example 18 with MemorySection

use of com.google.security.zynamics.binnavi.debug.models.processmanager.MemorySection in project binnavi by google.

the class CStackMemoryProvider method getStartAddress.

@Override
public long getStartAddress() {
    if (m_activeThread == null || m_activeThread.getRegisterValues().size() == 0 || m_debugger == null) {
        return -1;
    }
    final BigInteger stackValue = getStackValue(m_activeThread.getRegisterValues());
    if (stackValue == null) {
        return -1;
    }
    final MemorySection section = m_debugger.getProcessManager().getMemoryMap().findOffset(stackValue);
    if (section == null) {
        if (m_debugger.isConnected()) {
            return stackValue.and(BigInteger.valueOf(~0xFFF)).longValue();
        } else {
            return -1;
        }
    } else {
        return section.getStart().toLong();
    }
}
Also used : MemorySection(com.google.security.zynamics.binnavi.debug.models.processmanager.MemorySection) BigInteger(java.math.BigInteger)

Example 19 with MemorySection

use of com.google.security.zynamics.binnavi.debug.models.processmanager.MemorySection in project binnavi by google.

the class CMemorySelectionFunctions method askMemoryRange.

/**
   * Asks the user for a memory range and displays it afterwards.
   *
   * @param dlg Dialog where the user can select a range.
   * @param debugPerspectiveModel Describes the debug GUI perspective where the refresh action takes
   *        place.
   */
public static void askMemoryRange(final CMemoryRangeDialog dlg, final CDebugPerspectiveModel debugPerspectiveModel) {
    final IDebugger debugger = debugPerspectiveModel.getCurrentSelectedDebugger();
    if (debugger == null) {
        return;
    }
    dlg.setVisible(true);
    final IAddress start = dlg.getStart();
    final IAddress numberOfBytes = dlg.getBytes();
    if (start != null && numberOfBytes != null) {
        debugPerspectiveModel.setActiveMemoryAddress(start, true);
        final ProcessManager pmanager = debugger.getProcessManager();
        pmanager.setMemoryMap(new MemoryMap(new FilledList<MemorySection>()));
        pmanager.getMemory().clear();
        final ArrayList<MemorySection> sections = new ArrayList<MemorySection>();
        sections.add(new MemorySection(start, new CAddress(start.toBigInteger().add(numberOfBytes.toBigInteger()).subtract(BigInteger.ONE))));
        final MemoryMap map = new MemoryMap(sections);
        pmanager.setMemoryMap(map);
    }
}
Also used : MemoryMap(com.google.security.zynamics.binnavi.debug.models.processmanager.MemoryMap) MemorySection(com.google.security.zynamics.binnavi.debug.models.processmanager.MemorySection) FilledList(com.google.security.zynamics.zylib.types.lists.FilledList) ArrayList(java.util.ArrayList) IDebugger(com.google.security.zynamics.binnavi.debug.debugger.interfaces.IDebugger) IAddress(com.google.security.zynamics.zylib.disassembly.IAddress) ProcessManager(com.google.security.zynamics.binnavi.debug.models.processmanager.ProcessManager) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress)

Example 20 with MemorySection

use of com.google.security.zynamics.binnavi.debug.models.processmanager.MemorySection in project binnavi by google.

the class CModulesPanelFunctions method gotoModule.

/**
   * Displays the beginning of a module in the memory viewer.
   * 
   * @param parent Parent window used for dialogs.
   * @param debugPerspectiveModel Debug perspective model that provides the active debugger.
   * @param module The module to show in the memory viewer.
   */
public static void gotoModule(final Window parent, final CDebugPerspectiveModel debugPerspectiveModel, final MemoryModule module) {
    Preconditions.checkNotNull(parent, "IE01462: Parent argument can not be null");
    Preconditions.checkNotNull(debugPerspectiveModel, "IE01463: Debug perspective model argument can not be null");
    Preconditions.checkNotNull(module, "IE01464: Module argument can not be null");
    final IDebugger debugger = debugPerspectiveModel.getCurrentSelectedDebugger();
    if (debugger == null) {
        return;
    }
    final MemoryMap memoryMap = debugger.getProcessManager().getMemoryMap();
    final MemorySection section = ProcessHelpers.getSectionWith(memoryMap, module.getBaseAddress().getAddress());
    if (section == null) {
        final String message = String.format("E00046: " + "Could not display module '%s' in the memory view", module.getName());
        final String description = String.format("The module '%s' could not be displayed in the memory view because " + "the offset %s is not currently known to BinNavi. " + "Try refreshing the memory map to fix this issue.", module.getName(), module.getBaseAddress());
        NaviErrorDialog.show(parent, message, description);
    } else {
        CMemoryFunctions.gotoOffset(debugPerspectiveModel, module.getBaseAddress().getAddress(), true);
    }
}
Also used : MemoryMap(com.google.security.zynamics.binnavi.debug.models.processmanager.MemoryMap) MemorySection(com.google.security.zynamics.binnavi.debug.models.processmanager.MemorySection) IDebugger(com.google.security.zynamics.binnavi.debug.debugger.interfaces.IDebugger)

Aggregations

MemorySection (com.google.security.zynamics.binnavi.debug.models.processmanager.MemorySection)38 CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)32 MemoryMap (com.google.security.zynamics.binnavi.debug.models.processmanager.MemoryMap)31 Test (org.junit.Test)27 MemoryMapReply (com.google.security.zynamics.binnavi.debug.connection.packets.replies.MemoryMapReply)19 TargetProcessThread (com.google.security.zynamics.binnavi.debug.models.processmanager.TargetProcessThread)18 ModuleTargetSettings (com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings)17 ArrayList (java.util.ArrayList)17 MockDebugger (com.google.security.zynamics.binnavi.Debug.Debugger.MockDebugger)16 DebuggerOptions (com.google.security.zynamics.binnavi.debug.models.targetinformation.DebuggerOptions)16 TargetInformation (com.google.security.zynamics.binnavi.debug.models.targetinformation.TargetInformation)16 RegisterDescription (com.google.security.zynamics.binnavi.debug.models.targetinformation.RegisterDescription)14 TargetInformationReply (com.google.security.zynamics.binnavi.debug.connection.packets.replies.TargetInformationReply)13 RelocatedAddress (com.google.security.zynamics.binnavi.disassembly.RelocatedAddress)7 IDebugger (com.google.security.zynamics.binnavi.debug.debugger.interfaces.IDebugger)6 MemoryModule (com.google.security.zynamics.binnavi.debug.models.processmanager.MemoryModule)6 RegisterValue (com.google.security.zynamics.binnavi.debug.models.targetinformation.RegisterValue)6 BigInteger (java.math.BigInteger)6 DebuggerException (com.google.security.zynamics.binnavi.debug.models.targetinformation.DebuggerException)4 FilledList (com.google.security.zynamics.zylib.types.lists.FilledList)4