use of com.google.security.zynamics.binnavi.disassembly.RelocatedAddress in project binnavi by google.
the class BreakpointHitSynchronizer method handleSuccess.
/**
* Handles incoming Breakpoint Hit replies.
*
* @param reply The incoming Breakpoint Hit reply to handle.
*/
@Override
protected void handleSuccess(final BreakpointHitReply reply) {
final ProcessManager processManager = getDebugger().getProcessManager();
// When the debug client notifies BinNavi that a
// breakpoint was hit, it is necessary to mark the
// breakpoint as hit.
// TODO: Check for success
RelocatedAddress eventAddress = 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()) {
eventAddress = new RelocatedAddress(new CAddress(registerValue.getValue()));
}
}
}
}
if (eventAddress != null) {
updateHitBreakpoints(DebuggerHelpers.getBreakpointAddress(getDebugger(), eventAddress));
} else {
throw new IllegalStateException("IE00173: register reply did not include program counter");
}
try {
final TargetProcessThread thread = processManager.getThread(reply.getThreadId());
// Update the thread with the new register values.
for (final ThreadRegisters threadRegisters : registerValues) {
if (tid == threadRegisters.getTid()) {
thread.setRegisterValues(threadRegisters.getRegisters());
break;
}
}
processManager.setActiveThread(thread);
thread.setCurrentAddress(eventAddress);
} catch (final MaybeNullException exception) {
NaviLogger.info("Error: there is no thread with the specified thread id %d Exception: %s", reply.getThreadId(), exception);
}
}
use of com.google.security.zynamics.binnavi.disassembly.RelocatedAddress in project binnavi by google.
the class BreakpointRemovedSynchronizer method handleSuccess.
@Override
protected void handleSuccess(final BreakpointsRemovedReply reply) {
// If a breakpoint was removed from the target process, it can be removed
// from the breakpoint manager too unless the breakpoint is set to disabled
// there.
final BreakpointManager manager = getDebugger().getBreakpointManager();
final Set<BreakpointAddress> addressesToRemove = new HashSet<>();
final Set<BreakpointAddress> addressesToInvalidate = new HashSet<>();
for (final Pair<RelocatedAddress, Integer> resultPair : reply.getAddresses()) {
if (resultPair.second() == 0) {
final BreakpointAddress address = DebuggerHelpers.getBreakpointAddress(getDebugger(), resultPair.first());
if (manager.getBreakpointStatus(address, BreakpointType.REGULAR) == BreakpointStatus.BREAKPOINT_DELETING) {
addressesToRemove.add(address);
}
} else {
addressesToInvalidate.add(DebuggerHelpers.getBreakpointAddress(getDebugger(), resultPair.first()));
}
}
manager.removeBreakpointsPassive(BreakpointType.REGULAR, addressesToRemove);
manager.setBreakpointStatus(addressesToInvalidate, BreakpointType.REGULAR, BreakpointStatus.BREAKPOINT_INVALID);
}
use of com.google.security.zynamics.binnavi.disassembly.RelocatedAddress in project binnavi by google.
the class BreakpointSetSynchronizer method handleSuccess.
@Override
protected void handleSuccess(final BreakpointSetReply reply) {
final BreakpointManager manager = getDebugger().getBreakpointManager();
final Set<BreakpointAddress> addressesToActivate = new HashSet<>();
final Set<BreakpointAddress> addressesToInvalidate = new HashSet<>();
for (final Pair<RelocatedAddress, Integer> resultPair : reply.getAddresses()) {
if (resultPair.second() == 0) {
// If a breakpoint was successfully set in the target process, its status is
// set to ACTIVE in the breakpoint manager.
final BreakpointAddress breakpointAddress = DebuggerHelpers.getBreakpointAddress(getDebugger(), resultPair.first());
if (manager.getBreakpointStatus(breakpointAddress, BreakpointType.REGULAR) != BreakpointStatus.BREAKPOINT_DISABLED) {
addressesToActivate.add(breakpointAddress);
}
} else {
// If a breakpoint could not be set in the target process, its status in the
// breakpoint manager is set to INVALID. The real status of the breakpoint
// is unknown though.
addressesToInvalidate.add(DebuggerHelpers.getBreakpointAddress(getDebugger(), resultPair.first()));
}
}
manager.setBreakpointStatus(addressesToInvalidate, BreakpointType.REGULAR, BreakpointStatus.BREAKPOINT_INVALID);
manager.setBreakpointStatus(addressesToActivate, BreakpointType.REGULAR, BreakpointStatus.BREAKPOINT_ACTIVE);
}
use of com.google.security.zynamics.binnavi.disassembly.RelocatedAddress in project binnavi by google.
the class StepBreakpointRemovedParser method parseSuccess.
@Override
public StepBreakpointsRemovedReply parseSuccess(final int packetId, final int argumentCount) throws IOException {
final List<Pair<RelocatedAddress, Integer>> addresses = new ArrayList<>();
for (int i = 0; i < parseInteger(); i++) {
final RelocatedAddress address = new RelocatedAddress(parseAddress());
addresses.add(new Pair<RelocatedAddress, Integer>(address, parseInteger()));
}
return new StepBreakpointsRemovedReply(packetId, 0, addresses);
}
use of com.google.security.zynamics.binnavi.disassembly.RelocatedAddress in project binnavi by google.
the class StepBreakpointSetParser method parseSuccess.
@Override
public StepBreakpointSetReply parseSuccess(final int packetId, final int argumentCount) throws IOException {
final List<Pair<RelocatedAddress, Integer>> addresses = new ArrayList<>();
final int numberOfAddresses = parseInteger();
for (int i = 0; i < numberOfAddresses; i++) {
final RelocatedAddress address = new RelocatedAddress(parseAddress());
addresses.add(new Pair<RelocatedAddress, Integer>(address, parseInteger()));
}
return new StepBreakpointSetReply(packetId, 0, addresses);
}
Aggregations