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

The following examples show how to use org.jf.dexlib2.iface.instruction.formats.Instruction23x. 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: AputInstruction.java    From JAADAS with GNU General Public License v3.0 6 votes vote down vote up
public void jimplify (DexBody body) {
      if(!(instruction instanceof Instruction23x))
          throw new IllegalArgumentException("Expected Instruction23x but got: "+instruction.getClass());

      Instruction23x aPutInstr = (Instruction23x)instruction;
      int source = aPutInstr.getRegisterA();

      Local arrayBase = body.getRegisterLocal(aPutInstr.getRegisterB());
      Local index = body.getRegisterLocal(aPutInstr.getRegisterC());
      ArrayRef arrayRef = Jimple.v().newArrayRef(arrayBase, index);

      Local sourceValue = body.getRegisterLocal(source);
      assign = getAssignStmt(body, sourceValue, arrayRef);
      if (aPutInstr.getOpcode().value == Opcode.APUT_OBJECT.value)
        assign.addTag(new ObjectOpTag());
      
      setUnit(assign);
      addTags(assign);
      body.add(assign);
      
if (IDalvikTyper.ENABLE_DVKTYPER) {
	Debug.printDbg(IDalvikTyper.DEBUG, "constraint: "+ assign);
        DalvikTyper.v().addConstraint(assign.getLeftOpBox(), assign.getRightOpBox());
        DalvikTyper.v().setType(arrayRef.getIndexBox(), IntType.v(), true);
      }
  }
 
Example #2
Source File: ImmutableInstruction23x.java    From ZjDroid with Apache License 2.0 5 votes vote down vote up
public static ImmutableInstruction23x of(Instruction23x instruction) {
    if (instruction instanceof ImmutableInstruction23x) {
        return (ImmutableInstruction23x)instruction;
    }
    return new ImmutableInstruction23x(
            instruction.getOpcode(),
            instruction.getRegisterA(),
            instruction.getRegisterB(),
            instruction.getRegisterC());
}
 
Example #3
Source File: ImmutableInstruction23x.java    From zjdroid with Apache License 2.0 5 votes vote down vote up
public static ImmutableInstruction23x of(Instruction23x instruction) {
    if (instruction instanceof ImmutableInstruction23x) {
        return (ImmutableInstruction23x)instruction;
    }
    return new ImmutableInstruction23x(
            instruction.getOpcode(),
            instruction.getRegisterA(),
            instruction.getRegisterB(),
            instruction.getRegisterC());
}
 
Example #4
Source File: BinopInstruction.java    From JAADAS with GNU General Public License v3.0 5 votes vote down vote up
public void jimplify (DexBody body) {
     if(!(instruction instanceof Instruction23x))
         throw new IllegalArgumentException("Expected Instruction23x but got: "+instruction.getClass());

     Instruction23x binOpInstr = (Instruction23x)instruction;
     int dest = binOpInstr.getRegisterA();

     Local source1 = body.getRegisterLocal(binOpInstr.getRegisterB());
     Local source2 = body.getRegisterLocal(binOpInstr.getRegisterC());

     expr = getExpression(source1, source2);

     assign = Jimple.v().newAssignStmt(body.getRegisterLocal(dest), expr);
     assign.addTag(getTag());
     
     setUnit(assign);
     addTags(assign);
     body.add(assign);
     
     if (IDalvikTyper.ENABLE_DVKTYPER) {
Debug.printDbg(IDalvikTyper.DEBUG, "constraint: "+ assign);
       int op = (int)instruction.getOpcode().value;
       BinopExpr bexpr = (BinopExpr)expr;
       JAssignStmt jassign = (JAssignStmt)assign;
       DalvikTyper.v().setType(bexpr.getOp1Box(), op1BinType[op-0x90], true);
       DalvikTyper.v().setType(bexpr.getOp2Box(), op2BinType[op-0x90], true);
       DalvikTyper.v().setType(jassign.leftBox, resBinType[op-0x90], false);
     }
 }
 
Example #5
Source File: AgetInstruction.java    From JAADAS with GNU General Public License v3.0 5 votes vote down vote up
public void jimplify (DexBody body) throws InvalidDalvikBytecodeException {
      if(!(instruction instanceof Instruction23x))
          throw new IllegalArgumentException("Expected Instruction23x but got: "+instruction.getClass());

      Instruction23x aGetInstr = (Instruction23x)instruction;
      int dest = aGetInstr.getRegisterA();
     
      Local arrayBase = body.getRegisterLocal(aGetInstr.getRegisterB());
      Local index = body.getRegisterLocal(aGetInstr.getRegisterC());

      ArrayRef arrayRef = Jimple.v().newArrayRef(arrayBase, index);
      Local l = body.getRegisterLocal(dest);
      
      assign = Jimple.v().newAssignStmt(l, arrayRef);
      if (aGetInstr.getOpcode().value == Opcode.AGET_OBJECT.value)
        assign.addTag(new ObjectOpTag());

      setUnit(assign);
      addTags(assign);
      body.add(assign);
      
if (IDalvikTyper.ENABLE_DVKTYPER) {
	Debug.printDbg(IDalvikTyper.DEBUG, "constraint: "+ assign);
        DalvikTyper.v().addConstraint(assign.getLeftOpBox(), assign.getRightOpBox());
        DalvikTyper.v().setType(arrayRef.getIndexBox(), IntType.v(), true);
      }
  }
 
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: AputInstruction.java    From JAADAS with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected Type getTargetType(DexBody body) {
    Instruction23x aPutInstr = (Instruction23x)instruction;
    Type t = body.getRegisterLocal(aPutInstr.getRegisterB()).getType();
    if (t instanceof ArrayType)
        return ((ArrayType) t).getElementType();
    else
        return UnknownType.v();
}
 
Example #8
Source File: ImmutableInstruction23x.java    From HeyGirl with Apache License 2.0 5 votes vote down vote up
public static ImmutableInstruction23x of(Instruction23x instruction) {
    if (instruction instanceof ImmutableInstruction23x) {
        return (ImmutableInstruction23x)instruction;
    }
    return new ImmutableInstruction23x(
            instruction.getOpcode(),
            instruction.getRegisterA(),
            instruction.getRegisterB(),
            instruction.getRegisterC());
}
 
Example #9
Source File: ImmutableInstruction23x.java    From ZjDroid with Apache License 2.0 5 votes vote down vote up
public static ImmutableInstruction23x of(Instruction23x instruction) {
    if (instruction instanceof ImmutableInstruction23x) {
        return (ImmutableInstruction23x)instruction;
    }
    return new ImmutableInstruction23x(
            instruction.getOpcode(),
            instruction.getRegisterA(),
            instruction.getRegisterB(),
            instruction.getRegisterC());
}
 
Example #10
Source File: CmpInstruction.java    From JAADAS with GNU General Public License v3.0 4 votes vote down vote up
public void jimplify (DexBody body) {
      if(!(instruction instanceof Instruction23x))
          throw new IllegalArgumentException("Expected Instruction23x but got: "+instruction.getClass());

      Instruction23x cmpInstr = (Instruction23x)instruction;
      int dest = cmpInstr.getRegisterA();

      Local first = body.getRegisterLocal(cmpInstr.getRegisterB());
      Local second = body.getRegisterLocal(cmpInstr.getRegisterC());

      //Expr cmpExpr;
      //Type type = null
      Opcode opcode = instruction.getOpcode();
      switch (opcode) {
      case CMPL_DOUBLE:
        setTag (new DoubleOpTag());
        type = DoubleType.v();
        cmpExpr = Jimple.v().newCmplExpr(first, second);
        break;
      case CMPL_FLOAT:
        setTag (new FloatOpTag());
        type = FloatType.v();
          cmpExpr = Jimple.v().newCmplExpr(first, second);
          break;
      case CMPG_DOUBLE:
        setTag (new DoubleOpTag());
        type = DoubleType.v();
        cmpExpr = Jimple.v().newCmpgExpr(first, second);
        break;
      case CMPG_FLOAT:
        setTag (new FloatOpTag());
        type = FloatType.v();
          cmpExpr = Jimple.v().newCmpgExpr(first, second);
          break;
      case CMP_LONG:
        setTag (new LongOpTag());
        type = LongType.v();
        cmpExpr = Jimple.v().newCmpExpr(first, second);
        break;
      default:
          throw new RuntimeException("no opcode for CMP: 0x"+ Integer.toHexString(opcode.value));
      }

      assign = Jimple.v().newAssignStmt(body.getRegisterLocal(dest), cmpExpr);
      assign.addTag(getTag());

      setUnit(assign);
      addTags(assign);
      body.add(assign);
      
if (IDalvikTyper.ENABLE_DVKTYPER) {
	Debug.printDbg(IDalvikTyper.DEBUG, "constraint: "+ assign);
        getTag().getName();
        BinopExpr bexpr = (BinopExpr)cmpExpr;
        DalvikTyper.v().setType(bexpr.getOp1Box(), type, true);
        DalvikTyper.v().setType(bexpr.getOp2Box(), type, true);
        DalvikTyper.v().setType(((JAssignStmt)assign).leftBox, IntType.v(), false);
      }
  }