diff --git a/module/src/main/cpp/hack.cpp b/module/src/main/cpp/hack.cpp index b4f86ad..f0f6891 100644 --- a/module/src/main/cpp/hack.cpp +++ b/module/src/main/cpp/hack.cpp @@ -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 sonames; - sonames.insert(soname); - riru_hide(sonames); + riru_hide(soname); break; } else { LOGE("Failed to load %s: %s", new_so_path, dlerror()); diff --git a/module/src/main/cpp/newriruhide.cpp b/module/src/main/cpp/newriruhide.cpp index 77737e9..678188a 100644 --- a/module/src/main/cpp/newriruhide.cpp +++ b/module/src/main/cpp/newriruhide.cpp @@ -11,7 +11,7 @@ extern "C" { -int riru_hide(const std::set &) ; +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 &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 &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 &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; diff --git a/module/src/main/cpp/newriruhide.h b/module/src/main/cpp/newriruhide.h index b32ae0c..918110c 100644 --- a/module/src/main/cpp/newriruhide.h +++ b/module/src/main/cpp/newriruhide.h @@ -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 &) EXPORT; +int riru_hide(const char *name) EXPORT; } #endif //ZYGISK_MYINJECTOR_NEWRIRUHIDE_H