Skip to content

Instantly share code, notes, and snippets.

@shauvik
Last active August 29, 2015 14:05
Show Gist options
  • Save shauvik/889477b28a34ad80ba9e to your computer and use it in GitHub Desktop.
Save shauvik/889477b28a34ad80ba9e to your computer and use it in GitHub Desktop.
SwiftHand patch
diff --git a/src/java/edu/berkeley/wtchoi/instrument/DexProcessor/printingVisitor/ApplicationPrintingVisitor.java b/src/java/edu/berkeley/wtchoi/instrument/DexProcessor/printingVisitor/ApplicationPrintingVisitor.java
index 37e98f4..2351b30 100644
--- a/src/java/edu/berkeley/wtchoi/instrument/DexProcessor/printingVisitor/ApplicationPrintingVisitor.java
+++ b/src/java/edu/berkeley/wtchoi/instrument/DexProcessor/printingVisitor/ApplicationPrintingVisitor.java
@@ -67,12 +67,12 @@
}
public ApplicationPrintingVisitor(ApplicationVisitor av, Writer w){
- super(av);
+ super(4, av);
pw = new IndentingPrintWriter(w);
}
public ApplicationPrintingVisitor(Writer w){
- super();
+ super(4);
pw = new IndentingPrintWriter(w);
}
diff --git a/src/scala/edu/berkeley/wtchoi/instrument/DexProcessor/annotatedPrintingVisitor/AnnotatedApplicationPrintingVisitor.scala b/src/scala/edu/berkeley/wtchoi/instrument/DexProcessor/annotatedPrintingVisitor/AnnotatedApplicationPrintingVisitor.scala
index 768ac34..6c0de91 100644
--- a/src/scala/edu/berkeley/wtchoi/instrument/DexProcessor/annotatedPrintingVisitor/AnnotatedApplicationPrintingVisitor.scala
+++ b/src/scala/edu/berkeley/wtchoi/instrument/DexProcessor/annotatedPrintingVisitor/AnnotatedApplicationPrintingVisitor.scala
@@ -41,7 +41,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-class AnnotatedApplicationPrintingVisitor( _av:ApplicationVisitor, w:Writer, appInfo:ApplicationInfo) extends ApplicationVisitor(new ApplicationPrintingVisitor(_av, w)){
+class AnnotatedApplicationPrintingVisitor( _av:ApplicationVisitor, w:Writer, appInfo:ApplicationInfo) extends ApplicationVisitor(4, new ApplicationPrintingVisitor(_av, w)){
override def visitClass(access:Int, name:String, signature:Array[String], superName:String, interfaces:Array[String]) : ClassVisitor = {
val chained = super.visitClass(access, name, signature, superName, interfaces);
diff --git a/src/scala/edu/berkeley/wtchoi/instrument/DexProcessor/annotatedPrintingVisitor/AnnotatedClassPrintingVisitor.scala b/src/scala/edu/berkeley/wtchoi/instrument/DexProcessor/annotatedPrintingVisitor/AnnotatedClassPrintingVisitor.scala
index e7f3bdf..47f39d1 100644
--- a/src/scala/edu/berkeley/wtchoi/instrument/DexProcessor/annotatedPrintingVisitor/AnnotatedClassPrintingVisitor.scala
+++ b/src/scala/edu/berkeley/wtchoi/instrument/DexProcessor/annotatedPrintingVisitor/AnnotatedClassPrintingVisitor.scala
@@ -41,7 +41,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-class AnnotatedClassPrintingVisitor(_cv:ClassVisitor, _pw:IndentingPrintWriterWrapper, ci:ClassInfo) extends ClassVisitor( _cv){
+class AnnotatedClassPrintingVisitor(_cv:ClassVisitor, _pw:IndentingPrintWriterWrapper, ci:ClassInfo) extends ClassVisitor(4, _cv){
override protected def visitMethod(access:Int, name:String, desc:String, signature:Array[String], exceptions:Array[String]) : MethodVisitor = {
diff --git a/src/scala/edu/berkeley/wtchoi/instrument/DexProcessor/annotatedPrintingVisitor/AnnotatedMethodPrintingVisitor.scala b/src/scala/edu/berkeley/wtchoi/instrument/DexProcessor/annotatedPrintingVisitor/AnnotatedMethodPrintingVisitor.scala
index 1a7df4e..a6fb561 100644
--- a/src/scala/edu/berkeley/wtchoi/instrument/DexProcessor/annotatedPrintingVisitor/AnnotatedMethodPrintingVisitor.scala
+++ b/src/scala/edu/berkeley/wtchoi/instrument/DexProcessor/annotatedPrintingVisitor/AnnotatedMethodPrintingVisitor.scala
@@ -42,7 +42,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-class AnnotatedMethodPrintingVisitor(_mv:MethodVisitor, pw:IndentingPrintWriterWrapper, mi:MethodInfo) extends MethodVisitor(_mv){
+class AnnotatedMethodPrintingVisitor(_mv:MethodVisitor, pw:IndentingPrintWriterWrapper, mi:MethodInfo) extends MethodVisitor(4, _mv){
val mpv = mv.asInstanceOf[MethodPrintingVisitor]
diff --git a/src/scala/edu/berkeley/wtchoi/instrument/DexProcessor/il/helper/MethodVisitorHelper.scala b/src/scala/edu/berkeley/wtchoi/instrument/DexProcessor/il/helper/MethodVisitorHelper.scala
index bb0059c..ecd351a 100644
--- a/src/scala/edu/berkeley/wtchoi/instrument/DexProcessor/il/helper/MethodVisitorHelper.scala
+++ b/src/scala/edu/berkeley/wtchoi/instrument/DexProcessor/il/helper/MethodVisitorHelper.scala
@@ -40,7 +40,7 @@
import org.ow2.asmdex.structureCommon.Label
import edu.berkeley.wtchoi.instrument.DexProcessor.il._
-abstract class MethodVisitorHelper(mv:MethodVisitor) extends MethodVisitor(mv){
+abstract class MethodVisitorHelper(mv:MethodVisitor) extends MethodVisitor(4, mv){
//Instead of defining number of functions, you can define a single handleInst function.
def handleInst(inst:Instruction):Unit
diff --git a/src/scala/edu/berkeley/wtchoi/instrument/DexProcessor/ilbuilder/imp/ILBuilderApplicationVisitor.scala b/src/scala/edu/berkeley/wtchoi/instrument/DexProcessor/ilbuilder/imp/ILBuilderApplicationVisitor.scala
index 7ee7c43..035809d 100644
--- a/src/scala/edu/berkeley/wtchoi/instrument/DexProcessor/ilbuilder/imp/ILBuilderApplicationVisitor.scala
+++ b/src/scala/edu/berkeley/wtchoi/instrument/DexProcessor/ilbuilder/imp/ILBuilderApplicationVisitor.scala
@@ -42,7 +42,7 @@
B. providing ILBuilderClassVisitor class
C. providing interface to register CFG
*/
-class ILBuilderApplicationVisitor(appInfo:ApplicationInfo) extends ApplicationVisitor(null) {
+class ILBuilderApplicationVisitor(appInfo:ApplicationInfo) extends ApplicationVisitor(4, null) {
override def visitClass(access: Int, name: String, signature: Array[String], superName: String, interfaces: Array[String]): ClassVisitor = {
val classInfo = appInfo.registerClass(name)
diff --git a/src/scala/edu/berkeley/wtchoi/instrument/DexProcessor/ilbuilder/imp/ILBuilderClassVisitor.scala b/src/scala/edu/berkeley/wtchoi/instrument/DexProcessor/ilbuilder/imp/ILBuilderClassVisitor.scala
index afd1492..93f2fa8 100644
--- a/src/scala/edu/berkeley/wtchoi/instrument/DexProcessor/ilbuilder/imp/ILBuilderClassVisitor.scala
+++ b/src/scala/edu/berkeley/wtchoi/instrument/DexProcessor/ilbuilder/imp/ILBuilderClassVisitor.scala
@@ -43,7 +43,7 @@
*/
-class ILBuilderClassVisitor(classInfo:ClassInfo) extends ClassVisitor(null) {
+class ILBuilderClassVisitor(classInfo:ClassInfo) extends ClassVisitor(4, null) {
override def visitMethod(access: Int, name: String, desc: String, sig: Array[String], exception: Array[String]): MethodVisitor = {
diff --git a/src/scala/edu/berkeley/wtchoi/instrument/DexProcessor/instrument/InstrumentingApplicationVisitor.scala b/src/scala/edu/berkeley/wtchoi/instrument/DexProcessor/instrument/InstrumentingApplicationVisitor.scala
index e0e37f1..7c0dd99 100644
--- a/src/scala/edu/berkeley/wtchoi/instrument/DexProcessor/instrument/InstrumentingApplicationVisitor.scala
+++ b/src/scala/edu/berkeley/wtchoi/instrument/DexProcessor/instrument/InstrumentingApplicationVisitor.scala
@@ -41,7 +41,7 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
class InstrumentingApplicationVisitor(appInfo:ApplicationInfo, lrs:Array[ApplicationReader], _av:ApplicationVisitor, spec:InstrumentSpecification)
- extends ApplicationVisitor(new NestedTryResolvingApplicationVisitor(_av)){
+ extends ApplicationVisitor(4, new NestedTryResolvingApplicationVisitor(_av)){
//extends ApplicationVisitor(api,_av){
override def visitClass(access: Int, name: String, signature: Array[String], superName: String, interfaces: Array[String]): ClassVisitor = {
diff --git a/src/scala/edu/berkeley/wtchoi/instrument/DexProcessor/instrument/InstrumentingClassVisitor.scala b/src/scala/edu/berkeley/wtchoi/instrument/DexProcessor/instrument/InstrumentingClassVisitor.scala
index 17bb3f0..fa8bb9a 100644
--- a/src/scala/edu/berkeley/wtchoi/instrument/DexProcessor/instrument/InstrumentingClassVisitor.scala
+++ b/src/scala/edu/berkeley/wtchoi/instrument/DexProcessor/instrument/InstrumentingClassVisitor.scala
@@ -39,7 +39,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-class InstrumentingClassVisitor(classInfo:ClassInfo,cv:ClassVisitor, spec:InstrumentSpecification) extends ClassVisitor(cv){
+class InstrumentingClassVisitor(classInfo:ClassInfo,cv:ClassVisitor, spec:InstrumentSpecification) extends ClassVisitor(4, cv){
override def visitMethod(access: Int, name: String, desc: String, sig: Array[String], exception: Array[String]): MethodVisitor = {
val mv:MethodVisitor = cv.visitMethod(access,name,desc,sig,exception)
val methodInfo = classInfo.getMethodInfo(name,desc)
diff --git a/src/scala/edu/berkeley/wtchoi/instrument/DexProcessor/instrument/LibraryHijack.scala b/src/scala/edu/berkeley/wtchoi/instrument/DexProcessor/instrument/LibraryHijack.scala
index f42b077..9fd34d9 100644
--- a/src/scala/edu/berkeley/wtchoi/instrument/DexProcessor/instrument/LibraryHijack.scala
+++ b/src/scala/edu/berkeley/wtchoi/instrument/DexProcessor/instrument/LibraryHijack.scala
@@ -45,7 +45,7 @@
}
private var classes:Set[String] = Set.empty
- class ClassHijackingApplicationVisitor(av:ApplicationVisitor) extends ApplicationVisitor(av){
+ class ClassHijackingApplicationVisitor(av:ApplicationVisitor) extends ApplicationVisitor(4, av){
override def visit(){}
override def visitEnd(){}
@@ -58,7 +58,7 @@
}
}
- class ClassHijackClassVisitor(cv:ClassVisitor) extends ClassVisitor(cv){
+ class ClassHijackClassVisitor(cv:ClassVisitor) extends ClassVisitor(4, cv){
override def visit(version:Int, access:Int, name:String, signature:Array[String], superName:String, interfaces:Array[String]){
classes += name
cv.visit(version, access, name, signature, superName, interfaces)
From 6ad7e811f49da08f99e3b2a9c44b3ee328b370e8 Mon Sep 17 00:00:00 2001
From: Shauvik Roy Choudhary <[email protected]>
Date: Wed, 20 Aug 2014 01:04:40 -0400
Subject: [PATCH] modifying sources to make it work with latest versions
---
src/back-end/pom.xml | 2 +-
.../edu/berkeley/wtchoi/instrument/DexProcessor/DexProcess.java | 6 +++---
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/back-end/pom.xml b/src/back-end/pom.xml
index e2f586c..cd3e7e5 100644
--- a/src/back-end/pom.xml
+++ b/src/back-end/pom.xml
@@ -83,7 +83,7 @@
<artifactId>guava</artifactId>
<version>local</version>
<scope>system</scope>
- <systemPath>${env.ADK_ROOT}/tools/lib/guava-13.0.1.jar</systemPath>
+ <systemPath>${env.ADK_ROOT}/tools/lib/guava-15.0.jar</systemPath>
</dependency>
<dependency>
<groupId>edu.berkeley.wtchoi.gv</groupId>
diff --git a/src/front-end/src/main/java/edu/berkeley/wtchoi/instrument/DexProcessor/DexProcess.java b/src/front-end/src/main/java/edu/berkeley/wtchoi/instrument/DexProcessor/DexProcess.java
index 9b63671..1257fa9 100644
--- a/src/front-end/src/main/java/edu/berkeley/wtchoi/instrument/DexProcessor/DexProcess.java
+++ b/src/front-end/src/main/java/edu/berkeley/wtchoi/instrument/DexProcessor/DexProcess.java
@@ -180,7 +180,7 @@ public class DexProcess {
String pathEventLog = config.getLogPath(prefix + ".events");
EchoingWriter eventWriter = EchoingWriter.create(pathEventLog, logFlag, config.flagVerboseILBuilder);
Debug.registerAbortListener(new WriterFlushingWrapper(eventWriter));
- ApplicationVisitor apv = new AnnotatedApplicationPrintingVisitor(ASM_API_VERSION, null, eventWriter, appInfo);
+ ApplicationVisitor apv = new AnnotatedApplicationPrintingVisitor(null, eventWriter, appInfo);
appReader.accept(apv, 0);
printDexifier(prefix);
@@ -192,7 +192,7 @@ public class DexProcess {
ilbuilder = new ILBuilderImp();
//Generate ILBuilderApplicationVisitor
- ApplicationVisitor ilb = ilbuilder.getApplicationVisitor(ASM_API_VERSION, new ManifestInfo(config.manifestInfo));
+ ApplicationVisitor ilb = ilbuilder.getApplicationVisitor(new ManifestInfo(config.manifestInfo));
// Feed Pretty Printer with application parsing RESULT
String pathLoadLog = config.getLogPath("build.log");
@@ -264,7 +264,7 @@ public class DexProcess {
//connect PrintingVisitor and InstrumentingVisitor
- ApplicationVisitor iv = Instrument.getApplicationVisitor(appInfo, ASM_API_VERSION, lrs, eventLogVisitor, spec);
+ ApplicationVisitor iv = Instrument.getApplicationVisitor(appInfo, lrs, eventLogVisitor, spec);
String pathInstrumentLog = config.getLogPath("instrument.log");
EchoingWriter instrumentLogWriter = EchoingWriter.create(pathInstrumentLog, logFlag, config.flagVerboseInstrumentation);
--
1.8.5.2 (Apple Git-48)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment