Search in sources :

Example 71 with OperandSize

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

the class ARMUdivTranslator method translateCore.

@Override
protected void translateCore(final ITranslationEnvironment environment, final IInstruction instruction, final List<ReilInstruction> instructions) {
    final String destination = instruction.getOperands().get(0).getRootNode().getChildren().get(0).getValue();
    final String dividend = instruction.getOperands().get(1).getRootNode().getChildren().get(0).getValue();
    final String divisor = instruction.getOperands().get(2).getRootNode().getChildren().get(0).getValue();
    final OperandSize dw = OperandSize.DWORD;
    final long baseOffset = ReilHelpers.nextReilAddress(instruction, instructions);
    long offset = baseOffset;
    instructions.add(ReilHelpers.createDiv(offset++, dw, dividend, dw, divisor, dw, destination));
}
Also used : OperandSize(com.google.security.zynamics.reil.OperandSize)

Example 72 with OperandSize

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

the class ARMUhadd16Translator method translateCore.

@Override
protected void translateCore(final ITranslationEnvironment environment, final IInstruction instruction, final List<ReilInstruction> instructions) {
    final IOperandTreeNode registerOperand1 = instruction.getOperands().get(0).getRootNode().getChildren().get(0);
    final IOperandTreeNode registerOperand2 = instruction.getOperands().get(1).getRootNode().getChildren().get(0);
    final IOperandTreeNode registerOperand3 = instruction.getOperands().get(2).getRootNode().getChildren().get(0);
    final String targetRegister = (registerOperand1.getValue());
    final String sourceRegister1 = (registerOperand2.getValue());
    final String sourceRegister2 = (registerOperand3.getValue());
    final OperandSize bt = OperandSize.BYTE;
    final OperandSize dw = OperandSize.DWORD;
    long baseOffset = ReilHelpers.nextReilAddress(instruction, instructions);
    final String tmpResult = environment.getNextVariableString();
    final String tmpRm15to0 = environment.getNextVariableString();
    final String tmpRm31to16 = environment.getNextVariableString();
    final String tmpRn15to0 = environment.getNextVariableString();
    final String tmpRn31to16 = environment.getNextVariableString();
    final String tmpVar1 = environment.getNextVariableString();
    final String tmpVar1Safe = environment.getNextVariableString();
    final String tmpVar1SafeShifted = environment.getNextVariableString();
    final String tmpVar3 = environment.getNextVariableString();
    final String tmpVar3Safe = environment.getNextVariableString();
    // Low
    instructions.add(ReilHelpers.createAnd(baseOffset++, dw, sourceRegister1, dw, String.valueOf(0xFFFFL), dw, tmpRn15to0));
    instructions.add(ReilHelpers.createAnd(baseOffset++, dw, sourceRegister2, dw, String.valueOf(0xFFFFL), dw, tmpRm15to0));
    instructions.add(ReilHelpers.createAdd(baseOffset++, dw, tmpRn15to0, dw, tmpRm15to0, dw, tmpVar1));
    instructions.add(ReilHelpers.createAnd(baseOffset++, dw, tmpVar1, dw, String.valueOf(0x1FFFEL), dw, tmpVar1Safe));
    instructions.add(ReilHelpers.createBsh(baseOffset++, dw, tmpVar1Safe, bt, String.valueOf(-1L), dw, tmpVar1SafeShifted));
    // High
    instructions.add(ReilHelpers.createBsh(baseOffset++, dw, sourceRegister1, dw, String.valueOf(-16), dw, tmpRn31to16));
    instructions.add(ReilHelpers.createBsh(baseOffset++, dw, sourceRegister2, dw, String.valueOf(-16), dw, tmpRm31to16));
    instructions.add(ReilHelpers.createAdd(baseOffset++, dw, tmpRn31to16, dw, tmpRm31to16, dw, tmpVar3));
    instructions.add(ReilHelpers.createAnd(baseOffset++, dw, tmpVar3, dw, String.valueOf(0x1FFFEL), dw, tmpVar3Safe));
    instructions.add(ReilHelpers.createBsh(baseOffset++, dw, tmpVar3Safe, dw, String.valueOf(16 - 1), dw, tmpResult));
    // Result
    instructions.add(ReilHelpers.createOr(baseOffset++, dw, tmpResult, dw, tmpVar1SafeShifted, dw, targetRegister));
}
Also used : IOperandTreeNode(com.google.security.zynamics.zylib.disassembly.IOperandTreeNode) OperandSize(com.google.security.zynamics.reil.OperandSize)

Example 73 with OperandSize

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

the class ARMUhsub16Translator method translateCore.

@Override
protected void translateCore(final ITranslationEnvironment environment, final IInstruction instruction, final List<ReilInstruction> instructions) {
    final IOperandTreeNode registerOperand1 = instruction.getOperands().get(0).getRootNode().getChildren().get(0);
    final IOperandTreeNode registerOperand2 = instruction.getOperands().get(1).getRootNode().getChildren().get(0);
    final IOperandTreeNode registerOperand3 = instruction.getOperands().get(2).getRootNode().getChildren().get(0);
    final String targetRegister = (registerOperand1.getValue());
    final String sourceRegister1 = (registerOperand2.getValue());
    final String sourceRegister2 = (registerOperand3.getValue());
    final OperandSize bt = OperandSize.BYTE;
    final OperandSize dw = OperandSize.DWORD;
    long baseOffset = (instruction.getAddress().toLong() * 0x100) + instructions.size();
    final String tmpResult = environment.getNextVariableString();
    final String tmpRm15to0 = environment.getNextVariableString();
    final String tmpRm31to16 = environment.getNextVariableString();
    final String tmpRn15to0 = environment.getNextVariableString();
    final String tmpRn31to16 = environment.getNextVariableString();
    final String tmpVar1 = environment.getNextVariableString();
    final String tmpVar1Safe = environment.getNextVariableString();
    final String tmpVar1SafeShifted = environment.getNextVariableString();
    final String tmpVar3 = environment.getNextVariableString();
    final String tmpVar3Safe = environment.getNextVariableString();
    // Low
    instructions.add(ReilHelpers.createAnd(baseOffset++, dw, sourceRegister1, dw, String.valueOf(0xFFFFL), dw, tmpRn15to0));
    instructions.add(ReilHelpers.createAnd(baseOffset++, dw, sourceRegister2, dw, String.valueOf(0xFFFFL), dw, tmpRm15to0));
    instructions.add(ReilHelpers.createSub(baseOffset++, dw, tmpRn15to0, dw, tmpRm15to0, dw, tmpVar1));
    instructions.add(ReilHelpers.createAnd(baseOffset++, dw, tmpVar1, dw, String.valueOf(0x1FFFEL), dw, tmpVar1Safe));
    instructions.add(ReilHelpers.createBsh(baseOffset++, dw, tmpVar1Safe, bt, String.valueOf(-1L), dw, tmpVar1SafeShifted));
    // High
    instructions.add(ReilHelpers.createBsh(baseOffset++, dw, sourceRegister1, dw, String.valueOf(-16), dw, tmpRn31to16));
    instructions.add(ReilHelpers.createBsh(baseOffset++, dw, sourceRegister2, dw, String.valueOf(-16), dw, tmpRm31to16));
    instructions.add(ReilHelpers.createSub(baseOffset++, dw, tmpRn31to16, dw, tmpRm31to16, dw, tmpVar3));
    instructions.add(ReilHelpers.createAnd(baseOffset++, dw, tmpVar3, dw, String.valueOf(0x1FFFEL), dw, tmpVar3Safe));
    instructions.add(ReilHelpers.createBsh(baseOffset++, dw, tmpVar3Safe, dw, String.valueOf(16 - 1), dw, tmpResult));
    // Result
    instructions.add(ReilHelpers.createOr(baseOffset++, dw, tmpResult, dw, tmpVar1SafeShifted, dw, targetRegister));
}
Also used : IOperandTreeNode(com.google.security.zynamics.zylib.disassembly.IOperandTreeNode) OperandSize(com.google.security.zynamics.reil.OperandSize)

Example 74 with OperandSize

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

the class ARMUhsub8Translator method translateCore.

@Override
protected void translateCore(final ITranslationEnvironment environment, final IInstruction instruction, final List<ReilInstruction> instructions) {
    final IOperandTreeNode registerOperand1 = instruction.getOperands().get(0).getRootNode().getChildren().get(0);
    final IOperandTreeNode registerOperand2 = instruction.getOperands().get(1).getRootNode().getChildren().get(0);
    final IOperandTreeNode registerOperand3 = instruction.getOperands().get(2).getRootNode().getChildren().get(0);
    final String targetRegister = (registerOperand1.getValue());
    final String sourceRegister1 = (registerOperand2.getValue());
    final String sourceRegister2 = (registerOperand3.getValue());
    final OperandSize wd = OperandSize.WORD;
    final long baseOffset = (instruction.getAddress().toLong() * 0x100) + instructions.size();
    new Processor() {

        @Override
        protected int getResultShiftDelta() {
            return -1;
        }

        @Override
        protected String[] process(final long offset, final String[] firstFour, final String[] secondFour) {
            final String diff1 = environment.getNextVariableString();
            final String diff2 = environment.getNextVariableString();
            final String diff3 = environment.getNextVariableString();
            final String diff4 = environment.getNextVariableString();
            long baseOffset = offset;
            instructions.add(ReilHelpers.createSub(baseOffset++, wd, firstFour[0], wd, secondFour[0], dw, diff1));
            instructions.add(ReilHelpers.createSub(baseOffset++, wd, firstFour[1], wd, secondFour[1], dw, diff2));
            instructions.add(ReilHelpers.createSub(baseOffset++, wd, firstFour[2], wd, secondFour[2], dw, diff3));
            instructions.add(ReilHelpers.createSub(baseOffset++, wd, firstFour[3], wd, secondFour[3], dw, diff4));
            return new String[] { diff1, diff2, diff3, diff4 };
        }
    }.generate(environment, baseOffset, 8, sourceRegister1, sourceRegister2, targetRegister, instructions);
}
Also used : IOperandTreeNode(com.google.security.zynamics.zylib.disassembly.IOperandTreeNode) OperandSize(com.google.security.zynamics.reil.OperandSize)

Example 75 with OperandSize

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

the class ARMUhsubaddxTranslator method translateCore.

@Override
protected void translateCore(final ITranslationEnvironment environment, final IInstruction instruction, final List<ReilInstruction> instructions) {
    final IOperandTreeNode registerOperand1 = instruction.getOperands().get(0).getRootNode().getChildren().get(0);
    final IOperandTreeNode registerOperand2 = instruction.getOperands().get(1).getRootNode().getChildren().get(0);
    final IOperandTreeNode registerOperand3 = instruction.getOperands().get(2).getRootNode().getChildren().get(0);
    final String targetRegister = (registerOperand1.getValue());
    final String sourceRegister1 = (registerOperand2.getValue());
    final String sourceRegister2 = (registerOperand3.getValue());
    final long baseOffset = (instruction.getAddress().toLong() * 0x100) + instructions.size();
    new Processor() {

        @Override
        protected int getResultShiftDelta() {
            return -1;
        }

        @Override
        protected String[] process(final long offset, final String[] firstTwo, final String[] secondTwo) {
            final String sum1 = environment.getNextVariableString();
            final String diff1 = environment.getNextVariableString();
            long baseOffset = offset;
            final OperandSize dw = OperandSize.DWORD;
            // do the add
            instructions.add(ReilHelpers.createAdd(baseOffset++, dw, firstTwo[0], dw, secondTwo[1], dw, sum1));
            // do the sub
            instructions.add(ReilHelpers.createSub(baseOffset++, dw, firstTwo[1], dw, secondTwo[0], dw, diff1));
            return new String[] { sum1, diff1 };
        }
    }.generate(environment, baseOffset, 16, sourceRegister1, sourceRegister2, targetRegister, instructions);
}
Also used : IOperandTreeNode(com.google.security.zynamics.zylib.disassembly.IOperandTreeNode) OperandSize(com.google.security.zynamics.reil.OperandSize)

Aggregations

OperandSize (com.google.security.zynamics.reil.OperandSize)442 IOperandTreeNode (com.google.security.zynamics.zylib.disassembly.IOperandTreeNode)257 IOperandTree (com.google.security.zynamics.zylib.disassembly.IOperandTree)53 InternalTranslationException (com.google.security.zynamics.reil.translators.InternalTranslationException)46 TranslationResult (com.google.security.zynamics.reil.translators.TranslationResult)45 ReilInstruction (com.google.security.zynamics.reil.ReilInstruction)16 ArrayList (java.util.ArrayList)15 BigInteger (java.math.BigInteger)12 CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)5 OperandType (com.google.security.zynamics.reil.OperandType)2 ReilOperandNode (com.google.security.zynamics.reil.ReilOperandNode)2 TranslationResultType (com.google.security.zynamics.reil.translators.TranslationResultType)2 ReilBlock (com.google.security.zynamics.reil.ReilBlock)1 ReilEdge (com.google.security.zynamics.reil.ReilEdge)1 ReilGraph (com.google.security.zynamics.reil.ReilGraph)1 ReilOperand (com.google.security.zynamics.reil.ReilOperand)1 Pair (com.google.security.zynamics.zylib.general.Pair)1 EdgeType (com.google.security.zynamics.zylib.gui.zygraph.edges.EdgeType)1 HashMap (java.util.HashMap)1 StringTokenizer (java.util.StringTokenizer)1