diff --git a/app/src/main/cpp/CMakeLists.txt b/app/src/main/cpp/CMakeLists.txt index 28e3db0..d5b8e28 100644 --- a/app/src/main/cpp/CMakeLists.txt +++ b/app/src/main/cpp/CMakeLists.txt @@ -2,12 +2,13 @@ cmake_minimum_required(VERSION 3.30.3) project("playintegrityfix") -find_package(cxx REQUIRED CONFIG) - -link_libraries(cxx::cxx) - add_library(${CMAKE_PROJECT_NAME} SHARED main.cpp) add_subdirectory(Dobby) -target_link_libraries(${CMAKE_PROJECT_NAME} log dobby_static) +find_package(cxx REQUIRED CONFIG) + +target_link_libraries(dobby cxx::cxx) +target_link_libraries(dobby_static cxx::cxx) + +target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE log dobby_static) diff --git a/app/src/main/cpp/main.cpp b/app/src/main/cpp/main.cpp index ab68635..880379e 100644 --- a/app/src/main/cpp/main.cpp +++ b/app/src/main/cpp/main.cpp @@ -20,9 +20,6 @@ #define CUSTOM_JSON_FORK "/data/adb/modules/playintegrityfix/custom.pif.json" #define CUSTOM_JSON "/data/adb/pif.json" -#define VENDING_PACKAGE "com.android.vending" -#define DROIDGUARD_PACKAGE "com.google.android.gms.unstable" - static ssize_t xread(int fd, void *buffer, size_t count) { ssize_t total = 0; char *buf = static_cast(buffer); @@ -119,25 +116,23 @@ public: } void preAppSpecialize(zygisk::AppSpecializeArgs *args) override { + const char *rawDir = env->GetStringUTFChars(args->app_data_dir, nullptr); + const char *rawName = env->GetStringUTFChars(args->nice_name, nullptr); - if (!args) { - api->setOption(zygisk::DLCLOSE_MODULE_LIBRARY); - return; + std::string dir, name; + + if (rawDir) { + dir = rawDir; + env->ReleaseStringUTFChars(args->app_data_dir, rawDir); } - auto dir = env->GetStringUTFChars(args->app_data_dir, nullptr); - - if (!dir) { - api->setOption(zygisk::DLCLOSE_MODULE_LIBRARY); - return; + if (rawName) { + name = rawName; + env->ReleaseStringUTFChars(args->nice_name, rawName); } - std::string_view vDir(dir); - - bool isGms = - vDir.ends_with("/com.google.android.gms") || vDir.ends_with("/com.android.vending"); - - env->ReleaseStringUTFChars(args->app_data_dir, dir); + bool isGms = dir.ends_with("/com.google.android.gms"); + bool isGmsUnstable = name == "com.google.android.gms.unstable"; if (!isGms) { api->setOption(zygisk::DLCLOSE_MODULE_LIBRARY); @@ -146,31 +141,11 @@ public: api->setOption(zygisk::FORCE_DENYLIST_UNMOUNT); - auto name = env->GetStringUTFChars(args->nice_name, nullptr); - - if (!name) { + if (!isGmsUnstable) { api->setOption(zygisk::DLCLOSE_MODULE_LIBRARY); return; } - std::string_view vName(name); - - isGmsUnstable = vName == DROIDGUARD_PACKAGE; - isVending = vName == VENDING_PACKAGE; - - env->ReleaseStringUTFChars(args->nice_name, name); - - if (!isGmsUnstable && !isVending) { - api->setOption(zygisk::DLCLOSE_MODULE_LIBRARY); - return; - } - - if (isGmsUnstable) - LOGD("We are in GMS unstable process!"); - - if (isVending) - LOGD("We are in Play Store process!"); - int fd = api->connectCompanion(); size_t dexSize = 0, jsonSize = 0; @@ -217,26 +192,21 @@ public: } void postAppSpecialize(const zygisk::AppSpecializeArgs *args) override { - if (dexVector.empty()) return; + if (dexVector.empty() || json.empty()) return; - if (isGmsUnstable) { - UpdateBuildFields(); + UpdateBuildFields(); - if (spoofProvider || spoofSignature) { - injectDex(); - } else { - LOGD("Dex file won't be injected due spoofProvider and spoofSignature are false"); - } + if (spoofProvider || spoofSignature) { + injectDex(); + } else { + LOGD("Dex file won't be injected due spoofProvider and spoofSignature are false"); + } - if (spoofProps) { - if (!doHook()) { - dlclose(); - } - } else { + if (spoofProps) { + if (!doHook()) { dlclose(); } - } else if (isVending) { - doSpoofVending(); + } else { dlclose(); } @@ -253,84 +223,20 @@ public: private: zygisk::Api *api = nullptr; JNIEnv *env = nullptr; - bool isGmsUnstable = false; - bool isVending = false; std::vector dexVector; nlohmann::json json; bool spoofProps = true; bool spoofProvider = true; bool spoofSignature = false; - int spoofVendingSdk = 0; void dlclose() { LOGD("dlclose zygisk lib"); api->setOption(zygisk::DLCLOSE_MODULE_LIBRARY); } - void doSpoofVending() { - if (spoofVendingSdk < 1) return; - int requestSdk = (spoofVendingSdk == 1) ? 32 : spoofVendingSdk; - int targetSdk; - int oldValue; - - jclass buildVersionClass = nullptr; - jfieldID sdkIntFieldID = nullptr; - - buildVersionClass = env->FindClass("android/os/Build$VERSION"); - if (buildVersionClass == nullptr) { - LOGE("Build.VERSION class not found"); - env->ExceptionClear(); - return; - } - - sdkIntFieldID = env->GetStaticFieldID(buildVersionClass, "SDK_INT", "I"); - if (sdkIntFieldID == nullptr) { - LOGE("SDK_INT field not found"); - env->ExceptionClear(); - env->DeleteLocalRef(buildVersionClass); - return; - } - - oldValue = env->GetStaticIntField(buildVersionClass, sdkIntFieldID); - targetSdk = std::min(oldValue, requestSdk); - - if (oldValue == targetSdk) { - env->DeleteLocalRef(buildVersionClass); - return; - } - - env->SetStaticIntField(buildVersionClass, sdkIntFieldID, targetSdk); - - if (env->ExceptionCheck()) { - env->ExceptionDescribe(); - env->ExceptionClear(); - LOGE("SDK_INT field not accessible (JNI Exception)"); - } else { - LOGE("[SDK_INT]: %d -> %d", oldValue, targetSdk); - } - - env->DeleteLocalRef(buildVersionClass); - } - void parseJSON() { if (json.empty()) return; - if (json.contains("spoofVendingSdk")) { - if (json["spoofVendingSdk"].is_string()) { - spoofVendingSdk = std::stoi(json["spoofVendingSdk"].get()); - } else if (json["spoofVendingSdk"].is_number_integer()) { - spoofVendingSdk = json["spoofVendingSdk"].get(); - } else { - LOGE("Error parsing spoofVendingSdk!"); - } - json.erase("spoofVendingSdk"); - } - - if (isVending) { - json.clear(); - return; - } - if (json.contains("DEVICE_INITIAL_SDK_INT")) { if (json["DEVICE_INITIAL_SDK_INT"].is_string()) { DEVICE_INITIAL_SDK_INT = json["DEVICE_INITIAL_SDK_INT"].get(); diff --git a/module/post-fs-data.sh b/module/post-fs-data.sh index 4a0efb9..5fb28e3 100644 --- a/module/post-fs-data.sh +++ b/module/post-fs-data.sh @@ -4,7 +4,6 @@ MODPATH="${0%/*}" # Remove Play Services and Play Store from Magisk DenyList when set to Enforce in normal mode if magisk --denylist status; then magisk --denylist rm com.google.android.gms - magisk --denylist rm com.android.vending else # Check if Shamiko is installed and whitelist feature isn't enabled if [ -d "/data/adb/modules/zygisk_shamiko" ] && [ ! -f "/data/adb/shamiko/whitelist" ]; then