Search in sources :

Example 6 with IOperandTree

use of com.google.security.zynamics.zylib.disassembly.IOperandTree in project binnavi by google.

the class OrTranslator method translate.

@Override
public void translate(final ITranslationEnvironment environment, final IInstruction instruction, final List<ReilInstruction> instructions) throws InternalTranslationException {
    TranslationHelpers.checkTranslationArguments(environment, instruction, instructions, "or");
    final Triple<IOperandTree, IOperandTree, IOperandTree> operands = OperandLoader.loadDuplicateFirst(instruction);
    final String targetRegister = operands.first().getRootNode().getChildren().get(0).getValue();
    final String sourceRegister1 = operands.second().getRootNode().getChildren().get(0).getValue();
    final String sourceRegister2 = operands.third().getRootNode().getChildren().get(0).getValue();
    final OperandSize dw = OperandSize.DWORD;
    final long baseOffset = ReilHelpers.toReilAddress(instruction.getAddress()).toLong();
    final long offset = baseOffset;
    instructions.add(ReilHelpers.createOr(offset, dw, sourceRegister1, dw, sourceRegister2, dw, targetRegister));
}
Also used : IOperandTree(com.google.security.zynamics.zylib.disassembly.IOperandTree) OperandSize(com.google.security.zynamics.reil.OperandSize)

Example 7 with IOperandTree

use of com.google.security.zynamics.zylib.disassembly.IOperandTree in project binnavi by google.

the class RotrTranslator method translate.

@Override
public void translate(final ITranslationEnvironment environment, final IInstruction instruction, final List<ReilInstruction> instructions) throws InternalTranslationException {
    TranslationHelpers.checkTranslationArguments(environment, instruction, instructions, "rotr");
    final Triple<IOperandTree, IOperandTree, IOperandTree> operands = OperandLoader.loadDuplicateFirst(instruction);
    final String rd = operands.first().getRootNode().getChildren().get(0).getValue();
    final String rt = operands.second().getRootNode().getChildren().get(0).getValue();
    final String sa = operands.third().getRootNode().getChildren().get(0).getValue();
    final OperandSize dw = OperandSize.DWORD;
    final String lowRotateBits = environment.getNextVariableString();
    final String highRotateBits = environment.getNextVariableString();
    final String temporaryRotateResult = environment.getNextVariableString();
    final long baseOffset = ReilHelpers.toReilAddress(instruction.getAddress()).toLong();
    long offset = baseOffset;
    instructions.add(ReilHelpers.createBsh(offset++, dw, rt, dw, "-" + Integer.decode(sa), dw, lowRotateBits));
    instructions.add(ReilHelpers.createBsh(offset++, dw, rt, dw, String.valueOf(32 - Integer.decode(sa)), dw, highRotateBits));
    instructions.add(ReilHelpers.createOr(offset++, dw, lowRotateBits, dw, highRotateBits, dw, temporaryRotateResult));
    instructions.add(ReilHelpers.createAnd(offset++, dw, temporaryRotateResult, dw, String.valueOf(0xFFFFFFFFL), dw, rd));
}
Also used : IOperandTree(com.google.security.zynamics.zylib.disassembly.IOperandTree) OperandSize(com.google.security.zynamics.reil.OperandSize)

Example 8 with IOperandTree

use of com.google.security.zynamics.zylib.disassembly.IOperandTree in project binnavi by google.

the class RotrvTranslator method translate.

@Override
public void translate(final ITranslationEnvironment environment, final IInstruction instruction, final List<ReilInstruction> instructions) throws InternalTranslationException {
    TranslationHelpers.checkTranslationArguments(environment, instruction, instructions, "rotrv");
    final Triple<IOperandTree, IOperandTree, IOperandTree> operands = OperandLoader.loadDuplicateFirst(instruction);
    final String rd = operands.first().getRootNode().getChildren().get(0).getValue();
    final String rt = operands.second().getRootNode().getChildren().get(0).getValue();
    final String rs = operands.third().getRootNode().getChildren().get(0).getValue();
    final OperandSize dw = OperandSize.DWORD;
    final String lowShiftRegisterBits = environment.getNextVariableString();
    final String lowRotateBits = environment.getNextVariableString();
    final String highRotateBits = environment.getNextVariableString();
    final String temporaryRotateResult = environment.getNextVariableString();
    final String negativeRt = environment.getNextVariableString();
    final String negativeShiftValue = environment.getNextVariableString();
    final long baseOffset = ReilHelpers.toReilAddress(instruction.getAddress()).toLong();
    long offset = baseOffset;
    instructions.add(ReilHelpers.createAnd(offset++, dw, rs, dw, String.valueOf(0x1FL), dw, lowShiftRegisterBits));
    instructions.add(ReilHelpers.createSub(offset++, dw, String.valueOf(0L), dw, rs, dw, negativeRt));
    instructions.add(ReilHelpers.createSub(offset++, dw, String.valueOf(32L), dw, rs, dw, negativeShiftValue));
    instructions.add(ReilHelpers.createBsh(offset++, dw, rt, dw, negativeRt, dw, lowRotateBits));
    instructions.add(ReilHelpers.createBsh(offset++, dw, rt, dw, negativeShiftValue, dw, highRotateBits));
    instructions.add(ReilHelpers.createOr(offset++, dw, lowRotateBits, dw, highRotateBits, dw, temporaryRotateResult));
    instructions.add(ReilHelpers.createAnd(offset++, dw, temporaryRotateResult, dw, String.valueOf(0xFFFFFFFFL), dw, rd));
}
Also used : IOperandTree(com.google.security.zynamics.zylib.disassembly.IOperandTree) OperandSize(com.google.security.zynamics.reil.OperandSize)

Example 9 with IOperandTree

use of com.google.security.zynamics.zylib.disassembly.IOperandTree in project binnavi by google.

the class SraTranslator method translate.

@Override
public void translate(final ITranslationEnvironment environment, final IInstruction instruction, final List<ReilInstruction> instructions) throws InternalTranslationException {
    TranslationHelpers.checkTranslationArguments(environment, instruction, instructions, "sra");
    final Triple<IOperandTree, IOperandTree, IOperandTree> operands = OperandLoader.loadDuplicateFirst(instruction);
    final String rd = operands.first().getRootNode().getChildren().get(0).getValue();
    final String rt = operands.second().getRootNode().getChildren().get(0).getValue();
    final String sa = operands.third().getRootNode().getChildren().get(0).getValue();
    final OperandSize dw = OperandSize.DWORD;
    final OperandSize qw = OperandSize.QWORD;
    final long baseOffset = ReilHelpers.toReilAddress(instruction.getAddress()).toLong();
    long offset = baseOffset;
    final String tempOperand1 = environment.getNextVariableString();
    final String tempOperand2 = environment.getNextVariableString();
    final String tempOperand3 = environment.getNextVariableString();
    final String tempOperand4 = environment.getNextVariableString();
    instructions.add(ReilHelpers.createBsh(offset++, dw, String.valueOf(0x80000000L), dw, "-" + sa, dw, tempOperand1));
    instructions.add(ReilHelpers.createBsh(offset++, dw, rt, dw, "-" + sa, dw, tempOperand2));
    instructions.add(ReilHelpers.createXor(offset++, dw, tempOperand1, dw, tempOperand2, dw, tempOperand3));
    instructions.add(ReilHelpers.createSub(offset++, dw, tempOperand3, dw, tempOperand1, qw, tempOperand4));
    instructions.add(ReilHelpers.createAnd(offset, qw, tempOperand4, dw, String.valueOf(0xFFFFFFFFL), dw, rd));
}
Also used : IOperandTree(com.google.security.zynamics.zylib.disassembly.IOperandTree) OperandSize(com.google.security.zynamics.reil.OperandSize)

Example 10 with IOperandTree

use of com.google.security.zynamics.zylib.disassembly.IOperandTree in project binnavi by google.

the class SllvTranslator method translate.

@Override
public void translate(final ITranslationEnvironment environment, final IInstruction instruction, final List<ReilInstruction> instructions) throws InternalTranslationException {
    TranslationHelpers.checkTranslationArguments(environment, instruction, instructions, "sllv");
    final Triple<IOperandTree, IOperandTree, IOperandTree> operands = OperandLoader.loadDuplicateFirst(instruction);
    final String rd = operands.first().getRootNode().getChildren().get(0).getValue();
    final String rt = operands.second().getRootNode().getChildren().get(0).getValue();
    final String rs = operands.third().getRootNode().getChildren().get(0).getValue();
    final OperandSize dw = OperandSize.DWORD;
    final OperandSize qw = OperandSize.QWORD;
    final String lowFiveShiftBits = environment.getNextVariableString();
    final String temporaryShiftResult = environment.getNextVariableString();
    final long baseOffset = ReilHelpers.toReilAddress(instruction.getAddress()).toLong();
    long offset = baseOffset;
    instructions.add(ReilHelpers.createAnd(offset++, dw, rs, dw, String.valueOf(0x1FL), dw, lowFiveShiftBits));
    instructions.add(ReilHelpers.createBsh(offset++, dw, rt, dw, lowFiveShiftBits, qw, temporaryShiftResult));
    instructions.add(ReilHelpers.createAnd(offset, qw, temporaryShiftResult, dw, String.valueOf(0xFFFFFFFFL), dw, rd));
}
Also used : IOperandTree(com.google.security.zynamics.zylib.disassembly.IOperandTree) OperandSize(com.google.security.zynamics.reil.OperandSize)

Aggregations

IOperandTree (com.google.security.zynamics.zylib.disassembly.IOperandTree)60 OperandSize (com.google.security.zynamics.reil.OperandSize)53 TranslationResult (com.google.security.zynamics.reil.translators.TranslationResult)39 InternalTranslationException (com.google.security.zynamics.reil.translators.InternalTranslationException)35 ReilInstruction (com.google.security.zynamics.reil.ReilInstruction)2 TranslationResultType (com.google.security.zynamics.reil.translators.TranslationResultType)2 OperandType (com.google.security.zynamics.reil.OperandType)1 ReilOperand (com.google.security.zynamics.reil.ReilOperand)1 ReilOperandNode (com.google.security.zynamics.reil.ReilOperandNode)1 Triple (com.google.security.zynamics.zylib.general.Triple)1 ArrayList (java.util.ArrayList)1