Search in sources :

Example 1 with CEvaluationVisitor

use of com.google.security.zynamics.binnavi.Gui.Debug.MemoryPanel.Implementations.CEvaluationVisitor 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.");
        }
    }
}
Also used : MemorySection(com.google.security.zynamics.binnavi.debug.models.processmanager.MemorySection) BigInteger(java.math.BigInteger) CEvaluationVisitor(com.google.security.zynamics.binnavi.Gui.Debug.MemoryPanel.Implementations.CEvaluationVisitor) RecognitionException(org.antlr.runtime.RecognitionException) MemoryExpressionElement(com.google.security.zynamics.binnavi.debug.models.memoryexpressions.MemoryExpressionElement) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress)

Aggregations

CEvaluationVisitor (com.google.security.zynamics.binnavi.Gui.Debug.MemoryPanel.Implementations.CEvaluationVisitor)1 MemoryExpressionElement (com.google.security.zynamics.binnavi.debug.models.memoryexpressions.MemoryExpressionElement)1 MemorySection (com.google.security.zynamics.binnavi.debug.models.processmanager.MemorySection)1 CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)1 BigInteger (java.math.BigInteger)1 RecognitionException (org.antlr.runtime.RecognitionException)1