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;
|
bool isGms = false, isGmsUnstable = false;
|
||||||
|
|
||||||
auto rawProcess = env->GetStringUTFChars(args->nice_name, nullptr);
|
auto rawProcess = env->GetStringUTFChars(args->nice_name, nullptr);
|
||||||
|
auto rawDir = env->GetStringUTFChars(args->app_data_dir, nullptr);
|
||||||
|
|
||||||
if (rawProcess) {
|
// Prevent crash on apps with no data dir
|
||||||
std::string_view process(rawProcess);
|
if (rawDir == nullptr) {
|
||||||
|
env->ReleaseStringUTFChars(args->nice_name, rawProcess);
|
||||||
isGms = process.starts_with("com.google.android.gms");
|
api->setOption(zygisk::DLCLOSE_MODULE_LIBRARY);
|
||||||
isGmsUnstable = process.compare("com.google.android.gms.unstable") == 0;
|
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->nice_name, rawProcess);
|
||||||
|
env->ReleaseStringUTFChars(args->app_data_dir, rawDir);
|
||||||
|
|
||||||
if (!isGms) {
|
if (!isGms) {
|
||||||
api->setOption(zygisk::DLCLOSE_MODULE_LIBRARY);
|
api->setOption(zygisk::DLCLOSE_MODULE_LIBRARY);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// We are in GMS now, force unmount
|
||||||
api->setOption(zygisk::FORCE_DENYLIST_UNMOUNT);
|
api->setOption(zygisk::FORCE_DENYLIST_UNMOUNT);
|
||||||
|
|
||||||
if (!isGmsUnstable) {
|
if (!isGmsUnstable) {
|
||||||
@@ -115,7 +124,9 @@ public:
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<char> jsonVector;
|
||||||
long dexSize = 0, jsonSize = 0;
|
long dexSize = 0, jsonSize = 0;
|
||||||
|
|
||||||
int fd = api->connectCompanion();
|
int fd = api->connectCompanion();
|
||||||
|
|
||||||
read(fd, &dexSize, sizeof(long));
|
read(fd, &dexSize, sizeof(long));
|
||||||
@@ -135,22 +146,22 @@ public:
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LOGD("Read from file descriptor for 'dex' -> %ld bytes", dexSize);
|
||||||
|
LOGD("Read from file descriptor for 'json' -> %ld bytes", jsonSize);
|
||||||
|
|
||||||
dexVector.resize(dexSize);
|
dexVector.resize(dexSize);
|
||||||
read(fd, dexVector.data(), dexSize);
|
read(fd, dexVector.data(), dexSize);
|
||||||
|
|
||||||
std::vector<char> jsonVector(jsonSize);
|
jsonVector.resize(jsonSize);
|
||||||
read(fd, jsonVector.data(), jsonSize);
|
read(fd, jsonVector.data(), jsonSize);
|
||||||
|
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
||||||
LOGD("Read from file descriptor for 'dex' -> %ld bytes", dexSize);
|
std::string jsonString(jsonVector.cbegin(), jsonVector.cend());
|
||||||
LOGD("Read from file descriptor for 'json' -> %ld bytes", jsonSize);
|
json = nlohmann::json::parse(jsonString, nullptr, false, true);
|
||||||
|
|
||||||
std::string data(jsonVector.cbegin(), jsonVector.cend());
|
|
||||||
json = nlohmann::json::parse(data, nullptr, false, true);
|
|
||||||
|
|
||||||
jsonVector.clear();
|
jsonVector.clear();
|
||||||
data.clear();
|
jsonString.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void postAppSpecialize(const zygisk::AppSpecializeArgs *args) override {
|
void postAppSpecialize(const zygisk::AppSpecializeArgs *args) override {
|
||||||
|
|||||||
Reference in New Issue
Block a user