Search in sources :

Example 26 with OperandSize

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

the class THUMBCmnTranslator 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 String sourceRegister1 = (registerOperand1.getValue());
    final String sourceRegister2 = (registerOperand2.getValue());
    final OperandSize bt = OperandSize.BYTE;
    final OperandSize dw = OperandSize.DWORD;
    final OperandSize qw = OperandSize.QWORD;
    long baseOffset = (instruction.getAddress().toLong() * 0x100) + instructions.size();
    final String tmpVar1 = environment.getNextVariableString();
    final String tmpVar2 = environment.getNextVariableString();
    final String tmpVar3 = environment.getNextVariableString();
    instructions.add(ReilHelpers.createAdd(baseOffset++, dw, sourceRegister1, dw, sourceRegister2, qw, tmpVar1));
    // N Flag
    instructions.add(ReilHelpers.createBsh(baseOffset++, qw, tmpVar1, dw, String.valueOf(-31L), bt, tmpVar2));
    instructions.add(ReilHelpers.createAnd(baseOffset++, bt, tmpVar2, bt, String.valueOf(1L), bt, "N"));
    // Z Flag
    instructions.add(ReilHelpers.createBisz(baseOffset++, qw, tmpVar1, bt, "Z"));
    // C Flag
    instructions.add(ReilHelpers.createBsh(baseOffset++, qw, tmpVar1, dw, String.valueOf(-32L), bt, tmpVar3));
    instructions.add(ReilHelpers.createAnd(baseOffset++, bt, tmpVar3, bt, String.valueOf(1L), bt, "C"));
    Helpers.addOverflow(baseOffset, environment, instructions, dw, sourceRegister1, dw, sourceRegister2, qw, tmpVar1, "V", 32);
}
Also used : IOperandTreeNode(com.google.security.zynamics.zylib.disassembly.IOperandTreeNode) OperandSize(com.google.security.zynamics.reil.OperandSize)

Example 27 with OperandSize

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

the class THUMBCmpTranslator 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 String sourceRegister1 = (registerOperand1.getValue());
    final String sourceRegister2 = (registerOperand2.getValue());
    final OperandSize bt = OperandSize.BYTE;
    final OperandSize dw = OperandSize.DWORD;
    final OperandSize qw = OperandSize.QWORD;
    long baseOffset = (instruction.getAddress().toLong() * 0x100) + instructions.size();
    final String tmpVar1 = environment.getNextVariableString();
    final String tmpVar2 = environment.getNextVariableString();
    final String tmpVar3 = environment.getNextVariableString();
    final String tmpVar4 = environment.getNextVariableString();
    instructions.add(ReilHelpers.createSub(baseOffset++, dw, sourceRegister1, dw, sourceRegister2, qw, tmpVar1));
    // N Flag
    instructions.add(ReilHelpers.createBsh(baseOffset++, qw, tmpVar1, dw, String.valueOf(-31L), bt, tmpVar2));
    instructions.add(ReilHelpers.createAnd(baseOffset++, bt, tmpVar2, bt, String.valueOf(1L), bt, "N"));
    // Z Flag
    instructions.add(ReilHelpers.createBisz(baseOffset++, qw, tmpVar1, bt, "Z"));
    // C Flag
    instructions.add(ReilHelpers.createBsh(baseOffset++, qw, tmpVar1, dw, String.valueOf(-32L), bt, tmpVar3));
    instructions.add(ReilHelpers.createAnd(baseOffset++, bt, tmpVar3, bt, String.valueOf(1L), bt, tmpVar4));
    instructions.add(ReilHelpers.createBisz(baseOffset++, bt, tmpVar4, bt, "C"));
    // V Flag
    Helpers.subOverflow(baseOffset, environment, instruction, instructions, dw, sourceRegister1, dw, sourceRegister2, qw, tmpVar1, "V", 32);
}
Also used : IOperandTreeNode(com.google.security.zynamics.zylib.disassembly.IOperandTreeNode) OperandSize(com.google.security.zynamics.reil.OperandSize)

Example 28 with OperandSize

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

the class THUMBCpyTranslator 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 String sourceRegister1 = (registerOperand1.getValue());
    final String sourceRegister2 = (registerOperand2.getValue());
    final OperandSize dw = OperandSize.DWORD;
    long baseOffset = (instruction.getAddress().toLong() * 0x100) + instructions.size();
    instructions.add(ReilHelpers.createStr(baseOffset++, dw, sourceRegister2, dw, sourceRegister1));
}
Also used : IOperandTreeNode(com.google.security.zynamics.zylib.disassembly.IOperandTreeNode) OperandSize(com.google.security.zynamics.reil.OperandSize)

Example 29 with OperandSize

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

the class THUMBEorTranslator 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 String sourceRegister1 = (registerOperand1.getValue());
    final String sourceRegister2 = (registerOperand2.getValue());
    final OperandSize bt = OperandSize.BYTE;
    final OperandSize wd = OperandSize.WORD;
    final OperandSize dw = OperandSize.DWORD;
    long baseOffset = (instruction.getAddress().toLong() * 0x100) + instructions.size();
    instructions.add(ReilHelpers.createXor(baseOffset++, dw, sourceRegister1, dw, sourceRegister2, dw, sourceRegister1));
    // N flag
    instructions.add(ReilHelpers.createBsh(baseOffset++, dw, sourceRegister1, wd, String.valueOf(-31), bt, "N"));
    // Z flag
    instructions.add(ReilHelpers.createBisz(baseOffset++, dw, sourceRegister1, bt, "Z"));
}
Also used : IOperandTreeNode(com.google.security.zynamics.zylib.disassembly.IOperandTreeNode) OperandSize(com.google.security.zynamics.reil.OperandSize)

Example 30 with OperandSize

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

the class THUMBLdmiaTranslator 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).getChildren().size() == 1 ? instruction.getOperands().get(0).getRootNode().getChildren().get(0).getChildren().get(0) : instruction.getOperands().get(0).getRootNode().getChildren().get(0);
    final Boolean wback = instruction.getOperands().get(0).getRootNode().getChildren().get(0).getChildren().size() == 1 ? true : false;
    /*
     * get size to see how many registers we have to load
     */
    final int registerListLength = instruction.getOperands().get(1).getRootNode().getChildren().get(0).getChildren().size();
    final String sourceRegister1 = (registerOperand1.getValue());
    final OperandSize bt = OperandSize.BYTE;
    final OperandSize dw = OperandSize.DWORD;
    long baseOffset = (instruction.getAddress().toLong() * 0x100) + instructions.size();
    final String tmpAddress = environment.getNextVariableString();
    instructions.add(ReilHelpers.createStr(baseOffset++, dw, sourceRegister1, dw, tmpAddress));
    for (int i = 0; i < registerListLength; i++) {
        final String currentRegisterValue = instruction.getOperands().get(1).getRootNode().getChildren().get(0).getChildren().get(i).getValue();
        instructions.add(ReilHelpers.createLdm(baseOffset++, dw, tmpAddress, dw, currentRegisterValue));
        instructions.add(ReilHelpers.createAdd(baseOffset++, dw, tmpAddress, bt, String.valueOf(4L), dw, tmpAddress));
    }
    if (wback) {
        instructions.add(ReilHelpers.createAdd(baseOffset++, dw, sourceRegister1, dw, String.valueOf(registerListLength * 4), dw, sourceRegister1));
    }
}
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