org.jf.dexlib2.iface.instruction.formats.Instruction31t Java Examples

The following examples show how to use org.jf.dexlib2.iface.instruction.formats.Instruction31t. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ImmutableInstruction31t.java    From ZjDroid with Apache License 2.0 5 votes vote down vote up
public static ImmutableInstruction31t of(Instruction31t instruction) {
    if (instruction instanceof ImmutableInstruction31t) {
        return (ImmutableInstruction31t)instruction;
    }
    return new ImmutableInstruction31t(
            instruction.getOpcode(),
            instruction.getRegisterA(),
            instruction.getCodeOffset());
}
 
Example #2
Source File: ImmutableInstruction31t.java    From zjdroid with Apache License 2.0 5 votes vote down vote up
public static ImmutableInstruction31t of(Instruction31t instruction) {
    if (instruction instanceof ImmutableInstruction31t) {
        return (ImmutableInstruction31t)instruction;
    }
    return new ImmutableInstruction31t(
            instruction.getOpcode(),
            instruction.getRegisterA(),
            instruction.getCodeOffset());
}
 
Example #3
Source File: ImmutableInstruction31t.java    From HeyGirl with Apache License 2.0 5 votes vote down vote up
public static ImmutableInstruction31t of(Instruction31t instruction) {
    if (instruction instanceof ImmutableInstruction31t) {
        return (ImmutableInstruction31t)instruction;
    }
    return new ImmutableInstruction31t(
            instruction.getOpcode(),
            instruction.getRegisterA(),
            instruction.getCodeOffset());
}
 
Example #4
Source File: ImmutableInstruction31t.java    From ZjDroid with Apache License 2.0 5 votes vote down vote up
public static ImmutableInstruction31t of(Instruction31t instruction) {
    if (instruction instanceof ImmutableInstruction31t) {
        return (ImmutableInstruction31t)instruction;
    }
    return new ImmutableInstruction31t(
            instruction.getOpcode(),
            instruction.getRegisterA(),
            instruction.getCodeOffset());
}
 
Example #5
Source File: FillArrayDataInstruction.java    From JAADAS with GNU General Public License v3.0 4 votes vote down vote up
public void jimplify (DexBody body) {
  if(!(instruction instanceof Instruction31t))
    throw new IllegalArgumentException("Expected Instruction31t but got: "+instruction.getClass());

  Instruction31t fillArrayInstr = (Instruction31t)instruction;
  int destRegister = fillArrayInstr.getRegisterA();
  int offset = fillArrayInstr.getCodeOffset();
  int targetAddress = codeAddress + offset;

  Instruction referenceTable = body.instructionAtAddress(targetAddress).instruction;

  if(!(referenceTable instanceof ArrayPayload)) {
    throw new RuntimeException("Address " + targetAddress + "refers to an invalid PseudoInstruction.");
  }

  ArrayPayload arrayTable = (ArrayPayload)referenceTable;

  //        NopStmt nopStmtBeginning = Jimple.v().newNopStmt();
  //        body.add(nopStmtBeginning);

  Local arrayReference = body.getRegisterLocal(destRegister);
  List<Number> elements = arrayTable.getArrayElements();
  int numElements = elements.size();

  Stmt firstAssign = null;
  for (int i = 0; i < numElements; i++) {
    ArrayRef arrayRef = Jimple.v().newArrayRef(arrayReference, IntConstant.v(i));
    NumericConstant element = getArrayElement(elements.get(i),body,destRegister);
    if (element == null) //array was not defined -> element type can not be found (obfuscated bytecode?)
      break;
    AssignStmt assign = Jimple.v().newAssignStmt(arrayRef, element);
    addTags(assign);
    body.add(assign);
    if (i == 0) {
      firstAssign = assign;
    }
  }
  if (firstAssign == null) { // if numElements == 0. Is it possible?
      firstAssign = Jimple.v().newNopStmt();
      body.add (firstAssign);
  }

  //        NopStmt nopStmtEnd = Jimple.v().newNopStmt();
  //        body.add(nopStmtEnd);

  //        defineBlock(nopStmtBeginning, nopStmtEnd);
  setUnit (firstAssign);

}