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));
}
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));
}
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);
}
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"));
}
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));
}
Aggregations