/** * Returns a (possibly not yet resolved) SootClass to be used in references to a class. If/when the class is resolved, it * will be resolved into this SootClass. */ public SootClass makeClassRef(String className) { if (Scene.v().containsClass(className)) { return Scene.v().getSootClass(className); } SootClass newClass; newClass = new SootClass(className); newClass.setResolvingLevel(SootClass.DANGLING); Scene.v().addClass(newClass); return newClass; }
Scene.v().addClass(tclass); if (enclosingClass.isApplicationClass()) { tclass.setApplicationClass();
public MonitorConverter(Singletons.Global g) { SootClass davaMonitor = new SootClass("soot.dava.toolkits.base.DavaMonitor.DavaMonitor", Modifier.PUBLIC); davaMonitor.setSuperclass(Scene.v().loadClassAndSupport("java.lang.Object")); LinkedList objectSingleton = new LinkedList(); objectSingleton.add(RefType.v("java.lang.Object")); v = Scene.v().makeSootMethod("v", new LinkedList(), RefType.v("soot.dava.toolkits.base.DavaMonitor.DavaMonitor"), Modifier.PUBLIC | Modifier.STATIC); enter = Scene.v().makeSootMethod("enter", objectSingleton, VoidType.v(), Modifier.PUBLIC | Modifier.SYNCHRONIZED); exit = Scene.v().makeSootMethod("exit", objectSingleton, VoidType.v(), Modifier.PUBLIC | Modifier.SYNCHRONIZED); davaMonitor.addMethod(v); davaMonitor.addMethod(enter); davaMonitor.addMethod(exit); Scene.v().addClass(davaMonitor); }
private soot.SootClass getSpecialInterfaceAnonClass(soot.SootClass addToClass) { // check to see if there is already a special anon class for this // interface if ((InitialResolver.v().specialAnonMap() != null) && (InitialResolver.v().specialAnonMap().containsKey(addToClass))) { return InitialResolver.v().specialAnonMap().get(addToClass); } else { String specialClassName = addToClass.getName() + "$" + InitialResolver.v().getNextAnonNum(); // add class to scene and other maps and lists as needed soot.SootClass specialClass = new soot.SootClass(specialClassName); soot.Scene.v().addClass(specialClass); specialClass.setApplicationClass(); specialClass.addTag(new soot.tagkit.SyntheticTag()); specialClass.setSuperclass(soot.Scene.v().getSootClass("java.lang.Object")); Util.addInnerClassTag(addToClass, specialClass.getName(), addToClass.getName(), null, soot.Modifier.STATIC); Util.addInnerClassTag(specialClass, specialClass.getName(), addToClass.getName(), null, soot.Modifier.STATIC); InitialResolver.v().addNameToAST(specialClassName); references.add(RefType.v(specialClassName)); if (InitialResolver.v().specialAnonMap() == null) { InitialResolver.v().setSpecialAnonMap(new HashMap<SootClass, SootClass>()); } InitialResolver.v().specialAnonMap().put(addToClass, specialClass); return specialClass; } }
/** * @apilevel internal */ private SootClass sootClass_compute() { if(!Scene.v().isIncrementalBuild()) { return refined_EmitJimpleRefinements_ClassDecl_sootClass(); } if(Scene.v().containsClass(jvmName())) { Scene.v().removeClass(Scene.v().getSootClass(jvmName())); } SootClass sc = null; if(options().verbose()) System.out.println("Creating from source " + jvmName()); sc = new SootClass(jvmName()); sc.setResolvingLevel(SootClass.DANGLING); Scene.v().addClass(sc); return sc; } /**
sc = new SootClass(jvmName()); sc.setResolvingLevel(SootClass.DANGLING); Scene.v().addClass(sc);
Scene.v().addClass(reflectiveCallsClass); reflectiveCallsClass.setApplicationClass();
mediatingClass.setSuperclass(originalSuperclass); Scene.v().addClass(mediatingClass); mediatingClass.setApplicationClass(); mediatingClass.setInScene(true);
/** * Returns the SootClass with the given className. */ public SootClass getSootClass(String className) { RefType type = (RefType) nameToClass.get(className); SootClass toReturn = null; if (type != null) toReturn = type.getSootClass(); if (toReturn != null) { return toReturn; } else if (allowsPhantomRefs() || className.equals(SootClass.INVOKEDYNAMIC_DUMMY_CLASS_NAME)) { SootClass c = new SootClass(className); c.setPhantom(true); addClass(c); return c; } else { throw new RuntimeException(System.getProperty("line.separator") + "Aborting: can't find classfile " + className); } }
/** * Returns the SootClass with the given className. */ public SootClass getSootClass(String className) { RefType type = (RefType) nameToClass.get(className); SootClass toReturn = null; if (type != null) toReturn = type.getSootClass(); if (toReturn != null) { return toReturn; } else if (allowsPhantomRefs() || className.equals(SootClass.INVOKEDYNAMIC_DUMMY_CLASS_NAME)) { SootClass c = new SootClass(className); c.setPhantom(true); addClass(c); return c; } else { throw new RuntimeException(System.getProperty("line.separator") + "Aborting: can't find classfile " + className); } }
/** Returns a (possibly not yet resolved) SootClass to be used in references * to a class. If/when the class is resolved, it will be resolved into this * SootClass. * */ public SootClass makeClassRef(String className) { if(Scene.v().containsClass(className)) return Scene.v().getSootClass(className); SootClass newClass; newClass = new SootClass(className); newClass.setResolvingLevel(SootClass.DANGLING); Scene.v().addClass(newClass); return newClass; }
/** Returns a (possibly not yet resolved) SootClass to be used in references * to a class. If/when the class is resolved, it will be resolved into this * SootClass. * */ public SootClass makeClassRef(String className) { if(Scene.v().containsClass(className)) return Scene.v().getSootClass(className); SootClass newClass; newClass = new SootClass(className); newClass.setResolvingLevel(SootClass.DANGLING); Scene.v().addClass(newClass); return newClass; }
/** * Creates the main method based on the current callback information, injects it * into the Soot scene. * * @param The class name of a component to create a main method containing only * that component, or null to create main method for all components */ private void createMainMethod(SootClass component) { // There is no need to create a main method if we don't want to generate // a callgraph if (config.getSootIntegrationMode() == SootIntegrationMode.UseExistingCallgraph) return; // Always update the entry point creator to reflect the newest set // of callback methods entryPointCreator = createEntryPointCreator(component); SootMethod dummyMainMethod = entryPointCreator.createDummyMain(); Scene.v().setEntryPoints(Collections.singletonList(dummyMainMethod)); if (!dummyMainMethod.getDeclaringClass().isInScene()) Scene.v().addClass(dummyMainMethod.getDeclaringClass()); // addClass() declares the given class as a library class. We need to // fix this. dummyMainMethod.getDeclaringClass().setApplicationClass(); }
/** * Loads the class with the given name into the scene. This makes sure that * there is at least a phantom class with the given name * * @param className The name of the class to load */ private void loadClass(String className) { SootClass sc = Scene.v().getSootClassUnsafe(className); if (sc == null) { sc = Scene.v().makeSootClass(className); sc.setPhantomClass(); Scene.v().addClass(sc); } else if (sc.resolvingLevel() < SootClass.HIERARCHY) Scene.v().forceResolve(className, SootClass.HIERARCHY); }
/** * 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()); }
sClass.addMethod(staticInitializer); Scene.v().addClass(sClass); sClass.setApplicationClass();
/** * return the ApplicationHolder class (created if needed) This is a class with 1 * static field to save the application instance in */ public static SootClass createOrGetApplicationHolder() { SootClass scApplication = Scene.v().getSootClassUnsafe("android.app.Application"); if (scApplication == null || scApplication.resolvingLevel() < SootClass.SIGNATURES) return null; String applicationHolderClassName = "il.ac.tau.MyApplicationHolder"; SootClass scApplicationHolder; if (!Scene.v().containsClass(applicationHolderClassName)) { scApplicationHolder = Scene.v().makeSootClass(applicationHolderClassName, Modifier.PUBLIC); scApplicationHolder.setSuperclass(Scene.v().getSootClass("java.lang.Object")); Scene.v().addClass(scApplicationHolder); scApplicationHolder.addField( Scene.v().makeSootField("application", scApplication.getType(), Modifier.PUBLIC | Modifier.STATIC)); scApplicationHolder.validate(); } else { scApplicationHolder = Scene.v().getSootClassUnsafe(applicationHolderClassName); } return scApplicationHolder; }
exceptionClass = Scene.v().makeSootClass("FLOWDROID_EXCEPTIONS", Modifier.PUBLIC); exceptionClass.setSuperclass(Scene.v().getSootClass("java.lang.Object")); Scene.v().addClass(exceptionClass);
mainClass = Scene.v().makeSootClass(dummyClassName); mainClass.setResolvingLevel(SootClass.BODIES); Scene.v().addClass(mainClass);
private void createBytecodeFlowSensitivityTest1() { SootClass testClass = new SootClass("TestClass"); Scene.v().addClass(testClass); testClass.setApplicationClass();