Search in sources :

Example 1 with ITranslationExtension

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

the class ReilTranslator method translateInstruction.

// ! Translates an instruction to REIL code.
/**
   * Translates a single instruction to REIL code.
   *
   * @param architecture The source architecture of the instruction.
   * @param instruction The instruction to translate.
   *
   * @return The generated REIL code for that instruction.
   *
   * @throws InternalTranslationException Thrown if something goes wrong during translation.
   */
public static List<ReilInstruction> translateInstruction(final NativeArchitecture architecture, final Instruction instruction) throws InternalTranslationException {
    Preconditions.checkNotNull(architecture, "Error: Architecture argument can not be null");
    Preconditions.checkNotNull(instruction, "Error: Instruction argument can't be null");
    final List<ReilInstruction> instructions = new ArrayList<ReilInstruction>();
    final StandardEnvironment environment = new StandardEnvironment();
    try {
        for (final com.google.security.zynamics.reil.ReilInstruction reilInstruction : getTranslator(architecture).translate(environment, instruction.getNative(), new ArrayList<ITranslationExtension<INaviInstruction>>())) {
            instructions.add(new ReilInstruction(reilInstruction));
        }
        return instructions;
    } catch (final com.google.security.zynamics.reil.translators.InternalTranslationException e) {
        throw new InternalTranslationException(e, instruction);
    }
}
Also used : ArrayList(java.util.ArrayList) ITranslationExtension(com.google.security.zynamics.reil.translators.ITranslationExtension) StandardEnvironment(com.google.security.zynamics.reil.translators.StandardEnvironment)

Aggregations

ITranslationExtension (com.google.security.zynamics.reil.translators.ITranslationExtension)1 StandardEnvironment (com.google.security.zynamics.reil.translators.StandardEnvironment)1 ArrayList (java.util.ArrayList)1