implement enough to launch 2.2 (#2)

* generic maintenance and allow armv8

* implement missing java functions

* Update build.yml

* add missing audiodevice code

* split apk support

* ignore (gitignore)

* replace library load with native code

* set supported abis again

---------

Co-authored-by: alk <45172705+altalk23@users.noreply.github.com>
This commit is contained in:
Chloeandalk authored and GitHub committed 2023-12-22 04:14:05 -07:00
1 parent c08ae0ec13
commit c85470013f
24 files changed
+522 -252

No files matched your search

+3 -1
View File
@@ -22,4 +22,6 @@ if(NOT dobby_POPULATED)
add_subdirectory("${dobby_SOURCE_DIR}" ${dobby_BINARY_DIR} EXCLUDE_FROM_ALL)
target_include_directories(launcherfix PRIVATE ${dobby_SOURCE_DIR}/include)
target_link_libraries(launcherfix dobby)
endif()
endif()
target_link_libraries(launcherfix log)
+44 -2
View File
@@ -1,7 +1,13 @@
#include <android/dlext.h>
#include <android/log.h>
#include <dlfcn.h>
#include <string>
#include <dobby.h>
#include <jni.h>
#include <string>
#include <unistd.h>
#ifndef DISABLE_LAUNCHER_FIX
#include <dobby.h>
#endif
class DataPaths {
public:
@@ -27,6 +33,8 @@ JNIEXPORT void JNICALL Java_com_geode_launcher_LauncherFix_setDataPath(
auto data_path_str = env->GetStringUTFChars(data_path, &is_copy);
DataPaths::get_instance().data_path = std::string(data_path_str);
env->ReleaseStringUTFChars(data_path, data_path_str);
}
extern "C"
@@ -39,6 +47,38 @@ JNIEXPORT void JNICALL Java_com_geode_launcher_LauncherFix_setOriginalDataPath(
auto data_path_str = env->GetStringUTFChars(data_path, &is_copy);
DataPaths::get_instance().original_data_path = std::string(data_path_str);
env->ReleaseStringUTFChars(data_path, data_path_str);
}
extern "C"
JNIEXPORT jboolean JNICALL Java_com_geode_launcher_LauncherFix_loadLibraryFromOffset(JNIEnv *env, jobject, jstring library_name, jint fd, jlong offset) {
// loads a given library at an offset and file descriptor
// assumes we have ownership of the file passed in fd
auto is_copy = jboolean();
auto library_cname = env->GetStringUTFChars(library_name, &is_copy);
android_dlextinfo ext_info{};
ext_info.flags = ANDROID_DLEXT_USE_LIBRARY_FD | ANDROID_DLEXT_USE_LIBRARY_FD_OFFSET;
ext_info.library_fd = fd;
ext_info.library_fd_offset = offset;
auto handle = android_dlopen_ext(library_cname, RTLD_NOW | RTLD_GLOBAL, &ext_info);
env->ReleaseStringUTFChars(library_name, library_cname);
close(fd);
if (handle == nullptr) {
auto error = dlerror();
__android_log_print(ANDROID_LOG_WARN, "GeodeLauncher-Fix", "dlopen_ext failed. given: %s\n", error);
return false;
}
// we don't need the library anymore
dlclose(handle);
return true;
}
FILE* (*fopen_original)(const char *pathname, const char *mode);
@@ -60,6 +100,7 @@ FILE* fopen_hook(const char* pathname, const char* mode) {
}
[[gnu::constructor]] [[gnu::used]] void setup_hooks() {
#ifndef DISABLE_LAUNCHER_FIX
auto fopen_addr = dlsym(RTLD_NEXT, "fopen");
DobbyHook(
@@ -67,4 +108,5 @@ FILE* fopen_hook(const char* pathname, const char* mode) {
reinterpret_cast<dobby_dummy_func_t>(&fopen_hook),
reinterpret_cast<dobby_dummy_func_t*>(&fopen_original)
);
#endif
}