Closed darkgirl closed 4 years ago
dvmObject参数可区别
On Tue, Sep 15, 2020 at 16:01 darkgirl notifications@github.com wrote:
今天测试的时候再jni里面获取一个类的类名时发现需要在AbstractJni::CallObjectMethodV中添加 `public DvmObject callObjectMethodV(BaseVM vm, DvmObject dvmObject, String signature, VaList vaList) { if ("java/lang/Class->getName()Ljava.lang.String;".equals(signature)) { System.out.println("???? " + dvmClass.getValue()); // System.out.println(vaList.getObject(0)); return new StringObject(vm,"hhhh"); }
... }jni代码:jclass classClass = env->GetObjectClass(classObj); { const char* methodName = "getName"; jmethodID methodId = env->GetMethodID(classClass, methodName, "()Ljava.lang.String;"); if (NULL == methodId){ LOGD("can not find method ", methodName); return; }
jstring className = static_cast<jstring>(env->CallObjectMethod(classObj, methodId)); LOGD("className: %s", env->GetStringUTFChars(className, NULL)); }`
如果不能获取 jstring className = static_cast(env->CallObjectMethod(classObj, methodId));中的classObj 就只能实现返回一个固定的className, 但是如果其他类也调用了这个函数就有问题了吧
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/zhkl0228/unidbg/issues/183, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAKSR77DV2TCQN6IOKKYFK3SF4NOBANCNFSM4RMW6RZA .
dvmObject
我试过打印dvmObject的信息, 发现这个参数其实是指向当前函数所在类 callObjectMethodV>>> java/lang/Class->getName()Ljava.lang.String; ???? com.mozzie.jingdongtool.JingdongHook ???? class java/lang/Class ???? com.mozzie.jingdongtool.JingdongHook JNIEnv->CallObjectMethodV(class com/jingdong/jdsdk/depend/DependUtil, getName() => "hhhh") was called from RX@0x400009f9[libjingdongtool.so]0x9f9 JNIEnv->GetStringUtfChars("hhhh") was called from RX@0x40000ad1[libjingdongtool.so]0xad1
我是在JingdongHook这个类下的native函数中调用DependUtil.getClass().getName() 如果我代码没有问题的话dvmObject只能区分在这个类之外调用的情况, 如果在这个类下调用多次Object.getClass().getName()也是不能区分的吧
刚才打印错对象了, dvmObject确实是调用者
今天测试的时候再jni里面获取一个类的类名时发现需要在AbstractJni::CallObjectMethodV中添加
`
public DvmObject<?> callObjectMethodV(BaseVM vm, DvmObject<?> dvmObject, String signature, VaList vaList) { if ("java/lang/Class->getName()Ljava.lang.String;".equals(signature)) { System.out.println("???? " + dvmClass.getValue()); // System.out.println(vaList.getObject(0)); return new StringObject(vm,"hhhh"); }
... }(env->CallObjectMethod(classObj, methodId));
LOGD("className: %s", env->GetStringUTFChars(className, NULL));
}
`
jni代码:
jclass classClass = env->GetObjectClass(classObj); { const char* methodName = "getName"; jmethodID methodId = env->GetMethodID(classClass, methodName, "()Ljava.lang.String;"); if (NULL == methodId){ LOGD("can not find method ", methodName); return; } jstring className = static_cast如果不能获取 jstring className = static_cast(env->CallObjectMethod(classObj, methodId));中的classObj
就只能实现返回一个固定的className, 但是如果其他类也调用了这个函数就有问题了吧