mirror of
https://github.com/geode-sdk/android-launcher.git
synced 2026-10-23 16:59:21 +00:00
we don't need a singleton here
This commit is contained in:
4 files changed
+26
-38
No files matched your search
@@ -7,16 +7,10 @@
|
|||||||
|
|
||||||
class DataPaths {
|
class DataPaths {
|
||||||
public:
|
public:
|
||||||
std::string original_data_path{};
|
static std::string original_data_path;
|
||||||
std::string data_path{};
|
static std::string data_path;
|
||||||
std::string load_symbols_from{};
|
|
||||||
|
|
||||||
bool patch_exceptions{};
|
static bool patch_exceptions;
|
||||||
|
|
||||||
static DataPaths& get_instance();
|
|
||||||
|
|
||||||
private:
|
|
||||||
DataPaths() {}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// this is every function that i thought would be relevant
|
// this is every function that i thought would be relevant
|
||||||
|
|||||||
@@ -4,10 +4,10 @@
|
|||||||
#include "base.h"
|
#include "base.h"
|
||||||
#include "log.hpp"
|
#include "log.hpp"
|
||||||
|
|
||||||
DataPaths& DataPaths::get_instance() {
|
std::string DataPaths::original_data_path{};
|
||||||
static auto paths_instance = DataPaths();
|
std::string DataPaths::data_path{};
|
||||||
return paths_instance;
|
|
||||||
}
|
bool DataPaths::patch_exceptions{};
|
||||||
|
|
||||||
extern "C"
|
extern "C"
|
||||||
JNIEXPORT void JNICALL Java_com_geode_launcher_LauncherFix_setDataPath(
|
JNIEXPORT void JNICALL Java_com_geode_launcher_LauncherFix_setDataPath(
|
||||||
@@ -18,25 +18,11 @@ JNIEXPORT void JNICALL Java_com_geode_launcher_LauncherFix_setDataPath(
|
|||||||
auto is_copy = jboolean();
|
auto is_copy = jboolean();
|
||||||
auto data_path_str = env->GetStringUTFChars(data_path, &is_copy);
|
auto data_path_str = env->GetStringUTFChars(data_path, &is_copy);
|
||||||
|
|
||||||
DataPaths::get_instance().data_path = std::string(data_path_str);
|
DataPaths::data_path = std::string(data_path_str);
|
||||||
|
|
||||||
env->ReleaseStringUTFChars(data_path, data_path_str);
|
env->ReleaseStringUTFChars(data_path, data_path_str);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C"
|
|
||||||
JNIEXPORT void JNICALL Java_com_geode_launcher_LauncherFix_enableCustomSymbolList(
|
|
||||||
JNIEnv* env,
|
|
||||||
jobject,
|
|
||||||
jstring symbol_path
|
|
||||||
) {
|
|
||||||
auto is_copy = jboolean();
|
|
||||||
auto symbol_path_str = env->GetStringUTFChars(symbol_path, &is_copy);
|
|
||||||
|
|
||||||
DataPaths::get_instance().load_symbols_from = std::string(symbol_path_str);
|
|
||||||
|
|
||||||
env->ReleaseStringUTFChars(symbol_path, symbol_path_str);
|
|
||||||
}
|
|
||||||
|
|
||||||
extern "C"
|
extern "C"
|
||||||
JNIEXPORT void JNICALL Java_com_geode_launcher_LauncherFix_setOriginalDataPath(
|
JNIEXPORT void JNICALL Java_com_geode_launcher_LauncherFix_setOriginalDataPath(
|
||||||
JNIEnv *env,
|
JNIEnv *env,
|
||||||
@@ -46,14 +32,14 @@ JNIEXPORT void JNICALL Java_com_geode_launcher_LauncherFix_setOriginalDataPath(
|
|||||||
auto is_copy = jboolean();
|
auto is_copy = jboolean();
|
||||||
auto data_path_str = env->GetStringUTFChars(data_path, &is_copy);
|
auto data_path_str = env->GetStringUTFChars(data_path, &is_copy);
|
||||||
|
|
||||||
DataPaths::get_instance().original_data_path = std::string(data_path_str);
|
DataPaths::original_data_path = std::string(data_path_str);
|
||||||
|
|
||||||
env->ReleaseStringUTFChars(data_path, data_path_str);
|
env->ReleaseStringUTFChars(data_path, data_path_str);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C"
|
extern "C"
|
||||||
JNIEXPORT void JNICALL Java_com_geode_launcher_LauncherFix_enableExceptionsRenaming(JNIEnv*, jobject) {
|
JNIEXPORT void JNICALL Java_com_geode_launcher_LauncherFix_enableExceptionsRenaming(JNIEnv*, jobject) {
|
||||||
DataPaths::get_instance().patch_exceptions = true;
|
DataPaths::patch_exceptions = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// this should be called after gd is loaded but before geode
|
// this should be called after gd is loaded but before geode
|
||||||
@@ -62,14 +48,24 @@ extern "C" JNIEXPORT void JNICALL Java_com_geode_launcher_LauncherFix_performPat
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::optional<std::string> redirect_path(const char* pathname) {
|
std::optional<std::string> redirect_path(const char* pathname) {
|
||||||
std::string_view data_path = DataPaths::get_instance().data_path;
|
std::string_view data_path = DataPaths::data_path;
|
||||||
std::string_view original_data_path = DataPaths::get_instance().original_data_path;
|
std::string_view original_data_path = DataPaths::original_data_path;
|
||||||
|
|
||||||
|
if (data_path.empty() || original_data_path.empty()) [[unlikely]] {
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
|
||||||
if (!data_path.empty() && !original_data_path.empty()) {
|
|
||||||
// call this a c string optimization
|
// call this a c string optimization
|
||||||
if (std::strncmp(pathname, original_data_path.data(), original_data_path.size()) == 0) {
|
if (std::strncmp(pathname, original_data_path.data(), original_data_path.size()) == 0) {
|
||||||
return std::format("{}{}", data_path, (pathname + original_data_path.size()));
|
auto remaining_path = (pathname + original_data_path.size());
|
||||||
}
|
auto remaining_len = strlen(remaining_path);
|
||||||
|
|
||||||
|
std::string x;
|
||||||
|
x.reserve(data_path.size() + remaining_len);
|
||||||
|
x.append(data_path);
|
||||||
|
x.append(remaining_path, remaining_len);
|
||||||
|
|
||||||
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
|
|||||||
@@ -277,7 +277,7 @@ int on_dl_iterate(dl_phdr_info* info, size_t size, void* data) {
|
|||||||
failed = true;
|
failed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DataPaths::get_instance().patch_exceptions) {
|
if (DataPaths::patch_exceptions) {
|
||||||
if (!perform_symbol_patches(info, state)) {
|
if (!perform_symbol_patches(info, state)) {
|
||||||
failed = true;
|
failed = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,4 @@ object LauncherFix {
|
|||||||
external fun enableExceptionsRenaming()
|
external fun enableExceptionsRenaming()
|
||||||
|
|
||||||
external fun performPatches()
|
external fun performPatches()
|
||||||
|
|
||||||
external fun enableCustomSymbolList(symbolsPath: String)
|
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user