Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refine logic #157

Merged
merged 1 commit into from
Dec 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 21 additions & 17 deletions app/src/main/cpp/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,21 +65,26 @@ class PlayIntegrityFix : public zygisk::ModuleBase {
}

void preAppSpecialize(zygisk::AppSpecializeArgs *args) override {
int is_gms = 0;

if (to_app_id(args->uid) < 10000 || to_app_id(args->uid) > 19999 || // not app process
(args->is_child_zygote && *(args->is_child_zygote))) { // app_zygote
api->setOption(zygisk::DLCLOSE_MODULE_LIBRARY);
return;
goto dlclose_module;
}

const auto *process = env->GetStringUTFChars(args->nice_name, nullptr);
const auto *app_data_dir = env->GetStringUTFChars(args->app_data_dir, nullptr);

if (std::string_view(app_data_dir).ends_with("/com.google.android.gms")) { // gms processes
{
const auto *process = env->GetStringUTFChars(args->nice_name, nullptr);
const auto *app_data_dir = env->GetStringUTFChars(args->app_data_dir, nullptr);
is_gms += (std::string_view(app_data_dir).ends_with("/com.google.android.gms"));
is_gms += (is_gms && std::string_view(process) == "com.google.android.gms.unstable");
env->ReleaseStringUTFChars(args->nice_name, process);
env->ReleaseStringUTFChars(args->app_data_dir, app_data_dir);
}

if (is_gms) { // gms processes
api->setOption(zygisk::FORCE_DENYLIST_UNMOUNT);

if (std::string_view(process) == "com.google.android.gms.unstable") { // play integrity process

if (is_gms == 2) { // play integrity process
long size = 0;
int fd = api->connectCompanion();

Expand All @@ -88,19 +93,18 @@ class PlayIntegrityFix : public zygisk::ModuleBase {
if (size > 0) {
vector.resize(size);
read(fd, vector.data(), size);
} else {
api->setOption(zygisk::DLCLOSE_MODULE_LIBRARY);
LOGD("Couldn't read classes.dex");
close(fd);
return;
}


LOGD("Couldn't read classes.dex");
close(fd);
}
}

} else api->setOption(zygisk::DLCLOSE_MODULE_LIBRARY);

} else api->setOption(zygisk::DLCLOSE_MODULE_LIBRARY);
dlclose_module:
api->setOption(zygisk::DLCLOSE_MODULE_LIBRARY);

env->ReleaseStringUTFChars(args->nice_name, process);
env->ReleaseStringUTFChars(args->app_data_dir, app_data_dir);
}

void postAppSpecialize(const zygisk::AppSpecializeArgs *args) override {
Expand Down