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
Renamed some functions
This commit is contained in:
@@ -6,5 +6,5 @@
|
||||
ret (*old_##func)(__VA_ARGS__); \
|
||||
ret new_##func(__VA_ARGS__)
|
||||
|
||||
int is_userapp_uid(int uid);
|
||||
bool hook_plt_by_name(zygisk::Api *api, const std::string &libName, const std::string &symbolName, void *hookFunc, void **origFunc);
|
||||
int isUserAppUID(int uid);
|
||||
bool hookPLTByName(zygisk::Api *api, const std::string &libName, const std::string &symbolName, void *hookFunc, void **origFunc);
|
||||
|
||||
@@ -10,8 +10,8 @@ using zygisk::Api;
|
||||
using zygisk::AppSpecializeArgs;
|
||||
using zygisk::ServerSpecializeArgs;
|
||||
|
||||
void do_unmount();
|
||||
void do_remount();
|
||||
void doUnmount();
|
||||
void doRemount();
|
||||
|
||||
DCL_HOOK_FUNC(static int, unshare, int flags)
|
||||
{
|
||||
@@ -42,12 +42,11 @@ public:
|
||||
uint32_t flags = api->getFlags();
|
||||
bool isRoot = (flags & zygisk::StateFlag::PROCESS_GRANTED_ROOT) != 0;
|
||||
bool isOnDenylist = (flags & zygisk::StateFlag::PROCESS_ON_DENYLIST) != 0;
|
||||
if (isRoot || !isOnDenylist || !is_userapp_uid(args->uid))
|
||||
if (isRoot || !isOnDenylist || !isUserAppUID(args->uid))
|
||||
{
|
||||
LOGD("Skipping pid=%d ppid=%d uid=%d", getpid(), getppid(), args->uid);
|
||||
return;
|
||||
}
|
||||
|
||||
LOGD("Processing pid=%d ppid=%d uid=%d", getpid(), getppid(), args->uid);
|
||||
|
||||
/*
|
||||
@@ -56,7 +55,7 @@ public:
|
||||
* 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.
|
||||
*/
|
||||
if (!plt_hook_wrapper("libandroid_runtime.so", "unshare", new_unshare, (void **)&old_unshare))
|
||||
if (!hookPLTByName("libandroid_runtime.so", "unshare", &new_unshare, &old_unshare))
|
||||
{
|
||||
LOGE("plt_hook_wrapper(\"libandroid_runtime.so\", \"unshare\", new_unshare, old_unshare) returned false");
|
||||
return;
|
||||
@@ -84,8 +83,8 @@ public:
|
||||
return;
|
||||
}
|
||||
|
||||
do_unmount();
|
||||
do_remount();
|
||||
doUnmount();
|
||||
doRemount();
|
||||
}
|
||||
|
||||
void preServerSpecialize(ServerSpecializeArgs *args) override
|
||||
@@ -97,7 +96,7 @@ public:
|
||||
{
|
||||
if (isHooked)
|
||||
{
|
||||
if (!plt_hook_wrapper("libandroid_runtime.so", "unshare", old_unshare, nullptr))
|
||||
if (!hookPLTByName("libandroid_runtime.so", "unshare", old_unshare))
|
||||
{
|
||||
LOGE("plt_hook_wrapper(\"libandroid_runtime.so\", \"unshare\", old_unshare, nullptr) returned false");
|
||||
return;
|
||||
@@ -105,9 +104,10 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
bool plt_hook_wrapper(const std::string &libName, const std::string &symbolName, void *hookFunction, void **originalFunction)
|
||||
template <typename T>
|
||||
bool hookPLTByName(const std::string &libName, const std::string &symbolName, T *hookFunction, T **originalFunction = nullptr)
|
||||
{
|
||||
return hook_plt_by_name(api, libName, symbolName, hookFunction, originalFunction) && api->pltHookCommit();
|
||||
return ::hookPLTByName(api, libName, symbolName, (void *)hookFunction, (void **)originalFunction) && api->pltHookCommit();
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -116,4 +116,4 @@ private:
|
||||
JNIEnv *env;
|
||||
};
|
||||
|
||||
REGISTER_ZYGISK_MODULE(ZygiskModule)
|
||||
REGISTER_ZYGISK_MODULE(ZygiskModule)
|
||||
|
||||
@@ -57,7 +57,7 @@ static bool shouldUnmount(const mount_entry_t &mount)
|
||||
return false;
|
||||
}
|
||||
|
||||
void do_unmount()
|
||||
void doUnmount()
|
||||
{
|
||||
std::vector<std::string> mountPoints;
|
||||
|
||||
@@ -96,7 +96,7 @@ void do_unmount()
|
||||
}
|
||||
}
|
||||
|
||||
void do_remount()
|
||||
void doRemount()
|
||||
{
|
||||
std::vector<mount_entry_t> mounts = parseMountsFromPath("/proc/self/mounts");
|
||||
auto data_mount_it = std::find_if(mounts.begin(), mounts.end(), [](const mount_entry_t &mount)
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include "android_filesystem_config.h"
|
||||
#include "zygisk.hpp"
|
||||
|
||||
bool hook_plt_by_name(zygisk::Api *api, const std::string &libName, const std::string &symbolName, void *hookFunc, void **origFunc)
|
||||
bool hookPLTByName(zygisk::Api *api, const std::string &libName, const std::string &symbolName, void *hookFunc, void **origFunc)
|
||||
{
|
||||
for (const auto &map : parseMapsFromPath("/proc/self/maps"))
|
||||
{
|
||||
@@ -18,7 +18,7 @@ bool hook_plt_by_name(zygisk::Api *api, const std::string &libName, const std::s
|
||||
return false;
|
||||
}
|
||||
|
||||
int is_userapp_uid(int uid)
|
||||
int isUserAppUID(int uid)
|
||||
{
|
||||
int appid = uid % AID_USER_OFFSET;
|
||||
if (appid >= AID_APP_START && appid <= AID_APP_END)
|
||||
|
||||
Reference in New Issue
Block a user