diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 88ddfee..713ff74 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,3 +24,7 @@ jobs: run: | chmod +x ./gradlew ./gradlew :module:assembleRelease + - uses: actions/upload-artifact@v3 + with: + name: ZygiskFrida + path: out/magisk_module_release/ \ No newline at end of file diff --git a/module.gradle b/module.gradle index c2cb28c..8e3d7e6 100644 --- a/module.gradle +++ b/module.gradle @@ -5,7 +5,7 @@ ext { moduleName = "ZygiskFrida" moduleAuthor = "lico-n" moduleDescription = "Injects frida gadget via zygisk." - moduleVersion = "v1.0.0" + moduleVersion = "v1.1.0" moduleVersionCode = 1 modulePackageName = "re.zyg.fri" diff --git a/module/src/jni/main.cpp b/module/src/jni/main.cpp index 3cfd4fe..70cd085 100644 --- a/module/src/jni/main.cpp +++ b/module/src/jni/main.cpp @@ -17,36 +17,28 @@ class MyModule : public zygisk::ModuleBase { this->env = env; } - void preAppSpecialize(AppSpecializeArgs *args) override { - auto raw_app_name = env->GetStringUTFChars(args->nice_name, nullptr); - this->app_name = std::string(raw_app_name); + void postAppSpecialize(const AppSpecializeArgs *args) override { + const char* raw_app_name = env->GetStringUTFChars(args->nice_name, nullptr); + std::string app_name = std::string(raw_app_name); this->env->ReleaseStringUTFChars(args->nice_name, raw_app_name); std::string module_dir = std::string("/data/local/tmp/") + ModulePackageName; - this->gadget_path = module_dir + "/" + GadgetLibraryName; + std::string gadget_path = module_dir + "/" + GadgetLibraryName; - this->inject = should_inject(module_dir, this->app_name); - if (!this->inject) { + if (!should_inject(module_dir, app_name)) { this->api->setOption(zygisk::Option::DLCLOSE_MODULE_LIBRARY); return; } - LOGI("App detected: %s", this->app_name.c_str()); - } + LOGI("App detected: %s", app_name.c_str()); - void postAppSpecialize(const AppSpecializeArgs *) override { - if (this->inject) { - std::thread inject_thread(inject_gadget, this->gadget_path, this->app_name); - inject_thread.detach(); - } + std::thread inject_thread(inject_gadget, gadget_path, app_name); + inject_thread.detach(); } private: Api *api; JNIEnv *env; - bool inject; - std::string gadget_path; - std::string app_name; }; REGISTER_ZYGISK_MODULE(MyModule) diff --git a/template/magisk_module/customize.sh b/template/magisk_module/customize.sh index c141010..380de89 100644 --- a/template/magisk_module/customize.sh +++ b/template/magisk_module/customize.sh @@ -4,6 +4,8 @@ mkdir -p \$TMP_MODULE_DIR cp \$MODPATH/gadget/libgadget-\$ARCH.so.xz \$TMP_MODULE_DIR/${gadgetLibraryName}.xz /data/adb/magisk/busybox unxz \$TMP_MODULE_DIR/${gadgetLibraryName}.xz +rm \$TMP_MODULE_DIR/${gadgetLibraryName}.xz + touch \$TMP_MODULE_DIR/target_packages set_perm_recursive \$TMP_MODULE_DIR 0 0 0755 0644