use of com.google.security.zynamics.binnavi.disassembly.RelocatedAddress in project binnavi by google.
the class CModulesTableModelSynchronizerTest method testSwitchDebugger.
@Test
public void testSwitchDebugger() 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));
final MockDebugger debugger2 = new MockDebugger(new ModuleTargetSettings(CommonTestObjects.MODULE));
debugger2.connect();
debugger2.getProcessManager().addModule(new MemoryModule("Hannes", "C:\\Hannes.dll", new RelocatedAddress(new CAddress(0x200)), 0x100));
debugger2.getProcessManager().addModule(new MemoryModule("Hannes", "C:\\Hannes.dll", new RelocatedAddress(new CAddress(0x200)), 0x100));
m_model.setActiveDebugger(debugger);
assertEquals(1, m_tableModel.getRowCount());
m_model.setActiveDebugger(debugger2);
assertEquals(2, m_tableModel.getRowCount());
m_model.setActiveDebugger(null);
assertEquals(0, m_tableModel.getRowCount());
m_synchronizer.dispose();
debugger.close();
debugger2.close();
}
use of com.google.security.zynamics.binnavi.disassembly.RelocatedAddress 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();
}
use of com.google.security.zynamics.binnavi.disassembly.RelocatedAddress 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.disassembly.RelocatedAddress in project binnavi by google.
the class EchoBreakpointHitSynchronizer method handleSuccess.
@Override
protected void handleSuccess(final EchoBreakpointHitReply reply) {
final BreakpointManager manager = getDebugger().getBreakpointManager();
final long tid = reply.getThreadId();
for (final ThreadRegisters threadRegisters : reply.getRegisterValues()) {
if (tid == threadRegisters.getTid()) {
for (final RegisterValue registerValue : threadRegisters) {
if (registerValue.isPc()) {
final RelocatedAddress address = new RelocatedAddress(new CAddress(registerValue.getValue()));
manager.setBreakpointStatus(Sets.newHashSet(DebuggerHelpers.getBreakpointAddress(getDebugger(), address)), BreakpointType.ECHO, BreakpointStatus.BREAKPOINT_HIT);
break;
}
}
}
}
}
use of com.google.security.zynamics.binnavi.disassembly.RelocatedAddress in project binnavi by google.
the class StepBreakpointHitSynchronizer method handleSuccess.
@Override
protected void handleSuccess(final StepBreakpointHitReply reply) {
final BreakpointManager manager = getDebugger().getBreakpointManager();
final ProcessManager processManager = getDebugger().getProcessManager();
RelocatedAddress breakpointAddress = null;
final RegisterValues registerValues = reply.getRegisterValues();
final long tid = reply.getThreadId();
for (final ThreadRegisters threadRegisters : registerValues) {
if (tid == threadRegisters.getTid()) {
for (final RegisterValue registerValue : threadRegisters) {
if (registerValue.isPc()) {
breakpointAddress = new RelocatedAddress(new CAddress(registerValue.getValue()));
break;
}
}
}
}
manager.clearBreakpointsPassive(BreakpointType.STEP);
try {
final TargetProcessThread thread = processManager.getThread(tid);
for (final ThreadRegisters threadRegisters : registerValues) {
if (tid == threadRegisters.getTid()) {
// Update the thread with the new register values.
thread.setRegisterValues(threadRegisters.getRegisters());
}
}
processManager.setActiveThread(thread);
thread.setCurrentAddress(breakpointAddress);
} catch (final MaybeNullException exception) {
// Apparently there is no thread with the specified TID.
// This is not necessarily an error because the thread might have
// been closed while this handler was active.
// Nevertheless this should be logged.
NaviLogger.info("Error: Process manager could not get thread. Exception %s", exception);
return;
}
}
Aggregations