VirtualHook icon indicating copy to clipboard operation
VirtualHook copied to clipboard

native中的JNIENV?

Open netstu opened this issue 7 years ago • 2 comments

比如: public class Hook_URL_openConnection { public static String className = "java.net.URL"; public static String methodName = "openConnection"; public static String methodSig = "()Ljava/net/URLConnection;"; public static URLConnection hook(URL thiz) { Log.w("YAHFA", "openConnection to "+thiz.toString()); return backup(thiz); }

public static URLConnection backup(URL thiz) {
    Log.w("YAHFA", "should not be here");
    return null;
}

}

改写为:

public class Hook_URL_openConnection { public static String className = "java.net.URL"; public static String methodName = "openConnection"; public static String methodSig = "()Ljava/net/URLConnection;"; native public static URLConnection hook(URL thiz);

native public static URLConnection backup(URL thiz);

}

in cpp file: 下面为伪代码

JNIExport jobject Java_com_test_testpack_hook(JNIENV* env, jclass jcls, jobject thiz) {

在这里如何调用thiz对象的方法和属性,如果使用jni中的CallxxxMethod或getFiled之类的方法好像不行,我怀疑是不是thiz 的 env和当前hook plugin不是同一个env导致的?

}

netstu avatar Jan 17 '18 23:01 netstu

没这么写过,应该不行,至少target方法的flag需要修改为native

rk700 avatar Jan 18 '18 07:01 rk700

@rk700 target方法是第三方应用,没办法修改为native。

还有没有其他的办法呢

netstu avatar Jan 19 '18 15:01 netstu