use of com.google.security.zynamics.binnavi.debug.models.processmanager.MemorySection in project binnavi by google.
the class CMemoryViewerSynchronizerTest method testLifeCycle.
@Test
public void testLifeCycle() throws DebugExceptionWrapper {
m_debugger.connect();
m_debugger.getProcessManager().setAttached(true);
m_debugger.getProcessManager().setAttached(true);
final MockMemoryViewerSynchronizerListener listener = new MockMemoryViewerSynchronizerListener();
m_synchronizer.addListener(listener);
m_model.setActiveMemoryAddress(new CAddress(0x100), false);
assertEquals("requestedUnsectionedAddress;", listener.events);
m_debugger.getProcessManager().setMemoryMap(new MemoryMap(Lists.newArrayList(new MemorySection(new CAddress(0x100), new CAddress(0x1FF)))));
assertEquals("requestedUnsectionedAddress;", listener.events);
m_model.setActiveMemoryAddress(new CAddress(0x100), false);
assertEquals(0x100, m_hexView.getCurrentOffset());
assertEquals("requestedUnsectionedAddress;", listener.events);
m_synchronizer.removeListener(listener);
m_debugger.getProcessManager().setAttached(false);
m_synchronizer.dispose();
}
use of com.google.security.zynamics.binnavi.debug.models.processmanager.MemorySection in project binnavi by google.
the class CMemoryViewerSynchronizerTest method testSwitchDebuggers.
@Test
public void testSwitchDebuggers() 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());
final IDebugger debugger2 = new MockDebugger(new ModuleTargetSettings(CommonTestObjects.MODULE));
debugger2.connect();
debugger2.getProcessManager().setMemoryMap(new MemoryMap(Lists.newArrayList(new MemorySection(new CAddress(0x10), new CAddress(0x50)))));
m_model.setActiveDebugger(debugger2);
assertEquals(0x10, m_hexView.getCurrentOffset());
assertEquals(0x41, m_hexView.getData().getDataLength());
m_debugger.getProcessManager().setAttached(false);
m_synchronizer.dispose();
debugger2.close();
}
use of com.google.security.zynamics.binnavi.debug.models.processmanager.MemorySection in project binnavi by google.
the class CMemorySectionPanelSynchronizerTest method testReceivedMemoryMap.
@Test
public void testReceivedMemoryMap() throws DebugExceptionWrapper {
final MockDebugger debugger = new MockDebugger(new ModuleTargetSettings(CommonTestObjects.MODULE));
debugger.connect();
m_model.setActiveDebugger(debugger);
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));
assertEquals(2, m_sectionBox.getItemCount());
assertEquals(section1, m_sectionBox.getItemAt(0).getObject());
assertEquals(section2, m_sectionBox.getItemAt(1).getObject());
m_synchronizer.dispose();
debugger.close();
}
use of com.google.security.zynamics.binnavi.debug.models.processmanager.MemorySection in project binnavi by google.
the class CMemorySectionPanelSynchronizerTest method testSwitchDebugger.
@Test
public void testSwitchDebugger() throws DebugExceptionWrapper {
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));
final TargetProcessThread thread = new TargetProcessThread(0x666, ThreadState.RUNNING);
final MemoryModule module = new MemoryModule("narf.exe", "C:\\zort\\narf.exe", new RelocatedAddress(new CAddress(0x1000)), 123345);
final MockDebugger debugger = new MockDebugger(new ModuleTargetSettings(CommonTestObjects.MODULE));
debugger.connect();
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))));
debugger.connection.m_synchronizer.receivedEvent(new MemoryMapReply(0, 0, memoryMap));
debugger.connection.m_synchronizer.receivedEvent(new ProcessStartReply(0, 0, new ProcessStart(thread, module)));
final MockDebugger debugger2 = new MockDebugger(new ModuleTargetSettings(CommonTestObjects.MODULE));
debugger2.connect();
debugger2.connection.m_synchronizer.receivedEvent(new TargetInformationReply(0, 0, new TargetInformation(32, new FilledList<RegisterDescription>(), new DebuggerOptions(false, false, false, false, false, false, false, false, false, false, 1, 0, new ArrayList<DebuggerException>(), false, false, false))));
debugger2.connection.m_synchronizer.receivedEvent(new MemoryMapReply(0, 0, memoryMap));
debugger2.connection.m_synchronizer.receivedEvent(new ProcessStartReply(0, 0, new ProcessStart(thread, module)));
m_model.setActiveDebugger(debugger);
assertTrue(m_sectionBox.isEnabled());
m_model.setActiveDebugger(debugger2);
assertFalse(m_sectionBox.isEnabled());
m_synchronizer.dispose();
debugger.close();
debugger2.close();
}
use of com.google.security.zynamics.binnavi.debug.models.processmanager.MemorySection in project binnavi by google.
the class CMemorySectionPanelSynchronizerTest 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));
assertEquals(2, m_sectionBox.getItemCount());
assertEquals(section1, m_sectionBox.getItemAt(0).getObject());
assertEquals(section2, m_sectionBox.getItemAt(1).getObject());
assertTrue(m_sectionBox.isEnabled());
debugger.connection.m_synchronizer.receivedEvent(new DetachReply(0, 0));
assertEquals(0, m_sectionBox.getItemCount());
assertFalse(m_sectionBox.isEnabled());
m_synchronizer.dispose();
debugger.close();
}
Aggregations