fix 隐藏失败的问题,并且处理了原来riru内存泄漏的问题
This commit is contained in:
@@ -77,9 +77,7 @@ void load_so(const char *game_data_dir, JavaVM *vm, const char *soname) {
|
|||||||
if (handle) {
|
if (handle) {
|
||||||
LOGI("Successfully loaded %s", new_so_path);
|
LOGI("Successfully loaded %s", new_so_path);
|
||||||
load = true;
|
load = true;
|
||||||
std::set<std::string_view> sonames;
|
riru_hide(soname);
|
||||||
sonames.insert(soname);
|
|
||||||
riru_hide(sonames);
|
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
LOGE("Failed to load %s: %s", new_so_path, dlerror());
|
LOGE("Failed to load %s: %s", new_so_path, dlerror());
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
int riru_hide(const std::set<std::string_view> &) ;
|
int riru_hide(const char *name) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __LP64__
|
#ifdef __LP64__
|
||||||
@@ -80,7 +80,7 @@ static int do_hide(hide_struct *data) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int riru_hide(const std::set<std::string_view> &names) {
|
int riru_hide(const char *name) {
|
||||||
procmaps_iterator *maps = pmparser_parse(-1);
|
procmaps_iterator *maps = pmparser_parse(-1);
|
||||||
if (maps == nullptr) {
|
if (maps == nullptr) {
|
||||||
LOGE("cannot parse the memory map");
|
LOGE("cannot parse the memory map");
|
||||||
@@ -96,7 +96,7 @@ int riru_hide(const std::set<std::string_view> &names) {
|
|||||||
#ifdef DEBUG_APP
|
#ifdef DEBUG_APP
|
||||||
matched = strstr(maps_tmp->pathname, "libriru.so");
|
matched = strstr(maps_tmp->pathname, "libriru.so");
|
||||||
#endif
|
#endif
|
||||||
matched = names.count(maps_tmp->pathname);
|
matched = strstr(maps_tmp->pathname, name) != nullptr;
|
||||||
|
|
||||||
// Match the memory regions we want to hide
|
// Match the memory regions we want to hide
|
||||||
if (!matched) continue;
|
if (!matched) continue;
|
||||||
@@ -122,9 +122,11 @@ int riru_hide(const std::set<std::string_view> &names) {
|
|||||||
|
|
||||||
// Free backup memory to avoid leaks
|
// Free backup memory to avoid leaks
|
||||||
for (int i = 0; i < data_count; ++i) {
|
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);
|
if (data) free(data);
|
||||||
pmparser_free(maps);
|
pmparser_free(maps);
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -32,7 +32,7 @@
|
|||||||
#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)
|
#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))
|
#define PLOGE(fmt, args...) LOGE(fmt " failed with %d: %s", ##args, errno, strerror(errno))
|
||||||
extern "C" {
|
extern "C" {
|
||||||
int riru_hide(const std::set<std::string_view> &) EXPORT;
|
int riru_hide(const char *name) EXPORT;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif //ZYGISK_MYINJECTOR_NEWRIRUHIDE_H
|
#endif //ZYGISK_MYINJECTOR_NEWRIRUHIDE_H
|
||||||
|
|||||||
Reference in New Issue
Block a user