use of com.google.security.zynamics.binnavi.debug.models.processmanager.MemoryMap in project binnavi by google.
the class CRegisterViewSynchronizerTest 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 MockDebugger debugger = new MockDebugger(new ModuleTargetSettings(CommonTestObjects.MODULE));
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);
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 ProcessStartReply(0, 0, new ProcessStart(thread, module)));
debugger.connection.m_synchronizer.receivedEvent(new MemoryMapReply(0, 0, memoryMap));
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_registerView.isEnabled());
m_model.setActiveDebugger(debugger2);
assertTrue(m_registerView.isEnabled());
m_synchronizer.dispose();
debugger.close();
debugger2.close();
}
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();
}
use of com.google.security.zynamics.binnavi.debug.models.processmanager.MemoryMap in project binnavi by google.
the class CStackMemoryProviderTest method testElement.
@Test
public void testElement() throws DebugExceptionWrapper {
m_provider.setDebugger(m_debugger);
m_debugger.connect();
final TargetProcessThread thread = new TargetProcessThread(0, ThreadState.SUSPENDED);
thread.setRegisterValues(Lists.newArrayList(new RegisterValue("esp", BigInteger.valueOf(0x123), new byte[0], false, true)));
m_provider.setActiveThread(thread);
m_debugger.getProcessManager().setMemoryMap(new MemoryMap(Lists.newArrayList(new MemorySection(new CAddress(0x100), new CAddress(0x180)))));
m_debugger.getProcessManager().getMemory().store(0x100, new byte[] { 0x12, 0x34, 0x56, 0x78, (byte) 0x9A, (byte) 0xBC, (byte) 0xDE, (byte) 0xF0 });
assertEquals("12345678", m_provider.getElement(0x100));
m_provider.setDataLayout(StackDataLayout.Dwords);
assertEquals("78563412", m_provider.getElement(0x100));
}
use of com.google.security.zynamics.binnavi.debug.models.processmanager.MemoryMap in project binnavi by google.
the class CStackViewSynchronizerTest method testNewThread2.
/**
* This test makes sure that the stack view is filled properly when switching from no debugger to
* a debugger with an active thread.
*
* Fix for Case 2034: Stack view is not initialized correctly when opening graph windows with
* connected debuggers
*
* @throws DebugExceptionWrapper
*/
@Test
public void testNewThread2() 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);
thread.setRegisterValues(Lists.newArrayList(new RegisterValue("esp", BigInteger.valueOf(0x110), new byte[0], false, true)));
debugger.getProcessManager().addThread(thread);
debugger.getProcessManager().setActiveThread(thread);
m_model.setActiveDebugger(debugger);
assertEquals(0x110, m_stackModel.getStackPointer());
m_synchronizer.dispose();
debugger.close();
}
use of com.google.security.zynamics.binnavi.debug.models.processmanager.MemoryMap in project binnavi by google.
the class CStackViewSynchronizerTest 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);
m_model.setActiveDebugger(debugger);
debugger.getProcessManager().setActiveThread(null);
assertFalse(m_stackView.isEnabled());
debugger.getProcessManager().addThread(thread);
assertFalse(m_stackView.isEnabled());
debugger.getProcessManager().setActiveThread(thread);
assertTrue(m_stackView.isEnabled());
debugger.getProcessManager().setActiveThread(null);
assertFalse(m_stackView.isEnabled());
debugger.getProcessManager().removeThread(thread);
assertFalse(m_stackView.isEnabled());
debugger.getProcessManager().setAttached(false);
m_synchronizer.dispose();
debugger.close();
}
Aggregations