use of com.google.security.zynamics.binnavi.debug.models.processmanager.MemorySection in project binnavi by google.
the class CStackMemoryProviderTest method testAddressMode.
@Test
public void testAddressMode() 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(0x120, new byte[] { 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 });
// Bytes + 32
assertEquals("01000000", m_provider.getElement(0x120));
m_provider.setDataLayout(StackDataLayout.Dwords);
// Dwords + 32
assertEquals("00000001", m_provider.getElement(0x120));
m_provider.setAddressMode(AddressMode.BIT64);
// Dwords + 64
assertEquals("0000000000000001", m_provider.getElement(0x120));
m_provider.setDataLayout(StackDataLayout.Bytes);
// Bytes + 64
assertEquals("0100000000000000", m_provider.getElement(0x120));
}
use of com.google.security.zynamics.binnavi.debug.models.processmanager.MemorySection in project binnavi by google.
the class CStackMemoryProviderTest method testNumberOfEntries.
@Test
public void testNumberOfEntries() throws DebugExceptionWrapper {
m_provider.setDebugger(m_debugger);
m_debugger.getProcessManager().setTargetInformation(new TargetInformation(5, new FilledList<RegisterDescription>(), new DebuggerOptions(false, false, false, false, false, false, false, false, false, false, 12, 0, new ArrayList<DebuggerException>(), false, false, false)));
assertEquals(0, m_provider.getNumberOfEntries());
m_debugger.connect();
assertEquals(0, m_provider.getNumberOfEntries());
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);
assertEquals(0, m_provider.getNumberOfEntries());
m_debugger.getProcessManager().setMemoryMap(new MemoryMap(Lists.newArrayList(new MemorySection(new CAddress(0x100), new CAddress(0x180)))));
assertEquals(0x80 / 0x04, m_provider.getNumberOfEntries());
}
use of com.google.security.zynamics.binnavi.debug.models.processmanager.MemorySection in project binnavi by google.
the class CStackMemoryProviderTest method testStartAddress.
@Test
public void testStartAddress() throws DebugExceptionWrapper {
m_provider.setDebugger(m_debugger);
m_debugger.getProcessManager().setMemoryMap(new MemoryMap(Lists.newArrayList(new MemorySection(new CAddress(0x100), new CAddress(0x200)))));
assertEquals(-1, m_provider.getStartAddress());
m_debugger.connect();
assertEquals(-1, m_provider.getStartAddress());
final TargetProcessThread thread = new TargetProcessThread(0, ThreadState.SUSPENDED);
thread.setRegisterValues(Lists.newArrayList(new RegisterValue("esp", BigInteger.valueOf(0x123), new byte[0], false, true)));
assertEquals(-1, m_provider.getStartAddress());
m_provider.setActiveThread(thread);
assertEquals(0x100, m_provider.getStartAddress());
}
use of com.google.security.zynamics.binnavi.debug.models.processmanager.MemorySection in project binnavi by google.
the class CStackViewSynchronizerTest method testNewThread.
/**
* This test makes sure that freshly created threads have listeners attached.
*
* Test for 2035: Listener issue in the stack view synchronizer
*
* @throws DebugExceptionWrapper
*/
@Test
public void testNewThread() 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));
m_model.setActiveDebugger(debugger);
final TargetProcessThread thread = new TargetProcessThread(1, ThreadState.RUNNING);
debugger.getProcessManager().addThread(thread);
m_synchronizer.dispose();
debugger.close();
}
use of com.google.security.zynamics.binnavi.debug.models.processmanager.MemorySection in project binnavi by google.
the class CRegisterViewSynchronizerTest 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);
debugger.getProcessManager().addThread(thread);
m_model.setActiveDebugger(debugger);
assertFalse(m_registerView.isEnabled());
final TargetProcessThread thread2 = new TargetProcessThread(2, ThreadState.RUNNING);
debugger.getProcessManager().addThread(thread2);
assertFalse(m_registerView.isEnabled());
debugger.getProcessManager().setActiveThread(thread2);
assertTrue(m_registerView.isEnabled());
debugger.getProcessManager().setActiveThread(null);
assertFalse(m_registerView.isEnabled());
debugger.getProcessManager().removeThread(thread);
assertFalse(m_registerView.isEnabled());
debugger.getProcessManager().setAttached(false);
m_synchronizer.dispose();
debugger.close();
}
Aggregations