From: Jay Freeman (saurik) Date: Mon, 4 Jan 2016 21:24:48 +0000 (-0800) Subject: libnativehelper.so was there before JniInvocation. X-Git-Tag: v0.9.590~60 X-Git-Url: https://git.saurik.com/cycript.git/commitdiff_plain/95be164556de14834c2040ac7bea1632b63e5764?ds=inline libnativehelper.so was there before JniInvocation. --- diff --git a/Java/Execute.cpp b/Java/Execute.cpp index 471f71c..f450a5d 100644 --- a/Java/Execute.cpp +++ b/Java/Execute.cpp @@ -1391,22 +1391,24 @@ static JNIEnv *GetJNI_(JSContextRef context) { dlset(JniInvocation$Init, "_ZN13JniInvocation4InitEPKc", libnativehelper); dlset(JniInvocation$finalize, "_ZN13JniInvocationD1Ev", libnativehelper); - // XXX: we should attach a pool to the VM itself and deallocate this there - //auto invocation(pool.calloc(1, 1024)); - //_assert(JniInvocation$finalize != NULL); - //pool.atexit(reinterpret_cast(JniInvocation$finalize), invocation); - - auto invocation(static_cast(calloc(1, 1024))); - - _assert(JniInvocation$$init$ != NULL); - JniInvocation$$init$(invocation); - - _assert(JniInvocation$Init != NULL); - JniInvocation$Init(invocation, NULL); - - dlset($JNI_GetCreatedJavaVMs, "JNI_GetCreatedJavaVMs", libnativehelper); - if (JNIEnv *jni = CYGetCreatedJava($JNI_GetCreatedJavaVMs)) - return jni; + if (JniInvocation$$init$ == NULL) + dlclose(libnativehelper); + else { + // XXX: we should attach a pool to the VM itself and deallocate this there + //auto invocation(pool.calloc(1, 1024)); + //_assert(JniInvocation$finalize != NULL); + //pool.atexit(reinterpret_cast(JniInvocation$finalize), invocation); + + auto invocation(static_cast(calloc(1, 1024))); + JniInvocation$$init$(invocation); + + _assert(JniInvocation$Init != NULL); + JniInvocation$Init(invocation, NULL); + + dlset($JNI_GetCreatedJavaVMs, "JNI_GetCreatedJavaVMs", libnativehelper); + if (JNIEnv *jni = CYGetCreatedJava($JNI_GetCreatedJavaVMs)) + return jni; + } } if (void *libandroid_runtime = dlopen("libandroid_runtime.so", RTLD_LAZY | RTLD_GLOBAL)) {