use of com.google.security.zynamics.binnavi.debug.models.targetinformation.ThreadRegisters 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.debug.models.targetinformation.ThreadRegisters 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;
}
}
use of com.google.security.zynamics.binnavi.debug.models.targetinformation.ThreadRegisters in project binnavi by google.
the class TraceLoggerTest method testHits.
@Test
public void testHits() throws CouldntSaveDataException, DebugExceptionWrapper {
m_mockDebugger.connect();
final Trace trace = m_logger.start("Name", "Description", Lists.newArrayList(new TracePoint(m_mockModule, new Address(0x100)), new TracePoint(m_mockModule, new Address(0x100))));
m_mockDebugger.connection.m_synchronizer.receivedEvent(new EchoBreakpointHitReply(0, 0, 0, new RegisterValues(Lists.<ThreadRegisters>newArrayList(new ThreadRegisters(0, Lists.newArrayList(new RegisterValue("esp", BigInteger.valueOf(0x1100), new byte[0], true, false)))))));
m_logger.stop();
assertEquals("Name", trace.getName());
assertEquals("Description", trace.getDescription());
assertEquals(1, trace.getEvents().size());
assertEquals(0x100, trace.getEvents().get(0).getAddress().toLong());
assertEquals("TraceLogger [Debugger 'Mock' : Mock Module]", m_logger.toString());
}
use of com.google.security.zynamics.binnavi.debug.models.targetinformation.ThreadRegisters in project binnavi by google.
the class TraceLoggerTest method testHitsProject.
@Test
public void testHitsProject() throws CouldntSaveDataException, DebugExceptionWrapper {
m_mockDebugger.connect();
final Trace trace = m_projectLogger.start("Name", "Description", Lists.newArrayList(new TracePoint(m_mockModule, new Address(0x100))));
m_mockDebugger.connection.m_synchronizer.receivedEvent(new EchoBreakpointHitReply(0, 0, 0, new RegisterValues(Lists.<ThreadRegisters>newArrayList(new ThreadRegisters(0, Lists.newArrayList(new RegisterValue("esp", BigInteger.valueOf(0x1100), new byte[0], true, false)))))));
m_projectLogger.stop();
assertEquals("Name", trace.getName());
assertEquals("Description", trace.getDescription());
assertEquals(1, trace.getEvents().size());
assertEquals(0x100, trace.getEvents().get(0).getAddress().toLong());
assertEquals("TraceLogger [Debugger 'Mock' : Mock Project]", m_projectLogger.toString());
}
use of com.google.security.zynamics.binnavi.debug.models.targetinformation.ThreadRegisters in project binnavi by google.
the class RegisterValuesParser method parse.
/**
* Parses a byte array from the debug client into usable register information.
*
* @param data Byte array from the debug client.
*
* @return Usable register information.
*
* @throws IllegalArgumentException If the data argument is null.
* @throws MessageParserException If parsing the message failed.
*/
public static RegisterValues parse(final byte[] data) throws MessageParserException {
Preconditions.checkNotNull(data, "IE01299: Data argument can not be null");
final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
try {
final DocumentBuilder builder = factory.newDocumentBuilder();
final Document document = builder.parse(new ByteArrayInputStream(data, 0, data.length));
final NodeList nodes = document.getFirstChild().getChildNodes();
final List<ThreadRegisters> threads = new ArrayList<>();
for (int i = 0; i < nodes.getLength(); ++i) {
final Node node = nodes.item(i);
if (node.getNodeName().equals("Thread")) {
threads.add(parseThreadNode(node));
} else {
throw new MessageParserException(String.format("IE01040: Invalid node '%s' found during register values message parsing", node.getNodeName()));
}
}
return new RegisterValues(threads);
} catch (IOException | ParserConfigurationException | SAXException exception) {
CUtilityFunctions.logException(exception);
throw new MessageParserException(exception.getLocalizedMessage());
}
}
Aggregations