Search in sources :

Example 91 with IOperandTreeNode

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

the class ARMUxtabTranslator 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 registerOperand2 = instruction.getOperands().get(1).getRootNode().getChildren().get(0);
    final IOperandTreeNode shifter = instruction.getOperands().get(2).getRootNode();
    final String targetRegister = (registerOperand1.getValue());
    final String sourceRegister = (registerOperand2.getValue());
    final OperandSize dw = OperandSize.DWORD;
    long baseOffset = (instruction.getAddress().toLong() * 0x100) + instructions.size();
    final String operand2 = environment.getNextVariableString();
    final Pair<String, String> shifterPair = AddressingModeOneGenerator.generate(baseOffset, environment, instruction, instructions, shifter);
    baseOffset = (instruction.getAddress().toLong() * 0x100) + instructions.size();
    final String shifterOperand = shifterPair.first();
    instructions.add(ReilHelpers.createAnd(baseOffset++, dw, shifterOperand, dw, String.valueOf(0x000000FFL), dw, operand2));
    instructions.add(ReilHelpers.createAdd(baseOffset++, dw, sourceRegister, dw, operand2, dw, targetRegister));
}
Also used : IOperandTreeNode(com.google.security.zynamics.zylib.disassembly.IOperandTreeNode) OperandSize(com.google.security.zynamics.reil.OperandSize)

Example 92 with IOperandTreeNode

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

the class ARMUxtahTranslator 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 registerOperand2 = instruction.getOperands().get(1).getRootNode().getChildren().get(0);
    final IOperandTreeNode shifter = instruction.getOperands().get(2).getRootNode();
    final String targetRegister = (registerOperand1.getValue());
    final String sourceRegister = (registerOperand2.getValue());
    final OperandSize dw = OperandSize.DWORD;
    long baseOffset = (instruction.getAddress().toLong() * 0x100) + instructions.size();
    final String operand2 = environment.getNextVariableString();
    final Pair<String, String> shifterPair = AddressingModeOneGenerator.generate(baseOffset, environment, instruction, instructions, shifter);
    baseOffset = (instruction.getAddress().toLong() * 0x100) + instructions.size();
    final String shifterOperand = shifterPair.first();
    instructions.add(ReilHelpers.createAnd(baseOffset++, dw, shifterOperand, dw, String.valueOf(0x0000FFFFL), dw, operand2));
    instructions.add(ReilHelpers.createAdd(baseOffset++, dw, sourceRegister, dw, operand2, dw, targetRegister));
}
Also used : IOperandTreeNode(com.google.security.zynamics.zylib.disassembly.IOperandTreeNode) OperandSize(com.google.security.zynamics.reil.OperandSize)

Example 93 with IOperandTreeNode

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

the class ARMUxtb16Translator 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 shifter = instruction.getOperands().get(1).getRootNode();
    final String targetRegister = (registerOperand1.getValue());
    final OperandSize dw = OperandSize.DWORD;
    long baseOffset = (instruction.getAddress().toLong() * 0x100) + instructions.size();
    final Pair<String, String> shifterPair = AddressingModeOneGenerator.generate(baseOffset, environment, instruction, instructions, shifter);
    baseOffset = (instruction.getAddress().toLong() * 0x100) + instructions.size();
    final String shifterOperand = shifterPair.first();
    instructions.add(ReilHelpers.createAnd(baseOffset++, dw, shifterOperand, dw, String.valueOf(0x00FF00FFL), dw, targetRegister));
}
Also used : IOperandTreeNode(com.google.security.zynamics.zylib.disassembly.IOperandTreeNode) OperandSize(com.google.security.zynamics.reil.OperandSize)

Example 94 with IOperandTreeNode

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

the class ARMStmTranslator method translateCore.

/**
   * STM{<cond>}<addressing_mode> <Rn>{!}, <registers
   */
@Override
protected void translateCore(final ITranslationEnvironment environment, final IInstruction instruction, final List<ReilInstruction> instructions) throws InternalTranslationException {
    String typeValue = "";
    if (instruction.getMnemonic().endsWith(".W")) {
        typeValue = instruction.getMnemonic().length() == 9 ? instruction.getMnemonic().substring(5, 7) : instruction.getMnemonic().substring(3, 5);
    } else {
        typeValue = instruction.getMnemonic().length() == 7 ? instruction.getMnemonic().substring(5) : instruction.getMnemonic().substring(3);
    }
    IOperandTreeNode registerOperand1;
    String wBit = "1";
    if (instruction.getOperands().get(0).getRootNode().getChildren().get(0).getChildren().size() == 1) {
        wBit = "2";
        registerOperand1 = instruction.getOperands().get(0).getRootNode().getChildren().get(0).getChildren().get(0);
    } else {
        registerOperand1 = instruction.getOperands().get(0).getRootNode().getChildren().get(0);
    }
    final IOperandTreeNode rootNodeOfRegisterList = instruction.getOperands().get(1).getRootNode().getChildren().get(0);
    final String registerNodeValue = (registerOperand1.getValue());
    final int registerListLength = rootNodeOfRegisterList.getChildren().size();
    final OperandSize bt = OperandSize.BYTE;
    final OperandSize dw = OperandSize.DWORD;
    long baseOffset = ReilHelpers.nextReilAddress(instruction, instructions);
    String tmpAddress = AddressingModeFourGenerator.generate(baseOffset, environment, instruction, instructions, typeValue, registerNodeValue, wBit, rootNodeOfRegisterList);
    baseOffset = ReilHelpers.nextReilAddress(instruction, instructions);
    for (int i = 0; i < registerListLength; i++) {
        // STM Ri, addi
        // ADD addi, 4, addi+1
        final String nextAddress = environment.getNextVariableString();
        instructions.add(ReilHelpers.createStm(baseOffset++, dw, (rootNodeOfRegisterList.getChildren().get(i).getValue()), dw, tmpAddress));
        instructions.add(ReilHelpers.createAdd(baseOffset++, dw, tmpAddress, bt, String.valueOf(4L), dw, nextAddress));
        tmpAddress = nextAddress;
    }
}
Also used : IOperandTreeNode(com.google.security.zynamics.zylib.disassembly.IOperandTreeNode) OperandSize(com.google.security.zynamics.reil.OperandSize)

Example 95 with IOperandTreeNode

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

the class ARMStrdTranslator method translateCore.

@Override
protected void translateCore(final ITranslationEnvironment environment, final IInstruction instruction, final List<ReilInstruction> instructions) throws InternalTranslationException {
    final Boolean writeBack = instruction.getOperands().get(0).getRootNode().getChildren().get(0).getChildren().size() == 1 ? true : false;
    final IOperandTreeNode registerOperand1 = instruction.getOperands().get(0).getRootNode().getChildren().get(0).getChildren().size() == 1 ? instruction.getOperands().get(0).getRootNode().getChildren().get(0).getChildren().get(0) : 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 = ReilHelpers.nextReilAddress(instruction, instructions);
    final Pair<String, String> resultPair = AddressingModeTwoGenerator.generate(baseOffset, environment, instruction, instructions, rootNode);
    final String tmpAddress = resultPair.first();
    final String tmpAddress2 = environment.getNextVariableString();
    final int registerNum = Helpers.getRegisterIndex(registerNodeValue);
    baseOffset = ReilHelpers.nextReilAddress(instruction, instructions);
    if (((registerNum % 2) == 0) && (registerNum != 14)) {
        instructions.add(ReilHelpers.createStm(baseOffset++, dw, registerNodeValue, dw, tmpAddress));
        instructions.add(ReilHelpers.createAdd(baseOffset++, dw, tmpAddress, bt, String.valueOf(4), dw, tmpAddress2));
        instructions.add(ReilHelpers.createStm(baseOffset++, dw, "R" + String.valueOf(registerNum + 1), dw, tmpAddress2));
        if (writeBack) {
            instructions.add(ReilHelpers.createStr(baseOffset++, dw, tmpAddress2, dw, registerNodeValue));
        }
    } else {
        instructions.add(ReilHelpers.createUnknown(baseOffset++));
    }
}
Also used : IOperandTreeNode(com.google.security.zynamics.zylib.disassembly.IOperandTreeNode) OperandSize(com.google.security.zynamics.reil.OperandSize)

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