Files
Zygisk-Assistant/module/jni/utils.cpp
2024-04-14 18:37:38 +02:00

30 lines
816 B
C++

#include <string>
#include "map_parser.hpp"
#include "utils.hpp"
#include "android_filesystem_config.h"
#include "zygisk.hpp"
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"))
{
if (map.getPathname().ends_with("/" + libName))
{
api->pltHookRegister(map.getDevice(), map.getInode(), symbolName.c_str(), hookFunc, origFunc);
return true;
}
}
return false;
}
int isUserAppUID(int uid)
{
int appid = uid % AID_USER_OFFSET;
if (appid >= AID_APP_START && appid <= AID_APP_END)
return true;
if (appid >= AID_ISOLATED_START && appid <= AID_ISOLATED_END)
return true;
return false;
}