fix 隐藏失败的问题,并且处理了原来riru内存泄漏的问题

This commit is contained in:
jiqiu2021
2024-11-16 21:56:05 +08:00
parent b50d500319
commit 8e715b8148
3 changed files with 8 additions and 8 deletions

View File

@@ -77,9 +77,7 @@ void load_so(const char *game_data_dir, JavaVM *vm, const char *soname) {
if (handle) {
LOGI("Successfully loaded %s", new_so_path);
load = true;
std::set<std::string_view> sonames;
sonames.insert(soname);
riru_hide(sonames);
riru_hide(soname);
break;
} else {
LOGE("Failed to load %s: %s", new_so_path, dlerror());

View File

@@ -11,7 +11,7 @@
extern "C" {
int riru_hide(const std::set<std::string_view> &) ;
int riru_hide(const char *name) ;
}
#ifdef __LP64__
@@ -80,7 +80,7 @@ static int do_hide(hide_struct *data) {
return 0;
}
int riru_hide(const std::set<std::string_view> &names) {
int riru_hide(const char *name) {
procmaps_iterator *maps = pmparser_parse(-1);
if (maps == nullptr) {
LOGE("cannot parse the memory map");
@@ -96,7 +96,7 @@ int riru_hide(const std::set<std::string_view> &names) {
#ifdef DEBUG_APP
matched = strstr(maps_tmp->pathname, "libriru.so");
#endif
matched = names.count(maps_tmp->pathname);
matched = strstr(maps_tmp->pathname, name) != nullptr;
// Match the memory regions we want to hide
if (!matched) continue;
@@ -122,9 +122,11 @@ int riru_hide(const std::set<std::string_view> &names) {
// Free backup memory to avoid leaks
for (int i = 0; i < data_count; ++i) {
FAILURE_RETURN(munmap((void *) data[i].backup_address, (uintptr_t) maps_tmp->addr_end - (uintptr_t) maps_tmp->addr_start), -1);
FAILURE_RETURN(munmap((void *) data[i].backup_address,
(uintptr_t) data[i].original->addr_end - (uintptr_t) data[i].original->addr_start), -1);
}
if (data) free(data);
pmparser_free(maps);
return 0;

View File

@@ -32,7 +32,7 @@
#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)
#define PLOGE(fmt, args...) LOGE(fmt " failed with %d: %s", ##args, errno, strerror(errno))
extern "C" {
int riru_hide(const std::set<std::string_view> &) EXPORT;
int riru_hide(const char *name) EXPORT;
}
#endif //ZYGISK_MYINJECTOR_NEWRIRUHIDE_H