Search in sources :

Example 1 with IOperandTreeNode

use of com.google.security.zynamics.zylib.disassembly.IOperandTreeNode 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 IOperandTreeNode

use of com.google.security.zynamics.zylib.disassembly.IOperandTreeNode 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 IOperandTreeNode

use of com.google.security.zynamics.zylib.disassembly.IOperandTreeNode 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 IOperandTreeNode

use of com.google.security.zynamics.zylib.disassembly.IOperandTreeNode 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 IOperandTreeNode

use of com.google.security.zynamics.zylib.disassembly.IOperandTreeNode 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

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