You've already forked PlayIntegrityFork
mirror of
https://github.com/osm0sis/PlayIntegrityFork.git
synced 2025-09-06 06:37:06 +00:00
Use app data dir to detect GMS package
Prevent injecting into unrelated apps because apps can use whatever process name. This effectively restores df20bdb but with null checks added to prevent crash. Reference: topjohnwu/Magisk@07c22cc Co-authored-by: chiteroman <98092901+chiteroman@users.noreply.github.com> Co-authored-by: Wang Han <416810799@qq.com>
This commit is contained in:
@@ -93,21 +93,30 @@ public:
|
||||
bool isGms = false, isGmsUnstable = false;
|
||||
|
||||
auto rawProcess = env->GetStringUTFChars(args->nice_name, nullptr);
|
||||
auto rawDir = env->GetStringUTFChars(args->app_data_dir, nullptr);
|
||||
|
||||
if (rawProcess) {
|
||||
std::string_view process(rawProcess);
|
||||
|
||||
isGms = process.starts_with("com.google.android.gms");
|
||||
isGmsUnstable = process.compare("com.google.android.gms.unstable") == 0;
|
||||
// Prevent crash on apps with no data dir
|
||||
if (rawDir == nullptr) {
|
||||
env->ReleaseStringUTFChars(args->nice_name, rawProcess);
|
||||
api->setOption(zygisk::DLCLOSE_MODULE_LIBRARY);
|
||||
return;
|
||||
}
|
||||
|
||||
std::string_view process(rawProcess);
|
||||
std::string_view dir(rawDir);
|
||||
|
||||
isGms = dir.ends_with("/com.google.android.gms");
|
||||
isGmsUnstable = process == "com.google.android.gms.unstable";
|
||||
|
||||
env->ReleaseStringUTFChars(args->nice_name, rawProcess);
|
||||
env->ReleaseStringUTFChars(args->app_data_dir, rawDir);
|
||||
|
||||
if (!isGms) {
|
||||
api->setOption(zygisk::DLCLOSE_MODULE_LIBRARY);
|
||||
return;
|
||||
}
|
||||
|
||||
// We are in GMS now, force unmount
|
||||
api->setOption(zygisk::FORCE_DENYLIST_UNMOUNT);
|
||||
|
||||
if (!isGmsUnstable) {
|
||||
@@ -115,7 +124,9 @@ public:
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector<char> jsonVector;
|
||||
long dexSize = 0, jsonSize = 0;
|
||||
|
||||
int fd = api->connectCompanion();
|
||||
|
||||
read(fd, &dexSize, sizeof(long));
|
||||
@@ -135,22 +146,22 @@ public:
|
||||
return;
|
||||
}
|
||||
|
||||
LOGD("Read from file descriptor for 'dex' -> %ld bytes", dexSize);
|
||||
LOGD("Read from file descriptor for 'json' -> %ld bytes", jsonSize);
|
||||
|
||||
dexVector.resize(dexSize);
|
||||
read(fd, dexVector.data(), dexSize);
|
||||
|
||||
std::vector<char> jsonVector(jsonSize);
|
||||
jsonVector.resize(jsonSize);
|
||||
read(fd, jsonVector.data(), jsonSize);
|
||||
|
||||
close(fd);
|
||||
|
||||
LOGD("Read from file descriptor for 'dex' -> %ld bytes", dexSize);
|
||||
LOGD("Read from file descriptor for 'json' -> %ld bytes", jsonSize);
|
||||
|
||||
std::string data(jsonVector.cbegin(), jsonVector.cend());
|
||||
json = nlohmann::json::parse(data, nullptr, false, true);
|
||||
std::string jsonString(jsonVector.cbegin(), jsonVector.cend());
|
||||
json = nlohmann::json::parse(jsonString, nullptr, false, true);
|
||||
|
||||
jsonVector.clear();
|
||||
data.clear();
|
||||
jsonString.clear();
|
||||
}
|
||||
|
||||
void postAppSpecialize(const zygisk::AppSpecializeArgs *args) override {
|
||||
|
||||
Reference in New Issue
Block a user