Search in sources :

Example 11 with Method

use of com.googlecode.d2j.Method in project dex2jar by pxb1988.

the class ZeroTest method testZero.

@Test
public static void testZero(DexClassVisitor cv) {
    DexMethodVisitor mv = cv.visitMethod(ACC_STATIC, new Method("La;", "b", new String[] {}, "[Ljava/lang/Object;"));
    if (mv != null) {
        DexCodeVisitor code = mv.visitCode();
        if (code != null) {
            int v0 = 0;
            code.visitRegister(1);
            DexLabel L1 = new DexLabel();
            DexLabel L2 = new DexLabel();
            DexLabel L3 = new DexLabel();
            code.visitConstStmt(CONST, v0, 0);
            code.visitJumpStmt(IF_EQ, v0, v0, L2);
            code.visitLabel(L1);
            code.visitStmt1R(RETURN_OBJECT, v0);
            code.visitLabel(L2);
            code.visitJumpStmt(IF_EQ, v0, v0, L3);
            code.visitMethodStmt(INVOKE_STATIC, new int[0], new Method("La;", "getBytes", new String[0], "[B"));
            code.visitStmt1R(MOVE_RESULT_OBJECT, v0);
            code.visitLabel(L3);
            code.visitMethodStmt(INVOKE_STATIC, new int[] { v0 }, new Method("La;", "useBytes", new String[] { "[B" }, "V"));
            code.visitMethodStmt(INVOKE_STATIC, new int[0], new Method("La;", "getObjects", new String[0], "[Ljava/lang/Object;"));
            code.visitStmt1R(MOVE_RESULT, v0);
            code.visitJumpStmt(GOTO, -1, -1, L1);
            code.visitEnd();
        }
        mv.visitEnd();
    }
}
Also used : DexCodeVisitor(com.googlecode.d2j.visitors.DexCodeVisitor) DexLabel(com.googlecode.d2j.DexLabel) Method(com.googlecode.d2j.Method) DexMethodVisitor(com.googlecode.d2j.visitors.DexMethodVisitor) Test(org.junit.Test)

Example 12 with Method

use of com.googlecode.d2j.Method in project dex2jar by pxb1988.

the class ArrayTypeTest method a123.

@Test
public static void a123(DexClassVisitor cv) {
    DexMethodVisitor mv = cv.visitMethod(ACC_PUBLIC | ACC_STATIC, new Method("La;", "b", new String[] {}, "V"));
    DexCodeVisitor code = mv.visitCode();
    code.visitRegister(3);
    code.visitConstStmt(CONST, 0, 0);
    code.visitConstStmt(CONST, 1, 1);
    code.visitConstStmt(CONST, 2, 0x63);
    code.visitStmt3R(APUT, 2, 0, 1);
    code.visitStmt0R(RETURN_VOID);
    code.visitEnd();
    mv.visitEnd();
}
Also used : DexCodeVisitor(com.googlecode.d2j.visitors.DexCodeVisitor) Method(com.googlecode.d2j.Method) DexMethodVisitor(com.googlecode.d2j.visitors.DexMethodVisitor) Test(org.junit.Test)

Example 13 with Method

use of com.googlecode.d2j.Method in project dex2jar by pxb1988.

the class ArrayTypeTest method a122.

@Test
public static void a122(DexClassVisitor cv) {
    DexMethodVisitor mv = cv.visitMethod(ACC_PUBLIC | ACC_STATIC, new Method("La;", "b", new String[] {}, "V"));
    DexCodeVisitor code = mv.visitCode();
    code.visitRegister(3);
    code.visitConstStmt(CONST, 0, Integer.valueOf(0));
    code.visitConstStmt(CONST, 2, Integer.valueOf(1));
    code.visitStmt3R(AGET, 1, 0, 2);
    code.visitStmt0R(RETURN_VOID);
    code.visitEnd();
    mv.visitEnd();
}
Also used : DexCodeVisitor(com.googlecode.d2j.visitors.DexCodeVisitor) Method(com.googlecode.d2j.Method) DexMethodVisitor(com.googlecode.d2j.visitors.DexMethodVisitor) Test(org.junit.Test)

Example 14 with Method

use of com.googlecode.d2j.Method in project dex2jar by pxb1988.

the class EmptyTrapTest method m005_toJSONString.

@Test
public static void m005_toJSONString(DexClassVisitor cv) {
    DexMethodVisitor mv = cv.visitMethod(0, new Method("LJSResponseTest;", "toJSONString", new String[] {}, "Ljava/lang/String;"));
    if (mv != null) {
        DexCodeVisitor code = mv.visitCode();
        if (code != null) {
            code.visitRegister(6);
            DexLabel L8 = new DexLabel();
            DexLabel L9 = new DexLabel();
            DexLabel L10 = new DexLabel();
            DexLabel L0 = new DexLabel();
            DexLabel L1 = new DexLabel();
            DexLabel L2 = new DexLabel();
            code.visitTryCatch(L0, L1, new DexLabel[] { L2 }, new String[] { "Lorg/json/JSONException;" });
            DexLabel L3 = new DexLabel();
            DexLabel L4 = new DexLabel();
            code.visitTryCatch(L3, L4, new DexLabel[] { L2 }, new String[] { "Lorg/json/JSONException;" });
            DexLabel L5 = new DexLabel();
            DexLabel L6 = new DexLabel();
            code.visitTryCatch(L5, L6, new DexLabel[] { L2 }, new String[] { "Lorg/json/JSONException;" });
            code.visitConstStmt(CONST_STRING, 2, "response");
            code.visitConstStmt(CONST_STRING, 4, "");
            code.visitLabel(L0);
            code.visitFieldStmt(IGET, 2, 5, new Field("LJSResponseTest;", "className", "Ljava/lang/String;"));
            code.visitJumpStmt(IF_EQZ, 2, -1, L8);
            code.visitFieldStmt(IGET, 2, 5, new Field("LJSResponseTest;", "methodName", "Ljava/lang/String;"));
            code.visitJumpStmt(IF_NEZ, 2, -1, L10);
            code.visitLabel(L8);
            code.visitConstStmt(CONST_STRING, 2, "");
            code.visitStmt2R(MOVE, 2, 4);
            code.visitLabel(L9);
            code.visitStmt1R(RETURN_OBJECT, 2);
            code.visitLabel(L10);
            code.visitTypeStmt(NEW_INSTANCE, 1, -1, "Lorg/json/JSONObject;");
            code.visitMethodStmt(INVOKE_DIRECT, new int[] { 1 }, new Method("Lorg/json/JSONObject;", "<init>", new String[] {}, "V"));
            code.visitConstStmt(CONST_STRING, 2, "class");
            code.visitFieldStmt(IGET, 3, 5, new Field("LJSResponseTest;", "className", "Ljava/lang/String;"));
            code.visitMethodStmt(INVOKE_VIRTUAL, new int[] { 1, 2, 3 }, new Method("Lorg/json/JSONObject;", "put", new String[] { "Ljava/lang/String;", "Ljava/lang/Object;" }, "Lorg/json/JSONObject;"));
            code.visitConstStmt(CONST_STRING, 2, "call");
            code.visitFieldStmt(IGET, 3, 5, new Field("LJSResponseTest;", "methodName", "Ljava/lang/String;"));
            code.visitMethodStmt(INVOKE_VIRTUAL, new int[] { 1, 2, 3 }, new Method("Lorg/json/JSONObject;", "put", new String[] { "Ljava/lang/String;", "Ljava/lang/Object;" }, "Lorg/json/JSONObject;"));
            code.visitConstStmt(CONST_STRING, 2, "result");
            code.visitFieldStmt(IGET, 3, 5, new Field("LJSResponseTest;", "result", "I"));
            code.visitMethodStmt(INVOKE_VIRTUAL, new int[] { 1, 2, 3 }, new Method("Lorg/json/JSONObject;", "put", new String[] { "Ljava/lang/String;", "I" }, "Lorg/json/JSONObject;"));
            code.visitFieldStmt(IGET, 2, 5, new Field("LJSResponseTest;", "response", "Ljava/lang/Object;"));
            code.visitJumpStmt(IF_EQZ, 2, -1, L3);
            code.visitConstStmt(CONST_STRING, 2, "response");
            code.visitFieldStmt(IGET, 3, 5, new Field("LJSResponseTest;", "response", "Ljava/lang/Object;"));
            code.visitMethodStmt(INVOKE_VIRTUAL, new int[] { 1, 2, 3 }, new Method("Lorg/json/JSONObject;", "put", new String[] { "Ljava/lang/String;", "Ljava/lang/Object;" }, "Lorg/json/JSONObject;"));
            code.visitLabel(L1);
            code.visitMethodStmt(INVOKE_VIRTUAL, new int[] { 1 }, new Method("Lorg/json/JSONObject;", "toString", new String[] {}, "Ljava/lang/String;"));
            code.visitStmt1R(MOVE_RESULT_OBJECT, 2);
            code.visitJumpStmt(GOTO, -1, -1, L9);
            code.visitLabel(L3);
            code.visitFieldStmt(IGET, 2, 5, new Field("LJSResponseTest;", "dataResponse", "[B"));
            code.visitJumpStmt(IF_EQZ, 2, -1, L5);
            code.visitConstStmt(CONST_STRING, 2, "response");
            code.visitFieldStmt(IGET, 3, 5, new Field("LJSResponseTest;", "dataResponse", "[B"));
            code.visitMethodStmt(INVOKE_STATIC, new int[] { 3 }, new Method("LBase64;", "encode", new String[] { "[B" }, "Ljava/lang/String;"));
            code.visitStmt1R(MOVE_RESULT, 3);
            code.visitMethodStmt(INVOKE_VIRTUAL, new int[] { 1, 2, 3 }, new Method("Lorg/json/JSONObject;", "put", new String[] { "Ljava/lang/String;", "Ljava/lang/Object;" }, "Lorg/json/JSONObject;"));
            code.visitLabel(L4);
            code.visitJumpStmt(GOTO, -1, -1, L1);
            code.visitLabel(L2);
            code.visitStmt1R(MOVE_EXCEPTION, 2);
            code.visitStmt2R(MOVE, 0, 2);
            code.visitConstStmt(CONST_STRING, 2, "MillennialMediaSDK");
            code.visitMethodStmt(INVOKE_VIRTUAL, new int[] { 0 }, new Method("Lorg/json/JSONException;", "getMessage", new String[] {}, "Ljava/lang/String;"));
            code.visitStmt1R(MOVE_RESULT, 3);
            code.visitMethodStmt(INVOKE_STATIC, new int[] { 2, 3 }, new Method("Landroid/util/Log;", "e", new String[] { "Ljava/lang/String;", "Ljava/lang/String;" }, "I"));
            code.visitConstStmt(CONST_STRING, 2, "");
            code.visitStmt2R(MOVE, 2, 4);
            code.visitJumpStmt(GOTO, -1, -1, L9);
            code.visitLabel(L5);
            code.visitConstStmt(CONST_STRING, 2, "");
            code.visitLabel(L6);
            code.visitStmt2R(MOVE, 2, 4);
            code.visitJumpStmt(GOTO, -1, -1, L9);
            code.visitEnd();
        }
        mv.visitEnd();
    }
}
Also used : Field(com.googlecode.d2j.Field) DexCodeVisitor(com.googlecode.d2j.visitors.DexCodeVisitor) DexLabel(com.googlecode.d2j.DexLabel) Method(com.googlecode.d2j.Method) DexMethodVisitor(com.googlecode.d2j.visitors.DexMethodVisitor) Test(org.junit.Test)

Example 15 with Method

use of com.googlecode.d2j.Method in project dex2jar by pxb1988.

the class I101Test method a.

public static void a(DexClassVisitor cv) {
    DexMethodVisitor mv = cv.visitMethod(ACC_PUBLIC | ACC_STATIC, new Method("La;", "b", new String[] {}, "V"));
    DexCodeVisitor code = mv.visitCode();
    code.visitRegister(2);
    DexLabel L0 = new DexLabel();
    DexLabel L1 = new DexLabel();
    DexLabel L2 = new DexLabel();
    code.visitTryCatch(L0, L1, new DexLabel[] { L2 }, new String[] { "Lsome/Exception;" });
    code.visitLabel(L0);
    code.visitConstStmt(CONST_STRING, 0, "abc");
    code.visitLabel(L1);
    code.visitMethodStmt(INVOKE_VIRTUAL, new int[] { 0 }, new Method("Ljava/lang/String;", "toString", new String[] {}, "Ljava/lang/String;"));
    code.visitStmt0R(RETURN_VOID);
    code.visitLabel(L2);
    code.visitStmt1R(MOVE_EXCEPTION, 1);
    code.visitMethodStmt(INVOKE_VIRTUAL, new int[] { 1 }, new Method("Ljava/lang/String;", "toString", new String[] {}, "Ljava/lang/String;"));
    code.visitStmt0R(RETURN_VOID);
    code.visitEnd();
    mv.visitEnd();
}
Also used : DexCodeVisitor(com.googlecode.d2j.visitors.DexCodeVisitor) DexLabel(com.googlecode.d2j.DexLabel) Method(com.googlecode.d2j.Method) DexMethodVisitor(com.googlecode.d2j.visitors.DexMethodVisitor)

Aggregations

Method (com.googlecode.d2j.Method)22 DexCodeVisitor (com.googlecode.d2j.visitors.DexCodeVisitor)18 DexMethodVisitor (com.googlecode.d2j.visitors.DexMethodVisitor)18 Test (org.junit.Test)13 DexLabel (com.googlecode.d2j.DexLabel)10 Field (com.googlecode.d2j.Field)9 DexClassVisitor (com.googlecode.d2j.visitors.DexClassVisitor)4 Op (com.googlecode.d2j.reader.Op)3 HashMap (java.util.HashMap)3 DexFileWriter (com.googlecode.d2j.dex.writer.DexFileWriter)2 DexFieldVisitor (com.googlecode.d2j.visitors.DexFieldVisitor)2 File (java.io.File)2 DexType (com.googlecode.d2j.DexType)1 DexCodeNode (com.googlecode.d2j.node.DexCodeNode)1 DexMethodNode (com.googlecode.d2j.node.DexMethodNode)1 DvmInterpreter (com.googlecode.d2j.node.analysis.DvmInterpreter)1 DexFileReader (com.googlecode.d2j.reader.DexFileReader)1 ASMifierFileV (com.googlecode.d2j.util.ASMifierFileV)1 DexAnnotationAble (com.googlecode.d2j.visitors.DexAnnotationAble)1 DexAnnotationVisitor (com.googlecode.d2j.visitors.DexAnnotationVisitor)1