Search in sources :

Example 11 with ReilOperand

use of com.google.security.zynamics.reil.ReilOperand in project binnavi by google.

the class RegisterTrackingTransformationProvider method transformStm.

@Override
protected Pair<RegisterSetLatticeElement, RegisterSetLatticeElement> transformStm(final ReilInstruction ins, final RegisterSetLatticeElement state) {
    final ReilOperand op1 = ins.getFirstOperand();
    if (op1.getType().equals(OperandType.REGISTER)) {
        if (state.isTainted(op1.getValue())) {
            final RegisterSetLatticeElement newState = state.copy();
            newState.addReadReg(op1.getValue());
            return new Pair<RegisterSetLatticeElement, RegisterSetLatticeElement>(newState, null);
        }
    }
    return new Pair<RegisterSetLatticeElement, RegisterSetLatticeElement>(state, null);
}
Also used : ReilOperand(com.google.security.zynamics.reil.ReilOperand) Pair(com.google.security.zynamics.zylib.general.Pair)

Example 12 with ReilOperand

use of com.google.security.zynamics.reil.ReilOperand in project binnavi by google.

the class BaseTransformer method transformLiterals.

/**
   * Transforms MNEM L1, L2, R1 to (R1 => CALC(L1, L2))
   * 
   * @param instruction The instruction in question.
   * @param incomingState The incoming state from the parents of the instruction.
   * @param generator Combines the input operand values of the instruction.
   * 
   * @return The new state of the graph node that represents the instruction.
   */
protected static ValueTrackerElement transformLiterals(final ReilInstruction instruction, final ValueTrackerElement incomingState, final IElementGenerator generator) {
    // The easiest case is handling the combination of two integer literals.
    // The result of this combination is obviously another literal.
    final ReilOperand firstOperand = instruction.getFirstOperand();
    final ReilOperand secondOperand = instruction.getSecondOperand();
    final String thirdOperand = instruction.getThirdOperand().getValue();
    // Now we can update the state of the registers after this instruction is executed.
    // The register in the output operand is updated while the values of all other
    // registers are taken from the incoming state.
    final Register resultAloc = new Register(thirdOperand);
    final IValueElement alocValue = generator.generate(getAtomicType(firstOperand), getAtomicType(secondOperand));
    assert alocValue instanceof Literal : "The combination of two literals was not a literal";
    return incomingState.update(instruction, resultAloc, alocValue);
}
Also used : IValueElement(com.google.security.zynamics.reil.algorithms.mono.valuetracking.elements.IValueElement) Register(com.google.security.zynamics.reil.algorithms.mono.valuetracking.elements.Register) Literal(com.google.security.zynamics.reil.algorithms.mono.valuetracking.elements.Literal) ReilOperand(com.google.security.zynamics.reil.ReilOperand)

Example 13 with ReilOperand

use of com.google.security.zynamics.reil.ReilOperand in project binnavi by google.

the class StrTransformer method transform.

public static ValueTrackerElement transform(final ReilInstruction instruction, final ValueTrackerElement incomingState) {
    // STR x, , y
    final ReilOperand inputOperand = instruction.getFirstOperand();
    final ReilOperand outputOperand = instruction.getThirdOperand();
    final Register outputRegister = new Register(outputOperand.getValue());
    final IValueElement previousState = getOperandValue(inputOperand, incomingState);
    if (previousState == null) {
        final IValueElement inputValue = getAtomicType(inputOperand);
        return incomingState.update(instruction, outputRegister, inputValue);
    } else {
        return incomingState.update(instruction, outputRegister, previousState.clone());
    }
}
Also used : IValueElement(com.google.security.zynamics.reil.algorithms.mono.valuetracking.elements.IValueElement) Register(com.google.security.zynamics.reil.algorithms.mono.valuetracking.elements.Register) ReilOperand(com.google.security.zynamics.reil.ReilOperand)

Aggregations

ReilOperand (com.google.security.zynamics.reil.ReilOperand)13 IValueElement (com.google.security.zynamics.reil.algorithms.mono.valuetracking.elements.IValueElement)8 Register (com.google.security.zynamics.reil.algorithms.mono.valuetracking.elements.Register)7 Undefined (com.google.security.zynamics.reil.algorithms.mono.valuetracking.elements.Undefined)3 Pair (com.google.security.zynamics.zylib.general.Pair)3 ReilInstruction (com.google.security.zynamics.reil.ReilInstruction)2 BitwiseAnd (com.google.security.zynamics.reil.algorithms.mono.valuetracking.elements.BitwiseAnd)2 Literal (com.google.security.zynamics.reil.algorithms.mono.valuetracking.elements.Literal)2 MemoryCell (com.google.security.zynamics.reil.algorithms.mono.valuetracking.elements.MemoryCell)2 TreeSet (java.util.TreeSet)2 OperandSize (com.google.security.zynamics.reil.OperandSize)1 OperandType (com.google.security.zynamics.reil.OperandType)1 ReilOperandNode (com.google.security.zynamics.reil.ReilOperandNode)1 Dereference (com.google.security.zynamics.reil.algorithms.mono.valuetracking.elements.Dereference)1 InternalTranslationException (com.google.security.zynamics.reil.translators.InternalTranslationException)1 TranslationResult (com.google.security.zynamics.reil.translators.TranslationResult)1 IAddress (com.google.security.zynamics.zylib.disassembly.IAddress)1 IOperandTree (com.google.security.zynamics.zylib.disassembly.IOperandTree)1 BigInteger (java.math.BigInteger)1 ArrayList (java.util.ArrayList)1