本文整理汇总了Java中soot.jimple.StaticInvokeExpr类的典型用法代码示例。如果您正苦于以下问题:Java StaticInvokeExpr类的具体用法?Java StaticInvokeExpr怎么用?Java StaticInvokeExpr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
StaticInvokeExpr类属于soot.jimple包,在下文中一共展示了StaticInvokeExpr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: prepareAlarmManagerSet
import soot.jimple.StaticInvokeExpr; //导入依赖的package包/类
private void prepareAlarmManagerSet(Body body, InvokeStmt setStmt, SootMethodRef reportRef) {
Value oldVal = setStmt.getInvokeExpr().getArg(1);
Local longLocal = UtilInstrumenter.generateFreshLocal(body, LongType.v());
SootMethod currentTimeMillis = Scene.v().getMethod("<java.lang.System: long currentTimeMillis()>");
StaticInvokeExpr timeInvoke = Jimple.v().newStaticInvokeExpr(currentTimeMillis.makeRef());
AssignStmt timeInitalize = Jimple.v().newAssignStmt(longLocal, timeInvoke);
AddExpr addTime = Jimple.v().newAddExpr(longLocal, LongConstant.v(2000L));
AssignStmt timeAssign = Jimple.v().newAssignStmt(longLocal, addTime);
body.getUnits().insertBefore(timeInitalize, setStmt);
body.getUnits().insertBefore(timeAssign, setStmt);
InvokeExpr expr = setStmt.getInvokeExpr();
expr.setArg(0, IntConstant.v(0));
expr.setArg(1, longLocal);
// Report the change
InvokeStmt reportStmt = Jimple.v().newInvokeStmt(Jimple.v().newStaticInvokeExpr(
reportRef, oldVal, longLocal));
reportStmt.addTag(new InstrumentedCodeTag());
body.getUnits().insertAfter(reportStmt, setStmt);
}
示例2: fill
import soot.jimple.StaticInvokeExpr; //导入依赖的package包/类
public void fill() {
DomI domI = (DomI) doms[0];
DomM domM = (DomM) doms[1];
int numI = domI.size();
for (int iIdx = 0; iIdx < numI; iIdx++) {
Unit i = (Unit) domI.get(iIdx);
if(SootUtilities.isInvoke(i)){
InvokeExpr ie = SootUtilities.getInvokeExpr(i);
if(ie instanceof StaticInvokeExpr){
SootMethod m = ie.getMethod();
if(m.isStatic()){
m = StubRewrite.maybeReplaceCallDest(SootUtilities.getMethod(i), m);
int mIdx = domM.indexOf(m);
if (mIdx >= 0)
add(iIdx, mIdx);
else if (Config.verbose >= 2)
Messages.log(NOT_FOUND, m, SootUtilities.toLocStr(i));
}
}
}
}
}
示例3: caseStaticInvokeExpr
import soot.jimple.StaticInvokeExpr; //导入依赖的package包/类
@Override
public void caseStaticInvokeExpr(StaticInvokeExpr v) {
logger.fine("Invoke expression is of type StaticInvoke");
logger.finest(v.toString());
rightElement = RightElement.NOT;
if (actualContext == StmtContext.INVOKE
|| actualContext == StmtContext.ASSIGNRIGHT ) {
Local[] args = vh.getArgumentsForInvokedMethod(v);
String method = v.getMethod().toString();
if (ExternalClasses.methodMap.containsKey(method)) {
logger.fine("Found an external class " + method);
logger.fine("This class is treated in a special way");
ExternalClasses.receiveCommand(method, callingStmt, args);
} else {
logger.fine("Found an external class " + method);
logger.fine("This class is treated as an internal class");
JimpleInjector.storeArgumentLevels(callingStmt, args);
}
} else {
throw new InternalAnalyzerException(
"Unexpected Context for Invoke Expression");
}
}
示例4: detectValueCastFromCall
import soot.jimple.StaticInvokeExpr; //导入依赖的package包/类
@Override
public Try<Option<ValueCast<Level>>> detectValueCastFromCall(StaticInvokeExpr e) {
SootMethod m = e.getMethod();
BiFunction<TypeView<Level>, TypeView<Level>, Try<Option<ValueCast<Level>>>>
makeCast =
(t1, t2) -> {
Optional<ValueCast<Level>> result = Interop.asJavaStream(Vars.getAll(e.getArg(0))).findFirst().map(value -> makeValueCast(t1, t2, Option.apply(value)));
return new Success<>(Interop.asScalaOption(result));
};
if (castEquals(castHighToDyn, m)) {
return makeCast.apply(THIGH, DYN);
} else if (castEquals(castLowToDyn, m)) {
return makeCast.apply(TLOW, DYN);
} else if (castEquals(castDynToLow, m)) {
return makeCast.apply(DYN, TLOW);
} else if (castEquals(castDynToHigh, m)) {
return makeCast.apply(DYN, THIGH);
} else {
return new Success<>(Option.empty());
}
}
示例5: makeJimpleStaticCallForPathExecution
import soot.jimple.StaticInvokeExpr; //导入依赖的package包/类
public static Unit makeJimpleStaticCallForPathExecution(String methodName, Object... args) {
SootClass sootClass = Scene.v().getSootClass(UtilInstrumenter.JAVA_CLASS_FOR_PATH_EXECUTION);
Unit generated = null;
ArrayList<Type> argTypes = new ArrayList<Type>();
ArrayList<Value> argList = new ArrayList<Value>();
if (args != null) {
if (args.length % 2 != 0) {
throw new RuntimeException(
"Mismatched argument types:values in static call to "
+ methodName);
} else {
for (int i = 0; i < args.length; i++)
if (i % 2 == 0) // First type, then argument
argTypes.add((Type) args[i]);
else
argList.add((Value) args[i]);
}
}
SootMethod createAndAdd = sootClass.getMethod(methodName, argTypes);
StaticInvokeExpr sie = Jimple.v().newStaticInvokeExpr(
createAndAdd.makeRef(), argList);
generated = Jimple.v().newInvokeStmt(sie);
return generated;
}
示例6: instrumentEachBranchAccess
import soot.jimple.StaticInvokeExpr; //导入依赖的package包/类
private void instrumentEachBranchAccess(Body body, Unit unit){
SootClass sootClass = Scene.v().getSootClass(
UtilInstrumenter.JAVA_CLASS_FOR_PATH_INSTRUMENTATION);
// Create the method invocation
SootMethod createAndAdd = sootClass.getMethod("reportConditionOutcomeSynchronous",
Collections.<Type>singletonList(BooleanType.v()));
StaticInvokeExpr sieThen = Jimple.v().newStaticInvokeExpr(
createAndAdd.makeRef(), IntConstant.v(1));
StaticInvokeExpr sieElse = Jimple.v().newStaticInvokeExpr(
createAndAdd.makeRef(), IntConstant.v(0));
Unit sieThenUnit = Jimple.v().newInvokeStmt(sieThen);
sieThenUnit.addTag(new InstrumentedCodeTag());
Unit sieElseUnit = Jimple.v().newInvokeStmt(sieElse);
sieElseUnit.addTag(new InstrumentedCodeTag());
//treatment of target statement ("true"-branch)
IfStmt ifStmt = (IfStmt)unit;
Stmt targetStmt = ifStmt.getTarget();
if(!branchTargetStmt.contains(targetStmt.toString())) {
branchTargetStmt.add(sieThenUnit.toString());
body.getUnits().insertBefore(sieThenUnit, targetStmt);
NopStmt nop = Jimple.v().newNopStmt();
GotoStmt gotoNop = Jimple.v().newGotoStmt(nop);
body.getUnits().insertBeforeNoRedirect(nop, targetStmt);
body.getUnits().insertBeforeNoRedirect(gotoNop, sieThenUnit);
}
//treatment of "else"-branch
body.getUnits().insertAfter(sieElseUnit, unit);
}
示例7: caseStaticInvokeExpr
import soot.jimple.StaticInvokeExpr; //导入依赖的package包/类
@Override
public void caseStaticInvokeExpr(StaticInvokeExpr v) {
//just propagate the taint value of previous statement
Stmt prevStmt = stmtVisitor.getPreviousDataFlowPathElement(currentStatement);
if(prevStmt == null)
throw new RuntimeException("there is no previous statement");
else {
//create an assignment between the incoming taint-value and the
//assigned taint-value inside the method
SMTBinding bindingPrevStmt = stmtVisitor.getBindingForTaintedValue(prevStmt);
//if there is no taint-tracking involved, we do not have to create an SMT formula
if(bindingPrevStmt == null)
return;
AccessPath accessPath = stmtVisitor.getCorrectAccessPathForStmt(currentStatement);
Local identityStmtTaintValue = accessPath.getPlainValue();
SMTBinding bindingCurentStmt = stmtVisitor.getLatestBindingForValue(identityStmtTaintValue);
if(bindingCurentStmt == null) {
bindingCurentStmt = stmtVisitor.createNewBindingForValue(identityStmtTaintValue);
stmtVisitor.addValueBindingToVariableDeclaration(identityStmtTaintValue, bindingCurentStmt);
}
if(bindingCurentStmt != bindingPrevStmt) {
SMTSimpleAssignment simpleAssignForTaintProp = new SMTSimpleAssignment(bindingCurentStmt, new SMTBindingValue(bindingPrevStmt));
SMTAssertStatement simpleAssignAssert = new SMTAssertStatement(simpleAssignForTaintProp);
stmtVisitor.addAssertStmtToAllPrograms(simpleAssignAssert);
}
this.result = bindingCurentStmt;
}
}
示例8: applySanitizer
import soot.jimple.StaticInvokeExpr; //导入依赖的package包/类
/***** API calls *****/
// Sanitizer for user study. Kill the parameter and its aliases
private boolean applySanitizer(Unit call, FlowAbstraction source) {
// Call itself
Stmt stmt = (Stmt) call;
final String target = stmt.getInvokeExpr().getMethod().getSignature();
final List<Value> args = stmt.getInvokeExpr().getArgs();
if (!target.equals("<sanitizers.Sanitizer: void sanitize(java.lang.Object)>"))
return false;
if (killforSanit(call, args.get(0), source))
return true;
// Case of valueOf for primitive types
// a = Integer.valueOf(b); and sanit(a) -> must also treat aliases of b
List<Unit> predecessors = icfg.getPredsOf(call);
for (Unit predecessor : predecessors) {
if (predecessor instanceof DefinitionStmt) {
DefinitionStmt def = (DefinitionStmt) predecessor;
if (def.getLeftOp().equals(args.get(0)) && def.getRightOp() instanceof StaticInvokeExpr) {
InvokeExpr expr = (StaticInvokeExpr) def.getRightOp();
final SootMethod method = expr.getMethod();
if (method.getName().equals("valueOf") && expr.getArgCount() == 1
&& method.getDeclaringClass().getType().equals(method.getReturnType())
&& isPrimitiveType(method.getReturnType())) {
if (killforSanit(predecessor, expr.getArg(0), source))
return true;
}
}
}
}
return false;
}
示例9: caseStaticInvokeExpr
import soot.jimple.StaticInvokeExpr; //导入依赖的package包/类
@Override
public void caseStaticInvokeExpr(StaticInvokeExpr sie) {
BuilderMethodReference method = DexPrinter.toMethodReference
(sie.getMethodRef(), dexFile);
List<Register> arguments = getInvokeArgumentRegs(sie);
stmtV.addInsn(buildInvokeInsn("INVOKE_STATIC", method, arguments), origStmt);
}
示例10: caseStaticInvokeExpr
import soot.jimple.StaticInvokeExpr; //导入依赖的package包/类
public void caseStaticInvokeExpr(StaticInvokeExpr expr) {
result = result.add(mgr.INITIALIZATION_ERRORS);
for (int i = 0; i < expr.getArgCount(); i++) {
result = result.add(mightThrow(expr.getArg(i)));
}
result = result.add(mightThrow(expr.getMethodRef()));
}
示例11: isStaticInvoke
import soot.jimple.StaticInvokeExpr; //导入依赖的package包/类
public static boolean isStaticInvoke(Unit q){
assert (q instanceof JInvokeStmt || q instanceof JAssignStmt);
InvokeExpr ie;
if (q instanceof JInvokeStmt)
ie = ((JInvokeStmt)q).getInvokeExpr();
else if (q instanceof JAssignStmt)
ie = ((InvokeExpr)(((JAssignStmt)q).rightBox.getValue()));
else
ie = null;
if (ie != null && ie instanceof StaticInvokeExpr)
return true;
return false;
}
示例12: createJimpleStaticInvokeExpr
import soot.jimple.StaticInvokeExpr; //导入依赖的package包/类
public static StaticInvokeExpr createJimpleStaticInvokeExpr(String javaClass, String call, List<Object> args) {
SootClass sootClass = Scene.v().getSootClass(javaClass);
ArrayList<Type> argTypes = new ArrayList<Type>();
ArrayList<Value> argList = new ArrayList<Value>();
if (args != null) {
if (args.size() % 2 != 0) {
throw new RuntimeException(
"Mismatched argument types:values in static call to "
+ call);
} else {
for (int i = 0; i < args.size(); i++)
if (i % 2 == 0) // First type, then argument
argTypes.add((Type) args.get(i));
else
argList.add((Value) args.get(i));
}
}
SootMethod createAndAdd = sootClass.getMethod(call, argTypes);
StaticInvokeExpr sie = Jimple.v().newStaticInvokeExpr(
createAndAdd.makeRef(), argList);
log.debug("new invoke expression: "+ sie);
return sie;
}
示例13: initializePeP
import soot.jimple.StaticInvokeExpr; //导入依赖的package包/类
private static void initializePeP(SootClass sc){
SootMethod onCreate = null;
log.info("add Pep initialization in class "+ sc);
for(SootMethod sm : sc.getMethods()){
if(sm.getName().equals("onCreate") &&
sm.getParameterCount() == 1 &&
sm.getParameterType(0).toString().equals("android.os.Bundle")){
onCreate = sm;
}
}
if(onCreate != null){
List<Unit> generated = new ArrayList<Unit>();
Body body = onCreate.retrieveActiveBody();
Local thisLocal = body.getThisLocal();
SootClass context = Scene.v().forceResolve("android.content.Context", SootClass.BODIES);
// SootMethod applicationContext =sc.getMethod("android.content.Context getApplicationContext()");
SootMethod applicationContext = context.getMethod("android.content.Context getApplicationContext()");
SpecialInvokeExpr virtInvExpr = Jimple.v().newSpecialInvokeExpr(thisLocal, applicationContext.makeRef());
Local applicationContextLocal = generateFreshLocal(body, RefType.v("android.content.Context"));
generated.add(Jimple.v().newAssignStmt(applicationContextLocal, virtInvExpr));
List<Object> args = new ArrayList<Object>();
args.add(RefType.v("android.content.Context"));
args.add(applicationContextLocal);
StaticInvokeExpr staticInvExpr = Instrumentation.createJimpleStaticInvokeExpr(Settings.instance.INSTRUMENTATION_HELPER_JAVA, Settings.instance.INSTRUMENTATION_HELPER_INITIALIZE_METHOD, args);
generated.add(Jimple.v().newInvokeStmt(staticInvExpr));
Unit onCreateSpecialInvoke = getSuperOnCreateUnit(body);
if(onCreateSpecialInvoke == null)
throw new RuntimeException("error: super.onCreate() statement missing in method "+ onCreate);
body.getUnits().insertAfter(generated, onCreateSpecialInvoke);
}
}
示例14: caseStaticInvokeExpr
import soot.jimple.StaticInvokeExpr; //导入依赖的package包/类
@Override
public void caseStaticInvokeExpr(StaticInvokeExpr v) {
SootClass sootClass = v.getMethod().getDeclaringClass();
handleStatic(sootClass);
handleInvoke(v);
addProgramCounterConstraint(sootClass.getName());
}
示例15: detectValueCastFromStmt
import soot.jimple.StaticInvokeExpr; //导入依赖的package包/类
public Option<ValueCast<Level>> detectValueCastFromStmt(Stmt s) throws TypingException {
if (s.containsInvokeExpr()) {
InvokeExpr e = s.getInvokeExpr();
if (e instanceof StaticInvokeExpr) {
Try<Option<ValueCast<Level>>> result = this.detectValueCastFromCall((StaticInvokeExpr) e);
if (result.isSuccess()) {
return result.get();
} else {
throw new TypingException(result.failed().get().getMessage());
}
}
}
return Option.empty();
}