use of com.google.security.zynamics.binnavi.disassembly.RelocatedAddress in project binnavi by google.
the class EchoBreakpointSetSynchronizer method handleSuccess.
@Override
protected void handleSuccess(final EchoBreakpointSetReply reply) {
final BreakpointManager manager = getDebugger().getBreakpointManager();
final Set<BreakpointAddress> addressesToActivate = new HashSet<>();
final Set<BreakpointAddress> addressesToRemove = new HashSet<>();
for (final Pair<RelocatedAddress, Integer> resultPair : reply.getAddresses()) {
final RelocatedAddress address = resultPair.first();
if (resultPair.second() == 0) {
addressesToActivate.add(DebuggerHelpers.getBreakpointAddress(getDebugger(), address));
} else {
addressesToRemove.add(DebuggerHelpers.getBreakpointAddress(getDebugger(), address));
}
}
manager.setBreakpointStatus(addressesToActivate, BreakpointType.ECHO, BreakpointStatus.BREAKPOINT_ACTIVE);
manager.removeBreakpointsPassive(BreakpointType.ECHO, addressesToRemove);
}
use of com.google.security.zynamics.binnavi.disassembly.RelocatedAddress in project binnavi by google.
the class ReplySynchronizer method setRegisterValues.
/**
* Updates the thread the register data belongs to with the new values.
*
* @param registerValues The new register values.
*/
protected void setRegisterValues(final RegisterValues registerValues) {
Preconditions.checkNotNull(registerValues, "IE01046: Register values argument can not be null");
final ProcessManager processManager = debugger.getProcessManager();
for (final ThreadRegisters threadRegister : registerValues) {
for (final TargetProcessThread thread : processManager.getThreads()) {
if (thread.getThreadId() == threadRegister.getTid()) {
// Update the thread with the new register values.
thread.setRegisterValues(threadRegister.getRegisters());
for (final RegisterValue registerValue : threadRegister.getRegisters()) {
if (registerValue.isPc()) {
thread.setCurrentAddress(new RelocatedAddress(new CAddress(registerValue.getValue())));
}
}
}
}
}
}
use of com.google.security.zynamics.binnavi.disassembly.RelocatedAddress in project binnavi by google.
the class StepBreakpointSetSynchronizer method handleSuccess.
/**
* When a stepping breakpoint was set in the target process, its state is set to ACTIVE in the
* breakpoint manager.
*/
@Override
protected void handleSuccess(final StepBreakpointSetReply reply) {
final BreakpointManager manager = getDebugger().getBreakpointManager();
final Set<BreakpointAddress> addressesToActivate = new HashSet<BreakpointAddress>();
final Set<BreakpointAddress> addressesToRemove = new HashSet<BreakpointAddress>();
for (final Pair<RelocatedAddress, Integer> resultPair : reply.getAddresses()) {
final RelocatedAddress address = resultPair.first();
if (resultPair.second() == DebuggerErrorCodes.SUCCESS) {
addressesToActivate.add(DebuggerHelpers.getBreakpointAddress(getDebugger(), address));
} else {
addressesToRemove.add(DebuggerHelpers.getBreakpointAddress(getDebugger(), address));
}
}
manager.setBreakpointStatus(addressesToActivate, BreakpointType.STEP, BreakpointStatus.BREAKPOINT_ACTIVE);
manager.removeBreakpoints(BreakpointType.STEP, addressesToRemove);
}
use of com.google.security.zynamics.binnavi.disassembly.RelocatedAddress in project binnavi by google.
the class DebuggerTest method testListeners3.
@SuppressWarnings("unchecked")
@Test
public void testListeners3() throws MessageParserException, DebugExceptionWrapper, MaybeNullException {
mockDebugger.connect();
mockDebugger.getProcessManager().addThread(new TargetProcessThread(0, ThreadState.RUNNING));
mockDebugger.getProcessManager().getThread(0).setCurrentAddress(new RelocatedAddress(new CAddress(0)));
mockDebugger.connection.m_synchronizer.receivedEvent(new ResumeThreadReply(0, 0, 0));
mockDebugger.connection.m_synchronizer.receivedEvent(new ResumeThreadReply(0, 1, 0));
mockDebugger.connection.m_synchronizer.receivedEvent(new SearchReply(0, 0, new CAddress(0)));
mockDebugger.connection.m_synchronizer.receivedEvent(new SearchReply(0, 1, null));
mockDebugger.connection.m_synchronizer.receivedEvent(new SelectFileReply(0, 0));
mockDebugger.connection.m_synchronizer.receivedEvent(new SelectFileReply(0, 1));
mockDebugger.getProcessManager().addThread(new TargetProcessThread(0, ThreadState.RUNNING));
mockDebugger.getProcessManager().getThread(0).setCurrentAddress(new RelocatedAddress(new CAddress(0)));
mockDebugger.connection.m_synchronizer.receivedEvent(new SetRegisterReply(0, 0, 0, 0));
mockDebugger.connection.m_synchronizer.receivedEvent(new SetRegisterReply(0, 1, 0, 0));
mockDebugger.connection.m_synchronizer.receivedEvent(new SingleStepReply(0, 0, 0, new RelocatedAddress(new CAddress(0)), new RegisterValues(new FilledList<ThreadRegisters>())));
mockDebugger.connection.m_synchronizer.receivedEvent(new SingleStepReply(0, 1, 0, new RelocatedAddress(new CAddress(0)), new RegisterValues(new FilledList<ThreadRegisters>())));
mockDebugger.connection.m_synchronizer.receivedEvent(new StepBreakpointHitReply(0, 0, 1, new RegisterValues(Lists.<ThreadRegisters>newArrayList(new ThreadRegisters(1, Lists.newArrayList(new RegisterValue("eip", BigInteger.ONE, new byte[0], false, false)))))));
mockDebugger.connection.m_synchronizer.receivedEvent(new StepBreakpointHitReply(0, 0, 1, new RegisterValues(Lists.<ThreadRegisters>newArrayList(new ThreadRegisters(1, Lists.newArrayList(new RegisterValue("eip", BigInteger.ONE, new byte[0], true, false)))))));
mockDebugger.getBreakpointManager().addBreakpoints(BreakpointType.STEP, CommonTestObjects.BP_ADDRESS_123_SET);
mockDebugger.connection.m_synchronizer.receivedEvent(new StepBreakpointSetReply(0, 0, Lists.newArrayList(new Pair<RelocatedAddress, Integer>(CommonTestObjects.BP_ADDRESS_123_RELOC, 0))));
mockDebugger.connection.m_synchronizer.receivedEvent(new StepBreakpointSetReply(0, 1, Lists.newArrayList(new Pair<RelocatedAddress, Integer>(CommonTestObjects.BP_ADDRESS_123_RELOC, 1))));
mockDebugger.connection.m_synchronizer.receivedEvent(new StepBreakpointsRemovedReply(0, 0, Lists.newArrayList(new Pair<RelocatedAddress, Integer>(CommonTestObjects.BP_ADDRESS_123_RELOC, 0))));
mockDebugger.connection.m_synchronizer.receivedEvent(new StepBreakpointsRemovedReply(0, 1, Lists.newArrayList(new Pair<RelocatedAddress, Integer>(CommonTestObjects.BP_ADDRESS_123_RELOC, 1))));
mockDebugger.connection.m_synchronizer.receivedEvent(new SuspendThreadReply(0, 0, 0));
mockDebugger.connection.m_synchronizer.receivedEvent(new SuspendThreadReply(0, 1, 0));
mockDebugger.connection.m_synchronizer.receivedEvent(new TargetInformationReply(0, 0, TargetInformationParser.parse("<foo><size>32</size><registers></registers><options></options></foo>".getBytes())));
mockDebugger.connection.m_synchronizer.receivedEvent(new TargetInformationReply(0, 1, null));
mockDebugger.getProcessManager().addThread(new TargetProcessThread(0, ThreadState.RUNNING));
mockDebugger.connection.m_synchronizer.receivedEvent(new ThreadClosedReply(0, 0, 0));
mockDebugger.connection.m_synchronizer.receivedEvent(new ThreadClosedReply(0, 1, 0));
mockDebugger.connection.m_synchronizer.receivedEvent(new ThreadCreatedReply(0, 0, 0, ThreadState.RUNNING));
mockDebugger.connection.m_synchronizer.receivedEvent(new ThreadCreatedReply(0, 1, 0, null));
mockDebugger.connection.m_synchronizer.receivedEvent(new ValidateMemoryReply(0, 0, new CAddress(0), new CAddress(0)));
mockDebugger.connection.m_synchronizer.receivedEvent(new ValidateMemoryReply(0, 1, null, null));
mockDebugger.connection.m_synchronizer.receivedEvent(new WriteMemoryReply(0, 0));
mockDebugger.connection.m_synchronizer.receivedEvent(new WriteMemoryReply(0, 1));
mockDebugger.connection.m_synchronizer.receivedEvent(new TerminateReply(0, 0));
mockDebugger.connection.m_synchronizer.receivedEvent(new TerminateReply(0, 1));
}
use of com.google.security.zynamics.binnavi.disassembly.RelocatedAddress in project binnavi by google.
the class DebuggerTest method testListeners2.
@SuppressWarnings("unchecked")
@Test
public void testListeners2() throws DebugExceptionWrapper {
final DebuggerListener listener = new DebuggerListener();
debugger.addListener(listener);
mockDebugger.connect();
mockDebugger.getProcessManager().addThread(new TargetProcessThread(1, ThreadState.RUNNING));
mockDebugger.connection.m_synchronizer.receivedEvent(new BreakpointConditionSetReply(0, 0));
mockDebugger.connection.m_synchronizer.receivedEvent(new BreakpointConditionSetReply(0, 1));
mockDebugger.connection.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)))))));
mockDebugger.getBreakpointManager().addBreakpoints(BreakpointType.REGULAR, CommonTestObjects.BP_ADDRESS_123_SET);
mockDebugger.connection.m_synchronizer.receivedEvent(new BreakpointSetReply(0, 0, Lists.newArrayList(new Pair<RelocatedAddress, Integer>(CommonTestObjects.BP_ADDRESS_123_RELOC, 0))));
mockDebugger.connection.m_synchronizer.receivedEvent(new BreakpointSetReply(0, 0, Lists.newArrayList(new Pair<RelocatedAddress, Integer>(CommonTestObjects.BP_ADDRESS_123_RELOC, 1))));
mockDebugger.connection.m_synchronizer.receivedEvent(new BreakpointsRemovedReply(0, 0, Lists.newArrayList(new Pair<RelocatedAddress, Integer>(CommonTestObjects.BP_ADDRESS_123_RELOC, 0))));
mockDebugger.connection.m_synchronizer.receivedEvent(new BreakpointsRemovedReply(0, 0, Lists.newArrayList(new Pair<RelocatedAddress, Integer>(CommonTestObjects.BP_ADDRESS_123_RELOC, 1))));
mockDebugger.getBreakpointManager().removeBreakpoints(BreakpointType.REGULAR, CommonTestObjects.BP_ADDRESS_123_SET);
mockDebugger.connection.m_synchronizer.receivedEvent(new DebuggerClosedUnexpectedlyReply());
mockDebugger.connection.m_synchronizer.receivedEvent(new DetachReply(0, 0));
mockDebugger.connection.m_synchronizer.receivedEvent(new DetachReply(0, 1));
mockDebugger.connection.m_synchronizer.receivedEvent(new EchoBreakpointHitReply(0, 0, 1, new RegisterValues(Lists.<ThreadRegisters>newArrayList(new ThreadRegisters(1, Lists.newArrayList(new RegisterValue("eip", BigInteger.ONE, new byte[0], false, false)))))));
mockDebugger.connection.m_synchronizer.receivedEvent(new EchoBreakpointHitReply(0, 0, 1, new RegisterValues(Lists.<ThreadRegisters>newArrayList(new ThreadRegisters(1, Lists.newArrayList(new RegisterValue("eip", BigInteger.ONE, new byte[0], true, false)))))));
debugger.removeListener(listener);
}
Aggregations