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