Skip to content

Instantly share code, notes, and snippets.

@gauravssnl
Forked from vvb2060/hiddenapibypass.cpp
Created January 30, 2024 14:56
Show Gist options
  • Save gauravssnl/181b1ee841d2e5cece310bed255d1eed to your computer and use it in GitHub Desktop.
Save gauravssnl/181b1ee841d2e5cece310bed255d1eed to your computer and use it in GitHub Desktop.
`JNI_OnLoad` called by system
jint JNI_OnLoad(JavaVM *jvm, void *) {
JNIEnv *env;
jclass clazz;
if (jvm->GetEnv((void **) &env, JNI_VERSION_1_6) != JNI_OK) {
return JNI_ERR;
}
jclass vm = env->FindClass("dalvik/system/VMRuntime");
jclass string = env->FindClass("java/lang/String");
jmethodID set = env->GetMethodID(vm, "setHiddenApiExemptions", "([Ljava/lang/String;)V");
jmethodID get = env->GetStaticMethodID(vm, "getRuntime", "()Ldalvik/system/VMRuntime;");
jstring empty = env->NewStringUTF("");
jarray array = env->NewObjectArray(1, string, empty);
jobject runtime = env->CallStaticObjectMethod(vm, get);
env->CallVoidMethod(runtime, set, array);
return JNI_VERSION_1_6;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment