From 812d2911b27cedf7c028d96ff90a9826601a2354 Mon Sep 17 00:00:00 2001 From: 5ec1cff Date: Sat, 13 Jul 2024 16:53:06 +0800 Subject: [PATCH] add a switch for zygisk module --- README.md | 7 +++++++ module/src/main/cpp/zygisk/main.cpp | 19 +++++++++++++++++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 01bfd1d..fd172e4 100644 --- a/README.md +++ b/README.md @@ -37,3 +37,10 @@ format: ``` + +## Build Vars Spoofing + +If you can not pass strong integrity, you can try to enable build vars spoofing +by creating a file in `/data/adb/modules/tricky_store/spoof_build_vars`. + +Zygisk (or Zygisk Next) is needed for this feature to work. diff --git a/module/src/main/cpp/zygisk/main.cpp b/module/src/main/cpp/zygisk/main.cpp index 7d5db6b..694d81a 100644 --- a/module/src/main/cpp/zygisk/main.cpp +++ b/module/src/main/cpp/zygisk/main.cpp @@ -20,6 +20,16 @@ public: } void preAppSpecialize(AppSpecializeArgs *args) override { + int enabled = 0; + api_->setOption(zygisk::DLCLOSE_MODULE_LIBRARY); + { + auto fd = api_->connectCompanion(); + if (fd >= 0) { + read(fd, &enabled, sizeof(enabled)); + close(fd); + } + } + if (!enabled) return; const char *process = env_->GetStringUTFChars(args->nice_name, nullptr); if (process == "com.google.android.gms.unstable"sv) { LOGI("spoofing build vars in %s!", process); @@ -45,7 +55,6 @@ public: SET_FIELD(buildClass, "TAGS", "release-keys"); } env_->ReleaseStringUTFChars(args->nice_name, process); - api_->setOption(zygisk::DLCLOSE_MODULE_LIBRARY); } void preServerSpecialize(ServerSpecializeArgs *args) override { @@ -57,6 +66,12 @@ private: JNIEnv *env_; }; +static void companion_handler(int fd) { + int enabled = access("/data/adb/modules/tricky_store/spoof_build_vars", F_OK) == 0; + write(fd, &enabled, sizeof(enabled)); +} + // Register our module class and the companion handler function REGISTER_ZYGISK_MODULE(TrickyStore) -// REGISTER_ZYGISK_COMPANION(companion_handler) + +REGISTER_ZYGISK_COMPANION(companion_handler)