You've already forked Zygisk-Assistant
mirror of
https://github.com/snake-4/Zygisk-Assistant.git
synced 2025-09-06 06:37:02 +00:00
Unhook unshare at postAppSpecialize
This commit is contained in:
@@ -35,6 +35,7 @@ public:
|
|||||||
|
|
||||||
void preAppSpecialize(AppSpecializeArgs *args) override
|
void preAppSpecialize(AppSpecializeArgs *args) override
|
||||||
{
|
{
|
||||||
|
isHooked = false;
|
||||||
api->setOption(zygisk::Option::DLCLOSE_MODULE_LIBRARY);
|
api->setOption(zygisk::Option::DLCLOSE_MODULE_LIBRARY);
|
||||||
|
|
||||||
uint32_t flags = api->getFlags();
|
uint32_t flags = api->getFlags();
|
||||||
@@ -54,11 +55,12 @@ public:
|
|||||||
* The logic behind whether there's going to be an unshare or not changes with each major Android version.
|
* The logic behind whether there's going to be an unshare or not changes with each major Android version.
|
||||||
* For maximum compatibility, we will always unshare but prevent further unshare by this Zygote fork in appSpecialize.
|
* For maximum compatibility, we will always unshare but prevent further unshare by this Zygote fork in appSpecialize.
|
||||||
*/
|
*/
|
||||||
if (!plt_hook_wrapper("libandroid_runtime.so", "unshare", new_unshare, old_unshare))
|
if (!plt_hook_wrapper("libandroid_runtime.so", "unshare", new_unshare, (void **)&old_unshare))
|
||||||
{
|
{
|
||||||
LOGE("plt_hook_wrapper(\"libandroid_runtime.so\", \"unshare\", new_unshare, old_unshare) returned false");
|
LOGE("plt_hook_wrapper(\"libandroid_runtime.so\", \"unshare\", new_unshare, old_unshare) returned false");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
isHooked = true;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* preAppSpecialize is before any possible unshare calls.
|
* preAppSpecialize is before any possible unshare calls.
|
||||||
@@ -77,7 +79,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
if (mount("rootfs", "/", NULL, (MS_SLAVE | MS_REC), NULL) == -1)
|
if (mount("rootfs", "/", NULL, (MS_SLAVE | MS_REC), NULL) == -1)
|
||||||
{
|
{
|
||||||
LOGE("mount(\"rootfs\", \"/\", NULL, (MS_SLAVE | MS_REC), NULL) returned -1");
|
LOGE("mount(\"rootfs\", \"/\", NULL, (MS_SLAVE | MS_REC), NULL) returned -1: %d (%s)", errno, strerror(errno));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -89,13 +91,25 @@ public:
|
|||||||
api->setOption(zygisk::Option::DLCLOSE_MODULE_LIBRARY);
|
api->setOption(zygisk::Option::DLCLOSE_MODULE_LIBRARY);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Return, typename... Args>
|
void postAppSpecialize(const AppSpecializeArgs *args) override
|
||||||
bool plt_hook_wrapper(const std::string &libName, const std::string &symbolName, Return (&hookFunction)(Args...), Return (*&originalFunction)(Args...))
|
|
||||||
{
|
{
|
||||||
return hook_plt_by_name(api, libName, symbolName, (void *)&hookFunction, (void **)&originalFunction) && api->pltHookCommit();
|
if (isHooked)
|
||||||
|
{
|
||||||
|
if (!plt_hook_wrapper("libandroid_runtime.so", "unshare", old_unshare, nullptr))
|
||||||
|
{
|
||||||
|
LOGE("plt_hook_wrapper(\"libandroid_runtime.so\", \"unshare\", old_unshare, nullptr) returned false");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool plt_hook_wrapper(const std::string &libName, const std::string &symbolName, void *hookFunction, void **originalFunction)
|
||||||
|
{
|
||||||
|
return hook_plt_by_name(api, libName, symbolName, hookFunction, originalFunction) && api->pltHookCommit();
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
bool isHooked = false;
|
||||||
Api *api;
|
Api *api;
|
||||||
JNIEnv *env;
|
JNIEnv *env;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user