use of com.google.security.zynamics.reil.OperandType in project binnavi by google.
the class BaseTransformer method inputOperandsAreRegisters.
/**
* Determines whether the two input operands of an instruction are both registers.
*
* @param instruction The instruction whose input operands are checked.
*
* @return True, if both input operands of the instruction are registers.
*/
private static boolean inputOperandsAreRegisters(final ReilInstruction instruction) {
final OperandType firstOperandType = instruction.getFirstOperand().getType();
final OperandType secondOperandType = instruction.getSecondOperand().getType();
return (firstOperandType == OperandType.REGISTER) && (secondOperandType == OperandType.REGISTER);
}
use of com.google.security.zynamics.reil.OperandType in project binnavi by google.
the class StmTransformer method transform.
public static ValueTrackerElement transform(final ReilInstruction instruction, final ValueTrackerElement state) {
// STM x, , y
final ReilOperand inputOperand = instruction.getFirstOperand();
final ReilOperand addressOperand = instruction.getThirdOperand();
final OperandType inputOperandType = inputOperand.getType();
if (inputOperandType == OperandType.INTEGER_LITERAL) {
final IValueElement previousAddressState = state.getState(addressOperand.getValue());
final IValueElement outputValue = getValue(inputOperand, previousAddressState);
if ((previousAddressState == null) || (previousAddressState instanceof Undefined)) {
final IValueElement newThirdState = getAtomicType(addressOperand);
return state.update(instruction, new MemoryCell(newThirdState), outputValue);
} else {
final IValueElement previousState2b = state.getState(new MemoryCell(previousAddressState));
if ((previousState2b == null) || (previousState2b instanceof Undefined)) {
return state.update(instruction, new MemoryCell(previousAddressState), outputValue);
} else {
return state.update(instruction, new MemoryCell(previousState2b), outputValue);
}
}
} else if (inputOperandType == OperandType.REGISTER) {
final IValueElement newThirdState = getAtomicType(addressOperand);
final IValueElement previousStateInput = state.getState(inputOperand.getValue());
final IValueElement previousState2 = getOperandValue(addressOperand, state);
if ((previousStateInput == null) && (previousState2 == null)) {
return state.update(instruction, new MemoryCell(newThirdState), getAtomicType(inputOperand));
} else if ((previousStateInput == null) && (previousState2 != null)) {
final IValueElement previousState2b = state.getState(new MemoryCell(previousState2));
if (previousState2b == null) {
return state.update(instruction, new MemoryCell(previousState2), getAtomicType(inputOperand));
} else {
return state.update(instruction, new MemoryCell(previousState2b), getAtomicType(inputOperand));
}
} else if ((previousStateInput != null) && (previousState2 == null)) {
return state.update(instruction, new MemoryCell(newThirdState), previousStateInput);
} else if (previousState2 instanceof Undefined) {
return state.update(instruction, new MemoryCell(newThirdState), new Undefined());
} else {
final IValueElement previousState2b = state.getState(new MemoryCell(previousState2));
if ((previousState2b == null) || (previousState2b instanceof Undefined)) {
return state.update(instruction, new MemoryCell(previousState2), previousStateInput);
} else {
return state.update(instruction, new MemoryCell(previousState2b), previousStateInput);
}
}
}
throw new IllegalStateException("Not yet implemented");
}
use of com.google.security.zynamics.reil.OperandType in project binnavi by google.
the class ReilInterpreter method loadLongValue.
/**
* Loads the value of an operand into a long value.
*
* @param operand The operand to load
* @return A pair made of a bool and a long value. The bool indicates whether loading the value
* was successful.
*/
private Pair<Boolean, BigInteger> loadLongValue(final ReilOperand operand) {
final OperandType type = operand.getType();
String value = operand.getValue();
if (type == OperandType.INTEGER_LITERAL) {
return new Pair<Boolean, BigInteger>(true, new BigInteger(value));
} else if (type == OperandType.REGISTER) {
// Check if we have a negative prefix before the register name. This is
// a bit of a hack, because we never explicitly stated that we would allow
// a negation of a register operand in REIL.
// TODO(thomasdullien) remove this code once we have introduced explicit
// left-shift and right-shift instructions.
value = (value.charAt(0) == '-') ? operand.getValue().substring(1) : value;
return !isDefined(value) ? new Pair<Boolean, BigInteger>(false, BigInteger.ZERO) : new Pair<Boolean, BigInteger>(true, getVariableValue(value));
} else {
return new Pair<Boolean, BigInteger>(false, BigInteger.ZERO);
}
}
use of com.google.security.zynamics.reil.OperandType in project binnavi by google.
the class BaseTransformer method inputOperandsAreLiteralRegister.
/**
* Determines whether the two input operands of an instruction are a literal (first operand) and a
* register (second operand).
*
* @param instruction The instruction whose input operands are checked.
*
* @return True, if the first operand is a literal and the second operand is a register. False,
* otherwise.
*/
private static boolean inputOperandsAreLiteralRegister(final ReilInstruction instruction) {
final OperandType firstOperandType = instruction.getFirstOperand().getType();
final OperandType secondOperandType = instruction.getSecondOperand().getType();
return (firstOperandType == OperandType.INTEGER_LITERAL) && (secondOperandType == OperandType.REGISTER);
}
use of com.google.security.zynamics.reil.OperandType in project binnavi by google.
the class BaseTransformer method inputOperandsAreRegisterLiteral.
/**
* Determines whether the two input operands of an instruction are a register (first operand) and
* a literal (second operand).
*
* @param instruction The instruction whose input operands are checked.
*
* @return True, if the first operand is a register and the second operand is a literal. False,
* otherwise.
*/
protected static boolean inputOperandsAreRegisterLiteral(final ReilInstruction instruction) {
final OperandType firstOperandType = instruction.getFirstOperand().getType();
final OperandType secondOperandType = instruction.getSecondOperand().getType();
return (firstOperandType == OperandType.REGISTER) && (secondOperandType == OperandType.INTEGER_LITERAL);
}
Aggregations