[core] Fix huawei devices on zygisk (#1575)
This commit is contained in:
parent
998baed2aa
commit
ad59477953
|
|
@ -164,4 +164,9 @@ fi
|
||||||
set_perm_recursive "$MODPATH" 0 0 0755 0644
|
set_perm_recursive "$MODPATH" 0 0 0755 0644
|
||||||
chmod 0744 "$MODPATH/lspd"
|
chmod 0744 "$MODPATH/lspd"
|
||||||
|
|
||||||
|
if [ "$(grep_prop ro.maple.enable)" == "1" ] && [ "$FLAVOR" == "zygisk" ]; then
|
||||||
|
ui_print "- Add ro.maple.enable=0"
|
||||||
|
echo "ro.maple.enable=0" >> "$MODPATH/system.prop"
|
||||||
|
fi
|
||||||
|
|
||||||
ui_print "- Welcome to LSPosed!"
|
ui_print "- Welcome to LSPosed!"
|
||||||
|
|
|
||||||
|
|
@ -220,26 +220,35 @@ ElfImg::getSymbOffset(std::string_view name, uint32_t gnu_hash, uint32_t elf_has
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
constexpr inline bool contains(std::string_view a, std::string_view b) {
|
||||||
|
return a.find(b) != std::string_view::npos;
|
||||||
|
}
|
||||||
|
|
||||||
bool ElfImg::findModuleBase() {
|
bool ElfImg::findModuleBase() {
|
||||||
char buff[256];
|
|
||||||
off_t load_addr;
|
off_t load_addr;
|
||||||
bool found = false;
|
bool found = false;
|
||||||
FILE *maps = fopen("/proc/self/maps", "r");
|
FILE *maps = fopen("/proc/self/maps", "r");
|
||||||
|
|
||||||
|
char *buff = nullptr;
|
||||||
|
size_t len = 0;
|
||||||
|
ssize_t nread;
|
||||||
|
|
||||||
while (fgets(buff, sizeof(buff), maps)) {
|
while ((nread = getline(&buff, &len, maps)) != -1) {
|
||||||
if ((strstr(buff, "r-xp") || strstr(buff, "r--p")) && strstr(buff, elf.data())) {
|
std::string_view line{buff, static_cast<size_t>(nread)};
|
||||||
LOGD("found: %s", buff);
|
|
||||||
std::string_view b = buff;
|
if ((contains(line, "r-xp") || contains(line, "r--p")) && contains(line, elf)) {
|
||||||
if (auto begin = b.find_last_of(' '); begin != std::string_view::npos && b[++begin] == '/') {
|
LOGD("found: %*s", static_cast<int>(line.size()), line.data());
|
||||||
|
if (auto begin = line.find_last_of(' '); begin != std::string_view::npos &&
|
||||||
|
line[++begin] == '/') {
|
||||||
found = true;
|
found = true;
|
||||||
elf = b.substr(begin);
|
elf = line.substr(begin);
|
||||||
if (elf.back() == '\n') elf.pop_back();
|
if (elf.back() == '\n') elf.pop_back();
|
||||||
LOGD("update path: %s", elf.data());
|
LOGD("update path: %s", elf.data());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (buff) free(buff);
|
||||||
|
|
||||||
if (!found) {
|
if (!found) {
|
||||||
LOGE("failed to read load address for %s", elf.data());
|
LOGE("failed to read load address for %s", elf.data());
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue