public Set<SootMethod> methodInvokeMethods(SootMethod container) { Set<SootMethod> result = new LinkedHashSet<SootMethod>(); for (String signature : methodInvokeSignatures(container)) { result.add(Scene.v().getMethod(signature)); } return result; }
public Set<SootMethod> constructorNewInstanceConstructors(SootMethod container) { Set<SootMethod> result = new LinkedHashSet<SootMethod>(); for (String signature : constructorNewInstanceSignatures(container)) { result.add(Scene.v().getMethod(signature)); } return result; }
protected void addMethod(List<SootMethod> set, String methodSig) { if (Scene.v().containsMethod(methodSig)) { set.add(Scene.v().getMethod(methodSig)); } }
/** * Adds a special edge of kind {@link Kind#REFL_INVOKE} to all possible target methods of this call to * {@link Method#invoke(Object, Object...)}. Those kinds of edges are treated specially in terms of how parameters are * assigned, as parameters to the reflective call are passed into the argument array of * {@link Method#invoke(Object, Object...)}. * * @see PAG#addCallTarget(Edge) */ @Override public void methodInvoke(SootMethod container, Stmt invokeStmt) { Set<String> methodSignatures = reflectionInfo.methodInvokeSignatures(container); if (methodSignatures == null || methodSignatures.isEmpty()) { registerGuard(container, invokeStmt, "Method.invoke(..) call site; Soot did not expect this site to be reached"); } else { for (String methodSignature : methodSignatures) { SootMethod method = Scene.v().getMethod(methodSignature); addEdge(container, invokeStmt, method, Kind.REFL_INVOKE); } } }
/** * Adds a special edge of kind {@link Kind#REFL_CONSTR_NEWINSTANCE} to all possible target constructors of this call to * {@link Constructor#newInstance(Object...)}. Those kinds of edges are treated specially in terms of how parameters are * assigned, as parameters to the reflective call are passed into the argument array of * {@link Constructor#newInstance(Object...)}. * * @see PAG#addCallTarget(Edge) */ @Override public void contructorNewInstance(SootMethod container, Stmt newInstanceInvokeStmt) { Set<String> constructorSignatures = reflectionInfo.constructorNewInstanceSignatures(container); if (constructorSignatures == null || constructorSignatures.isEmpty()) { registerGuard(container, newInstanceInvokeStmt, "Constructor.newInstance(..) call site; Soot did not expect this site to be reached"); } else { for (String constructorSignature : constructorSignatures) { SootMethod constructor = Scene.v().getMethod(constructorSignature); addEdge(container, newInstanceInvokeStmt, constructor, Kind.REFL_CONSTR_NEWINSTANCE); } } }
static Stmt addThrowAfter(JimpleBody b, Stmt target) { Chain<Unit> units = b.getUnits(); Collection<Local> locals = b.getLocals(); int i = 0; // Bah! boolean canAddI = false; do { canAddI = true; Iterator<Local> localIt = locals.iterator(); while (localIt.hasNext()) { Local l = (Local) localIt.next(); if (l.getName().equals("__throwee" + i)) { canAddI = false; } } if (!canAddI) { i++; } } while (!canAddI); Local l = Jimple.v().newLocal("__throwee" + i, RefType.v("java.lang.NullPointerException")); b.getLocals().add(l); Stmt newStmt = Jimple.v().newAssignStmt(l, Jimple.v().newNewExpr(RefType.v("java.lang.NullPointerException"))); Stmt invStmt = Jimple.v().newInvokeStmt(Jimple.v().newSpecialInvokeExpr(l, Scene.v().getMethod("<java.lang.NullPointerException: void <init>()>").makeRef())); Stmt throwStmt = Jimple.v().newThrowStmt(l); units.insertAfter(newStmt, target); units.insertAfter(invStmt, newStmt); units.insertAfter(throwStmt, invStmt); return newStmt; }
Jimple.v().newStaticFieldRef(Scene.v().getField("<java.lang.System: java.io.PrintStream out>").makeRef()))); SootMethod toCall = Scene.v().getMethod("<java.lang.Thread: void dumpStack()>"); list.add(Jimple.v().newInvokeStmt(Jimple.v().newStaticInvokeExpr(toCall.makeRef()))); toCall = Scene.v().getMethod("<java.io.PrintStream: void println(java.lang.String)>"); list.add(Jimple.v().newInvokeStmt(Jimple.v().newVirtualInvokeExpr(tmpRef, toCall.makeRef(), StringConstant.v("Executing supposedly unreachable method:")))); StringConstant.v("\t" + method.getDeclaringClass().getName() + "." + method.getName())))); toCall = Scene.v().getMethod("<java.lang.System: void exit(int)>"); list.add(Jimple.v().newInvokeStmt(Jimple.v().newStaticInvokeExpr(toCall.makeRef(), IntConstant.v(1))));
.newInvokeStmt(Jimple.v() .newStaticInvokeExpr(Scene.v() .getMethod("<soot.rtlib.tamiflex.ReflectiveCalls: void knownClassForName(int,java.lang.String)>") .makeRef(), IntConstant.v(callSiteId), classNameValue))); } else if (callKind == Kind.ClassNewInstance .newInvokeStmt(Jimple.v() .newStaticInvokeExpr(Scene.v() .getMethod("<soot.rtlib.tamiflex.ReflectiveCalls: void knownClassNewInstance(int,java.lang.Class)>") .makeRef(), IntConstant.v(callSiteId), classLocal))); } else if (callKind == Kind.ConstructorNewInstance && ie.getMethodRef().getSignature() found = true; Local constrLocal = (Local) ((InstanceInvokeExpr) ie).getBase(); newUnits.add(Jimple.v().newInvokeStmt(Jimple.v().newStaticInvokeExpr(Scene.v().getMethod( "<soot.rtlib.tamiflex.ReflectiveCalls: void knownConstructorNewInstance(int,java.lang.reflect.Constructor)>") .makeRef(), IntConstant.v(callSiteId), constrLocal))); Local methodLocal = (Local) ((InstanceInvokeExpr) ie).getBase(); Value recv = ie.getArg(0); newUnits.add(Jimple.v().newInvokeStmt(Jimple.v().newStaticInvokeExpr(Scene.v().getMethod( "<soot.rtlib.tamiflex.ReflectiveCalls: void knownMethodInvoke(int,java.lang.Object,java.lang.reflect.Method)>") .makeRef(), IntConstant.v(callSiteId), recv, methodLocal))); newUnits.add(Jimple.v().newInvokeStmt(Jimple.v().newStaticInvokeExpr(Scene.v().getMethod( "<soot.rtlib.tamiflex.ReflectiveCalls: void knownFieldSet(int,java.lang.Object,java.lang.reflect.Field)>") .makeRef(), IntConstant.v(callSiteId), recv, field))); newUnits.add(Jimple.v().newInvokeStmt(Jimple.v().newStaticInvokeExpr(Scene.v().getMethod(
/** * @ast method * @aspect Expressions * @declaredat /Users/eric/Documents/workspaces/clara-soot/JastAddExtensions/JimpleBackend/Expressions.jrag:557 */ private soot.Value emitInnerMemberEnclosing(Body b, TypeDecl innerClass) { if(hasPrevExpr()) { Local base = asLocal(b, prevExpr().eval(b)); b.setLine(this); b.add(b.newInvokeStmt( b.newVirtualInvokeExpr( base, Scene.v().getMethod("<java.lang.Object: java.lang.Class getClass()>").makeRef(), this ), this )); return base; } else { TypeDecl enclosing = hostType(); while(!enclosing.hasType(innerClass.name())) enclosing = enclosing.enclosingType(); return emitThis(b, enclosing); } } /**
SootMethod constructor = Scene.v().getMethod(target); paramLocals = new Local[constructor.getParameterCount()]; if (constructor.getParameterCount() > 0) { SootMethod method = Scene.v().getMethod(target); SootMethod constructor = Scene.v().getMethod(target); SpecialInvokeExpr constrCallExpr = Jimple.v().newSpecialInvokeExpr(freshLocal, constructor.makeRef(), Arrays.asList(paramLocals)); SootMethod method = Scene.v().getMethod(target); InvokeExpr invokeExpr; if (method.isStatic()) {
units.add(asi = Jimple.v().newAssignStmt(l_r2, Jimple.v().newStaticInvokeExpr( Scene.v().getMethod("<java.lang.Class: java.lang.Class" + " forName(java.lang.String)>").makeRef(), Arrays.asList(new Value[] { l_r0 })))); Scene.v().getMethod("<java.lang.Throwable: java.lang.String getMessage()>").makeRef(), new LinkedList()))); Scene.v().getMethod("<java.lang.NoClassDefFoundError: void" + " <init>(java.lang.String)>").makeRef(), Arrays.asList(new Value[] { l_r5 }))));
public Set<SootMethod> methodInvokeMethods(SootMethod container) { Set<SootMethod> result = new LinkedHashSet<SootMethod>(); for(String signature: methodInvokeSignatures(container)) { result.add(Scene.v().getMethod(signature)); } return result; }
public Set<SootMethod> constructorNewInstanceConstructors(SootMethod container) { Set<SootMethod> result = new LinkedHashSet<SootMethod>(); for(String signature: constructorNewInstanceSignatures(container)) { result.add(Scene.v().getMethod(signature)); } return result; }
public Set<SootMethod> constructorNewInstanceConstructors(SootMethod container) { Set<SootMethod> result = new LinkedHashSet<SootMethod>(); for(String signature: constructorNewInstanceSignatures(container)) { result.add(Scene.v().getMethod(signature)); } return result; }
public Set<SootMethod> methodInvokeMethods(SootMethod container) { Set<SootMethod> result = new LinkedHashSet<SootMethod>(); for(String signature: methodInvokeSignatures(container)) { result.add(Scene.v().getMethod(signature)); } return result; }
private final void addMethod( List<SootMethod> set, String methodSig ) { if( Scene.v().containsMethod( methodSig ) ) { set.add( Scene.v().getMethod( methodSig ) ); } } /** Returns only the application entry points, not including entry points
private final void addMethod( List<SootMethod> set, String methodSig ) { if( Scene.v().containsMethod( methodSig ) ) { set.add( Scene.v().getMethod( methodSig ) ); } } /** Returns only the application entry points, not including entry points
private boolean isMethodToSummarize(SootMethod currentMethod) { // Initialize the method we are interested in if (method == null) method = Scene.v().getMethod(methodSig); // This must either be the method defined by signature or the // corresponding one in the parent class if (currentMethod == method) return true; return parentClass != null && currentMethod.getDeclaringClass().getName().equals(parentClass) && currentMethod.getSubSignature().equals(method.getSubSignature()); }