use of com.google.security.zynamics.binnavi.debug.models.processmanager.MemorySection in project binnavi by google.
the class CMemoryViewerSynchronizerTest method testResizeSection.
@Test
public void testResizeSection() throws DebugExceptionWrapper {
m_debugger.connect();
m_debugger.getProcessManager().setAttached(true);
m_debugger.getProcessManager().setMemoryMap(new MemoryMap(Lists.newArrayList(new MemorySection(new CAddress(0x100), new CAddress(0x1FF)))));
m_model.setActiveMemoryAddress(new CAddress(0x100), false);
assertEquals(0x100, m_hexView.getCurrentOffset());
assertEquals(0x100, m_hexView.getData().getDataLength());
m_debugger.getProcessManager().setMemoryMap(new MemoryMap(Lists.newArrayList(new MemorySection(new CAddress(0x100), new CAddress(0x1FF)), new MemorySection(new CAddress(0x500), new CAddress(0x5FF)))));
assertEquals(0x100, m_hexView.getCurrentOffset());
assertEquals(0x100, m_hexView.getData().getDataLength());
m_debugger.getProcessManager().setMemoryMap(new MemoryMap(Lists.newArrayList(new MemorySection(new CAddress(0x0), new CAddress(0x2FF)), new MemorySection(new CAddress(0x500), new CAddress(0x5FF)))));
assertEquals(0x100, m_hexView.getCurrentOffset());
assertEquals(0x300, m_hexView.getData().getDataLength());
final MockMemoryViewerSynchronizerListener listener = new MockMemoryViewerSynchronizerListener();
m_synchronizer.addListener(listener);
m_debugger.getProcessManager().setMemoryMap(new MemoryMap(Lists.newArrayList(new MemorySection(new CAddress(0x0), new CAddress(0xFF)), new MemorySection(new CAddress(0x500), new CAddress(0x5FF)))));
assertEquals(0x000, m_hexView.getCurrentOffset());
assertEquals(0x100, m_hexView.getData().getDataLength());
assertEquals("addressTurnedInvalid;", listener.events);
m_synchronizer.removeListener(listener);
m_debugger.getProcessManager().setAttached(false);
m_synchronizer.dispose();
}
use of com.google.security.zynamics.binnavi.debug.models.processmanager.MemorySection in project binnavi by google.
the class CMemoryViewerSynchronizerTest method testSwitchSection.
@Test
public void testSwitchSection() throws DebugExceptionWrapper {
m_debugger.connect();
m_debugger.getProcessManager().setAttached(true);
m_debugger.getProcessManager().setMemoryMap(new MemoryMap(Lists.newArrayList(new MemorySection(new CAddress(0x100), new CAddress(0x1FF)), new MemorySection(new CAddress(0x200), new CAddress(0x4FF)))));
m_model.setActiveMemoryAddress(new CAddress(0x400), false);
assertEquals(0x400, m_hexView.getCurrentOffset());
assertEquals(0x300, m_hexView.getData().getDataLength());
m_model.setActiveMemoryAddress(new CAddress(0x100), false);
assertEquals(0x100, m_hexView.getCurrentOffset());
assertEquals(0x100, m_hexView.getData().getDataLength());
m_debugger.getProcessManager().setAttached(false);
m_synchronizer.dispose();
}
use of com.google.security.zynamics.binnavi.debug.models.processmanager.MemorySection in project binnavi by google.
the class CGotoDialog method dialogClosedOk.
/**
* Does everything that is necessary if the user clicked the OK button.
*/
private void dialogClosedOk() {
final String input = offsetField.getText();
if (!"".equals(input)) {
try {
final MemoryExpressionElement expression = DebuggerMemoryExpressionParser.parse(input);
final CEvaluationVisitor visitor = new CEvaluationVisitor(m_bindings);
expression.visit(visitor);
final BigInteger value = visitor.getValue(expression);
if (value == null) {
final String errors = Commafier.commafy(visitor.getErrorMessages(), "\n");
CMessageBox.showError(m_parent, String.format("The expression you entered could not be evaluated:\n %s", errors));
} else if (value.compareTo(BigInteger.ZERO) == -1 || value.toString(16).length() > 8) {
// Negative or too long
CMessageBox.showError(m_parent, String.format("The expression you entered evaluates to the invalid memory address %s.", value.toString(16).toUpperCase()));
} else {
final MemorySection section = ProcessHelpers.getSectionWith(m_memoryMap, new CAddress(value.longValue()));
if (section == null) {
CMessageBox.showError(m_parent, String.format("There is no memory at address %s.", value.toString(16).toUpperCase()));
} else {
m_value = new CAddress(value.longValue());
dispose();
}
}
} catch (final RecognitionException exception) {
CMessageBox.showError(m_parent, "Invalid expression string.");
}
}
}
use of com.google.security.zynamics.binnavi.debug.models.processmanager.MemorySection in project binnavi by google.
the class CMemoryViewerSynchronizer method resizeData.
/**
* Adjusts size, base offset, and current offset of the hex view depending on a given address and
* the memory sections known to the debugger.
*
* @param address The memory address to consider.
*
* @return True, if the hex view was adjusted. False, if the address is not in any known memory
* section.
*/
private boolean resizeData(final IAddress address) {
if (address == null) {
return true;
}
final IDebugger debugger = m_debugPerspectiveModel.getCurrentSelectedDebugger();
if (debugger != null) {
final MemorySection section = ProcessHelpers.getSectionWith(debugger.getProcessManager().getMemoryMap(), address);
if (section == null) {
// No section with the given memory address
m_debugPerspectiveModel.setActiveMemoryAddress(null, false);
return false;
} else {
m_hexView.setBaseAddress(section.getStart().toLong());
m_provider.setMemorySize(section.getSize());
m_hexView.gotoOffset(address.toLong());
updateGui();
return true;
}
}
return true;
}
use of com.google.security.zynamics.binnavi.debug.models.processmanager.MemorySection in project binnavi by google.
the class CRegisterMenuProvider method getRegisterMenu.
@Override
public JPopupMenu getRegisterMenu(final int registerNumber) {
final IDebugger debugger = m_debugPerspectiveModel.getCurrentSelectedDebugger();
if (debugger == null) {
return null;
}
final JPopupMenu menu = new JPopupMenu();
final BigInteger value = m_dataProvider.getRegisterInformation(registerNumber).getValue();
menu.add(CActionProxy.proxy(new CCopyRegisterValueAction(value.toString(16).toUpperCase())));
final MemorySection section = ProcessHelpers.getSectionWith(debugger.getProcessManager().getMemoryMap(), new CAddress(value));
final JMenuItem gotoAddress = menu.add(CActionProxy.proxy(new CGotoOffsetAction(m_debugPerspectiveModel, new CAddress(value))));
gotoAddress.setEnabled(section != null);
if (containsAddress(m_debugPerspectiveModel.getGraphModel().getGraph().getRawView(), value.longValue())) {
menu.add(CActionProxy.proxy(new CZoomToAddressAction(m_debugPerspectiveModel.getGraphModel().getGraph(), new CAddress(value), debugger.getModule(new RelocatedAddress(new CAddress(value))))));
} else {
final IViewContainer container = m_debugPerspectiveModel.getGraphModel().getViewContainer();
menu.add(CActionProxy.proxy(new CSearchAction(m_debugPerspectiveModel.getGraphModel().getParent(), container, new CAddress(value))));
}
return menu;
}
Aggregations