From 9b4249424b71cc9410c9f612cb8095e1acfce57d Mon Sep 17 00:00:00 2001 From: chiteroman Date: Wed, 15 Jan 2025 21:11:31 +0100 Subject: [PATCH] fix bad code --- app/build.gradle.kts | 19 +++++++++++++++---- app/src/main/cpp/inject.cpp | 14 +++++++------- app/src/main/cpp/main.cpp | 4 ++-- module/module.prop | 4 ++-- 4 files changed, 26 insertions(+), 15 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index ab8071bf..7b3c9f07 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -25,8 +25,8 @@ android { applicationId = "es.chiteroman.playintegrityfix" minSdk = 26 targetSdk = 35 - versionCode = 18201 - versionName = "v18.2.1-EXPERIMENTAL" + versionCode = 18300 + versionName = "v18.3" multiDexEnabled = false externalNativeBuild { @@ -37,8 +37,19 @@ android { ) arguments( - "-DCMAKE_BUILD_TYPE=MinSizeRel", - "-DANDROID_STL=none" + "-DCMAKE_BUILD_TYPE=Release", + "-DANDROID_STL=none", + "-DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON", + "-DANDROID_ALLOW_UNDEFINED_SYMBOLS=ON", + "-DCMAKE_CXX_STANDARD=23", + "-DCMAKE_C_STANDARD=23", + "-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON", + "-DCMAKE_VISIBILITY_INLINES_HIDDEN=ON", + "-DCMAKE_CXX_VISIBILITY_PRESET=hidden", + "-DCMAKE_C_VISIBILITY_PRESET=hidden", + "-DCMAKE_ANDROID_EXCEPTIONS=OFF", + "-DCMAKE_ANDROID_RTTI=OFF", + "-DANDROID_CPP_FEATURES='no-rtti no-exceptions'" ) cFlags( diff --git a/app/src/main/cpp/inject.cpp b/app/src/main/cpp/inject.cpp index fd29a63d..2a6ca87b 100644 --- a/app/src/main/cpp/inject.cpp +++ b/app/src/main/cpp/inject.cpp @@ -241,7 +241,7 @@ void injectDex() { extern "C" { [[gnu::visibility("default"), maybe_unused]] -void init(const char *dir, JavaVM *jvm) { +void init(const char *dir, JavaVM *jvm, jint jni_version) { if (dir) { LOGD("[INJECT] GMS dir: %s", dir); @@ -251,18 +251,18 @@ void init(const char *dir, JavaVM *jvm) { } if (jvm) { - auto result = jvm->GetEnv(reinterpret_cast(&env), JNI_VERSION_1_6); - LOGD("[INJECT] JVM: %d", result); - if (result == JNI_EDETACHED) { - result = jvm->AttachCurrentThread(&env, nullptr); - LOGD("[INJECT] (JNI_EDETACHED) JVM: %d", result); + auto result = jvm->GetEnv(reinterpret_cast(&env), jni_version); + if (result != JNI_OK) { + LOGE("[INJECT] GetEnv error: %d", result); + return; } } else { LOGE("[INJECT] jvm is null!"); + return; } if (env) { - LOGD("[INJECT] JNIEnv: %d", env->GetVersion()); + LOGD("[INJECT] JNIEnv version: %x", env->GetVersion()); } else { LOGE("[INJECT] env is null!"); return; diff --git a/app/src/main/cpp/main.cpp b/app/src/main/cpp/main.cpp index 681d03f4..c73a8521 100644 --- a/app/src/main/cpp/main.cpp +++ b/app/src/main/cpp/main.cpp @@ -263,7 +263,7 @@ class PlayIntegrityFix : public ModuleBase { dlerror(); - typedef void (*init_t)(const char *, JavaVM *); + typedef void (*init_t)(const char *, JavaVM *, jint); auto init_func = reinterpret_cast(dlsym(handle, "init")); const char *error = dlerror(); @@ -281,7 +281,7 @@ class PlayIntegrityFix : public ModuleBase { return; } - init_func(gmsDir.c_str(), jvm); + init_func(gmsDir.c_str(), jvm, env->GetVersion()); } void preServerSpecialize(ServerSpecializeArgs *args) override { diff --git a/module/module.prop b/module/module.prop index 5bef5c55..629d0e6f 100644 --- a/module/module.prop +++ b/module/module.prop @@ -1,7 +1,7 @@ id=playintegrityfix name=Play Integrity Fix -version=v18.2.1-EXPERIMENTAL -versionCode=18201 +version=v18.3 +versionCode=18300 author=chiteroman description=Universal modular fix for Play Integrity (and SafetyNet) on devices running Android 8-15 updateJson=https://raw.githubusercontent.com/chiteroman/PlayIntegrityFix/main/update.json