From be6e449fb4458be471acceb8bd3c96d521346452 Mon Sep 17 00:00:00 2001 From: solohsu Date: Sat, 25 May 2019 21:27:08 +0800 Subject: [PATCH] Migrate to cmake --- edxp-core/build.gradle | 124 +++++++++--------- edxp-core/jni/.gitattributes | 1 - edxp-core/jni/Android.mk | 3 - edxp-core/jni/Application.mk | 22 ---- edxp-core/jni/external/Android.mk | 16 --- edxp-core/jni/main/Android.mk | 30 ----- edxp-core/src/main/cpp/CMakeLists.txt | 6 + .../src/main/cpp/external/CMakeLists.txt | 6 + .../src/main/cpp/external/riru/CMakeLists.txt | 6 + .../main/cpp/external/riru/src}/riru.c | 0 .../main/cpp/external/riru/src}/riru.h | 0 .../cpp/external/substrate/CMakeLists.txt | 6 + .../cpp/external/substrate/src}/Buffer.hpp | 0 .../external/substrate/src}/CydiaSubstrate.h | 0 .../external/substrate/src}/SubstrateARM.hpp | 0 .../substrate/src}/SubstrateDebug.cpp | 0 .../substrate/src}/SubstrateDebug.hpp | 0 .../external/substrate/src}/SubstrateHook.cpp | 0 .../external/substrate/src}/SubstrateHook.h | 0 .../external/substrate/src}/SubstrateLog.hpp | 0 .../substrate/src}/SubstratePosixMemory.cpp | 0 .../external/substrate/src}/SubstrateX86.hpp | 0 .../main/cpp/external/substrate/src}/hde64.c | 0 .../main/cpp/external/substrate/src}/hde64.h | 0 .../cpp/external/substrate/src}/table64.h | 0 .../main/cpp/external/xhook/CMakeLists.txt | 10 ++ .../main/cpp/external/xhook/include}/xhook.h | 0 .../main/cpp/external/xhook/src}/queue.h | 0 .../main/cpp/external/xhook/src}/tree.h | 0 .../main/cpp/external/xhook/src}/xh_core.c | 0 .../main/cpp/external/xhook/src}/xh_core.h | 0 .../main/cpp/external/xhook/src}/xh_elf.c | 0 .../main/cpp/external/xhook/src}/xh_elf.h | 0 .../main/cpp/external/xhook/src}/xh_errno.h | 0 .../main/cpp/external/xhook/src}/xh_jni.c | 0 .../main/cpp/external/xhook/src}/xh_log.c | 0 .../main/cpp/external/xhook/src}/xh_log.h | 0 .../main/cpp/external/xhook/src}/xh_util.c | 0 .../main/cpp/external/xhook/src}/xh_util.h | 0 .../main/cpp/external/xhook/src}/xh_version.c | 0 .../main/cpp/external/xhook/src}/xh_version.h | 0 .../main/cpp/external/xhook/src}/xhook.c | 0 .../main/cpp/external/xhook/src}/xhook.h | 0 .../main/cpp/external/yahfa/CMakeLists.txt | 10 ++ .../cpp/external/yahfa/include}/HookMain.h | 0 .../main/cpp/external/yahfa/src}/HookMain.c | 0 .../main/cpp/external/yahfa/src}/common.h | 0 .../main/cpp/external/yahfa/src}/env.h | 0 .../main/cpp/external/yahfa/src}/trampoline.c | 0 .../main/cpp/external/yahfa/src}/trampoline.h | 0 edxp-core/src/main/cpp/main/CMakeLists.txt | 18 +++ .../main/cpp}/main/include/ByteOrder.h | 0 .../main/cpp}/main/include/JNIHelper.h | 0 .../main/cpp}/main/include/android_build.h | 0 .../main/cpp}/main/include/config.h | 0 .../main/cpp}/main/include/fd_utils-inl.h | 0 .../main/cpp}/main/include/logging.h | 0 .../main/cpp}/main/include/misc.cpp | 0 .../{jni => src/main/cpp}/main/include/misc.h | 0 .../main/cpp}/main/inject/config_manager.cpp | 0 .../main/cpp}/main/inject/config_manager.h | 0 .../main/cpp}/main/inject/framework_hook.cpp | 0 .../main/cpp}/main/inject/framework_hook.h | 0 .../main/cpp}/main/java_hook/java_hook.cpp | 2 +- .../main/cpp}/main/java_hook/java_hook.h | 0 edxp-core/{jni => src/main/cpp}/main/main.cpp | 4 +- .../cpp}/main/native_hook/native_hook.cpp | 2 +- .../main/cpp}/main/native_hook/native_hook.h | 2 +- .../cpp}/main/native_hook/resource_hook.cpp | 0 .../cpp}/main/native_hook/resource_hook.h | 0 .../main/cpp}/main/native_hook/riru_hook.cpp | 4 +- .../main/cpp}/main/native_hook/riru_hook.h | 0 72 files changed, 129 insertions(+), 143 deletions(-) delete mode 100644 edxp-core/jni/.gitattributes delete mode 100644 edxp-core/jni/Android.mk delete mode 100644 edxp-core/jni/Application.mk delete mode 100644 edxp-core/jni/external/Android.mk delete mode 100644 edxp-core/jni/main/Android.mk create mode 100644 edxp-core/src/main/cpp/CMakeLists.txt create mode 100644 edxp-core/src/main/cpp/external/CMakeLists.txt create mode 100644 edxp-core/src/main/cpp/external/riru/CMakeLists.txt rename edxp-core/{jni/main/include => src/main/cpp/external/riru/src}/riru.c (100%) rename edxp-core/{jni/main/include => src/main/cpp/external/riru/src}/riru.h (100%) create mode 100644 edxp-core/src/main/cpp/external/substrate/CMakeLists.txt rename edxp-core/{jni/main/Substrate => src/main/cpp/external/substrate/src}/Buffer.hpp (100%) rename edxp-core/{jni/main/Substrate => src/main/cpp/external/substrate/src}/CydiaSubstrate.h (100%) rename edxp-core/{jni/main/Substrate => src/main/cpp/external/substrate/src}/SubstrateARM.hpp (100%) rename edxp-core/{jni/main/Substrate => src/main/cpp/external/substrate/src}/SubstrateDebug.cpp (100%) rename edxp-core/{jni/main/Substrate => src/main/cpp/external/substrate/src}/SubstrateDebug.hpp (100%) rename edxp-core/{jni/main/Substrate => src/main/cpp/external/substrate/src}/SubstrateHook.cpp (100%) rename edxp-core/{jni/main/Substrate => src/main/cpp/external/substrate/src}/SubstrateHook.h (100%) rename edxp-core/{jni/main/Substrate => src/main/cpp/external/substrate/src}/SubstrateLog.hpp (100%) rename edxp-core/{jni/main/Substrate => src/main/cpp/external/substrate/src}/SubstratePosixMemory.cpp (100%) rename edxp-core/{jni/main/Substrate => src/main/cpp/external/substrate/src}/SubstrateX86.hpp (100%) rename edxp-core/{jni/main/Substrate => src/main/cpp/external/substrate/src}/hde64.c (100%) rename edxp-core/{jni/main/Substrate => src/main/cpp/external/substrate/src}/hde64.h (100%) rename edxp-core/{jni/main/Substrate => src/main/cpp/external/substrate/src}/table64.h (100%) create mode 100644 edxp-core/src/main/cpp/external/xhook/CMakeLists.txt rename edxp-core/{jni/external/include/xhook => src/main/cpp/external/xhook/include}/xhook.h (100%) rename edxp-core/{jni/external/xhook => src/main/cpp/external/xhook/src}/queue.h (100%) rename edxp-core/{jni/external/xhook => src/main/cpp/external/xhook/src}/tree.h (100%) rename edxp-core/{jni/external/xhook => src/main/cpp/external/xhook/src}/xh_core.c (100%) rename edxp-core/{jni/external/xhook => src/main/cpp/external/xhook/src}/xh_core.h (100%) rename edxp-core/{jni/external/xhook => src/main/cpp/external/xhook/src}/xh_elf.c (100%) rename edxp-core/{jni/external/xhook => src/main/cpp/external/xhook/src}/xh_elf.h (100%) rename edxp-core/{jni/external/xhook => src/main/cpp/external/xhook/src}/xh_errno.h (100%) rename edxp-core/{jni/external/xhook => src/main/cpp/external/xhook/src}/xh_jni.c (100%) rename edxp-core/{jni/external/xhook => src/main/cpp/external/xhook/src}/xh_log.c (100%) rename edxp-core/{jni/external/xhook => src/main/cpp/external/xhook/src}/xh_log.h (100%) rename edxp-core/{jni/external/xhook => src/main/cpp/external/xhook/src}/xh_util.c (100%) rename edxp-core/{jni/external/xhook => src/main/cpp/external/xhook/src}/xh_util.h (100%) rename edxp-core/{jni/external/xhook => src/main/cpp/external/xhook/src}/xh_version.c (100%) rename edxp-core/{jni/external/xhook => src/main/cpp/external/xhook/src}/xh_version.h (100%) rename edxp-core/{jni/external/xhook => src/main/cpp/external/xhook/src}/xhook.c (100%) rename edxp-core/{jni/external/xhook => src/main/cpp/external/xhook/src}/xhook.h (100%) create mode 100644 edxp-core/src/main/cpp/external/yahfa/CMakeLists.txt rename edxp-core/{jni/main/yahfa => src/main/cpp/external/yahfa/include}/HookMain.h (100%) rename edxp-core/{jni/main/yahfa => src/main/cpp/external/yahfa/src}/HookMain.c (100%) rename edxp-core/{jni/main/yahfa => src/main/cpp/external/yahfa/src}/common.h (100%) rename edxp-core/{jni/main/yahfa => src/main/cpp/external/yahfa/src}/env.h (100%) rename edxp-core/{jni/main/yahfa => src/main/cpp/external/yahfa/src}/trampoline.c (100%) rename edxp-core/{jni/main/yahfa => src/main/cpp/external/yahfa/src}/trampoline.h (100%) create mode 100644 edxp-core/src/main/cpp/main/CMakeLists.txt rename edxp-core/{jni => src/main/cpp}/main/include/ByteOrder.h (100%) rename edxp-core/{jni => src/main/cpp}/main/include/JNIHelper.h (100%) rename edxp-core/{jni => src/main/cpp}/main/include/android_build.h (100%) rename edxp-core/{jni => src/main/cpp}/main/include/config.h (100%) rename edxp-core/{jni => src/main/cpp}/main/include/fd_utils-inl.h (100%) rename edxp-core/{jni => src/main/cpp}/main/include/logging.h (100%) rename edxp-core/{jni => src/main/cpp}/main/include/misc.cpp (100%) rename edxp-core/{jni => src/main/cpp}/main/include/misc.h (100%) rename edxp-core/{jni => src/main/cpp}/main/inject/config_manager.cpp (100%) rename edxp-core/{jni => src/main/cpp}/main/inject/config_manager.h (100%) rename edxp-core/{jni => src/main/cpp}/main/inject/framework_hook.cpp (100%) rename edxp-core/{jni => src/main/cpp}/main/inject/framework_hook.h (100%) rename edxp-core/{jni => src/main/cpp}/main/java_hook/java_hook.cpp (99%) rename edxp-core/{jni => src/main/cpp}/main/java_hook/java_hook.h (100%) rename edxp-core/{jni => src/main/cpp}/main/main.cpp (97%) rename edxp-core/{jni => src/main/cpp}/main/native_hook/native_hook.cpp (99%) rename edxp-core/{jni => src/main/cpp}/main/native_hook/native_hook.h (97%) rename edxp-core/{jni => src/main/cpp}/main/native_hook/resource_hook.cpp (100%) rename edxp-core/{jni => src/main/cpp}/main/native_hook/resource_hook.h (100%) rename edxp-core/{jni => src/main/cpp}/main/native_hook/riru_hook.cpp (98%) rename edxp-core/{jni => src/main/cpp}/main/native_hook/riru_hook.h (100%) diff --git a/edxp-core/build.gradle b/edxp-core/build.gradle index 214372e1..edb982f5 100644 --- a/edxp-core/build.gradle +++ b/edxp-core/build.gradle @@ -19,7 +19,6 @@ ext { whale_authors = "solohsu, asLody & MlgmXyysd" riruModuleId = "edxp" - libPathRelease = "$buildDir/ndkBuild/release/lib" zipPathMagiskRelease = "$buildDir/tmp/release/magisk" } @@ -30,15 +29,37 @@ android { targetSdkVersion rootProject.ext.targetSdkVersion externalNativeBuild { - ndkBuild { + cmake { abiFilters 'arm64-v8a', 'armeabi-v7a', 'x86', 'x86_64' - arguments "NDK_PROJECT_PATH=jni/" + cppFlags "-std=c++11 -ffixed-x18 -Qunused-arguments -frtti" + cFlags "-std=gnu99 -ffixed-x18 -Qunused-arguments -frtti" } } } + + buildTypes { + debug { + externalNativeBuild { + cmake { + cppFlags "-O0" + cFlags "-O0" + } + } + } + release { + externalNativeBuild { + cmake { + cppFlags "-fvisibility=hidden -fvisibility-inlines-hidden -O2 -s" + cFlags "-fvisibility=hidden -fvisibility-inlines-hidden -O2 -s" + } + } + minifyEnabled true + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } externalNativeBuild { - ndkBuild { - path 'jni/Android.mk' + cmake { + path "src/main/cpp/CMakeLists.txt" } } } @@ -75,57 +96,6 @@ task cleanTemplate(type: Delete) { delete file(templateSystemPath), file(templateSystemx86Path) } -// riru related tasks - -task buildNativeRelease(type: Exec) { - if (is_windows) - commandLine 'cmd', '/c', 'ndk-build.cmd', - '-j8', - "NDK_LIBS_OUT=$libPathRelease", - "NDK_OUT=$buildDir/ndkBuild/release/obj".replace("\\", "/") - else - commandLine 'ndk-build', - '-j8', - "NDK_LIBS_OUT=$libPathRelease", - "NDK_OUT=$buildDir/ndkBuild/release/obj" -} - -task cleanMagiskRelease(type: Delete) { - delete file(zipPathMagiskRelease) -} - -task copyFilesMagiskRelease { - doLast { - copy { - from "${projectDir}/template_override" - into zipPathMagiskRelease - } - copy { - from 'template_override/riru_module.prop' - into "$zipPathMagiskRelease/data/misc/riru/modules/${riruModuleId}" - } - copy { - from "$libPathRelease/armeabi-v7a" - into "$zipPathMagiskRelease/system/lib" - } - copy { - from "$libPathRelease/arm64-v8a" - into "$zipPathMagiskRelease/system/lib64" - } - copy { - from "$libPathRelease/x86" - into "$zipPathMagiskRelease/system_x86/lib" - } - copy { - from "$libPathRelease/x86_64" - into "$zipPathMagiskRelease/system_x86/lib64" - } - - file("$zipPathMagiskRelease/riru_module.prop").delete() - file("$zipPathMagiskRelease/data/misc/riru/modules/${riruModuleId}/riru_module.prop").renameTo("$zipPathMagiskRelease/data/misc/riru/modules/${riruModuleId}/module.prop") - } -} - afterEvaluate { android.libraryVariants.all { variant -> @@ -145,13 +115,9 @@ afterEvaluate { dependsOn tasks.getByPath(":edxp-${backendLowered}:makeAndCopy${variantCapped}") } - def preZipTask = task("preZip${backendCapped}${variantCapped}", type: GradleBuild) { - dependsOn prepareJarsTask - tasks = [ - 'buildNativeRelease', - 'cleanMagiskRelease', - 'copyFilesMagiskRelease' - ] + def prepareMagiskFilesTask = task("prepareMagiskFiles${backendCapped}${variantCapped}", type: Delete) { + dependsOn prepareJarsTask, "assemble${variantCapped}" + delete file(zipPathMagiskRelease) doFirst { copy { from "${projectDir}/tpl/edconfig.tpl" @@ -174,10 +140,40 @@ afterEvaluate { rename "module.prop", "riru_module.prop" } } + def libPathRelease = "${buildDir}/intermediates/cmake/${variantLowered}/obj" + doLast { + copy { + from "${projectDir}/template_override" + into zipPathMagiskRelease + } + copy { + from 'template_override/riru_module.prop' + into "$zipPathMagiskRelease/data/misc/riru/modules/${riruModuleId}" + } + copy { + from "$libPathRelease/armeabi-v7a" + into "$zipPathMagiskRelease/system/lib" + } + copy { + from "$libPathRelease/arm64-v8a" + into "$zipPathMagiskRelease/system/lib64" + } + copy { + from "$libPathRelease/x86" + into "$zipPathMagiskRelease/system_x86/lib" + } + copy { + from "$libPathRelease/x86_64" + into "$zipPathMagiskRelease/system_x86/lib64" + } + + file("$zipPathMagiskRelease/riru_module.prop").delete() + file("$zipPathMagiskRelease/data/misc/riru/modules/${riruModuleId}/riru_module.prop").renameTo("$zipPathMagiskRelease/data/misc/riru/modules/${riruModuleId}/module.prop") + } } def zipTask = task("zip${backendCapped}${variantCapped}", type: Zip) { - dependsOn preZipTask + dependsOn prepareMagiskFilesTask archiveName "magisk-${module_name}-${backend}-${project.version}-${variantLowered}.zip" destinationDir file("$projectDir/release") from "$zipPathMagiskRelease" diff --git a/edxp-core/jni/.gitattributes b/edxp-core/jni/.gitattributes deleted file mode 100644 index 63f9e342..00000000 --- a/edxp-core/jni/.gitattributes +++ /dev/null @@ -1 +0,0 @@ -libs/** binary diff --git a/edxp-core/jni/Android.mk b/edxp-core/jni/Android.mk deleted file mode 100644 index 16d6dcf0..00000000 --- a/edxp-core/jni/Android.mk +++ /dev/null @@ -1,3 +0,0 @@ -LOCAL_PATH := $(call my-dir) - -include $(call all-makefiles-under, $(LOCAL_PATH)) \ No newline at end of file diff --git a/edxp-core/jni/Application.mk b/edxp-core/jni/Application.mk deleted file mode 100644 index 7946ebf5..00000000 --- a/edxp-core/jni/Application.mk +++ /dev/null @@ -1,22 +0,0 @@ -APP_ABI := arm64-v8a armeabi-v7a x86 x86_64 -APP_PLATFORM := android-23 -APP_CFLAGS := -std=gnu99 -APP_CPPFLAGS := -std=c++11 -APP_STL := c++_static -APP_SHORT_COMMANDS := true - -ifeq ($(NDK_DEBUG),1) -$(info building DEBUG version...) -APP_CFLAGS += -O0 -APP_CPPFLAGS += -O0 -else -$(info building RELEASE version...) -APP_CFLAGS += -fvisibility=hidden -fvisibility-inlines-hidden -O2 -APP_CPPFLAGS += -fvisibility=hidden -fvisibility-inlines-hidden -O2 -endif - -# do not remove this, or your module will crash apps on Android Q -SCS_FLAGS := -ffixed-x18 -APP_LDFLAGS += $(SCS_FLAGS) -APP_CFLAGS += $(SCS_FLAGS) -APP_CPPFLAGS += $(SCS_FLAGS) \ No newline at end of file diff --git a/edxp-core/jni/external/Android.mk b/edxp-core/jni/external/Android.mk deleted file mode 100644 index 056ebfb0..00000000 --- a/edxp-core/jni/external/Android.mk +++ /dev/null @@ -1,16 +0,0 @@ -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) -LOCAL_MODULE := xhook -LOCAL_SRC_FILES := xhook/xhook.c \ - xhook/xh_core.c \ - xhook/xh_elf.c \ - xhook/xh_jni.c \ - xhook/xh_log.c \ - xhook/xh_util.c \ - xhook/xh_version.c -LOCAL_C_INCLUDES := $(LOCAL_PATH) -LOCAL_CFLAGS := -Wall -Wextra -Werror -fvisibility=hidden -LOCAL_CONLYFLAGS := -std=c11 -LOCAL_LDLIBS := -llog -include $(BUILD_STATIC_LIBRARY) \ No newline at end of file diff --git a/edxp-core/jni/main/Android.mk b/edxp-core/jni/main/Android.mk deleted file mode 100644 index 51647eb2..00000000 --- a/edxp-core/jni/main/Android.mk +++ /dev/null @@ -1,30 +0,0 @@ -LOCAL_PATH := $(call my-dir) -include $(CLEAR_VARS) - -LOCAL_MODULE := libriru_edxp -LOCAL_C_INCLUDES := \ - $(LOCAL_PATH) \ - jni/external/include -LOCAL_CPPFLAGS += $(CPPFLAGS) -LOCAL_STATIC_LIBRARIES := xhook -LOCAL_LDLIBS += -ldl -llog -LOCAL_LDFLAGS := -Wl,--hash-style=both - -LOCAL_SRC_FILES:= \ - main.cpp \ - native_hook/native_hook.cpp \ - native_hook/resource_hook.cpp \ - native_hook/riru_hook.cpp \ - include/misc.cpp \ - include/riru.c \ - yahfa/HookMain.c \ - yahfa/trampoline.c \ - java_hook/java_hook.cpp \ - inject/framework_hook.cpp \ - inject/config_manager.cpp \ - Substrate/SubstrateDebug.cpp \ - Substrate/SubstrateHook.cpp \ - Substrate/SubstratePosixMemory.cpp \ - Substrate/hde64.c \ - -include $(BUILD_SHARED_LIBRARY) \ No newline at end of file diff --git a/edxp-core/src/main/cpp/CMakeLists.txt b/edxp-core/src/main/cpp/CMakeLists.txt new file mode 100644 index 00000000..257ee6e5 --- /dev/null +++ b/edxp-core/src/main/cpp/CMakeLists.txt @@ -0,0 +1,6 @@ +cmake_minimum_required(VERSION 3.4.1) + +link_libraries("-ffixed-x18") + +add_subdirectory(main) +add_subdirectory(external) \ No newline at end of file diff --git a/edxp-core/src/main/cpp/external/CMakeLists.txt b/edxp-core/src/main/cpp/external/CMakeLists.txt new file mode 100644 index 00000000..1d3971a1 --- /dev/null +++ b/edxp-core/src/main/cpp/external/CMakeLists.txt @@ -0,0 +1,6 @@ +cmake_minimum_required(VERSION 3.4.1) + +add_subdirectory(xhook) +add_subdirectory(riru) +add_subdirectory(yahfa) +add_subdirectory(substrate) \ No newline at end of file diff --git a/edxp-core/src/main/cpp/external/riru/CMakeLists.txt b/edxp-core/src/main/cpp/external/riru/CMakeLists.txt new file mode 100644 index 00000000..7c9e84ef --- /dev/null +++ b/edxp-core/src/main/cpp/external/riru/CMakeLists.txt @@ -0,0 +1,6 @@ +cmake_minimum_required(VERSION 3.4.1) + +aux_source_directory(src SRC_LIST) +add_library(riru STATIC ${SRC_LIST}) + +target_include_directories(riru INTERFACE src) \ No newline at end of file diff --git a/edxp-core/jni/main/include/riru.c b/edxp-core/src/main/cpp/external/riru/src/riru.c similarity index 100% rename from edxp-core/jni/main/include/riru.c rename to edxp-core/src/main/cpp/external/riru/src/riru.c diff --git a/edxp-core/jni/main/include/riru.h b/edxp-core/src/main/cpp/external/riru/src/riru.h similarity index 100% rename from edxp-core/jni/main/include/riru.h rename to edxp-core/src/main/cpp/external/riru/src/riru.h diff --git a/edxp-core/src/main/cpp/external/substrate/CMakeLists.txt b/edxp-core/src/main/cpp/external/substrate/CMakeLists.txt new file mode 100644 index 00000000..b92c5574 --- /dev/null +++ b/edxp-core/src/main/cpp/external/substrate/CMakeLists.txt @@ -0,0 +1,6 @@ +cmake_minimum_required(VERSION 3.4.1) + +aux_source_directory(src SRC_LIST) +add_library(substrate STATIC ${SRC_LIST}) + +target_include_directories(substrate INTERFACE src) \ No newline at end of file diff --git a/edxp-core/jni/main/Substrate/Buffer.hpp b/edxp-core/src/main/cpp/external/substrate/src/Buffer.hpp similarity index 100% rename from edxp-core/jni/main/Substrate/Buffer.hpp rename to edxp-core/src/main/cpp/external/substrate/src/Buffer.hpp diff --git a/edxp-core/jni/main/Substrate/CydiaSubstrate.h b/edxp-core/src/main/cpp/external/substrate/src/CydiaSubstrate.h similarity index 100% rename from edxp-core/jni/main/Substrate/CydiaSubstrate.h rename to edxp-core/src/main/cpp/external/substrate/src/CydiaSubstrate.h diff --git a/edxp-core/jni/main/Substrate/SubstrateARM.hpp b/edxp-core/src/main/cpp/external/substrate/src/SubstrateARM.hpp similarity index 100% rename from edxp-core/jni/main/Substrate/SubstrateARM.hpp rename to edxp-core/src/main/cpp/external/substrate/src/SubstrateARM.hpp diff --git a/edxp-core/jni/main/Substrate/SubstrateDebug.cpp b/edxp-core/src/main/cpp/external/substrate/src/SubstrateDebug.cpp similarity index 100% rename from edxp-core/jni/main/Substrate/SubstrateDebug.cpp rename to edxp-core/src/main/cpp/external/substrate/src/SubstrateDebug.cpp diff --git a/edxp-core/jni/main/Substrate/SubstrateDebug.hpp b/edxp-core/src/main/cpp/external/substrate/src/SubstrateDebug.hpp similarity index 100% rename from edxp-core/jni/main/Substrate/SubstrateDebug.hpp rename to edxp-core/src/main/cpp/external/substrate/src/SubstrateDebug.hpp diff --git a/edxp-core/jni/main/Substrate/SubstrateHook.cpp b/edxp-core/src/main/cpp/external/substrate/src/SubstrateHook.cpp similarity index 100% rename from edxp-core/jni/main/Substrate/SubstrateHook.cpp rename to edxp-core/src/main/cpp/external/substrate/src/SubstrateHook.cpp diff --git a/edxp-core/jni/main/Substrate/SubstrateHook.h b/edxp-core/src/main/cpp/external/substrate/src/SubstrateHook.h similarity index 100% rename from edxp-core/jni/main/Substrate/SubstrateHook.h rename to edxp-core/src/main/cpp/external/substrate/src/SubstrateHook.h diff --git a/edxp-core/jni/main/Substrate/SubstrateLog.hpp b/edxp-core/src/main/cpp/external/substrate/src/SubstrateLog.hpp similarity index 100% rename from edxp-core/jni/main/Substrate/SubstrateLog.hpp rename to edxp-core/src/main/cpp/external/substrate/src/SubstrateLog.hpp diff --git a/edxp-core/jni/main/Substrate/SubstratePosixMemory.cpp b/edxp-core/src/main/cpp/external/substrate/src/SubstratePosixMemory.cpp similarity index 100% rename from edxp-core/jni/main/Substrate/SubstratePosixMemory.cpp rename to edxp-core/src/main/cpp/external/substrate/src/SubstratePosixMemory.cpp diff --git a/edxp-core/jni/main/Substrate/SubstrateX86.hpp b/edxp-core/src/main/cpp/external/substrate/src/SubstrateX86.hpp similarity index 100% rename from edxp-core/jni/main/Substrate/SubstrateX86.hpp rename to edxp-core/src/main/cpp/external/substrate/src/SubstrateX86.hpp diff --git a/edxp-core/jni/main/Substrate/hde64.c b/edxp-core/src/main/cpp/external/substrate/src/hde64.c similarity index 100% rename from edxp-core/jni/main/Substrate/hde64.c rename to edxp-core/src/main/cpp/external/substrate/src/hde64.c diff --git a/edxp-core/jni/main/Substrate/hde64.h b/edxp-core/src/main/cpp/external/substrate/src/hde64.h similarity index 100% rename from edxp-core/jni/main/Substrate/hde64.h rename to edxp-core/src/main/cpp/external/substrate/src/hde64.h diff --git a/edxp-core/jni/main/Substrate/table64.h b/edxp-core/src/main/cpp/external/substrate/src/table64.h similarity index 100% rename from edxp-core/jni/main/Substrate/table64.h rename to edxp-core/src/main/cpp/external/substrate/src/table64.h diff --git a/edxp-core/src/main/cpp/external/xhook/CMakeLists.txt b/edxp-core/src/main/cpp/external/xhook/CMakeLists.txt new file mode 100644 index 00000000..b6c5a321 --- /dev/null +++ b/edxp-core/src/main/cpp/external/xhook/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.4.1) + +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11 -Wall -Wextra -Werror -fvisibility=hidden") + +aux_source_directory(src SRC_LIST) +add_library(xhook STATIC ${SRC_LIST}) + +find_library(log-lib log) +target_link_libraries(xhook ${log-lib}) +target_include_directories(xhook INTERFACE include) \ No newline at end of file diff --git a/edxp-core/jni/external/include/xhook/xhook.h b/edxp-core/src/main/cpp/external/xhook/include/xhook.h similarity index 100% rename from edxp-core/jni/external/include/xhook/xhook.h rename to edxp-core/src/main/cpp/external/xhook/include/xhook.h diff --git a/edxp-core/jni/external/xhook/queue.h b/edxp-core/src/main/cpp/external/xhook/src/queue.h similarity index 100% rename from edxp-core/jni/external/xhook/queue.h rename to edxp-core/src/main/cpp/external/xhook/src/queue.h diff --git a/edxp-core/jni/external/xhook/tree.h b/edxp-core/src/main/cpp/external/xhook/src/tree.h similarity index 100% rename from edxp-core/jni/external/xhook/tree.h rename to edxp-core/src/main/cpp/external/xhook/src/tree.h diff --git a/edxp-core/jni/external/xhook/xh_core.c b/edxp-core/src/main/cpp/external/xhook/src/xh_core.c similarity index 100% rename from edxp-core/jni/external/xhook/xh_core.c rename to edxp-core/src/main/cpp/external/xhook/src/xh_core.c diff --git a/edxp-core/jni/external/xhook/xh_core.h b/edxp-core/src/main/cpp/external/xhook/src/xh_core.h similarity index 100% rename from edxp-core/jni/external/xhook/xh_core.h rename to edxp-core/src/main/cpp/external/xhook/src/xh_core.h diff --git a/edxp-core/jni/external/xhook/xh_elf.c b/edxp-core/src/main/cpp/external/xhook/src/xh_elf.c similarity index 100% rename from edxp-core/jni/external/xhook/xh_elf.c rename to edxp-core/src/main/cpp/external/xhook/src/xh_elf.c diff --git a/edxp-core/jni/external/xhook/xh_elf.h b/edxp-core/src/main/cpp/external/xhook/src/xh_elf.h similarity index 100% rename from edxp-core/jni/external/xhook/xh_elf.h rename to edxp-core/src/main/cpp/external/xhook/src/xh_elf.h diff --git a/edxp-core/jni/external/xhook/xh_errno.h b/edxp-core/src/main/cpp/external/xhook/src/xh_errno.h similarity index 100% rename from edxp-core/jni/external/xhook/xh_errno.h rename to edxp-core/src/main/cpp/external/xhook/src/xh_errno.h diff --git a/edxp-core/jni/external/xhook/xh_jni.c b/edxp-core/src/main/cpp/external/xhook/src/xh_jni.c similarity index 100% rename from edxp-core/jni/external/xhook/xh_jni.c rename to edxp-core/src/main/cpp/external/xhook/src/xh_jni.c diff --git a/edxp-core/jni/external/xhook/xh_log.c b/edxp-core/src/main/cpp/external/xhook/src/xh_log.c similarity index 100% rename from edxp-core/jni/external/xhook/xh_log.c rename to edxp-core/src/main/cpp/external/xhook/src/xh_log.c diff --git a/edxp-core/jni/external/xhook/xh_log.h b/edxp-core/src/main/cpp/external/xhook/src/xh_log.h similarity index 100% rename from edxp-core/jni/external/xhook/xh_log.h rename to edxp-core/src/main/cpp/external/xhook/src/xh_log.h diff --git a/edxp-core/jni/external/xhook/xh_util.c b/edxp-core/src/main/cpp/external/xhook/src/xh_util.c similarity index 100% rename from edxp-core/jni/external/xhook/xh_util.c rename to edxp-core/src/main/cpp/external/xhook/src/xh_util.c diff --git a/edxp-core/jni/external/xhook/xh_util.h b/edxp-core/src/main/cpp/external/xhook/src/xh_util.h similarity index 100% rename from edxp-core/jni/external/xhook/xh_util.h rename to edxp-core/src/main/cpp/external/xhook/src/xh_util.h diff --git a/edxp-core/jni/external/xhook/xh_version.c b/edxp-core/src/main/cpp/external/xhook/src/xh_version.c similarity index 100% rename from edxp-core/jni/external/xhook/xh_version.c rename to edxp-core/src/main/cpp/external/xhook/src/xh_version.c diff --git a/edxp-core/jni/external/xhook/xh_version.h b/edxp-core/src/main/cpp/external/xhook/src/xh_version.h similarity index 100% rename from edxp-core/jni/external/xhook/xh_version.h rename to edxp-core/src/main/cpp/external/xhook/src/xh_version.h diff --git a/edxp-core/jni/external/xhook/xhook.c b/edxp-core/src/main/cpp/external/xhook/src/xhook.c similarity index 100% rename from edxp-core/jni/external/xhook/xhook.c rename to edxp-core/src/main/cpp/external/xhook/src/xhook.c diff --git a/edxp-core/jni/external/xhook/xhook.h b/edxp-core/src/main/cpp/external/xhook/src/xhook.h similarity index 100% rename from edxp-core/jni/external/xhook/xhook.h rename to edxp-core/src/main/cpp/external/xhook/src/xhook.h diff --git a/edxp-core/src/main/cpp/external/yahfa/CMakeLists.txt b/edxp-core/src/main/cpp/external/yahfa/CMakeLists.txt new file mode 100644 index 00000000..53fb50fd --- /dev/null +++ b/edxp-core/src/main/cpp/external/yahfa/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.4.1) + +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11 -Wall -Wextra -fvisibility=hidden") + +aux_source_directory(src SRC_LIST) +add_library(yahfa STATIC ${SRC_LIST}) + +find_library(log-lib log) +target_link_libraries(yahfa ${log-lib}) +target_include_directories(yahfa PUBLIC include) \ No newline at end of file diff --git a/edxp-core/jni/main/yahfa/HookMain.h b/edxp-core/src/main/cpp/external/yahfa/include/HookMain.h similarity index 100% rename from edxp-core/jni/main/yahfa/HookMain.h rename to edxp-core/src/main/cpp/external/yahfa/include/HookMain.h diff --git a/edxp-core/jni/main/yahfa/HookMain.c b/edxp-core/src/main/cpp/external/yahfa/src/HookMain.c similarity index 100% rename from edxp-core/jni/main/yahfa/HookMain.c rename to edxp-core/src/main/cpp/external/yahfa/src/HookMain.c diff --git a/edxp-core/jni/main/yahfa/common.h b/edxp-core/src/main/cpp/external/yahfa/src/common.h similarity index 100% rename from edxp-core/jni/main/yahfa/common.h rename to edxp-core/src/main/cpp/external/yahfa/src/common.h diff --git a/edxp-core/jni/main/yahfa/env.h b/edxp-core/src/main/cpp/external/yahfa/src/env.h similarity index 100% rename from edxp-core/jni/main/yahfa/env.h rename to edxp-core/src/main/cpp/external/yahfa/src/env.h diff --git a/edxp-core/jni/main/yahfa/trampoline.c b/edxp-core/src/main/cpp/external/yahfa/src/trampoline.c similarity index 100% rename from edxp-core/jni/main/yahfa/trampoline.c rename to edxp-core/src/main/cpp/external/yahfa/src/trampoline.c diff --git a/edxp-core/jni/main/yahfa/trampoline.h b/edxp-core/src/main/cpp/external/yahfa/src/trampoline.h similarity index 100% rename from edxp-core/jni/main/yahfa/trampoline.h rename to edxp-core/src/main/cpp/external/yahfa/src/trampoline.h diff --git a/edxp-core/src/main/cpp/main/CMakeLists.txt b/edxp-core/src/main/cpp/main/CMakeLists.txt new file mode 100644 index 00000000..9d9994c0 --- /dev/null +++ b/edxp-core/src/main/cpp/main/CMakeLists.txt @@ -0,0 +1,18 @@ +cmake_minimum_required(VERSION 3.4.1) + +set(CMAKE_ANDROID_STL_TYPE c++_static) + +set(SRC_LIST + main.cpp + native_hook/native_hook.cpp + native_hook/resource_hook.cpp + native_hook/riru_hook.cpp + java_hook/java_hook.cpp + inject/framework_hook.cpp + inject/config_manager.cpp + ) +include_directories(include .) +add_library(riru_edxp SHARED ${SRC_LIST}) + +find_library(log-lib log) +target_link_libraries(riru_edxp yahfa riru xhook substrate ${log-lib}) \ No newline at end of file diff --git a/edxp-core/jni/main/include/ByteOrder.h b/edxp-core/src/main/cpp/main/include/ByteOrder.h similarity index 100% rename from edxp-core/jni/main/include/ByteOrder.h rename to edxp-core/src/main/cpp/main/include/ByteOrder.h diff --git a/edxp-core/jni/main/include/JNIHelper.h b/edxp-core/src/main/cpp/main/include/JNIHelper.h similarity index 100% rename from edxp-core/jni/main/include/JNIHelper.h rename to edxp-core/src/main/cpp/main/include/JNIHelper.h diff --git a/edxp-core/jni/main/include/android_build.h b/edxp-core/src/main/cpp/main/include/android_build.h similarity index 100% rename from edxp-core/jni/main/include/android_build.h rename to edxp-core/src/main/cpp/main/include/android_build.h diff --git a/edxp-core/jni/main/include/config.h b/edxp-core/src/main/cpp/main/include/config.h similarity index 100% rename from edxp-core/jni/main/include/config.h rename to edxp-core/src/main/cpp/main/include/config.h diff --git a/edxp-core/jni/main/include/fd_utils-inl.h b/edxp-core/src/main/cpp/main/include/fd_utils-inl.h similarity index 100% rename from edxp-core/jni/main/include/fd_utils-inl.h rename to edxp-core/src/main/cpp/main/include/fd_utils-inl.h diff --git a/edxp-core/jni/main/include/logging.h b/edxp-core/src/main/cpp/main/include/logging.h similarity index 100% rename from edxp-core/jni/main/include/logging.h rename to edxp-core/src/main/cpp/main/include/logging.h diff --git a/edxp-core/jni/main/include/misc.cpp b/edxp-core/src/main/cpp/main/include/misc.cpp similarity index 100% rename from edxp-core/jni/main/include/misc.cpp rename to edxp-core/src/main/cpp/main/include/misc.cpp diff --git a/edxp-core/jni/main/include/misc.h b/edxp-core/src/main/cpp/main/include/misc.h similarity index 100% rename from edxp-core/jni/main/include/misc.h rename to edxp-core/src/main/cpp/main/include/misc.h diff --git a/edxp-core/jni/main/inject/config_manager.cpp b/edxp-core/src/main/cpp/main/inject/config_manager.cpp similarity index 100% rename from edxp-core/jni/main/inject/config_manager.cpp rename to edxp-core/src/main/cpp/main/inject/config_manager.cpp diff --git a/edxp-core/jni/main/inject/config_manager.h b/edxp-core/src/main/cpp/main/inject/config_manager.h similarity index 100% rename from edxp-core/jni/main/inject/config_manager.h rename to edxp-core/src/main/cpp/main/inject/config_manager.h diff --git a/edxp-core/jni/main/inject/framework_hook.cpp b/edxp-core/src/main/cpp/main/inject/framework_hook.cpp similarity index 100% rename from edxp-core/jni/main/inject/framework_hook.cpp rename to edxp-core/src/main/cpp/main/inject/framework_hook.cpp diff --git a/edxp-core/jni/main/inject/framework_hook.h b/edxp-core/src/main/cpp/main/inject/framework_hook.h similarity index 100% rename from edxp-core/jni/main/inject/framework_hook.h rename to edxp-core/src/main/cpp/main/inject/framework_hook.h diff --git a/edxp-core/jni/main/java_hook/java_hook.cpp b/edxp-core/src/main/cpp/main/java_hook/java_hook.cpp similarity index 99% rename from edxp-core/jni/main/java_hook/java_hook.cpp rename to edxp-core/src/main/cpp/main/java_hook/java_hook.cpp index 1b1f4792..d087cf85 100644 --- a/edxp-core/jni/main/java_hook/java_hook.cpp +++ b/edxp-core/src/main/cpp/main/java_hook/java_hook.cpp @@ -14,7 +14,7 @@ extern "C" { -#include "../yahfa/HookMain.h" +#include "HookMain.h" } jobject gInjectDexClassLoader; diff --git a/edxp-core/jni/main/java_hook/java_hook.h b/edxp-core/src/main/cpp/main/java_hook/java_hook.h similarity index 100% rename from edxp-core/jni/main/java_hook/java_hook.h rename to edxp-core/src/main/cpp/main/java_hook/java_hook.h diff --git a/edxp-core/jni/main/main.cpp b/edxp-core/src/main/cpp/main/main.cpp similarity index 97% rename from edxp-core/jni/main/main.cpp rename to edxp-core/src/main/cpp/main/main.cpp index 634de5a7..8318ff2f 100644 --- a/edxp-core/jni/main/main.cpp +++ b/edxp-core/src/main/cpp/main/main.cpp @@ -10,8 +10,8 @@ #include #include #include -#include -#include +#include "inject/framework_hook.h" +#include "native_hook/native_hook.h" #include "include/logging.h" #include "include/misc.h" diff --git a/edxp-core/jni/main/native_hook/native_hook.cpp b/edxp-core/src/main/cpp/main/native_hook/native_hook.cpp similarity index 99% rename from edxp-core/jni/main/native_hook/native_hook.cpp rename to edxp-core/src/main/cpp/main/native_hook/native_hook.cpp index 0c17f590..51403971 100644 --- a/edxp-core/jni/main/native_hook/native_hook.cpp +++ b/edxp-core/src/main/cpp/main/native_hook/native_hook.cpp @@ -4,7 +4,7 @@ #include #include #include -#include +#include #include "include/logging.h" #include "native_hook.h" diff --git a/edxp-core/jni/main/native_hook/native_hook.h b/edxp-core/src/main/cpp/main/native_hook/native_hook.h similarity index 97% rename from edxp-core/jni/main/native_hook/native_hook.h rename to edxp-core/src/main/cpp/main/native_hook/native_hook.h index eb6f7a9a..291bafc4 100644 --- a/edxp-core/jni/main/native_hook/native_hook.h +++ b/edxp-core/src/main/cpp/main/native_hook/native_hook.h @@ -1,7 +1,7 @@ #ifndef HOOK_H #define HOOK_H -#include +#include #if defined(__LP64__) static constexpr const char *kLibArtPath = "/system/lib64/libart.so"; diff --git a/edxp-core/jni/main/native_hook/resource_hook.cpp b/edxp-core/src/main/cpp/main/native_hook/resource_hook.cpp similarity index 100% rename from edxp-core/jni/main/native_hook/resource_hook.cpp rename to edxp-core/src/main/cpp/main/native_hook/resource_hook.cpp diff --git a/edxp-core/jni/main/native_hook/resource_hook.h b/edxp-core/src/main/cpp/main/native_hook/resource_hook.h similarity index 100% rename from edxp-core/jni/main/native_hook/resource_hook.h rename to edxp-core/src/main/cpp/main/native_hook/resource_hook.h diff --git a/edxp-core/jni/main/native_hook/riru_hook.cpp b/edxp-core/src/main/cpp/main/native_hook/riru_hook.cpp similarity index 98% rename from edxp-core/jni/main/native_hook/riru_hook.cpp rename to edxp-core/src/main/cpp/main/native_hook/riru_hook.cpp index 4702b1c4..59aa3232 100644 --- a/edxp-core/jni/main/native_hook/riru_hook.cpp +++ b/edxp-core/src/main/cpp/main/native_hook/riru_hook.cpp @@ -4,8 +4,8 @@ #include #include -#include -#include +#include +#include #include #include #include diff --git a/edxp-core/jni/main/native_hook/riru_hook.h b/edxp-core/src/main/cpp/main/native_hook/riru_hook.h similarity index 100% rename from edxp-core/jni/main/native_hook/riru_hook.h rename to edxp-core/src/main/cpp/main/native_hook/riru_hook.h