[Soot-list] can't find method when I use sootclass.getmethod
Jin Li
lijin1988 at gmail.com
Mon Jun 2 08:59:06 EDT 2014
Hi Steven,
Follow your advice, I set the Soot classpath using "-soot-classpath . "
the fisrt exception is solved, but I enconter another exception,
Exception in thread "main" java.lang.RuntimeException: tried to get
nonexistent field <java.lang.System: java.io.PrintStream out>
at soot.Scene.getField(Scene.java:606)
at AndroidInstrument$1$1.caseInvokeStmt(AndroidInstrument.java:72)
at soot.jimple.internal.JInvokeStmt.apply(JInvokeStmt.java:100)
at AndroidInstrument$1.internalTransform(AndroidInstrument.java:62)
at soot.BodyTransformer.transform(BodyTransformer.java:51)
at soot.Transform.apply(Transform.java:105)
at soot.BodyPack.internalApply(BodyPack.java:49)
at soot.Pack.apply(Pack.java:126)
at soot.PackManager.runBodyPacks(PackManager.java:899)
at soot.PackManager.runBodyPacks(PackManager.java:584)
at soot.PackManager.runBodyPacks(PackManager.java:487)
at soot.PackManager.runPacksNormally(PackManager.java:464)
at soot.PackManager.runPacks(PackManager.java:388)
at soot.Main.run(Main.java:203)
at soot.Main.main(Main.java:146)
at AndroidInstrument.main(AndroidInstrument.java:105)
the exception cast from this line:
units.insertBefore(Jimple.v().newAssignStmt(
tmpRef,
Jimple.v().newStaticFieldRef(
Scene.v().getField("<java.lang.System: java.io.PrintStream
out>").makeRef())), u);
2014-06-02 18:24 GMT+08:00 Steven Arzt <Steven.Arzt at cased.de>:
> Hi Jin,
>
>
>
> Please first check whether your class object getIdsClass is phantom (field
> isPhantom). If so, Soot was unable to find it on its classpath and has
> replaced it by a so-called phantom which is essentially an empty mockup. If
> this is the case, you need to check your Soot classpath. Otherwise, check
> the method list contained in the class object in the debugger to see
> whether your methods are there or not.
>
>
>
> Best regards,
>
> Steven
>
>
>
> *Von:* soot-list-bounces at CS.McGill.CA [mailto:
> soot-list-bounces at CS.McGill.CA] *Im Auftrag von *Jin Li
> *Gesendet:* Montag, 2. Juni 2014 12:19
> *An:* soot-list at CS.McGill.CA
> *Betreff:* [Soot-list] can't find method when I use sootclass.getmethod
>
>
>
>
> Hi All,
>
> I am a beginner of soot. I want to instrument the android apk. I read
> about the blog "
> http://www.bodden.de/2013/01/08/soot-android-instrumentation/ " . I want
> to print uid,pid,tid if the target of invocation is onDraw().
>
> I wote a helper class:
>
> import android.os.Process;
> public class ThreadHelper {
> private static int uid,pid,tid;
>
> public static void getIDs(){
> uid = Process.myUid();
> pid = Process.myPid();
> tid = Process.myTid();
> }
>
> public static int getUid(){
> return uid;
> }
> public static int getPid(){
> return pid;
> }
> public static int getTid(){
> return tid;
> }
> public static void reportIds(){
> System.out.println("uid is " + uid + "pid is " + pid + "tid is " +
> tid);
> }
>
> }
>
> In the AndroidIntrument.java, I added some lines before iterate the
> patchchain.
>
> " final SootClass getIdsClass;
> final SootMethod getIds,getUid,getPid,getTid,reportIds;
>
> getIdsClass =
> Scene.v().loadClassAndSupport("ThreadHelper");
> getIds = getIdsClass.getMethod("void getIDs()");
> getUid = getIdsClass.getMethod("int getUid()");
> getPid = getIdsClass.getMethod("int getPid()");
> getTid = getIdsClass.getMethod("int getTid()");
> reportIds = getIdsClass.getMethod("void reportIds()");"
>
> And then, when the target of the invocation is onDraw(), I insert some
> invocations.
>
> InvokeExpr getExpr =
> Jimple.v().newStaticInvokeExpr(getIds.makeRef());
> Stmt getStmt = (Stmt)
> Jimple.v().newInvokeStmt(getExpr);
> units.insertBefore((Unit)getStmt, u);
>
> However, When I run java -cp .;soot.jar AndroidInstrument
> -force-android-jar android.jar -process-dir my.apk
>
> cast java.lang.RumtimeException: no method void getIDs() in class
> ThreadHelper.
>
> I don't know the reason. I need your help!
>
> thanks a lot!
>
>
>
>
>
--
Jin Li
Ph.D. Candidate
State Key Labratory of Computer Architecture
ICT, Chinese Academy of Sciences
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.CS.McGill.CA/pipermail/soot-list/attachments/20140602/e345937a/attachment.html
More information about the Soot-list
mailing list