public SootMethod makeSootMethod(String name, List<Type> parameterTypes, Type returnType) { return new SootMethod(name, parameterTypes, returnType); }
public SootMethod makeSootMethod(String name, List<Type> parameterTypes, Type returnType, int modifiers) { return new SootMethod(name, parameterTypes, returnType, modifiers); }
public SootMethod makeSootMethod(String name, List<Type> parameterTypes, Type returnType, int modifiers, List<SootClass> thrownExceptions) { return new SootMethod(name, parameterTypes, returnType, modifiers, thrownExceptions); }
private void addDispatch(String name, SootClass tclass, MethodType implMethodType, MethodType instantiatedMethodType, List<SootField> capFields, MethodHandle implMethod) { ThunkMethodSource ms = new ThunkMethodSource(capFields, implMethodType, implMethod, instantiatedMethodType); SootMethod m = new SootMethod(name, implMethodType.getParameterTypes(), implMethodType.getReturnType(), Modifier.PUBLIC); tclass.addMethod(m); m.setSource(ms); }
SootMethod tboot = new SootMethod("bootstrap$", capTypes, functionalInterfaceToImplement.getType(), Modifier.PUBLIC | Modifier.STATIC); tclass.addMethod(tboot); SootMethod tctor = new SootMethod("<init>", capTypes, VoidType.v(), Modifier.PUBLIC); tclass.addMethod(tctor); tctor.setSource(ms);
public SootMethod generateDummyMainMethod(List<String> entryPoints, String sootClassName) { SootClass compSootClass = Scene.v().getSootClass(sootClassName); List<SootClass> androidClasses = new ArrayList<>(); androidClasses.add(compSootClass); SootMethod mainMethod = new SootMethod(DUMMY_MAIN_METHOD, new ArrayList<Type>(), VoidType.v(), Modifier.PUBLIC);// | Modifier.STATIC); //no need be static JimpleBody body = Jimple.v().newBody(mainMethod); mainMethod.setActiveBody(body); compSootClass.addMethod(mainMethod); //this is mandatory, the default dummyMainMethod is static, so they //do not deal thisIdentity. since we don't need static dummyMainMethod, //we should define it explicit body.insertIdentityStmts(); MultiMap<SootClass, SootMethod> callbackFunctions = new HashMultiMap<>(); callbackFunctions.putAll(compSootClass, getCallbackFunctions(compSootClass)); AndroidEntryPointCreator androidEPCreator = new AndroidEntryPointCreator(androidClasses); androidEPCreator.setCallbackFunctions(callbackFunctions); return androidEPCreator.createDummyMain(mainMethod); }
staticInit = new SootMethod(SootMethod.staticInitializerName, new LinkedList<soot.Type>(), VoidType.v(), Modifier.STATIC | Modifier.PUBLIC); JimpleBody body = Jimple.v().newBody(staticInit);
/** * Get a method that returns an unknown value of type t. * * @param t * @return */ public SootMethod getHavocMethod(soot.Type t) { if (!Scene.v().containsClass(HavocClassName)) { SootClass sClass = new SootClass(HavocClassName, Modifier.PUBLIC | Modifier.PUBLIC); sClass.setSuperclass(Scene.v().getSootClass("java.lang.Object")); sClass.setResolvingLevel(SootClass.SIGNATURES); Scene.v().addClass(sClass); } SootClass cls = Scene.v().getSootClass(HavocClassName); final String havocMethodName = HavocMethodName + t.toString(); if (!cls.declaresMethodByName(havocMethodName)) { cls.addMethod(new SootMethod(havocMethodName, Arrays.asList(new Type[] {}), t, Modifier.PUBLIC | Modifier.STATIC)); } return cls.getMethodByName("havoc_" + t.toString()); }
SootMethod internalAssertMethod = new SootMethod(assertionProcedureName, Arrays.asList(new Type[] { BooleanType.v() }), VoidType.v(), Modifier.PUBLIC | Modifier.STATIC); sClass.addMethod(internalAssertMethod); body.getUnits().add(Jimple.v().newReturnVoidStmt()); SootMethod staticInitializer = new SootMethod(SootMethod.staticInitializerName, Arrays.asList(new Type[] {}), VoidType.v(), Modifier.PUBLIC | Modifier.STATIC); body = Jimple.v().newBody(staticInitializer);
if(Scene.v().allowsPhantomRefs() && cl.isPhantom()) SootMethod m = new SootMethod(name, parameterTypes, returnType, isStatic()?Modifier.STATIC:0); m.setPhantom(true); cl.addMethod(m); SootMethod m = new SootMethod(name, parameterTypes, returnType); JimpleBody body = Jimple.v().newBody(m); m.setActiveBody(body);
if(Scene.v().allowsPhantomRefs() && cl.isPhantom()) SootMethod m = new SootMethod(name, parameterTypes, returnType, isStatic()?Modifier.STATIC:0); m.setPhantom(true); cl.addMethod(m); SootMethod m = new SootMethod(name, parameterTypes, returnType); JimpleBody body = Jimple.v().newBody(m); m.setActiveBody(body);
method = new SootMethod(methodName, parameterTypes, returnType, modifiers); bclass.addMethod(method);
method = new SootMethod(methodName, parameterTypes, returnType, modifiers); bclass.addMethod(method);
Type returnType = VoidType.v(); int modifiers = Modifier.PUBLIC; SootMethod newConstructor = new SootMethod(name, parameters, returnType, modifiers); compSootClass.addMethod(newConstructor);
SootMethod constructor = new SootMethod(SootMethod.constructorName, argTypes, VoidType.v(), Modifier.PUBLIC); SootMethod getElement = new SootMethod(arrayGetName, Arrays.asList(new Type[] { IntType.v() }), elementType, Modifier.PUBLIC); arrayClass.addMethod(getElement); SootMethod setElement = new SootMethod(arraySetName, Arrays.asList(new Type[] { IntType.v(), elementType }), VoidType.v(), Modifier.PUBLIC); arrayClass.addMethod(setElement); for (int i = 0; i < numDimensions; i++) { List<Type> argTypes = new ArrayList<Type>(Collections.nCopies(i + 1, IntType.v())); SootMethod constructor = new SootMethod(SootMethod.constructorName, argTypes, VoidType.v(), Modifier.PUBLIC);