Search in sources :

Example 6 with MemorySection

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

the class CMemorySectionWrapperTest method testSimple.

@Test
public void testSimple() {
    assertEquals("00000000 - 000003FE (1023 bytes)", new CMemorySectionWrapper(new MemorySection(new CAddress(0), new CAddress(1022))).toString());
    assertEquals("00000000 - 000003FF (1.00 KB)", new CMemorySectionWrapper(new MemorySection(new CAddress(0), new CAddress(1023))).toString());
    assertEquals("00000000 - 000005DC (1.47 KB)", new CMemorySectionWrapper(new MemorySection(new CAddress(0), new CAddress(1500))).toString());
    assertEquals("00000000 - 00102710 (1.01 MB)", new CMemorySectionWrapper(new MemorySection(new CAddress(0), new CAddress((1024 * 1024) + 10000))).toString());
}
Also used : MemorySection(com.google.security.zynamics.binnavi.debug.models.processmanager.MemorySection) CMemorySectionWrapper(com.google.security.zynamics.binnavi.Gui.Debug.MemorySectionPanel.CMemorySectionWrapper) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) Test(org.junit.Test)

Example 7 with MemorySection

use of com.google.security.zynamics.binnavi.debug.models.processmanager.MemorySection 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 8 with MemorySection

use of com.google.security.zynamics.binnavi.debug.models.processmanager.MemorySection 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();
}
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)

Example 9 with MemorySection

use of com.google.security.zynamics.binnavi.debug.models.processmanager.MemorySection 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 10 with MemorySection

use of com.google.security.zynamics.binnavi.debug.models.processmanager.MemorySection 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));
}
Also used : MemoryMap(com.google.security.zynamics.binnavi.debug.models.processmanager.MemoryMap) RegisterValue(com.google.security.zynamics.binnavi.debug.models.targetinformation.RegisterValue) TargetProcessThread(com.google.security.zynamics.binnavi.debug.models.processmanager.TargetProcessThread) MemorySection(com.google.security.zynamics.binnavi.debug.models.processmanager.MemorySection) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) Test(org.junit.Test)

Aggregations

MemorySection (com.google.security.zynamics.binnavi.debug.models.processmanager.MemorySection)38 CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)32 MemoryMap (com.google.security.zynamics.binnavi.debug.models.processmanager.MemoryMap)31 Test (org.junit.Test)27 MemoryMapReply (com.google.security.zynamics.binnavi.debug.connection.packets.replies.MemoryMapReply)19 TargetProcessThread (com.google.security.zynamics.binnavi.debug.models.processmanager.TargetProcessThread)18 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 RelocatedAddress (com.google.security.zynamics.binnavi.disassembly.RelocatedAddress)7 IDebugger (com.google.security.zynamics.binnavi.debug.debugger.interfaces.IDebugger)6 MemoryModule (com.google.security.zynamics.binnavi.debug.models.processmanager.MemoryModule)6 RegisterValue (com.google.security.zynamics.binnavi.debug.models.targetinformation.RegisterValue)6 BigInteger (java.math.BigInteger)6 DebuggerException (com.google.security.zynamics.binnavi.debug.models.targetinformation.DebuggerException)4 FilledList (com.google.security.zynamics.zylib.types.lists.FilledList)4