[Soot-list] Bad use of primitive type(int)
xwlin.roy at gmail.com
xwlin.roy at gmail.com
Sun Sep 25 20:54:13 EDT 2016
Hi,all
I did instrumentation in apks,but encountered a problem.My steps:
- I used source code to generate apk, which could run normally.
`
public class InstrumentationHelper {
public int[] randomArr = {1, 2, 3};
public MethodContainer method(int index) {
Map<Integer, MethodContainer> methodMap = new HashMap();
MethodContainer mC1 = new MethodContainer1();
MethodContainer mC2 = new MethodContainer2();
MethodContainer mC3 = new MethodContainer3();
methodMap.put(1, mC2);
methodMap.put(2, mC3);
methodMap.put(3, mC1);
return methodMap.get(randomArr[index]);
}
}`
-
I used command java -Xmx6g -jar soot-trunk.jar soot.Main -w
-allow-phantom-refs -android-jars D:\AndroidSDK\platforms\ -src-prec apk -f
jimple -process-dir app-debug.apk to transform apk into jimple files.
-
I did my instrumentation according with jimple file generated.
[image: image]
<https://cloud.githubusercontent.com/assets/15721702/18819508/9568518a-83c4-11e6-9675-af7169bbe77a.png>
The left of picture was jimple generated form apk,the other was I used
soot's api to construct.
- When I did instrumentation with this statement $i0 = $r6[$i0];,Soot
reported error:
Stack trace:
Warning: Bad use of primitive type at $i0 = $r6[$i0] in <com.example.InstrumentationHelper: com.example.MethodContainer method(int)> in <com.example.InstrumentationHelper: com.example.MethodContainer method(int)>
at soot.validation.CheckTypesValidator.checkCopy(CheckTypesValidator.java:95)
at soot.validation.CheckTypesValidator.validate(CheckTypesValidator.java:45)
at soot.Body.validate(Body.java:258)
at soot.jimple.JimpleBody.validate(JimpleBody.java:120)
at soot.jimple.JimpleBody.validate(JimpleBody.java:110)
at soot.PackManager.runBodyPacks(PackManager.java:988)
at soot.PackManager.access$000(PackManager.java:138)
at soot.PackManager$1.run(PackManager.java:633)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
-
To do this instrumentation,I used these api:
` // Set method's parameter
List<Type> parameterTypes = new ArrayList<>();
Type intParam = IntType.v();
parameterTypes.add(intParam);
body.getMethod().setParameterTypes(parameterTypes);
Local intLocal = Jimple.v().newLocal("$i0", intParam);
body.getLocals().add(intLocal);
`
arrLocal = Jimple.v().newLocal("$r6", ArrayType.v(RefType.v("int"),
1));body.getLocals().add(arrLocal);
units.insertBefore(Jimple.v().newAssignStmt(intLocal,
Jimple.v().newArrayRef(arrLocal, intLocal)), stmt);
- Can you give me some advices on this issue?Maybe it's in connection
with autoboxing?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://mailman.CS.McGill.CA/pipermail/soot-list/attachments/20160925/067dc452/attachment.html
More information about the Soot-list
mailing list