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

The following examples show how to use org.jf.dexlib2.iface.instruction.formats.Instruction21c. 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: NewInstanceInstruction.java    From JAADAS with GNU General Public License v3.0 6 votes vote down vote up
public void jimplify (DexBody body) {
      Instruction21c i = (Instruction21c)instruction;
      int dest = i.getRegisterA();
      String className = dottedClassName(((TypeReference)(i.getReference())).toString());
      RefType type = RefType.v(className);
      NewExpr n = Jimple.v().newNewExpr(type);
      assign = Jimple.v().newAssignStmt(body.getRegisterLocal(dest), n);
      setUnit(assign);
      addTags(assign);
      body.add(assign);

if (IDalvikTyper.ENABLE_DVKTYPER) {
	Debug.printDbg(IDalvikTyper.DEBUG, "constraint: "+ assign);
        int op = (int)instruction.getOpcode().value;
        //DalvikTyper.v().captureAssign((JAssignStmt)assign, op); // TODO: ref. type may be null!
        DalvikTyper.v().setType(assign.getLeftOpBox(), type, false);
      }
  }
 
Example #2
Source File: CheckCastInstruction.java    From JAADAS with GNU General Public License v3.0 6 votes vote down vote up
public void jimplify (DexBody body) {
      if(!(instruction instanceof Instruction21c))
          throw new IllegalArgumentException("Expected Instruction21c but got: "+instruction.getClass());

      Instruction21c checkCastInstr = (Instruction21c)instruction;

      Local castValue = body.getRegisterLocal(checkCastInstr.getRegisterA());
      Type checkCastType = DexType.toSoot((TypeReference) checkCastInstr.getReference());

      CastExpr castExpr =  Jimple.v().newCastExpr(castValue, checkCastType);

      //generate "x = (Type) x"
      //splitter will take care of the rest
      assign = Jimple.v().newAssignStmt(castValue, castExpr);

      setUnit(assign);
      addTags(assign);
      body.add(assign);
      

      if (IDalvikTyper.ENABLE_DVKTYPER) {
	Debug.printDbg(IDalvikTyper.DEBUG, "constraint: "+ assign);
          DalvikTyper.v().setType(assign.getLeftOpBox(), checkCastType, false);
}

  }
 
Example #3
Source File: ConstClassInstruction.java    From JAADAS with GNU General Public License v3.0 6 votes vote down vote up
public void jimplify (DexBody body) {
      if(!(instruction instanceof Instruction21c))
          throw new IllegalArgumentException("Expected Instruction21c but got: "+instruction.getClass());

      ReferenceInstruction constClass = (ReferenceInstruction) this.instruction;

      TypeReference tidi = (TypeReference)(constClass.getReference());
      String type = tidi.getType();
      if (type.startsWith("L") && type.endsWith(";"))
        type = type.replaceAll("^L", "").replaceAll(";$", "");

      int dest = ((OneRegisterInstruction) instruction).getRegisterA();
      Constant cst = ClassConstant.v(type);
      assign = Jimple.v().newAssignStmt(body.getRegisterLocal(dest), cst);
      setUnit(assign);
      addTags(assign);
      body.add(assign);

if (IDalvikTyper.ENABLE_DVKTYPER) {
	Debug.printDbg(IDalvikTyper.DEBUG, "constraint: "+ assign);
        int op = (int)instruction.getOpcode().value;
        //DalvikTyper.v().captureAssign((JAssignStmt)assign, op); //TODO: classtype could be null!
        DalvikTyper.v().setType(assign.getLeftOpBox(), cst.getType(), false);
      }
  }
 
Example #4
Source File: ImmutableInstruction21c.java    From ZjDroid with Apache License 2.0 5 votes vote down vote up
public static ImmutableInstruction21c of(Instruction21c instruction) {
    if (instruction instanceof ImmutableInstruction21c) {
        return (ImmutableInstruction21c)instruction;
    }
    return new ImmutableInstruction21c(
            instruction.getOpcode(),
            instruction.getRegisterA(),
            instruction.getReference());
}
 
Example #5
Source File: ImmutableInstruction21c.java    From zjdroid with Apache License 2.0 5 votes vote down vote up
public static ImmutableInstruction21c of(Instruction21c instruction) {
    if (instruction instanceof ImmutableInstruction21c) {
        return (ImmutableInstruction21c)instruction;
    }
    return new ImmutableInstruction21c(
            instruction.getOpcode(),
            instruction.getRegisterA(),
            instruction.getReference());
}
 
Example #6
Source File: FieldInstruction.java    From JAADAS with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Return the source register for this instruction.
 */
private int sourceRegister() {
    // I hate smali's API ..
    if (instruction instanceof Instruction23x)
        return ((Instruction23x) instruction).getRegisterA();
    else if (instruction instanceof Instruction22c)
        return ((Instruction22c) instruction).getRegisterA();
    else if (instruction instanceof Instruction21c)
        return ((Instruction21c) instruction).getRegisterA();
    else throw new RuntimeException("Instruction is not a instance, array or static op");
}
 
Example #7
Source File: ImmutableInstruction21c.java    From HeyGirl with Apache License 2.0 5 votes vote down vote up
public static ImmutableInstruction21c of(Instruction21c instruction) {
    if (instruction instanceof ImmutableInstruction21c) {
        return (ImmutableInstruction21c)instruction;
    }
    return new ImmutableInstruction21c(
            instruction.getOpcode(),
            instruction.getRegisterA(),
            instruction.getReference());
}
 
Example #8
Source File: ImmutableInstruction21c.java    From ZjDroid with Apache License 2.0 5 votes vote down vote up
public static ImmutableInstruction21c of(Instruction21c instruction) {
    if (instruction instanceof ImmutableInstruction21c) {
        return (ImmutableInstruction21c)instruction;
    }
    return new ImmutableInstruction21c(
            instruction.getOpcode(),
            instruction.getRegisterA(),
            instruction.getReference());
}