int getCallingUid(JNIEnv *env, jclass jclazz) { int (*org_getCallingUid)(int) = (int (*)(int)) g_sym_IPCThreadState_getCallingUid; int (*func_self)(void) = (int (*)(void)) g_sym_IPCThreadState_self; int uid = org_getCallingUid(func_self()); if (uid == getuid()) { uid = env->CallStaticIntMethod(g_jclass, g_methodid_onGetCallingUid, uid); return uid; } return uid; }
jint getCallingUid(JNIEnv *env, jclass jclazz) { jint uid; if (gOffset.isArt) { uid = gOffset.orig_getCallingUid(env, jclazz); } else { int (*org_getCallingUid)(int) = (int (*)(int)) gOffset.sym_IPCThreadState_getCallingUid; int (*func_self)(void) = (int (*)(void)) gOffset.sym_IPCThreadState_self; uid = org_getCallingUid(func_self()); } uid = env->CallStaticIntMethod(gClass, gOffset.method_onGetCallingUid, uid); return uid; }