From 8e715b8148cd67ec36416e19ffe4731a1bd16ad6 Mon Sep 17 00:00:00 2001 From: jiqiu2021 Date: Sat, 16 Nov 2024 21:56:05 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E9=9A=90=E8=97=8F=E5=A4=B1=E8=B4=A5?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98=EF=BC=8C=E5=B9=B6=E4=B8=94=E5=A4=84?= =?UTF-8?q?=E7=90=86=E4=BA=86=E5=8E=9F=E6=9D=A5riru=E5=86=85=E5=AD=98?= =?UTF-8?q?=E6=B3=84=E6=BC=8F=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- module/src/main/cpp/hack.cpp | 4 +--- module/src/main/cpp/newriruhide.cpp | 10 ++++++---- module/src/main/cpp/newriruhide.h | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) 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