[Soot-list] Change method parameters in Android

Patrick Lam plam at sable.mcgill.ca
Thu Dec 12 13:14:11 EST 2013


Hi Benedikt,

You'll need to add another statement to the Body, say near the 
beginning, which initializes the tmpString variable you created to "null".

Your code, after that change, will also be correct but confusing, 
because you'll have multiple Locals all called "tmpString". Jimple can 
handle that, but any human readers will not be able to disambiguate the 
different tmpString variables.

pat

On 08/12/13 01:59 PM, Benedikt Lesch wrote:
> 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
>
>
> _______________________________________________
> Soot-list mailing list
> Soot-list at sable.mcgill.ca
> http://mailman.cs.mcgill.ca/mailman/listinfo/soot-list
>



More information about the Soot-list mailing list