[Soot-list] Change method parameters in Android

Benedikt Lesch solidus0815 at gmail.com
Sun Dec 8 13:59:14 EST 2013


Hey,
i want to change the parameters of an Android Log.d() method with soot but
I always get the following error "no defs for value: tmpString!"
how do i create such a definition?

this is my code so far

public static void main(String[] args) {
PackManager.v().getPack("jtp").add(new Transform("jtp.myInstrumenter", new
BodyTransformer() {

@Override
protected void internalTransform(final Body b, String phaseName, @
SuppressWarnings("rawtypes") Map options) {
Iterator<Unit> iter = b.getUnits().snapshotIterator();
while (iter.hasNext()) {
Stmt s = (Stmt) iter.next();
if (s.containsInvokeExpr()) {
SootMethod method = s.getInvokeExpr().getMethod();
String declaringClass = s.getInvokeExpr().getMethod().getDeclaringClass().
getName();
if (declaringClass.equals("android.util.Log") && method.getName().equals("d"))
{
s.getInvokeExpr().setArg(0, addTmpString(b));
}
}

}
}
}));
soot.Main
.main(new String[] { "-allow-phantom-refs",
"-validate",
"-output-format", "dex", "-process-dir", "path to apk",
"-force-android-jar",
"*****/android.jar", "-src-prec", "apk", "-cp",
"*****/android.jar" });

}

private static Local addTmpString(Body body) {
Local tmpString = Jimple.v().newLocal("tmpString", RefType.v("java.lang
.String"));
body.getLocals().add(tmpString);
return tmpString;
}


Thanks for your help.
Solidus
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.cs.mcgill.ca/pipermail/soot-list/attachments/20131208/c6664389/attachment.html 


More information about the Soot-list mailing list