Search in sources :

Example 1 with MemoryExpressionElement

use of com.google.security.zynamics.binnavi.debug.models.memoryexpressions.MemoryExpressionElement in project binnavi by google.

the class CEvaluationVisitor method visit.

@Override
public void visit(final SubExpression expression) {
    final MemoryExpressionElement child = expression.getChild();
    child.visit(this);
    final BigInteger childValue = getValue(child);
    if (childValue == null) {
        return;
    }
    m_partialEvaluationMap.put(expression, childValue);
}
Also used : BigInteger(java.math.BigInteger) MemoryExpressionElement(com.google.security.zynamics.binnavi.debug.models.memoryexpressions.MemoryExpressionElement)

Example 2 with MemoryExpressionElement

use of com.google.security.zynamics.binnavi.debug.models.memoryexpressions.MemoryExpressionElement 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)

Example 3 with MemoryExpressionElement

use of com.google.security.zynamics.binnavi.debug.models.memoryexpressions.MemoryExpressionElement in project binnavi by google.

the class CEvaluationVisitor method visit.

@Override
public void visit(final MemoryExpression memoryExpression) {
    final MemoryExpressionElement child = memoryExpression.getChild();
    child.visit(this);
    final BigInteger address = getValue(child);
    try {
        m_partialEvaluationMap.put(memoryExpression, m_binding.getValue(address));
    } catch (final CEvaluationException e) {
        m_errorMessages.add(String.format("Unknown memory address %s", address.toString(16)));
    }
}
Also used : BigInteger(java.math.BigInteger) MemoryExpressionElement(com.google.security.zynamics.binnavi.debug.models.memoryexpressions.MemoryExpressionElement)

Example 4 with MemoryExpressionElement

use of com.google.security.zynamics.binnavi.debug.models.memoryexpressions.MemoryExpressionElement in project binnavi by google.

the class CEvaluationVisitor method visit.

@Override
public void visit(final PlusExpression expression) {
    BigInteger value = null;
    for (final MemoryExpressionElement child : expression.getChildren()) {
        child.visit(this);
        final BigInteger childValue = getValue(child);
        if (childValue == null) {
            return;
        }
        if (value == null) {
            value = getValue(child);
            if (value == null) {
                return;
            }
        } else {
            value = value.add(getValue(child));
        }
    }
    m_partialEvaluationMap.put(expression, value);
}
Also used : BigInteger(java.math.BigInteger) MemoryExpressionElement(com.google.security.zynamics.binnavi.debug.models.memoryexpressions.MemoryExpressionElement)

Example 5 with MemoryExpressionElement

use of com.google.security.zynamics.binnavi.debug.models.memoryexpressions.MemoryExpressionElement in project binnavi by google.

the class CEvaluationVisitor method visit.

@Override
public void visit(final MinusExpression expression) {
    BigInteger value = null;
    for (final MemoryExpressionElement child : expression.getChildren()) {
        child.visit(this);
        final BigInteger childValue = getValue(child);
        if (childValue == null) {
            return;
        }
        if (value == null) {
            value = getValue(child);
            if (value == null) {
                return;
            }
        } else {
            value = value.subtract(getValue(child));
        }
    }
    m_partialEvaluationMap.put(expression, value);
}
Also used : BigInteger(java.math.BigInteger) MemoryExpressionElement(com.google.security.zynamics.binnavi.debug.models.memoryexpressions.MemoryExpressionElement)

Aggregations

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