use of com.google.security.zynamics.binnavi.disassembly.RelocatedAddress in project binnavi by google.
the class CModulesTableModelSynchronizerTest method testModuleLifecycle.
@Test
public void testModuleLifecycle() throws DebugExceptionWrapper, IllegalArgumentException, SecurityException, IllegalAccessException, NoSuchFieldException {
final MockDebugger debugger = new MockDebugger(new ModuleTargetSettings(CommonTestObjects.MODULE));
debugger.connect();
m_model.setActiveDebugger(debugger);
assertEquals(0, m_tableModel.getRowCount());
final MemoryModule module = new MemoryModule("Hannes", "C:\\Hannes.dll", new RelocatedAddress(new CAddress(0x100)), 0x200);
debugger.connection.m_synchronizer.receivedEvent(new ModuleLoadedReply(0, 0, module, new TargetProcessThread(123, ThreadState.SUSPENDED)));
assertEquals(1, m_tableModel.getRowCount());
assertEquals("Hannes", m_tableModel.getValueAt(0, 0));
assertEquals("00000100", m_tableModel.getValueAt(0, 1));
assertEquals(0x200L, m_tableModel.getValueAt(0, 2));
debugger.getProcessManager().setTargetInformation(new TargetInformation(5, Lists.newArrayList(new RegisterDescription("eax", 4, true), new RegisterDescription("ebx", 4, false)), new DebuggerOptions(false, false, false, false, false, false, false, false, false, false, 12, 0, new ArrayList<DebuggerException>(), false, false, false)));
debugger.connection.m_synchronizer.receivedEvent(new ModuleUnloadedReply(0, 0, module));
assertEquals(0, m_tableModel.getRowCount());
m_synchronizer.dispose();
debugger.close();
final LinkedHashSet<?> debuggerListeners = (LinkedHashSet<?>) ReflectionHelpers.getField(ReflectionHelpers.getField(ReflectionHelpers.getField(AbstractDebugger.class, debugger, "synchronizer"), "listeners"), "m_listeners");
final LinkedHashSet<?> processListeners = (LinkedHashSet<?>) ReflectionHelpers.getField(ReflectionHelpers.getField(ReflectionHelpers.getField(AbstractDebugger.class, debugger, "processManager"), "listeners"), "m_listeners");
// The debugger only has one internal memory synchronizer
assertEquals(1, debuggerListeners.size());
// The process manager only has one thread state synchronizer
assertEquals(1, processListeners.size());
}
use of com.google.security.zynamics.binnavi.disassembly.RelocatedAddress in project binnavi by google.
the class CCodeNodeUpdater method generateContent.
@Override
public void generateContent(final IZyNodeRealizer realizer, final ZyLabelContent content) {
ZyCodeNodeBuilder.buildContent(content, codeNode, graph.getSettings(), nodeModifier);
for (final INaviInstruction instruction : codeNode.getInstructions()) {
final INaviModule module = instruction.getModule();
if ((provider != null) && (provider.getDebugger(module) != null) && graph.getSettings().getDisplaySettings().getShowMemoryAddresses(provider.getDebugger(module))) {
final int line = CCodeNodeHelpers.instructionToLine(codeNode, instruction);
if (line != -1) {
final ZyLineContent lineContent = this.realizer.getNodeContent().getLineContent(line);
// TODO(timkornau) x64
lineContent.setTextColor(0, 8, Color.RED);
}
}
}
// Set highlighting for breakpoints and the instruction pointer.
final INaviInstruction instruction = codeNode.getInstructions().iterator().next();
if (instruction != null) {
final INaviModule module = instruction.getModule();
final IDebugger debugger = provider.getDebugger(module);
if (debugger == null) {
return;
}
final BreakpointManager manager = debugger.getBreakpointManager();
CBreakpointPainter.paintBreakpoints(manager, node, codeNode);
if (debugger.getProcessManager().getActiveThread() != null) {
final RelocatedAddress instructionPointer = debugger.getProcessManager().getActiveThread().getCurrentAddress();
final MemoryModule memoryModule = debugger.getProcessManager().getModule(instructionPointer);
final UnrelocatedAddress unrelocatedIP = new DefaultAddressConverter(memoryModule.getBaseAddress().getAddress(), module.getConfiguration().getFileBase()).memoryToFile(instructionPointer);
CDebuggerPainter.updateSingleNodeDebuggerHighlighting(graph, unrelocatedIP, node);
}
}
}
use of com.google.security.zynamics.binnavi.disassembly.RelocatedAddress in project binnavi by google.
the class CDebuggerSynchronizerTest method testRemoveBreakpointError_Invalid.
@SuppressWarnings("unchecked")
@Test
public void testRemoveBreakpointError_Invalid() {
debuggerSynchronizer.receivedEvent(new BreakpointsRemovedReply(0, 5, Lists.newArrayList(new Pair<RelocatedAddress, Integer>(CommonTestObjects.BP_ADDRESS_456_RELOC, 0))));
assertEquals(0, listener.exception);
assertEquals(0, breakpointManager.getNumberOfBreakpoints(BreakpointType.REGULAR));
}
use of com.google.security.zynamics.binnavi.disassembly.RelocatedAddress in project binnavi by google.
the class CDebuggerSynchronizerTest method testEchoBreakpointSetSucc.
@SuppressWarnings("unchecked")
@Test
public void testEchoBreakpointSetSucc() throws DebugExceptionWrapper {
mockDebugger.connect();
breakpointManager.addBreakpoints(BreakpointType.ECHO, CommonTestObjects.BP_ADDRESS_123_SET);
debuggerSynchronizer.receivedEvent(new EchoBreakpointSetReply(0, 0, Lists.newArrayList(new Pair<RelocatedAddress, Integer>(CommonTestObjects.BP_ADDRESS_123_RELOC, 0))));
assertEquals(1, breakpointManager.getNumberOfBreakpoints(BreakpointType.ECHO));
assertEquals(BreakpointStatus.BREAKPOINT_ACTIVE, breakpointManager.getBreakpointStatus(CommonTestObjects.BP_ADDRESS_123, BreakpointType.ECHO));
}
use of com.google.security.zynamics.binnavi.disassembly.RelocatedAddress in project binnavi by google.
the class CDebuggerSynchronizerTest method testRemoveBreakpoint_Active.
@SuppressWarnings("unchecked")
@Test
public void testRemoveBreakpoint_Active() throws DebugExceptionWrapper {
mockDebugger.connect();
breakpointManager.addBreakpoints(BreakpointType.REGULAR, CommonTestObjects.BP_ADDRESS_456_SET);
breakpointManager.setBreakpointStatus(CommonTestObjects.BP_ADDRESS_456_SET, BreakpointType.REGULAR, BreakpointStatus.BREAKPOINT_ACTIVE);
mockDebugger.getProcessManager().addThread(new TargetProcessThread(123, ThreadState.SUSPENDED));
breakpointManager.setBreakpointStatus(CommonTestObjects.BP_ADDRESS_456_SET, BreakpointType.REGULAR, BreakpointStatus.BREAKPOINT_DELETING);
debuggerSynchronizer.receivedEvent(new BreakpointsRemovedReply(0, 0, Lists.newArrayList(new Pair<RelocatedAddress, Integer>(CommonTestObjects.BP_ADDRESS_456_RELOC, 0))));
assertEquals(0, listener.exception);
assertEquals(0, breakpointManager.getNumberOfBreakpoints(BreakpointType.REGULAR));
}
Aggregations