<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title></title>
</head>
<body style="font-family:Arial;font-size:14px">
<p>Hi Bernhard,<br>
<br>
I still get the same Run-time Exception:<br>
<br>
oops java.io.FileOutputStream: void <init>(java.lang.String)<br>
<br>
Any idea why and any roundabouts.<br>
<br>
Thanks for all your help,<br>
Pallavi<br>
<br>
<br>
Quoting Bernhard Berger <<a href="mailto:berber@tzi.de">berber@tzi.de</a>>:</p>
<blockquote style="border-left:2px solid blue;margin-left:2px;padding-left:12px;" type="cite">
<p>Hi Pallavi,</p>
<div> </div>
<div>I haven’t tested it but I think you have to write:</div>
<div> </div>
<div>
<div style="margin: 0px; line-height: normal; font-family: 'Source Code Pro';"><span style="color: #931a68"><b>final</b></span> Jimple <span style="color: #7e504f">jimple</span> = Jimple.v();</div>
<div style="margin: 0px; line-height: normal; font-family: 'Source Code Pro';"><span style="color: #931a68"><b>final</b></span> RefType <span style="color: #7e504f">foStreamType</span> = RefType.v(<span style="color: #3933ff">"java.io.FileOutputStream"</span>);</div>
<div style="margin: 0px; line-height: normal; font-family: 'Source Code Pro'; color: rgb(57, 51, 255);"><span style="color: #931a68"><b>final</b></span> <span style="color: #000000">SootMethod</span> <span style="color: #7e504f">constructor</span> <span style="color: #000000">= Scene.v().getMethod(</span>"java.io.FileOutputStream: void <init>(java.lang.String)"<span style="color: #000000">);</span></div>
<div style="margin: 0px; line-height: normal; font-family: 'Source Code Pro'; min-height: 15px;"> </div>
<div style="margin: 0px; line-height: normal; font-family: 'Source Code Pro'; color: rgb(126, 80, 79);"><span style="color: #931a68"><b>final</b></span> <span style="color: #000000">Local</span> fileLocal <span style="color: #000000">=</span> jimple<span style="color: #000000">.newLocal(</span><span style="color: #3933ff">"writing"</span><span style="color: #000000">,</span> foStreamType<span style="color: #000000">);</span></div>
<div style="margin: 0px; line-height: normal; font-family: 'Source Code Pro';"><span style="color: #7e504f">body</span>.getLocals().add(<span style="color: #7e504f">fileLocal</span>);</div>
<div style="margin: 0px; line-height: normal; font-family: 'Source Code Pro'; min-height: 15px;"> </div>
<div style="margin: 0px; line-height: normal; font-family: 'Source Code Pro'; color: rgb(126, 80, 79);"><span style="color: rgb(147, 26, 104);"><b>final</b></span> <span style="color: #000000">Stmt</span> assignStmt <span style="color: #000000">=</span> jimple<span style="color: #000000">.newAssignStmt(</span>fileLocal<span style="color: #000000">,</span> jimple<span style="color: #000000">.newNewExpr(</span>foStreamType<span style="color: #000000">));</span></div>
<div style="margin: 0px; line-height: normal; font-family: 'Source Code Pro';"><span style="color: rgb(147, 26, 104);"><b>final</b></span> Stmt <span style="color: #7e504f">invokeStmt</span> = <span style="color: #7e504f">jimple</span>.newInvokeStmt(<span style="color: #7e504f">jimple</span>.newSpecialInvokeExpr(<span style="color: #7e504f">fileLocal</span>, <span style="color: #7e504f">constructor</span>.makeRef(), StringConstant.v(<span style="color: #3933ff">"file.txt"</span>)));</div>
<div style="margin: 0px; line-height: normal; font-family: 'Source Code Pro';"><span style="color: #7e504f">units</span>.insertBefore(<span style="color: #7e504f">invokeStmt</span>, <span style="color: #7e504f">stmt</span>);</div>
<div style="margin: 0px; line-height: normal; font-family: 'Source Code Pro'; color: rgb(126, 80, 79);">units<span style="color: #000000">.insertBefore(</span>assignStmt<span style="color: #000000">,</span> invokeStmt<span style="color: #000000">);</span></div>
</div>
<div> </div>
<div><span style="color: #000000">Regards, Bernhard</span></div>
<div><br>
<div>
<blockquote type="cite">
<div>Am 13.01.2017 um 13:16 schrieb Pallavi Majumder <<a href="mailto:s8pamaju@stud.uni-saarland.de">s8pamaju@stud.uni-saarland.de</a>>:</div>
<br class="Apple-interchange-newline">
<div> </div>
</blockquote>
</div>
</div>
</blockquote>
<div style="font-family:Arial;font-size:14px">
<p>Hi Bernhard,<br>
<br>
I am quite new to Soot so this may sound very silly. <br>
<br>
If I want to instrument this code:<br>
FileOutputStream writer=new FileOutputStream("file.txt");<br>
<br>
The jimple representation is:<br>
java.io.FileOutputStream $r6;<br>
$r6 = new java.io.FileOutputStream;<br>
specialinvoke $r6.<java.io.FileOutputStream: void <init>(java.lang.String)>("file.txt");<br>
<br>
Now to do this I write my code as:<br>
final Local fileLocal=Jimple.v().newLocal("writing",RefType.v("java.io.FileOutputStream"));<br>
body.getLocals().add(fileLocal);<br>
<br>
//What is the code for creating $r6 = new java.io.FileOutputStream;</p>
<div>units .insertBefore(Jimple.v() .newInvokeStmt(Jimple.v().newSpecialInvokeExpr(fileLocal, Scene.v() .getMethod("java.io.FileOutputStream: void <init>(java.lang.String)").makeRef( StringConstant.v("file.txt"))),stmt);</div>
<p>I am not able to create the "new FileOutputStream", when I create using newInstanceFieldRef it somehow throws error. Can you tell me what exactly is the code to use here.<br>
<br>
Thanks,<br>
Pallavi<br>
 </p>
<p><br>
<br>
<br>
Quoting Bernhard Berger <<a href="mailto:berber@tzi.de">berber@tzi.de</a>>:</p>
<blockquote style="border-left:2px solid blue;margin-left:2px;padding-left:12px;" type="cite">
<p>Hi Pallavi,</p>
<div> </div>
<div>is the exception thrown by Soot or by the application you are instrumenting? I think you forgot to call the new operator. If you take a look at some Jimple code you will see that for object creation there will be a JNewExpr (the result will be assigned to you local) and afterwards you are going to call the constructor.</div>
<div> </div>
<div>Regards, Bernhard</div>
<div><br>
<div>
<blockquote type="cite">
<div>Am 12.01.2017 um 11:41 schrieb Pallavi Majumder <<a href="mailto:s8pamaju@stud.uni-saarland.de">s8pamaju@stud.uni-saarland.de</a>>:</div>
<br class="Apple-interchange-newline">
<div> </div>
</blockquote>
</div>
</div>
</blockquote>
<div style="font-family:Arial;font-size:14px">
<p>Hi All,<br>
<br>
I want to instrument the below code using soot:<br>
<br>
PrintStream writing=new PrintStream(new FileOutputStream("file.txt"));<br>
<br>
So I thought I'll start with creating the FileOutputStream object first.<br>
<br>
Soot Code:</p>
<div>final Local fileLocal=Jimple.v().newLocal("writing",</div>
<div>RefType.v("java.io.FileOutputStream"));<br>
body.getLocals().add(fileLocal);<br>
<div>units</div>
<div>.insertBefore(Jimple.v()</div>
<div>.newInvokeStmt(Jimple.v()</div>
<div>.newSpecialInvokeExpr(fileLocal, Scene.v()</div>
<div>.getMethod("<java.io.FileOutputStream: void <init>(java.lang.String)").makeRef(),</div>
<div>StringConstant.v("file.txt"))),stmt);<br>
<br>
When I run this it gives the exception:<br>
Worker thread execution failed: oops <java.io.FileOutputStream: void <init>(java.lang.String)</div>
</div>
<p><br>
<br>
Does anyone know a solution to this?<br>
<br>
Thanks,<br>
Pallavi</p>
</div>
<p>_______________________________________________<br>
Soot-list mailing list<br>
<a href="mailto:Soot-list@CS.McGill.CA">Soot-list@CS.McGill.CA</a><br>
<a href="https://mailman.CS.McGill.CA/mailman/listinfo/soot-list">https://mailman.CS.McGill.CA/mailman/listinfo/soot-list</a><br>
<br>
<br>
 </p>
</div>
<p><br>
<br>
<br></p>
</body>
</html>