/** * Adds the given field to this class. */ public void addField(SootField f) { checkLevel(SIGNATURES); if (f.isDeclared()) { throw new RuntimeException("already declared: " + f.getName()); } if (declaresField(f.getName(), f.getType())) { throw new RuntimeException("Field already exists : " + f.getName() + " of type " + f.getType()); } if (fields == null) { fields = new HashChain<>(); } fields.add(f); f.setDeclared(true); f.setDeclaringClass(this); }
soot.Local sootLocal = localsMap.get(new polyglot.util.IdentityKey(li)); return sootLocal; } else if (body.getMethod().getDeclaringClass().declaresField("val$" + li.name(), Util.getSootType(li.type()))) { soot.Local fieldLocal = generateLocal(li.type()); soot.SootFieldRef field = soot.Scene.v().makeFieldRef(body.getMethod().getDeclaringClass(), "val$" + li.name(), if (outerClass.declaresField("val$" + li.name(), Util.getSootType(li.type()))) { fieldFound = true;
/** * Loads a single field from a dex file * * @param declaringClass * The class that declares the method to load * @param annotations * The worker object for handling annotations * @param field * The field to load */ protected void loadField(SootClass declaringClass, DexAnnotation annotations, Field sf) { if (declaringClass.declaresField(sf.getName(), DexType.toSoot(sf.getType()))) { return; } SootField sootField = DexField.makeSootField(sf); sootField = declaringClass.getOrAddField(sootField); annotations.handleFieldAnnotation(sootField, sf); }
while (it.hasNext()) { polyglot.types.LocalInstance li2 = (polyglot.types.LocalInstance) it.next().object(); if (!sootClass.declaresField("val$" + li2.name(), Util.getSootType(li2.type()))) { if (!luc.getLocalDecls().contains(new polyglot.util.IdentityKey(li2))) { addFinals(li2, finalFields); while (it.hasNext()) { polyglot.types.LocalInstance li2 = (polyglot.types.LocalInstance) it.next().object(); if (!sootClass.declaresField("val$" + li2.name(), Util.getSootType(li2.type()))) { if (!luc.getLocalDecls().contains(new polyglot.util.IdentityKey(li2))) { addFinals(li2, finalFields);
if (!addToClass.declaresField(fieldName, fieldType)) { addToClass.addField(sootField); sootField.addTag(new soot.tagkit.SyntheticTag());
if (!sootClass.declaresField(fieldName, fieldType)) { soot.SootField assertionsDisabledField = Scene.v().makeSootField(fieldName, fieldType, soot.Modifier.STATIC | soot.Modifier.FINAL); if (!addToClass.declaresField(fieldName, fieldType)) { soot.SootField classField = Scene.v().makeSootField(fieldName, fieldType, soot.Modifier.STATIC); addToClass.addField(classField);
public void checkAndSwitch(ValueBox valBox) { Value val = valBox.getValue(); Object finalField = check(val); if (finalField != null) { // System.out.println("Final field with this value exists"+finalField); /* * If the final field belongs to the same class then we should supress declaring class */ SootField field = (SootField) finalField; if (sootClass.declaresField(field.getName(), field.getType())) { // this field is of this class so supress the declaring class if (valBox.canContainValue(new DStaticFieldRef(field.makeRef(), true))) { valBox.setValue(new DStaticFieldRef(field.makeRef(), true)); } } else { if (valBox.canContainValue(new DStaticFieldRef(field.makeRef(), true))) { valBox.setValue(new DStaticFieldRef(field.makeRef(), false)); } } } // else // System.out.println("Final field not found"); }
/** Adds the given field to this class. */ public void addField(SootField f) { checkLevel(SIGNATURES); if(f.isDeclared()) throw new RuntimeException("already declared: "+f.getName()); if(declaresField(f.getName())) throw new RuntimeException("Field already exists : "+f.getName()); fields.add(f); f.isDeclared = true; f.declaringClass = this; }
/** Adds the given field to this class. */ public void addField(SootField f) { checkLevel(SIGNATURES); if(f.isDeclared()) throw new RuntimeException("already declared: "+f.getName()); if(declaresField(f.getName())) throw new RuntimeException("Field already exists : "+f.getName()); fields.add(f); f.isDeclared = true; f.declaringClass = this; }
public SootField getMessageForIPCField() { SootClass sc = iccLink.fromSM.getDeclaringClass(); if (!sc.declaresField("message_for_ipc_static", RefType.v("android.os.Messenge"))) { fieldSendingMessage(iccLink.fromSM); } return sc.getFieldByName("message_for_ipc_static"); }
private SootField grabField(String fieldSignature) { String cname = signatureToClass( fieldSignature ); String fname = signatureToSubsignature( fieldSignature ); if( !containsClass(cname) ) return null; SootClass c = getSootClass(cname); if( !c.declaresField( fname ) ) return null; return c.getField( fname ); }
private SootField grabField(String fieldSignature) { String cname = signatureToClass( fieldSignature ); String fname = signatureToSubsignature( fieldSignature ); if( !containsClass(cname) ) return null; SootClass c = getSootClass(cname); if( !c.declaresField( fname ) ) return null; return c.getField( fname ); }
if(trace != null) trace.append( "Looking in "+cl+" which has fields "+cl.getFields()+"\n" ); if( cl.declaresField(name, type) ) { return checkStatic(cl.getField(name, type)); if(trace != null) trace.append( "Looking in "+iface+" which has fields "+iface.getFields()+"\n" ); if( iface.declaresField(name, type) ) { return checkStatic(iface.getField( name, type ));
if(trace != null) trace.append( "Looking in "+cl+" which has fields "+cl.getFields()+"\n" ); if( cl.declaresField(name, type) ) { return checkStatic(cl.getField(name, type)); if(trace != null) trace.append( "Looking in "+iface+" which has fields "+iface.getFields()+"\n" ); if( iface.declaresField(name, type) ) { return checkStatic(iface.getField( name, type ));
if (sc.declaresField(s)) { sc.removeField(sc.getFieldByName(s));
public void fieldSendingMessage(SootMethod fromSM) { SootClass fromC = fromSM.getDeclaringClass(); if (fromC.declaresField("message_for_ipc_static", RefType.v("android.os.Message"))) { return; } int m = Modifier.PUBLIC | Modifier.STATIC; SootField sf = Scene.v().makeSootField("message_for_ipc_static", RefType.v("android.os.Message"), m); fromC.addField(sf); for (SootMethod sm : fromC.getMethods()) { if (sm.isConcrete()) { Body body = sm.retrieveActiveBody(); PatchingChain<Unit> units = body.getUnits(); for (Iterator<Unit> iter = units.snapshotIterator(); iter.hasNext();) { Stmt stmt = (Stmt) iter.next(); if (stmt.containsInvokeExpr()) { SootMethod toBeCheckedMethod = stmt.getInvokeExpr().getMethod(); if (toBeCheckedMethod.getName().equals("send") && equalsOrSubclassOf(toBeCheckedMethod.getDeclaringClass(), Scene.v().getSootClass("android.os.Messenger"))) { Value arg0 = stmt.getInvokeExpr().getArg(0); Unit assignUnit = Jimple.v().newAssignStmt(Jimple.v().newStaticFieldRef(sf.makeRef()), arg0); units.insertBefore(assignUnit, stmt); } } } } } }