use of com.google.security.zynamics.binnavi.debug.models.targetinformation.RegisterDescription in project binnavi by google.
the class CMemoryRefreshButtonSynchronizerTest method testReceiveTargetInformation.
@Test
public void testReceiveTargetInformation() throws DebugExceptionWrapper {
final MockDebugger debugger = new MockDebugger(new ModuleTargetSettings(CommonTestObjects.MODULE));
debugger.connect();
m_model.setActiveDebugger(debugger);
debugger.connection.m_synchronizer.receivedEvent(new TargetInformationReply(0, 0, new TargetInformation(32, new FilledList<RegisterDescription>(), new DebuggerOptions(false, false, false, false, false, true, false, false, false, false, 1, 0, new ArrayList<DebuggerException>(), false, false, false))));
assertFalse(m_refreshButton.isEnabled());
assertEquals(m_defaultAction, m_refreshButton.getAction());
debugger.connection.m_synchronizer.receivedEvent(new TargetInformationReply(0, 0, new TargetInformation(32, new FilledList<RegisterDescription>(), new DebuggerOptions(false, false, false, false, false, false, false, false, false, false, 1, 0, new ArrayList<DebuggerException>(), false, false, false))));
assertFalse(m_refreshButton.isEnabled());
assertEquals(m_askAction, m_refreshButton.getAction());
m_synchronizer.dispose();
debugger.close();
}
use of com.google.security.zynamics.binnavi.debug.models.targetinformation.RegisterDescription in project binnavi by google.
the class Debugger method writeRegister.
// ! Writes a register value.
/**
* Changes the value of a register in the given thread.
*
* @param tid Thread ID of the thread whose register value is changed.
* @param register Name of the register to change.
* @param value The new value of the register.
*
* @throws DebugException Thrown if the message could not be sent to the debug client.
*/
public void writeRegister(final long tid, final String register, final long value) throws DebugException {
Preconditions.checkNotNull(register, "Error: Register argument can not be null");
Preconditions.checkNotNull(m_debugger.getProcessManager().getTargetInformation(), "Error: Target information string has not yet been received");
final List<RegisterDescription> registers = m_debugger.getProcessManager().getTargetInformation().getRegisters();
int index = 0;
for (final RegisterDescription description : registers) {
if (description.getName().equalsIgnoreCase(register)) {
if (!description.isEditable()) {
throw new IllegalArgumentException("Error: Selected register can not be edited");
}
break;
}
index++;
}
if (index == registers.size()) {
throw new IllegalArgumentException("Error: Unknown register name");
}
try {
m_debugger.setRegister(tid, index, BigInteger.valueOf(value));
} catch (final DebugExceptionWrapper e) {
throw new DebugException(e);
}
}
use of com.google.security.zynamics.binnavi.debug.models.targetinformation.RegisterDescription in project binnavi by google.
the class CDebuggerSynchronizerTest method testModuleLifecycle.
/**
* This test makes sure that the memory module lifecycle (Module Loaded -> Module Unloaded) is
* working and that the process manager of the debugger is updated correctly.
*
* @throws DebugExceptionWrapper
*/
@Test
public void testModuleLifecycle() throws DebugExceptionWrapper {
assertTrue(mockDebugger.getProcessManager().getModules().isEmpty());
mockDebugger.connect();
mockDebugger.getProcessManager().getThreads().clear();
debuggerSynchronizer.receivedEvent(new ThreadCreatedReply(0, 0, 1000, ThreadState.RUNNING));
final MemoryModule module = new MemoryModule("hannes.dll", "C:\\hannes.dll", new RelocatedAddress(new CAddress(0x1000000)), 1000);
debuggerSynchronizer.receivedEvent(new ModuleLoadedReply(0, 0, module, new TargetProcessThread(1000, ThreadState.RUNNING)));
mockDebugger.getProcessManager().setTargetInformation(new TargetInformation(5, Lists.newArrayList(new RegisterDescription("eax", 4, true), new RegisterDescription("ebx", 4, false)), new DebuggerOptions(false, false, false, false, false, false, false, false, false, false, 12, 0, new ArrayList<DebuggerException>(), false, false, false)));
assertTrue(mockDebugger.getProcessManager().getModules().size() == 1);
assertTrue(mockDebugger.getProcessManager().getModules().get(0) == module);
debuggerSynchronizer.receivedEvent(new ModuleUnloadedReply(0, 0, module));
assertTrue(mockDebugger.getProcessManager().getModules().isEmpty());
}
use of com.google.security.zynamics.binnavi.debug.models.targetinformation.RegisterDescription in project binnavi by google.
the class CRegisterProvider method setRegisterInformation.
/**
* Updates the register information.
*
* @param information The new register information to display.
*/
public void setRegisterInformation(final List<RegisterValue> information) {
Preconditions.checkNotNull(information, "IE01475: Information argument can not be null");
if (!information.isEmpty() && (m_information == null)) {
throw new IllegalStateException("IE01124: Can not set register values if no target information is given");
}
final RegisterInformationInternal[] oldRegisterInformation = registerInformation;
final RegisterInformationInternal[] newRegisterInformation = new RegisterInformationInternal[information.size()];
int counter = 0;
if (!information.isEmpty()) {
Preconditions.checkNotNull(m_information, "IE01125: Target information should not be null at this point");
for (final RegisterValue registerValue : information) {
final RegisterDescription regInfo = getDescription(registerValue.getName());
Preconditions.checkNotNull(regInfo, "IE01476: Unknown register");
newRegisterInformation[counter] = new RegisterInformationInternal(regInfo.getName(), regInfo.getSize());
newRegisterInformation[counter].setValue(registerValue.getValue());
// Make sure to highlight modified register values.
highlightChangedRegister(counter, registerValue, oldRegisterInformation, newRegisterInformation);
counter++;
}
}
registerInformation = newRegisterInformation;
notifyRegisterChanged();
}
Aggregations