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);
}
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.");
}
}
}
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)));
}
}
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);
}
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);
}
Aggregations