public void jimplify (DexBody body) { Instruction22c i = (Instruction22c)instruction; int dest = i.getRegisterA(); int source = i.getRegisterB(); Type t = DexType.toSoot((TypeReference)(i.getReference())); InstanceOfExpr e = Jimple.v().newInstanceOfExpr(body.getRegisterLocal(source), t); assign = Jimple.v().newAssignStmt(body.getRegisterLocal(dest), e); 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().? } }
private void javafy_expr(ValueBox vb) { Expr e = (Expr) vb.getValue(); if (e instanceof BinopExpr) javafy_binop_expr(vb); else if (e instanceof UnopExpr) javafy_unop_expr(vb); else if (e instanceof CastExpr) javafy_cast_expr(vb); else if (e instanceof NewArrayExpr) javafy_newarray_expr(vb); else if (e instanceof NewMultiArrayExpr) javafy_newmultiarray_expr(vb); else if (e instanceof InstanceOfExpr) javafy_instanceof_expr(vb); else if (e instanceof InvokeExpr) javafy_invoke_expr(vb); else if (e instanceof NewExpr) javafy_new_expr(vb); }
public void caseInstanceOfExpr(InstanceOfExpr v) { String oldName = varName; suggestVariableName("type"); String lhsName = varName; ttp.setVariableName(varName); v.getType().apply(ttp); String rhsName = printValueAssignment(v.getOp(), "op"); p.println("Value "+oldName+" = Jimple.v().newInstanceOfExpr("+lhsName+","+rhsName+");"); varName = oldName; }
@Override public void caseInstanceOfExpr(InstanceOfExpr ioe) { final Value referenceToCheck = ioe.getOp(); // There are some strange apps that use constants here constantV.setOrigStmt(origStmt); Register referenceToCheckReg = regAlloc.asImmediate(referenceToCheck, constantV); BuilderReference checkType = DexPrinter.toTypeReference(ioe.getCheckType(), stmtV.getBelongingFile()); stmtV.addInsn(new Insn22c(Opcode.INSTANCE_OF, destinationReg, referenceToCheckReg, checkType), origStmt); }
@Override public void caseInstanceOfExpr(InstanceOfExpr arg0) { this.isLeftHandSide = false; arg0.getOp().apply(this); Expression lhs = this.getExpression(); if (arg0.getCheckType() instanceof RefType) { RefType rtype = (RefType) arg0.getCheckType(); Expression rhs = GlobalsCache.v().lookupClassVariable( rtype.getSootClass()); Expression isNonNull = this.pf.mkBinaryExpression( this.pf.getBoolType(), BinaryOperator.COMPNEQ, lhs, SootPrelude.v().getNullConstant()); Expression isSubtype = this.pf.mkBinaryExpression( this.pf.getBoolType(), BinaryOperator.COMPPO, this.getClassTypeFromExpression(lhs, false), rhs); this.expressionStack.push(this.pf.mkBinaryExpression( this.pf.getBoolType(), BinaryOperator.LOGICAND, isNonNull, isSubtype)); } else { Log.debug("instanceof for arrays not implemented"); this.expressionStack.push(createHavocedExpression(GlobalsCache.v() .getBoogieType(arg0.getType()))); } }
@Override public void caseInstanceOfExpr(InstanceOfExpr arg0) { this.isLeftHandSide = false; arg0.getOp().apply(this); Expression lhs = this.getExpression(); if (arg0.getCheckType() instanceof RefType) { RefType rtype = (RefType) arg0.getCheckType(); Expression rhs = GlobalsCache.v().lookupClassVariable( rtype.getSootClass()); Expression isNonNull = this.pf.mkBinaryExpression( this.pf.getBoolType(), BinaryOperator.COMPNEQ, lhs, SootPrelude.v().getNullConstant()); Expression isSubtype = this.pf.mkBinaryExpression( this.pf.getBoolType(), BinaryOperator.COMPPO, this.getClassTypeFromExpression(lhs, false), rhs); this.expressionStack.push(this.pf.mkBinaryExpression( this.pf.getBoolType(), BinaryOperator.LOGICAND, isNonNull, isSubtype)); } else { Log.error("instanceof for arrays not implemented"); this.expressionStack.push(createHavocedExpression(GlobalsCache.v() .getBoogieType(arg0.getType()))); } }
/** * Analyze an expression (a value) and computes an abstract value representing its contents. * @param r the expression to analyse. * @param u The unit that encapsulate the value. * @param seen What has already be seen (avoid loops). * @return */ public AbsValue analyze_expr(Value r, Unit u, Set<Unit> seen) { AbsValue result; if (r instanceof Local) { result = analyzeLocal((Local) r, u, seen); } else if (r instanceof StringConstant) result = new StringValue(((StringConstant) r).value); else if (r instanceof Constant) result = new ConstantValue((Constant) r,((Constant) r).getType()); else if (r instanceof InvokeExpr) { result = analyzeInvoke((InvokeExpr) r,u,seen); } else if (r instanceof CastExpr) { result = analyze_expr(((CastExpr) r).getOp(),u,seen); } else if (r instanceof ParameterRef) { result = analyzeParameterRef((ParameterRef) r, u, seen); } else if (r instanceof ConditionExpr) { result = analyzeConditionExpr((ConditionExpr) r, u, seen); } else if (r instanceof InstanceOfExpr) { result = analyzeInstanceOfExpr((InstanceOfExpr) r, u, seen); } else if (r instanceof StaticFieldRef) { result = analyzeStaticFieldRef((StaticFieldRef) r,u,seen); } else if (r instanceof InstanceFieldRef) { result = analyzeInstanceFieldRef((InstanceFieldRef) r,u,seen); } else if (r instanceof ArrayRef) { result = analyzeArrayRef((ArrayRef) r,u,seen); } else if (r instanceof NewExpr) { result = analyzeNewExpr((NewExpr) r, u, seen); } else { result = new UnknownValue(r.toString()); } return solve_init(result,u,seen); }
@Override public void caseInstanceOfExpr(InstanceOfExpr v) { rightElement = RightElement.NOT; if (actualContext == StmtContext.ASSIGNRIGHT) { throw new NotSupportedStmtException("InstanceOf"); } }
@Override public void caseInstanceOfExpr(InstanceOfExpr v) { throw new RuntimeException("todo"); }
private void javafy_instanceof_expr(ValueBox vb) { InstanceOfExpr ioe = (InstanceOfExpr) vb.getValue(); javafy(ioe.getOpBox()); }
public void caseInstanceOfExpr(InstanceOfExpr expr) { result = result.add(mgr.RESOLVE_CLASS_ERRORS); result = result.add(mightThrow(expr.getOp())); }
private AbsValue analyzeInstanceOfExpr(InstanceOfExpr rc, Unit u, Set<Unit> seen) { AbsValue av1 = analyze_expr(rc.getOp(),u,seen); AbsValue av2 = new StringValue(rc.getCheckType().toString()); return new MethValue("instanceof", av1,av2); }
@Override public void caseInstanceOfExpr(InstanceOfExpr v) { throwInvalidWriteException(v); }
@Override public void caseInstanceOfExpr(InstanceOfExpr v) { handleUnaryExpr(v.getOp()); }
/** * The method should update the <em>security level</em> of an expression * with type {@link InstanceOfExpr}, but it is not possible to update the * level of such an expression. * * @param v * The expression for which the <em>security level</em> should be * updated. * @see soot.jimple.ExprSwitch#caseInstanceOfExpr(soot.jimple.InstanceOfExpr) * @throws InvalidSwitchException * Always, because the update is not possible. */ @Override public void caseInstanceOfExpr(InstanceOfExpr v) { throw new SwitchException(getMsg("exception.analysis.switch.update_error", this.getClass().getSimpleName(), v.getClass().getSimpleName(), v.toString(), getSourceLine())); }
/** * DOC * * @see soot.jimple.ExprSwitch#caseInstanceOfExpr(soot.jimple.InstanceOfExpr) */ @Override public void caseInstanceOfExpr(InstanceOfExpr v) { v.getOp().apply(this); }
/** * Looks up the <em>security level</em> for the given instanceof expression * and stores the level in {@link SecurityLevelValueReadSwitch#level}. * * @param v * The instanceof expression for which the * <em>security level</em> should be looked up. * @see soot.jimple.ExprSwitch#caseInstanceOfExpr(soot.jimple.InstanceOfExpr) * @see SecurityLevelValueReadSwitch#handleOneValue(Value, Value) */ @Override public void caseInstanceOfExpr(InstanceOfExpr v) { Value value = v.getOp(); handleOneValue(value, v); }