Search in sources :

Example 21 with IOperandTreeNode

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

the class ARMLdrhtTranslator method translateCore.

@Override
protected void translateCore(final ITranslationEnvironment environment, final IInstruction instruction, final List<ReilInstruction> instructions) throws InternalTranslationException {
    final IOperandTreeNode registerOperand1 = instruction.getOperands().get(0).getRootNode().getChildren().get(0);
    final IOperandTreeNode rootNode = instruction.getOperands().get(1).getRootNode();
    final String registerNodeValue = (registerOperand1.getValue());
    final OperandSize wd = OperandSize.WORD;
    final OperandSize dw = OperandSize.DWORD;
    long baseOffset = (instruction.getAddress().toLong() * 0x100) + instructions.size();
    final Pair<String, String> resultPair = AddressingModeTwoGenerator.generate(baseOffset, environment, instruction, instructions, rootNode);
    final String tmpAddress = resultPair.first();
    instructions.add(ReilHelpers.createLdm(baseOffset++, dw, tmpAddress, wd, registerNodeValue));
}
Also used : IOperandTreeNode(com.google.security.zynamics.zylib.disassembly.IOperandTreeNode) OperandSize(com.google.security.zynamics.reil.OperandSize)

Example 22 with IOperandTreeNode

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

the class ARMLdrsbTranslator method translateCore.

@Override
protected void translateCore(final ITranslationEnvironment environment, final IInstruction instruction, final List<ReilInstruction> instructions) throws InternalTranslationException {
    final IOperandTreeNode registerOperand1 = instruction.getOperands().get(0).getRootNode().getChildren().get(0);
    final IOperandTreeNode rootNode = instruction.getOperands().get(1).getRootNode();
    final String registerNodeValue = (registerOperand1.getValue());
    final OperandSize bt = OperandSize.BYTE;
    final OperandSize dw = OperandSize.DWORD;
    long baseOffset = (instruction.getAddress().toLong() * 0x100) + instructions.size();
    final String tmpVal1 = environment.getNextVariableString();
    final Pair<String, String> resultPair = AddressingModeTwoGenerator.generate(baseOffset, environment, instruction, instructions, rootNode);
    final String tmpAddress = resultPair.first();
    baseOffset = (instruction.getAddress().toLong() * 0x100) + instructions.size();
    instructions.add(ReilHelpers.createLdm(baseOffset++, dw, tmpAddress, bt, tmpVal1));
    Helpers.signExtend(baseOffset, environment, instruction, instructions, bt, tmpVal1, dw, registerNodeValue, 8);
}
Also used : IOperandTreeNode(com.google.security.zynamics.zylib.disassembly.IOperandTreeNode) OperandSize(com.google.security.zynamics.reil.OperandSize)

Example 23 with IOperandTreeNode

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

the class ARMLdrshTranslator method translateCore.

@Override
protected void translateCore(final ITranslationEnvironment environment, final IInstruction instruction, final List<ReilInstruction> instructions) throws InternalTranslationException {
    final IOperandTreeNode registerOperand1 = instruction.getOperands().get(0).getRootNode().getChildren().get(0);
    final IOperandTreeNode rootNode = instruction.getOperands().get(1).getRootNode();
    final String registerNodeValue = (registerOperand1.getValue());
    final OperandSize wd = OperandSize.WORD;
    final OperandSize dw = OperandSize.DWORD;
    long baseOffset = ReilHelpers.nextReilAddress(instruction, instructions);
    final String tmpVal1 = environment.getNextVariableString();
    final Pair<String, String> resultPair = AddressingModeTwoGenerator.generate(baseOffset, environment, instruction, instructions, rootNode);
    final String tmpAddress = resultPair.first();
    baseOffset = ReilHelpers.nextReilAddress(instruction, instructions);
    instructions.add(ReilHelpers.createLdm(baseOffset++, dw, tmpAddress, wd, tmpVal1));
    Helpers.signExtend(baseOffset, environment, instruction, instructions, wd, tmpVal1, dw, registerNodeValue, 16);
}
Also used : IOperandTreeNode(com.google.security.zynamics.zylib.disassembly.IOperandTreeNode) OperandSize(com.google.security.zynamics.reil.OperandSize)

Example 24 with IOperandTreeNode

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

the class ARMLdrtTranslator method translateCore.

@Override
protected void translateCore(final ITranslationEnvironment environment, final IInstruction instruction, final List<ReilInstruction> instructions) throws InternalTranslationException {
    final IOperandTreeNode registerOperand1 = instruction.getOperands().get(0).getRootNode().getChildren().get(0);
    final IOperandTreeNode rootNode = instruction.getOperands().get(1).getRootNode();
    final String registerNodeValue = (registerOperand1.getValue());
    final OperandSize wd = OperandSize.WORD;
    final OperandSize dw = OperandSize.DWORD;
    final OperandSize bt = OperandSize.BYTE;
    long baseOffset = ReilHelpers.nextReilAddress(instruction, instructions);
    final Pair<String, String> resultPair = AddressingModeTwoGenerator.generate(baseOffset, environment, instruction, instructions, rootNode);
    final String tmpAddress = resultPair.first();
    final String negRotateVal = environment.getNextVariableString();
    final String posRotateVal = environment.getNextVariableString();
    final String rotateVal1 = environment.getNextVariableString();
    final String rotateVal2 = environment.getNextVariableString();
    final String rotResult1 = environment.getNextVariableString();
    final String rotResult2 = environment.getNextVariableString();
    final String tmpData1 = environment.getNextVariableString();
    final String tmpRotResult = environment.getNextVariableString();
    baseOffset = baseOffset + instructions.size();
    instructions.add(ReilHelpers.createLdm(baseOffset++, dw, tmpAddress, dw, tmpData1));
    // get rotate * 8
    instructions.add(ReilHelpers.createAnd(baseOffset++, dw, tmpAddress, bt, String.valueOf(0x3L), bt, rotateVal1));
    instructions.add(ReilHelpers.createMul(baseOffset++, bt, rotateVal1, bt, String.valueOf(8), wd, rotateVal2));
    // subtraction to get the negative shift val
    instructions.add(ReilHelpers.createSub(baseOffset++, wd, String.valueOf(0), wd, rotateVal2, dw, negRotateVal));
    instructions.add(ReilHelpers.createSub(baseOffset++, wd, String.valueOf(32), wd, rotateVal2, dw, posRotateVal));
    // do the rotation
    instructions.add(ReilHelpers.createBsh(baseOffset++, dw, tmpData1, dw, negRotateVal, dw, rotResult1));
    instructions.add(ReilHelpers.createBsh(baseOffset++, dw, tmpData1, dw, posRotateVal, dw, rotResult2));
    instructions.add(ReilHelpers.createOr(baseOffset++, dw, rotResult1, dw, rotResult2, dw, tmpRotResult));
    // assing it
    instructions.add(ReilHelpers.createAnd(baseOffset++, dw, tmpRotResult, dw, String.valueOf(0xFFFFFFFFL), dw, registerNodeValue));
}
Also used : IOperandTreeNode(com.google.security.zynamics.zylib.disassembly.IOperandTreeNode) OperandSize(com.google.security.zynamics.reil.OperandSize)

Example 25 with IOperandTreeNode

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

the class ARMQadd8Translator 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 = ReilHelpers.nextReilAddress(instruction, instructions);
    final String addOperation = "ADD";
    new Processor() {

        @Override
        protected String[] process(final long offset, final String[] firstFour, final String[] secondFour) {
            final String sum1 = environment.getNextVariableString();
            final String sum2 = environment.getNextVariableString();
            final String sum3 = environment.getNextVariableString();
            final String sum4 = environment.getNextVariableString();
            final String trueSum1 = environment.getNextVariableString();
            final String trueSum2 = environment.getNextVariableString();
            final String trueSum3 = environment.getNextVariableString();
            final String trueSum4 = environment.getNextVariableString();
            long baseOffset = offset;
            // do the adds
            instructions.add(ReilHelpers.createAdd(baseOffset++, dw, firstFour[0], dw, secondFour[0], dw, trueSum1));
            instructions.add(ReilHelpers.createAdd(baseOffset++, dw, firstFour[1], dw, secondFour[1], dw, trueSum2));
            instructions.add(ReilHelpers.createAdd(baseOffset++, dw, firstFour[2], dw, secondFour[2], dw, trueSum3));
            instructions.add(ReilHelpers.createAdd(baseOffset++, dw, firstFour[3], dw, secondFour[3], dw, trueSum4));
            // do the sats
            Helpers.signedSat(baseOffset, environment, instruction, instructions, dw, firstFour[0], dw, secondFour[0], dw, trueSum1, addOperation, sum1, 8, "");
            baseOffset = ReilHelpers.nextReilAddress(instruction, instructions);
            Helpers.signedSat(baseOffset, environment, instruction, instructions, dw, firstFour[1], dw, secondFour[1], dw, trueSum2, addOperation, sum2, 8, "");
            baseOffset = ReilHelpers.nextReilAddress(instruction, instructions);
            Helpers.signedSat(baseOffset, environment, instruction, instructions, dw, firstFour[2], dw, secondFour[2], dw, trueSum3, addOperation, sum3, 8, "");
            baseOffset = ReilHelpers.nextReilAddress(instruction, instructions);
            Helpers.signedSat(baseOffset, environment, instruction, instructions, dw, firstFour[3], dw, secondFour[3], dw, trueSum4, addOperation, sum4, 8, "");
            baseOffset = ReilHelpers.nextReilAddress(instruction, instructions);
            return new String[] { sum1, sum2, sum3, sum4 };
        }
    }.generate(environment, baseOffset, 8, sourceRegister1, sourceRegister2, targetRegister, instructions);
}
Also used : IOperandTreeNode(com.google.security.zynamics.zylib.disassembly.IOperandTreeNode)

Aggregations

IOperandTreeNode (com.google.security.zynamics.zylib.disassembly.IOperandTreeNode)518 OperandSize (com.google.security.zynamics.reil.OperandSize)257 BigInteger (java.math.BigInteger)5 INaviFunction (com.google.security.zynamics.binnavi.disassembly.INaviFunction)3 InternalTranslationException (com.google.security.zynamics.reil.translators.InternalTranslationException)2 IAddress (com.google.security.zynamics.zylib.disassembly.IAddress)2 IReference (com.google.security.zynamics.zylib.disassembly.IReference)2 INaviInstruction (com.google.security.zynamics.binnavi.disassembly.INaviInstruction)1 INaviModule (com.google.security.zynamics.binnavi.disassembly.INaviModule)1 ExpensiveBaseTest (com.google.security.zynamics.binnavi.disassembly.types.ExpensiveBaseTest)1 INaviView (com.google.security.zynamics.binnavi.disassembly.views.INaviView)1 ReilOperandNode (com.google.security.zynamics.reil.ReilOperandNode)1 TranslationResult (com.google.security.zynamics.reil.translators.TranslationResult)1 IInstruction (com.google.security.zynamics.zylib.disassembly.IInstruction)1 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1