Search in sources :

Example 1 with DetachReply

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

the class CDumpAllWaiterTest method testDetach.

@Test
public void testDetach() throws Exception {
    final MockDebugger debugger = new MockDebugger(new ModuleTargetSettings(CommonTestObjects.MODULE));
    debugger.connect();
    final CDumpAllWaiter waiter = new CDumpAllWaiter(debugger, new CAddress(0x300), 0x100);
    waiter.start();
    new Thread() {

        @Override
        public void run() {
            try {
                waiter.runExpensiveCommand();
            } catch (final Exception e) {
            }
        }
    }.start();
    Thread.sleep(250);
    debugger.connection.m_synchronizer.receivedEvent(new DetachReply(0, 0));
    Thread.sleep(250);
    assertFalse(waiter.isAlive());
    assertTrue(waiter.success());
    debugger.close();
}
Also used : MockDebugger(com.google.security.zynamics.binnavi.Debug.Debugger.MockDebugger) CDumpAllWaiter(com.google.security.zynamics.binnavi.Gui.Debug.MemoryPanel.Implementations.CDumpAllWaiter) DetachReply(com.google.security.zynamics.binnavi.debug.connection.packets.replies.DetachReply) ModuleTargetSettings(com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) Test(org.junit.Test)

Example 2 with DetachReply

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

the class CModulesTableModelSynchronizerTest method testDetach.

@Test
public void testDetach() throws DebugExceptionWrapper {
    final MockDebugger debugger = new MockDebugger(new ModuleTargetSettings(CommonTestObjects.MODULE));
    debugger.connect();
    debugger.getProcessManager().addModule(new MemoryModule("Hannes", "C:\\Hannes.dll", new RelocatedAddress(new CAddress(0x200)), 0x100));
    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));
    debugger.connection.m_synchronizer.receivedEvent(new DetachReply(0, 0));
    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) 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) 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) 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 3 with DetachReply

use of com.google.security.zynamics.binnavi.debug.connection.packets.replies.DetachReply 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 4 with DetachReply

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

the class CHistoryStringBuilderTest method testComplete2.

@SuppressWarnings("unchecked")
@Test
public void testComplete2() throws DebugExceptionWrapper {
    final CHistoryStringBuilder builder = new CHistoryStringBuilder();
    builder.setDebugger(m_debugger);
    m_debugger.connect();
    m_synchronizer.receivedEvent(DebuggerMessageBuilder.buildProcessStartReply(mockMemoryModule));
    m_debugger.getProcessManager().addThread(new TargetProcessThread(1, ThreadState.RUNNING));
    m_synchronizer.receivedEvent(new BreakpointConditionSetReply(0, 0));
    m_synchronizer.receivedEvent(new BreakpointConditionSetReply(0, 1));
    try {
        m_synchronizer.receivedEvent(new BreakpointHitReply(0, 0, 1, new RegisterValues(Lists.<ThreadRegisters>newArrayList(new ThreadRegisters(1, Lists.newArrayList(new RegisterValue("eip", BigInteger.ONE, new byte[0], false, false)))))));
        fail();
    } catch (final IllegalStateException e) {
    }
    m_synchronizer.receivedEvent(new BreakpointHitReply(0, 0, 1, new RegisterValues(Lists.<ThreadRegisters>newArrayList(new ThreadRegisters(1, Lists.newArrayList(new RegisterValue("eip", BigInteger.ONE, new byte[0], true, false)))))));
    m_breakpointManager.addBreakpoints(BreakpointType.REGULAR, BREAKPOINT_ADDRESS);
    m_synchronizer.receivedEvent(new BreakpointSetReply(0, 0, Lists.newArrayList(new Pair<RelocatedAddress, Integer>(BREAKPOINT_ADDRESS_RELOC, 0))));
    m_synchronizer.receivedEvent(new BreakpointSetReply(0, 0, Lists.newArrayList(new Pair<RelocatedAddress, Integer>(BREAKPOINT_ADDRESS_RELOC, 1))));
    m_synchronizer.receivedEvent(new BreakpointsRemovedReply(0, 0, Lists.newArrayList(new Pair<RelocatedAddress, Integer>(BREAKPOINT_ADDRESS_RELOC, 0))));
    m_synchronizer.receivedEvent(new BreakpointsRemovedReply(0, 0, Lists.newArrayList(new Pair<RelocatedAddress, Integer>(BREAKPOINT_ADDRESS_RELOC, 1))));
    m_breakpointManager.removeBreakpoints(BreakpointType.REGULAR, BREAKPOINT_ADDRESS);
    m_synchronizer.receivedEvent(new DebuggerClosedUnexpectedlyReply());
    m_synchronizer.receivedEvent(new DetachReply(0, 0));
    m_synchronizer.receivedEvent(new DetachReply(0, 1));
}
Also used : StepBreakpointSetReply(com.google.security.zynamics.binnavi.debug.connection.packets.replies.StepBreakpointSetReply) BreakpointSetReply(com.google.security.zynamics.binnavi.debug.connection.packets.replies.BreakpointSetReply) EchoBreakpointSetReply(com.google.security.zynamics.binnavi.debug.connection.packets.replies.EchoBreakpointSetReply) TargetProcessThread(com.google.security.zynamics.binnavi.debug.models.processmanager.TargetProcessThread) BreakpointConditionSetReply(com.google.security.zynamics.binnavi.debug.connection.packets.replies.BreakpointConditionSetReply) RelocatedAddress(com.google.security.zynamics.binnavi.disassembly.RelocatedAddress) StepBreakpointHitReply(com.google.security.zynamics.binnavi.debug.connection.packets.replies.StepBreakpointHitReply) EchoBreakpointHitReply(com.google.security.zynamics.binnavi.debug.connection.packets.replies.EchoBreakpointHitReply) BreakpointHitReply(com.google.security.zynamics.binnavi.debug.connection.packets.replies.BreakpointHitReply) RegisterValues(com.google.security.zynamics.binnavi.debug.models.targetinformation.RegisterValues) BigInteger(java.math.BigInteger) RegisterValue(com.google.security.zynamics.binnavi.debug.models.targetinformation.RegisterValue) DetachReply(com.google.security.zynamics.binnavi.debug.connection.packets.replies.DetachReply) EchoBreakpointsRemovedReply(com.google.security.zynamics.binnavi.debug.connection.packets.replies.EchoBreakpointsRemovedReply) BreakpointsRemovedReply(com.google.security.zynamics.binnavi.debug.connection.packets.replies.BreakpointsRemovedReply) StepBreakpointsRemovedReply(com.google.security.zynamics.binnavi.debug.connection.packets.replies.StepBreakpointsRemovedReply) ThreadRegisters(com.google.security.zynamics.binnavi.debug.models.targetinformation.ThreadRegisters) DebuggerClosedUnexpectedlyReply(com.google.security.zynamics.binnavi.debug.connection.packets.replies.DebuggerClosedUnexpectedlyReply) Test(org.junit.Test)

Example 5 with DetachReply

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

the class CSearchWaiterTest method testDetach.

@Test
public void testDetach() throws Exception {
    final MockDebugger debugger = new MockDebugger(new ModuleTargetSettings(CommonTestObjects.MODULE));
    debugger.connect();
    final CSearchWaiter waiter = new CSearchWaiter(debugger, new CAddress(0x300), 0x100, new byte[] { 10 });
    waiter.start();
    new Thread() {

        @Override
        public void run() {
            try {
                waiter.runExpensiveCommand();
            } catch (final Exception e) {
            }
        }
    }.start();
    Thread.sleep(250);
    debugger.connection.m_synchronizer.receivedEvent(new DetachReply(0, 0));
    Thread.sleep(250);
    assertFalse(waiter.isAlive());
    assertNull(waiter.getReply());
    debugger.close();
}
Also used : MockDebugger(com.google.security.zynamics.binnavi.Debug.Debugger.MockDebugger) DetachReply(com.google.security.zynamics.binnavi.debug.connection.packets.replies.DetachReply) CSearchWaiter(com.google.security.zynamics.binnavi.Gui.Debug.MemoryPanel.Implementations.CSearchWaiter) ModuleTargetSettings(com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) Test(org.junit.Test)

Aggregations

DetachReply (com.google.security.zynamics.binnavi.debug.connection.packets.replies.DetachReply)11 Test (org.junit.Test)11 MockDebugger (com.google.security.zynamics.binnavi.Debug.Debugger.MockDebugger)7 ModuleTargetSettings (com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings)7 TargetProcessThread (com.google.security.zynamics.binnavi.debug.models.processmanager.TargetProcessThread)6 CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)6 TargetInformationReply (com.google.security.zynamics.binnavi.debug.connection.packets.replies.TargetInformationReply)5 DebuggerOptions (com.google.security.zynamics.binnavi.debug.models.targetinformation.DebuggerOptions)5 RegisterDescription (com.google.security.zynamics.binnavi.debug.models.targetinformation.RegisterDescription)5 TargetInformation (com.google.security.zynamics.binnavi.debug.models.targetinformation.TargetInformation)5 ArrayList (java.util.ArrayList)5 MemoryMapReply (com.google.security.zynamics.binnavi.debug.connection.packets.replies.MemoryMapReply)4 MemoryMap (com.google.security.zynamics.binnavi.debug.models.processmanager.MemoryMap)4 MemorySection (com.google.security.zynamics.binnavi.debug.models.processmanager.MemorySection)4 RelocatedAddress (com.google.security.zynamics.binnavi.disassembly.RelocatedAddress)3 BreakpointConditionSetReply (com.google.security.zynamics.binnavi.debug.connection.packets.replies.BreakpointConditionSetReply)2 BreakpointHitReply (com.google.security.zynamics.binnavi.debug.connection.packets.replies.BreakpointHitReply)2 BreakpointSetReply (com.google.security.zynamics.binnavi.debug.connection.packets.replies.BreakpointSetReply)2 BreakpointsRemovedReply (com.google.security.zynamics.binnavi.debug.connection.packets.replies.BreakpointsRemovedReply)2 DebuggerClosedUnexpectedlyReply (com.google.security.zynamics.binnavi.debug.connection.packets.replies.DebuggerClosedUnexpectedlyReply)2