<html>
<head>
<meta name="generator" content="Windows Mail 17.5.9600.20856">
<style data-externalstyle="true"><!--
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph {
margin-top:0in;
margin-right:0in;
margin-bottom:0in;
margin-left:.5in;
margin-bottom:.0001pt;
}
p.MsoNormal, li.MsoNormal, div.MsoNormal {
margin:0in;
margin-bottom:.0001pt;
}
p.MsoListParagraphCxSpFirst, li.MsoListParagraphCxSpFirst, div.MsoListParagraphCxSpFirst,
p.MsoListParagraphCxSpMiddle, li.MsoListParagraphCxSpMiddle, div.MsoListParagraphCxSpMiddle,
p.MsoListParagraphCxSpLast, li.MsoListParagraphCxSpLast, div.MsoListParagraphCxSpLast {
margin-top:0in;
margin-right:0in;
margin-bottom:0in;
margin-left:.5in;
margin-bottom:.0001pt;
line-height:115%;
}
--></style></head>
<body dir="ltr">
<div data-externalstyle="false" dir="ltr" style="font-family: 'Calibri', 'Segoe UI', 'Meiryo', 'Microsoft YaHei UI', 'Microsoft JhengHei UI', 'Malgun Gothic', 'sans-serif';font-size:12pt;"><div>Hi,</div><div><br></div><div>I am trying to instrument an APK using soot. As a simple test, I want to re-compile the APK with no / null instrumentation. I am using the VM released at <a href="http://sseblog.ec-spride.de/tutorials/" target="_parent">http://sseblog.ec-spride.de/tutorials/</a></div><div><br></div><div>My instrumentation doesn’t modify any method bodies.</div><div>The code is:</div><div><br></div><div>public class MyBodyTransformer extends BodyTransformer{<br> @Override<br> protected void internalTransform(Body body, String arg0, Map arg1) {</div><div data-signatureblock="true"><div><br></div><div> }<br>}</div><div><br></div><div>When I try the RV2013.apk example (sample provided in the tutorial VM), it works fine. But, when I use a different apk it fails (e.g. the <a href="https://www.dropbox.com/s/qihaunn2qsvi034/foo.apk?dl=0" target="_parent">apk here</a>). The original APK works fine on the Android emulator.</div><div><br></div><div><br></div><div>In the console I see:</div><div>…</div><div>Transforming com.vladium.util.IntObjectMap... </div><div>…</div><div>Exception in thread "main" java.lang.RuntimeException: (<com.vladium.util.IntObjectMap: java.lang.Object put(int,java.lang.Object)>) no defs for value: $r5!</div><div>…</div><div> at soot.Body.validateUses(Body.java:365)<br> at soot.Body.validate(Body.java:234)<br> at soot.jimple.JimpleBody.validate(JimpleBody.java:71)<br> at soot.PackManager.runBodyPacks(PackManager.java:903)<br> at soot.PackManager.runBodyPacks(PackManager.java:585)<br> at soot.PackManager.runBodyPacks(PackManager.java:487)<br> at soot.PackManager.runPacksNormally(PackManager.java:464)<br> at soot.PackManager.runPacks(PackManager.java:388)<br> at instrumentation.Main.main(Main.java:12)<br></div><div><br></div><div><br></div><div>The options I provide are the same as the one that work for the sample APK:</div><div><br></div><div style="margin-right: 0px;" dir="ltr"><font face="Arial" style="font-size: 12pt;">public class Settings {</font><br><font face="Arial" style="font-size: 12pt;"> private static boolean SOOT_INITIALIZED = false;</font><br><font face="Arial" style="font-size: 12pt;"> private final static String TOAST_CLASS = "android.widget.Toast";</font><br><font face="Arial" style="font-size: 12pt;"> private final static String androidJAR = "./lib/android.jar";</font><br><font face="Arial" style="font-size: 12pt;"> private final static String apk = "./apk/foo.apk";</font><br><font face="Arial" style="font-size: 12pt;"> </font><br><font face="Arial" style="font-size: 12pt;"> public static void initialiseSoot(){</font><br><font face="Arial" style="font-size: 12pt;"> if (SOOT_INITIALIZED)</font><br><font face="Arial" style="font-size: 12pt;"> return;</font><br><font face="Arial" style="font-size: 12pt;"> G.reset();</font><br><font face="Arial" style="font-size: 12pt;"> </font><br><font face="Arial" style="font-size: 12pt;"> Options.v().set_allow_phantom_refs(true);</font><br><font face="Arial" style="font-size: 12pt;"> Options.v().set_prepend_classpath(true);</font><br><font face="Arial" style="font-size: 12pt;"> Options.v().set_validate(true)</font><br><font face="Arial" style="font-size: 12pt;"> Options.v().set_output_format(Options.output_format_dex);</font><br><font face="Arial" style="font-size: 12pt;"> Options.v().set_process_dir(Collections.singletonList(apk));</font><br><font face="Arial" style="font-size: 12pt;"> Options.v().set_force_android_jar(androidJAR);</font><br><font face="Arial" style="font-size: 12pt;"> Options.v().set_src_prec(Options.src_prec_apk);</font><br></div><div style="margin-right: 0px;" dir="ltr"><font face="Arial" style="font-size: 12pt;"> Options.v().set_soot_classpath(androidJAR);</font><br><font face="Arial" style="font-size: 12pt;"> Scene.v().loadNecessaryClasses();</font><br><font face="Arial" style="font-size: 12pt;"> Scene.v().forceResolve(TOAST_CLASS, SootClass.BODIES);</font><br></div><div><br></div><div style="margin-right: 0px;" dir="ltr"><font face="Arial" style="font-size: 12pt;"> SOOT_INITIALIZED = true;</font><br> }</div><div style="margin-right: 0px;" dir="ltr"><br></div><div>Could you please help?</div><div><br></div><div>Thanks,</div><div><br></div><div>-- Prateek.</div><div><br></div><div><br></div></div></div>
</body>
</html>