Skip to content

Commit

Permalink
Merge pull request #157 from HuskyDG/logic
Browse files Browse the repository at this point in the history
Refine logic
  • Loading branch information
chiteroman authored Dec 8, 2023
2 parents b8b1d12 + ce74df8 commit fdf2a0c
Showing 1 changed file with 21 additions and 17 deletions.
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

0 comments on commit fdf2a0c

Please sign in to comment.