Search in sources :

Example 26 with MemoryMap

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

the class CStackMemoryProviderTest method testStartAddress.

@Test
public void testStartAddress() throws DebugExceptionWrapper {
    m_provider.setDebugger(m_debugger);
    m_debugger.getProcessManager().setMemoryMap(new MemoryMap(Lists.newArrayList(new MemorySection(new CAddress(0x100), new CAddress(0x200)))));
    assertEquals(-1, m_provider.getStartAddress());
    m_debugger.connect();
    assertEquals(-1, m_provider.getStartAddress());
    final TargetProcessThread thread = new TargetProcessThread(0, ThreadState.SUSPENDED);
    thread.setRegisterValues(Lists.newArrayList(new RegisterValue("esp", BigInteger.valueOf(0x123), new byte[0], false, true)));
    assertEquals(-1, m_provider.getStartAddress());
    m_provider.setActiveThread(thread);
    assertEquals(0x100, m_provider.getStartAddress());
}
Also used : MemoryMap(com.google.security.zynamics.binnavi.debug.models.processmanager.MemoryMap) RegisterValue(com.google.security.zynamics.binnavi.debug.models.targetinformation.RegisterValue) MemorySection(com.google.security.zynamics.binnavi.debug.models.processmanager.MemorySection) TargetProcessThread(com.google.security.zynamics.binnavi.debug.models.processmanager.TargetProcessThread) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) Test(org.junit.Test)

Example 27 with MemoryMap

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

the class CStackViewSynchronizerTest method testNewThread.

/**
   * This test makes sure that freshly created threads have listeners attached.
   *
   * Test for 2035: Listener issue in the stack view synchronizer
   *
   * @throws DebugExceptionWrapper
   */
@Test
public void testNewThread() throws DebugExceptionWrapper {
    final MockDebugger debugger = new MockDebugger(new ModuleTargetSettings(CommonTestObjects.MODULE));
    debugger.connect();
    debugger.getProcessManager().setAttached(true);
    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));
    m_model.setActiveDebugger(debugger);
    final TargetProcessThread thread = new TargetProcessThread(1, ThreadState.RUNNING);
    debugger.getProcessManager().addThread(thread);
    m_synchronizer.dispose();
    debugger.close();
}
Also used : MemoryMap(com.google.security.zynamics.binnavi.debug.models.processmanager.MemoryMap) MemorySection(com.google.security.zynamics.binnavi.debug.models.processmanager.MemorySection) TargetProcessThread(com.google.security.zynamics.binnavi.debug.models.processmanager.TargetProcessThread) 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) 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 28 with MemoryMap

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

the class CRegisterViewSynchronizerTest method testThreads.

@Test
public void testThreads() throws DebugExceptionWrapper {
    final MockDebugger debugger = new MockDebugger(new ModuleTargetSettings(CommonTestObjects.MODULE));
    debugger.connect();
    debugger.getProcessManager().setAttached(true);
    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));
    final TargetProcessThread thread = new TargetProcessThread(1, ThreadState.RUNNING);
    debugger.getProcessManager().addThread(thread);
    m_model.setActiveDebugger(debugger);
    assertFalse(m_registerView.isEnabled());
    final TargetProcessThread thread2 = new TargetProcessThread(2, ThreadState.RUNNING);
    debugger.getProcessManager().addThread(thread2);
    assertFalse(m_registerView.isEnabled());
    debugger.getProcessManager().setActiveThread(thread2);
    assertTrue(m_registerView.isEnabled());
    debugger.getProcessManager().setActiveThread(null);
    assertFalse(m_registerView.isEnabled());
    debugger.getProcessManager().removeThread(thread);
    assertFalse(m_registerView.isEnabled());
    debugger.getProcessManager().setAttached(false);
    m_synchronizer.dispose();
    debugger.close();
}
Also used : MemoryMap(com.google.security.zynamics.binnavi.debug.models.processmanager.MemoryMap) MemorySection(com.google.security.zynamics.binnavi.debug.models.processmanager.MemorySection) TargetProcessThread(com.google.security.zynamics.binnavi.debug.models.processmanager.TargetProcessThread) 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) 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 29 with MemoryMap

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

the class CMemoryViewerSynchronizerTest method testResizeSection.

@Test
public void testResizeSection() throws DebugExceptionWrapper {
    m_debugger.connect();
    m_debugger.getProcessManager().setAttached(true);
    m_debugger.getProcessManager().setMemoryMap(new MemoryMap(Lists.newArrayList(new MemorySection(new CAddress(0x100), new CAddress(0x1FF)))));
    m_model.setActiveMemoryAddress(new CAddress(0x100), false);
    assertEquals(0x100, m_hexView.getCurrentOffset());
    assertEquals(0x100, m_hexView.getData().getDataLength());
    m_debugger.getProcessManager().setMemoryMap(new MemoryMap(Lists.newArrayList(new MemorySection(new CAddress(0x100), new CAddress(0x1FF)), new MemorySection(new CAddress(0x500), new CAddress(0x5FF)))));
    assertEquals(0x100, m_hexView.getCurrentOffset());
    assertEquals(0x100, m_hexView.getData().getDataLength());
    m_debugger.getProcessManager().setMemoryMap(new MemoryMap(Lists.newArrayList(new MemorySection(new CAddress(0x0), new CAddress(0x2FF)), new MemorySection(new CAddress(0x500), new CAddress(0x5FF)))));
    assertEquals(0x100, m_hexView.getCurrentOffset());
    assertEquals(0x300, m_hexView.getData().getDataLength());
    final MockMemoryViewerSynchronizerListener listener = new MockMemoryViewerSynchronizerListener();
    m_synchronizer.addListener(listener);
    m_debugger.getProcessManager().setMemoryMap(new MemoryMap(Lists.newArrayList(new MemorySection(new CAddress(0x0), new CAddress(0xFF)), new MemorySection(new CAddress(0x500), new CAddress(0x5FF)))));
    assertEquals(0x000, m_hexView.getCurrentOffset());
    assertEquals(0x100, m_hexView.getData().getDataLength());
    assertEquals("addressTurnedInvalid;", listener.events);
    m_synchronizer.removeListener(listener);
    m_debugger.getProcessManager().setAttached(false);
    m_synchronizer.dispose();
}
Also used : MemoryMap(com.google.security.zynamics.binnavi.debug.models.processmanager.MemoryMap) MemorySection(com.google.security.zynamics.binnavi.debug.models.processmanager.MemorySection) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) Test(org.junit.Test)

Example 30 with MemoryMap

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

the class CMemoryViewerSynchronizerTest method testSwitchSection.

@Test
public void testSwitchSection() throws DebugExceptionWrapper {
    m_debugger.connect();
    m_debugger.getProcessManager().setAttached(true);
    m_debugger.getProcessManager().setMemoryMap(new MemoryMap(Lists.newArrayList(new MemorySection(new CAddress(0x100), new CAddress(0x1FF)), new MemorySection(new CAddress(0x200), new CAddress(0x4FF)))));
    m_model.setActiveMemoryAddress(new CAddress(0x400), false);
    assertEquals(0x400, m_hexView.getCurrentOffset());
    assertEquals(0x300, m_hexView.getData().getDataLength());
    m_model.setActiveMemoryAddress(new CAddress(0x100), false);
    assertEquals(0x100, m_hexView.getCurrentOffset());
    assertEquals(0x100, m_hexView.getData().getDataLength());
    m_debugger.getProcessManager().setAttached(false);
    m_synchronizer.dispose();
}
Also used : MemoryMap(com.google.security.zynamics.binnavi.debug.models.processmanager.MemoryMap) MemorySection(com.google.security.zynamics.binnavi.debug.models.processmanager.MemorySection) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) Test(org.junit.Test)

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