Search in sources :

Example 1 with OperandSize

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

the class THUMBStrTranslator 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);
    // Hack for STR Rx, =0xSOMEADDR
    IOperandTreeNode registerOperand2 = null;
    if ((instruction.getOperands().get(1).getRootNode().getChildren().get(0).getChildren().get(0).getType() == ExpressionType.IMMEDIATE_INTEGER) || (instruction.getOperands().get(1).getRootNode().getChildren().get(0).getChildren().get(0).getType() == ExpressionType.REGISTER)) {
        registerOperand2 = instruction.getOperands().get(1).getRootNode().getChildren().get(0).getChildren().get(0);
    } else {
        registerOperand2 = instruction.getOperands().get(1).getRootNode().getChildren().get(0).getChildren().get(0).getChildren().get(0);
    }
    IOperandTreeNode variableOperand1 = null;
    if (instruction.getOperands().get(1).getRootNode().getChildren().get(0).getChildren().get(0).getChildren().size() == 2) {
        variableOperand1 = instruction.getOperands().get(1).getRootNode().getChildren().get(0).getChildren().get(0).getChildren().get(1);
    }
    final String targetRegister1 = (registerOperand1.getValue());
    final String sourceRegister2 = (registerOperand2.getValue());
    final String sourceVariable1 = variableOperand1 == null ? "0" : (variableOperand1.getValue());
    final OperandSize dw = OperandSize.DWORD;
    long baseOffset = (instruction.getAddress().toLong() * 0x100) + instructions.size();
    final String tmpAddress = environment.getNextVariableString();
    final String tmpVar1 = environment.getNextVariableString();
    instructions.add(ReilHelpers.createAnd(baseOffset++, dw, targetRegister1, dw, String.valueOf(0xFFFFFFFFL), dw, tmpVar1));
    instructions.add(ReilHelpers.createAdd(baseOffset++, dw, sourceRegister2, dw, sourceVariable1, dw, tmpAddress));
    instructions.add(ReilHelpers.createStm(baseOffset++, dw, tmpVar1, dw, tmpAddress));
}
Also used : IOperandTreeNode(com.google.security.zynamics.zylib.disassembly.IOperandTreeNode) OperandSize(com.google.security.zynamics.reil.OperandSize)

Example 2 with OperandSize

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

the class THUMBStrbTranslator 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);
    // Hack for STRB Rx, =0xSOMEADDR
    IOperandTreeNode registerOperand2 = null;
    if ((instruction.getOperands().get(1).getRootNode().getChildren().get(0).getChildren().get(0).getType() == ExpressionType.IMMEDIATE_INTEGER) || (instruction.getOperands().get(1).getRootNode().getChildren().get(0).getChildren().get(0).getType() == ExpressionType.REGISTER)) {
        registerOperand2 = instruction.getOperands().get(1).getRootNode().getChildren().get(0).getChildren().get(0);
    } else {
        registerOperand2 = instruction.getOperands().get(1).getRootNode().getChildren().get(0).getChildren().get(0).getChildren().get(0);
    }
    IOperandTreeNode variableOperand1 = null;
    if (instruction.getOperands().get(1).getRootNode().getChildren().get(0).getChildren().get(0).getChildren().size() == 2) {
        variableOperand1 = instruction.getOperands().get(1).getRootNode().getChildren().get(0).getChildren().get(0).getChildren().get(1);
    }
    final String targetRegister1 = (registerOperand1.getValue());
    final String sourceRegister2 = (registerOperand2.getValue());
    final String sourceVariable1 = variableOperand1 == null ? "0" : (variableOperand1.getValue());
    final OperandSize bt = OperandSize.BYTE;
    final OperandSize dw = OperandSize.DWORD;
    long baseOffset = (instruction.getAddress().toLong() * 0x100) + instructions.size();
    final String tmpAddress = environment.getNextVariableString();
    final String tmpVar1 = environment.getNextVariableString();
    instructions.add(ReilHelpers.createAnd(baseOffset++, dw, targetRegister1, dw, String.valueOf(0xFFL), bt, tmpVar1));
    instructions.add(ReilHelpers.createAdd(baseOffset++, dw, sourceRegister2, dw, sourceVariable1, dw, tmpAddress));
    instructions.add(ReilHelpers.createStm(baseOffset++, bt, tmpVar1, dw, tmpAddress));
}
Also used : IOperandTreeNode(com.google.security.zynamics.zylib.disassembly.IOperandTreeNode) OperandSize(com.google.security.zynamics.reil.OperandSize)

Example 3 with OperandSize

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

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

Example 4 with OperandSize

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

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

Example 5 with OperandSize

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

the class THUMBUxtbTranslator 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 targetRegister = (registerOperand1.getValue());
    final String sourceRegister = (registerOperand2.getValue());
    final OperandSize dw = OperandSize.DWORD;
    long baseOffset = ReilHelpers.nextReilAddress(instruction, instructions);
    instructions.add(ReilHelpers.createAnd(baseOffset++, dw, sourceRegister, dw, String.valueOf(0xFFL), dw, targetRegister));
}
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