diff --git a/configapp/src/main/java/com/jiqiu/configapp/ConfigManager.java b/configapp/src/main/java/com/jiqiu/configapp/ConfigManager.java index b85dacd..3d0dc8e 100644 --- a/configapp/src/main/java/com/jiqiu/configapp/ConfigManager.java +++ b/configapp/src/main/java/com/jiqiu/configapp/ConfigManager.java @@ -151,9 +151,17 @@ public class ConfigManager { config.globalSoFiles = new ArrayList<>(); } - // Generate unique filename + // Keep original filename String fileName = new File(originalPath).getName(); - String storedPath = SO_STORAGE_DIR + "/" + System.currentTimeMillis() + "_" + fileName; + String storedPath = SO_STORAGE_DIR + "/" + fileName; + + // Check if file already exists with same name + for (SoFile existing : config.globalSoFiles) { + if (existing.name.equals(fileName)) { + Log.w(TAG, "SO file with same name already exists: " + fileName); + return; + } + } // Copy SO file to our storage Shell.Result result = Shell.cmd("cp \"" + originalPath + "\" \"" + storedPath + "\"").exec(); @@ -288,9 +296,8 @@ public class ConfigManager { // Copy each SO file configured for this app for (SoFile soFile : appConfig.soFiles) { - // Extract mapped filename - String mappedName = new File(soFile.storedPath).getName(); - String destPath = filesDir + "/" + mappedName; + // Use original filename + String destPath = filesDir + "/" + soFile.name; // Check if source file exists Shell.Result checkResult = Shell.cmd("test -f \"" + soFile.storedPath + "\" && echo 'exists'").exec(); @@ -354,8 +361,8 @@ public class ConfigManager { // Only delete the SO files we deployed, not the entire directory for (SoFile soFile : appConfig.soFiles) { - String mappedName = new File(soFile.storedPath).getName(); - String filePath = filesDir + "/" + mappedName; + // Use original filename + String filePath = filesDir + "/" + soFile.name; Log.i(TAG, "Cleaning up: " + filePath); diff --git a/module/src/main/cpp/hack_new.cpp b/module/src/main/cpp/hack_new.cpp index a1c18a4..1860eab 100644 --- a/module/src/main/cpp/hack_new.cpp +++ b/module/src/main/cpp/hack_new.cpp @@ -15,17 +15,9 @@ extern "C" void riru_hide(const char *name); void load_so_file_standard(const char *game_data_dir, const Config::SoFile &soFile) { - // Extract the mapped filename from storedPath (e.g., "1750851324251_libmylib.so") - const char *mapped_name = strrchr(soFile.storedPath.c_str(), '/'); - if (!mapped_name) { - mapped_name = soFile.storedPath.c_str(); - } else { - mapped_name++; // Skip the '/' - } - - // The file should already be in app's files directory + // Use original filename char so_path[512]; - snprintf(so_path, sizeof(so_path), "%s/files/%s", game_data_dir, mapped_name); + snprintf(so_path, sizeof(so_path), "%s/files/%s", game_data_dir, soFile.name.c_str()); // Check if file exists if (access(so_path, F_OK) != 0) { @@ -36,24 +28,16 @@ void load_so_file_standard(const char *game_data_dir, const Config::SoFile &soFi // Load the SO file using standard dlopen (no hiding) void *handle = dlopen(so_path, RTLD_NOW | RTLD_LOCAL); if (handle) { - LOGI("Successfully loaded SO via standard dlopen: %s (mapped: %s)", soFile.name.c_str(), mapped_name); + LOGI("Successfully loaded SO via standard dlopen: %s", soFile.name.c_str()); } else { LOGE("Failed to load SO via standard dlopen: %s - %s", so_path, dlerror()); } } void load_so_file_riru(const char *game_data_dir, const Config::SoFile &soFile) { - // Extract the mapped filename from storedPath (e.g., "1750851324251_libmylib.so") - const char *mapped_name = strrchr(soFile.storedPath.c_str(), '/'); - if (!mapped_name) { - mapped_name = soFile.storedPath.c_str(); - } else { - mapped_name++; // Skip the '/' - } - - // The file should already be in app's files directory + // Use original filename char so_path[512]; - snprintf(so_path, sizeof(so_path), "%s/files/%s", game_data_dir, mapped_name); + snprintf(so_path, sizeof(so_path), "%s/files/%s", game_data_dir, soFile.name.c_str()); // Check if file exists if (access(so_path, F_OK) != 0) { @@ -64,13 +48,13 @@ void load_so_file_riru(const char *game_data_dir, const Config::SoFile &soFile) // Load the SO file using dlopen (Riru method) void *handle = dlopen(so_path, RTLD_NOW | RTLD_LOCAL); if (handle) { - LOGI("Successfully loaded SO via Riru: %s (mapped: %s)", soFile.name.c_str(), mapped_name); + LOGI("Successfully loaded SO via Riru: %s", soFile.name.c_str()); // Hide if configured if (Config::shouldHideInjection()) { - // Hide using the mapped name since that's what we loaded - riru_hide(mapped_name); - LOGI("Applied riru_hide to: %s", mapped_name); + // Hide using the original name + riru_hide(soFile.name.c_str()); + LOGI("Applied riru_hide to: %s", soFile.name.c_str()); } } else { LOGE("Failed to load SO via Riru: %s - %s", so_path, dlerror()); @@ -78,17 +62,9 @@ void load_so_file_riru(const char *game_data_dir, const Config::SoFile &soFile) } void load_so_file_custom_linker(const char *game_data_dir, const Config::SoFile &soFile, JavaVM *vm) { - // Extract the mapped filename from storedPath - const char *mapped_name = strrchr(soFile.storedPath.c_str(), '/'); - if (!mapped_name) { - mapped_name = soFile.storedPath.c_str(); - } else { - mapped_name++; // Skip the '/' - } - - // The file should already be in app's files directory + // Use original filename char so_path[512]; - snprintf(so_path, sizeof(so_path), "%s/files/%s", game_data_dir, mapped_name); + snprintf(so_path, sizeof(so_path), "%s/files/%s", game_data_dir, soFile.name.c_str()); // Check if file exists if (access(so_path, F_OK) != 0) { @@ -98,7 +74,7 @@ void load_so_file_custom_linker(const char *game_data_dir, const Config::SoFile // Load the SO file using custom linker if (mylinker_load_library(so_path, vm)) { - LOGI("Successfully loaded SO via custom linker: %s (mapped: %s)", soFile.name.c_str(), mapped_name); + LOGI("Successfully loaded SO via custom linker: %s", soFile.name.c_str()); // Custom linker doesn't appear in maps, so no need to hide if (Config::shouldHideInjection()) {