Search in sources :

Example 6 with TargetInformationReply

use of com.google.security.zynamics.binnavi.debug.connection.packets.replies.TargetInformationReply in project binnavi by google.

the class CMemoryViewerSynchronizerTest method testActiveDebugger.

@Test
public void testActiveDebugger() {
    final IGraphModel graphModel = new MockGraphModel();
    final CDebugPerspectiveModel model = new CDebugPerspectiveModel(graphModel);
    final JHexView hexView = new JHexView();
    final CMemoryProvider provider = new CMemoryProvider();
    final MockDebugger debugger = new MockDebugger(new ModuleTargetSettings(CommonTestObjects.MODULE));
    model.setActiveDebugger(debugger);
    final CMemoryViewerSynchronizer synchronizer = new CMemoryViewerSynchronizer(hexView, provider, model);
    debugger.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))));
    assertEquals(AddressMode.BIT32, hexView.getAddressMode());
    debugger.connection.m_synchronizer.receivedEvent(new TargetInformationReply(0, 0, new TargetInformation(64, new FilledList<RegisterDescription>(), new DebuggerOptions(false, false, false, false, false, false, false, false, false, false, 1, 0, new ArrayList<DebuggerException>(), false, false, false))));
    assertEquals(AddressMode.BIT64, hexView.getAddressMode());
    synchronizer.dispose();
}
Also used : CDebugPerspectiveModel(com.google.security.zynamics.binnavi.Gui.GraphWindows.Panels.CDebugPerspectiveModel) JHexView(com.google.security.zynamics.zylib.gui.JHexPanel.JHexView) IGraphModel(com.google.security.zynamics.binnavi.Gui.GraphWindows.IGraphModel) ArrayList(java.util.ArrayList) DebuggerOptions(com.google.security.zynamics.binnavi.debug.models.targetinformation.DebuggerOptions) ModuleTargetSettings(com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings) 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) MockGraphModel(com.google.security.zynamics.binnavi.Gui.GraphWindows.MockGraphModel) Test(org.junit.Test)

Example 7 with TargetInformationReply

use of com.google.security.zynamics.binnavi.debug.connection.packets.replies.TargetInformationReply 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();
}
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) RegisterValue(com.google.security.zynamics.binnavi.debug.models.targetinformation.RegisterValue) 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 8 with TargetInformationReply

use of com.google.security.zynamics.binnavi.debug.connection.packets.replies.TargetInformationReply 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();
}
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 9 with TargetInformationReply

use of com.google.security.zynamics.binnavi.debug.connection.packets.replies.TargetInformationReply in project binnavi by google.

the class CStackViewSynchronizerTest 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_stackView.isEnabled());
    debugger.connection.m_synchronizer.receivedEvent(new DetachReply(0, 0));
    assertFalse(m_stackView.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 10 with TargetInformationReply

use of com.google.security.zynamics.binnavi.debug.connection.packets.replies.TargetInformationReply in project binnavi by google.

the class CStackViewSynchronizerTest 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 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_stackView.isEnabled());
    m_model.setActiveDebugger(debugger2);
    assertTrue(m_stackView.isEnabled());
    m_synchronizer.dispose();
    debugger.close();
    debugger2.close();
}
Also used : MemoryMap(com.google.security.zynamics.binnavi.debug.models.processmanager.MemoryMap) ProcessStart(com.google.security.zynamics.binnavi.debug.models.processmanager.ProcessStart) 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) RelocatedAddress(com.google.security.zynamics.binnavi.disassembly.RelocatedAddress) ArrayList(java.util.ArrayList) DebuggerOptions(com.google.security.zynamics.binnavi.debug.models.targetinformation.DebuggerOptions) ProcessStartReply(com.google.security.zynamics.binnavi.debug.connection.packets.replies.ProcessStartReply) ModuleTargetSettings(com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings) MemoryModule(com.google.security.zynamics.binnavi.debug.models.processmanager.MemoryModule) 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)

Aggregations

TargetInformationReply (com.google.security.zynamics.binnavi.debug.connection.packets.replies.TargetInformationReply)20 Test (org.junit.Test)20 DebuggerOptions (com.google.security.zynamics.binnavi.debug.models.targetinformation.DebuggerOptions)18 RegisterDescription (com.google.security.zynamics.binnavi.debug.models.targetinformation.RegisterDescription)18 TargetInformation (com.google.security.zynamics.binnavi.debug.models.targetinformation.TargetInformation)18 ArrayList (java.util.ArrayList)17 MockDebugger (com.google.security.zynamics.binnavi.Debug.Debugger.MockDebugger)16 ModuleTargetSettings (com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings)16 TargetProcessThread (com.google.security.zynamics.binnavi.debug.models.processmanager.TargetProcessThread)15 CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)15 MemoryMapReply (com.google.security.zynamics.binnavi.debug.connection.packets.replies.MemoryMapReply)13 MemoryMap (com.google.security.zynamics.binnavi.debug.models.processmanager.MemoryMap)13 MemorySection (com.google.security.zynamics.binnavi.debug.models.processmanager.MemorySection)13 RelocatedAddress (com.google.security.zynamics.binnavi.disassembly.RelocatedAddress)7 MemoryModule (com.google.security.zynamics.binnavi.debug.models.processmanager.MemoryModule)6 DetachReply (com.google.security.zynamics.binnavi.debug.connection.packets.replies.DetachReply)5 ProcessStartReply (com.google.security.zynamics.binnavi.debug.connection.packets.replies.ProcessStartReply)3 ProcessStart (com.google.security.zynamics.binnavi.debug.models.processmanager.ProcessStart)3 RegisterValue (com.google.security.zynamics.binnavi.debug.models.targetinformation.RegisterValue)3 ResumeThreadReply (com.google.security.zynamics.binnavi.debug.connection.packets.replies.ResumeThreadReply)2