zygisk: Inject payload after specialization

This commit is contained in:
Danny Lin 2021-10-30 19:47:16 -07:00
parent cd84bf361f
commit 69e2aae3d8
No known key found for this signature in database
GPG Key ID: 1988FAA1797EE5AC

View File

@ -26,6 +26,15 @@ public:
preSpecialize(process);
}
void postAppSpecialize(const zygisk::AppSpecializeArgs *args) override {
// Inject if module was loaded, otherwise this would've been unloaded by now (for non-GMS)
if (!moduleDex.empty()) {
LOGD("Injecting payload...");
injectPayload();
LOGI("Payload injected");
}
}
private:
zygisk::Api *api;
JNIEnv *env;
@ -81,10 +90,12 @@ private:
// caused by model detection and flag provisioning, such as broken weather with the new
// smartspace on Android 12.
if (process == "com.google.android.gms.unstable") {
// This is post-fork, so just inject the payload now
// Load the payload, but don't inject it yet until after specialization
// Otherwise, specialization fails if any code from the payload still happens to be
// running
LOGD("Loading payload...");
loadPayload();
injectPayload();
LOGI("Payload injected");
LOGD("Payload loaded");
}
}