Search in sources :

Example 11 with MemoryMap

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

the class CRegisterViewSynchronizerTest method testDetach.

@Test
public void testDetach() throws DebugExceptionWrapper {
    final MockDebugger debugger = new MockDebugger(new ModuleTargetSettings(CommonTestObjects.MODULE));
    final TargetProcessThread thread = new TargetProcessThread(1, ThreadState.SUSPENDED);
    debugger.getProcessManager().addThread(thread);
    debugger.getProcessManager().setActiveThread(thread);
    debugger.connect();
    m_model.setActiveDebugger(debugger);
    debugger.connection.m_synchronizer.receivedEvent(new TargetInformationReply(0, 0, new TargetInformation(32, new FilledList<RegisterDescription>(), new DebuggerOptions(false, false, false, true, false, false, false, false, false, false, 1, 0, new ArrayList<DebuggerException>(), false, false, false))));
    final MemorySection section1 = new MemorySection(new CAddress(0x100), new CAddress(0x1FF));
    final MemorySection section2 = new MemorySection(new CAddress(0x300), new CAddress(0x3FF));
    final MemoryMap memoryMap = new MemoryMap(Lists.newArrayList(section1, section2));
    debugger.connection.m_synchronizer.receivedEvent(new MemoryMapReply(0, 0, memoryMap));
    assertTrue(m_registerView.isEnabled());
    debugger.connection.m_synchronizer.receivedEvent(new DetachReply(0, 0));
    assertFalse(m_registerView.isEnabled());
    m_synchronizer.dispose();
    debugger.close();
}
Also used : MemoryMap(com.google.security.zynamics.binnavi.debug.models.processmanager.MemoryMap) TargetProcessThread(com.google.security.zynamics.binnavi.debug.models.processmanager.TargetProcessThread) MemorySection(com.google.security.zynamics.binnavi.debug.models.processmanager.MemorySection) MemoryMapReply(com.google.security.zynamics.binnavi.debug.connection.packets.replies.MemoryMapReply) ArrayList(java.util.ArrayList) DebuggerOptions(com.google.security.zynamics.binnavi.debug.models.targetinformation.DebuggerOptions) ModuleTargetSettings(com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) MockDebugger(com.google.security.zynamics.binnavi.Debug.Debugger.MockDebugger) RegisterDescription(com.google.security.zynamics.binnavi.debug.models.targetinformation.RegisterDescription) DetachReply(com.google.security.zynamics.binnavi.debug.connection.packets.replies.DetachReply) TargetInformation(com.google.security.zynamics.binnavi.debug.models.targetinformation.TargetInformation) TargetInformationReply(com.google.security.zynamics.binnavi.debug.connection.packets.replies.TargetInformationReply) Test(org.junit.Test)

Example 12 with MemoryMap

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

the class ReplySynchronizer method resetTargetProcess.

/**
   * Resets information about the target process.
   */
protected void resetTargetProcess() {
    final BreakpointManager manager = debugger.getBreakpointManager();
    final ProcessManager processManager = debugger.getProcessManager();
    debugger.setTerminated();
    manager.clearBreakpointsPassive(BreakpointType.ECHO);
    manager.clearBreakpointsPassive(BreakpointType.STEP);
    deactivateBreakpoints();
    processManager.getMemory().clear();
    processManager.setMemoryMap(new MemoryMap(new ArrayList<MemorySection>()));
    final Collection<TargetProcessThread> threads = processManager.getThreads();
    for (final TargetProcessThread thread : threads) {
        processManager.removeThread(thread);
    }
    for (final MemoryModule module : processManager.getModules()) {
        processManager.removeModule(module);
    }
    processManager.setAttached(false);
    processManager.setActiveThread(null);
}
Also used : MemoryMap(com.google.security.zynamics.binnavi.debug.models.processmanager.MemoryMap) TargetProcessThread(com.google.security.zynamics.binnavi.debug.models.processmanager.TargetProcessThread) ArrayList(java.util.ArrayList) BreakpointManager(com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointManager) ProcessManager(com.google.security.zynamics.binnavi.debug.models.processmanager.ProcessManager) MemoryModule(com.google.security.zynamics.binnavi.debug.models.processmanager.MemoryModule)

Example 13 with MemoryMap

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

the class CMemoryLoaderTest method setUp.

@Before
public void setUp() {
    debugger = new MockDebugger(new ModuleTargetSettings(CommonTestObjects.MODULE));
    final ArrayList<MemorySection> sections = new ArrayList<MemorySection>();
    sections.add(new MemorySection(new CAddress(BigInteger.ZERO), new CAddress(BigInteger.valueOf(1000))));
    debugger.getProcessManager().setMemoryMap(new MemoryMap(sections));
    loader = new MemoryLoader(debugger);
}
Also used : MemoryMap(com.google.security.zynamics.binnavi.debug.models.processmanager.MemoryMap) MemorySection(com.google.security.zynamics.binnavi.debug.models.processmanager.MemorySection) ArrayList(java.util.ArrayList) MemoryLoader(com.google.security.zynamics.binnavi.debug.debugger.MemoryLoader) ModuleTargetSettings(com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) Before(org.junit.Before)

Example 14 with MemoryMap

use of com.google.security.zynamics.binnavi.debug.models.processmanager.MemoryMap 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 15 with MemoryMap

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

the class MemoryMapParser method parseSuccess.

@Override
public MemoryMapReply parseSuccess(final int packetId, final int argumentCount) throws IOException {
    final IAddress[] addresses = new IAddress[argumentCount];
    for (int i = 0; i < argumentCount; i++) {
        addresses[i] = parseAddress();
    }
    final List<MemorySection> map = new ArrayList<>();
    for (int i = 0; i < addresses.length / 2; i++) {
        final IAddress startAddress = addresses[2 * i];
        final IAddress endAddress = addresses[2 * i + 1];
        map.add(new MemorySection(startAddress, endAddress));
    }
    return new MemoryMapReply(packetId, 0, new MemoryMap(map));
}
Also used : MemoryMap(com.google.security.zynamics.binnavi.debug.models.processmanager.MemoryMap) MemorySection(com.google.security.zynamics.binnavi.debug.models.processmanager.MemorySection) MemoryMapReply(com.google.security.zynamics.binnavi.debug.connection.packets.replies.MemoryMapReply) ArrayList(java.util.ArrayList) IAddress(com.google.security.zynamics.zylib.disassembly.IAddress)

Aggregations

MemoryMap (com.google.security.zynamics.binnavi.debug.models.processmanager.MemoryMap)32 MemorySection (com.google.security.zynamics.binnavi.debug.models.processmanager.MemorySection)31 CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)29 Test (org.junit.Test)26 MemoryMapReply (com.google.security.zynamics.binnavi.debug.connection.packets.replies.MemoryMapReply)19 TargetProcessThread (com.google.security.zynamics.binnavi.debug.models.processmanager.TargetProcessThread)19 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 MemoryModule (com.google.security.zynamics.binnavi.debug.models.processmanager.MemoryModule)7 RegisterValue (com.google.security.zynamics.binnavi.debug.models.targetinformation.RegisterValue)6 RelocatedAddress (com.google.security.zynamics.binnavi.disassembly.RelocatedAddress)6 DetachReply (com.google.security.zynamics.binnavi.debug.connection.packets.replies.DetachReply)4 DebuggerException (com.google.security.zynamics.binnavi.debug.models.targetinformation.DebuggerException)4 FilledList (com.google.security.zynamics.zylib.types.lists.FilledList)4 IDebugger (com.google.security.zynamics.binnavi.debug.debugger.interfaces.IDebugger)3