use of com.google.security.zynamics.binnavi.debug.models.processmanager.ProcessManager 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.debug.models.processmanager.ProcessManager in project binnavi by google.
the class SingleStepSynchronizer method handleSuccess.
@Override
protected void handleSuccess(final SingleStepReply reply) {
final ProcessManager processManager = getDebugger().getProcessManager();
final long tid = reply.getThreadId();
try {
// Find the thread object with the specified TID
final TargetProcessThread thread = processManager.getThread(tid);
// At the end of a single step event, a thread is automatically suspended.
processManager.setActiveThread(thread);
// Update the thread object with the values from the event.
setRegisterValues(reply.getRegisterValues());
updateHitBreakpoints(DebuggerHelpers.getBreakpointAddress(getDebugger(), thread.getCurrentAddress()));
} catch (final MaybeNullException e) {
// 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.
NaviLogger.info("Error: Process manager could not get thread. Exception %s", e);
}
}
use of com.google.security.zynamics.binnavi.debug.models.processmanager.ProcessManager in project binnavi by google.
the class ThreadClosedSynchronizer method handleSuccess.
@Override
protected void handleSuccess(final ThreadClosedReply reply) {
final ProcessManager processManager = getDebugger().getProcessManager();
final long tid = reply.getThreadId();
try {
processManager.removeThread(processManager.getThread(tid));
} catch (final MaybeNullException e) {
CUtilityFunctions.logException(e);
}
}
use of com.google.security.zynamics.binnavi.debug.models.processmanager.ProcessManager in project binnavi by google.
the class ProcessTest method testLifeCycle.
@Test
public void testLifeCycle() {
final MockProcessListener listener = new MockProcessListener();
final ProcessManager manager = new ProcessManager();
final Process process = new Process(manager);
process.addListener(listener);
manager.setAttached(true);
assertEquals("attached;", listener.events);
process.removeListener(listener);
manager.setTargetInformation(new com.google.security.zynamics.binnavi.debug.models.targetinformation.TargetInformation(5, new FilledList<RegisterDescription>(), new DebuggerOptions(false, false, false, false, false, false, false, false, false, false, 12, 0, new ArrayList<DebuggerException>(), false, false, false)));
manager.addThread(new TargetProcessThread(0, ThreadState.RUNNING));
manager.addModule(new MemoryModule("Hannes", "C:\\Hannes.dll", new RelocatedAddress(new CAddress(0x100)), 0x100));
manager.setMemoryMap(new com.google.security.zynamics.binnavi.debug.models.processmanager.MemoryMap(Lists.newArrayList(new com.google.security.zynamics.binnavi.debug.models.processmanager.MemorySection(new CAddress(0), new CAddress(0x100)))));
manager.getMemory().store(0, new byte[] { 0, 1, 2, 3 });
process.addListener(listener);
manager.setTargetInformation(new com.google.security.zynamics.binnavi.debug.models.targetinformation.TargetInformation(5, new FilledList<RegisterDescription>(), new DebuggerOptions(false, false, false, false, false, false, false, false, false, false, 12, 0, new ArrayList<DebuggerException>(), false, false, false)));
assertEquals(0, process.getThreads().size());
assertEquals(0, process.getModules().size());
assertEquals(0, process.getMemoryMap().getSections().size());
assertEquals(false, process.getMemory().hasData(0, 4));
manager.setAttached(false);
assertEquals("attached;changedTargetInformation;detached;", listener.events);
assertEquals(0, process.getThreads().size());
assertEquals(0, process.getModules().size());
assertEquals(null, process.getTargetInformation());
assertEquals(0, process.getMemoryMap().getSections().size());
assertEquals(false, process.getMemory().hasData(0, 4));
process.removeListener(listener);
}
use of com.google.security.zynamics.binnavi.debug.models.processmanager.ProcessManager in project binnavi by google.
the class ProcessTest method testGetMemoryMap.
@Test
public void testGetMemoryMap() {
final MockProcessListener listener = new MockProcessListener();
final ProcessManager manager = new ProcessManager();
final Process process = new Process(manager);
process.addListener(listener);
assertEquals(0, process.getMemoryMap().getSections().size());
manager.setMemoryMap(new com.google.security.zynamics.binnavi.debug.models.processmanager.MemoryMap(Lists.newArrayList(new com.google.security.zynamics.binnavi.debug.models.processmanager.MemorySection(new CAddress(0), new CAddress(0x100)))));
assertEquals("changedMemoryMap;", listener.events);
assertEquals(1, process.getMemoryMap().getSections().size());
final MemoryMap m1 = process.getMemoryMap();
final MemoryMap m2 = process.getMemoryMap();
assertEquals(m1, m2);
process.removeListener(listener);
}
Aggregations