use of com.google.security.zynamics.binnavi.debug.models.processmanager.TargetProcessThread in project binnavi by google.
the class CDebuggerSynchronizerTest method testRegisterValues_Wellformed.
@Test
public void testRegisterValues_Wellformed() throws MessageParserException, MaybeNullException {
mockDebugger.getProcessManager().addThread(new TargetProcessThread(123, ThreadState.RUNNING));
debuggerSynchronizer.receivedEvent(new RegistersReply(0, 0, RegisterValuesParser.parse(("<Registers><Thread id=\"123\"><Register name=\"EAX\" " + "value=\"123\" memory=\"\" /><Register name=\"EBX\" value=\"456\" memory=\"\" " + "/><Register name=\"EIP\" value=\"999\" memory=\"\" pc=\"true\" /></Thread>" + "</Registers>").getBytes())));
assertEquals(0, listener.exception);
assertEquals(0x456, mockDebugger.getProcessManager().getThread(123).getRegisterValues().get(1).getValue().longValue());
assertEquals(0x999, mockDebugger.getProcessManager().getThread(123).getCurrentAddress().getAddress().toLong());
}
use of com.google.security.zynamics.binnavi.debug.models.processmanager.TargetProcessThread in project binnavi by google.
the class CDebuggerSynchronizerTest method testThreadLifecycle.
/**
* This test is used to test the thread lifecycle of suspending and resuming threads.
*
* @throws DebugExceptionWrapper Thrown if something goes wrong.
*/
@Test
public void testThreadLifecycle() throws DebugExceptionWrapper {
mockDebugger.connect();
final TargetProcessThread thread = new TargetProcessThread(123, ThreadState.RUNNING);
mockDebugger.getProcessManager().addThread(thread);
debuggerSynchronizer.receivedEvent(new SuspendThreadReply(0, 0, 123));
assertEquals(ThreadState.SUSPENDED, thread.getState());
debuggerSynchronizer.receivedEvent(new ResumeThreadReply(0, 0, 123));
assertEquals(ThreadState.RUNNING, thread.getState());
}
use of com.google.security.zynamics.binnavi.debug.models.processmanager.TargetProcessThread in project binnavi by google.
the class CDebuggerSynchronizerTest method testHitEchoBreakpoint_Wellformed.
@Test
public void testHitEchoBreakpoint_Wellformed() throws DebugExceptionWrapper, MessageParserException {
mockDebugger.connect();
breakpointManager.addBreakpoints(BreakpointType.ECHO, CommonTestObjects.BP_ADDRESS_456_SET);
breakpointManager.setBreakpointStatus(CommonTestObjects.BP_ADDRESS_456_SET, BreakpointType.ECHO, BreakpointStatus.BREAKPOINT_ACTIVE);
mockDebugger.getProcessManager().addThread(new TargetProcessThread(123, ThreadState.SUSPENDED));
assertEquals(1, breakpointManager.getNumberOfBreakpoints(BreakpointType.ECHO));
assertEquals(BreakpointStatus.BREAKPOINT_ACTIVE, breakpointManager.getBreakpointStatus(CommonTestObjects.BP_ADDRESS_456, BreakpointType.ECHO));
debuggerSynchronizer.receivedEvent(DebuggerMessageBuilder.buildEchoBreakpointHit(CommonTestObjects.BP_ADDRESS_456_RELOC));
assertEquals(0, listener.exception);
assertEquals(1, breakpointManager.getNumberOfBreakpoints(BreakpointType.ECHO));
debuggerSynchronizer.receivedEvent(DebuggerMessageBuilder.buildEchoBreakpointRemoveSucc(CommonTestObjects.BP_ADDRESS_456_RELOC));
assertEquals(0, breakpointManager.getNumberOfBreakpoints(BreakpointType.ECHO));
}
use of com.google.security.zynamics.binnavi.debug.models.processmanager.TargetProcessThread in project binnavi by google.
the class ThreadCreatedSynchronizer method handleSuccess.
@Override
protected void handleSuccess(final ThreadCreatedReply reply) {
final ProcessManager processManager = getDebugger().getProcessManager();
final TargetProcessThread thread = new TargetProcessThread(reply.getThreadId(), reply.getThreadState());
processManager.addThread(thread);
}
use of com.google.security.zynamics.binnavi.debug.models.processmanager.TargetProcessThread in project binnavi by google.
the class MemoryModuleParser method parseThreadId.
/**
* Parses the thread id from the data contents of the CModuleReply message.
*
* @param data The raw data of the CModuleReply message.
*
* @return The parsed thread id.
*
* @throws MessageParserException Thrown if parsing of the message failed.
*/
public static TargetProcessThread parseThreadId(final byte[] data) throws MessageParserException {
Preconditions.checkNotNull(data, "IE00057: 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 Node node = document.getFirstChild();
final long threadId = Long.valueOf(getAttribute(node, "threadid"));
return new TargetProcessThread(threadId, ThreadState.SUSPENDED);
} catch (final Exception exception) {
throw new MessageParserException(exception.getLocalizedMessage());
}
}
Aggregations