Use Dobby for native_api
LSPlt might not be capable for general native_api hooks Fix Dobby module repo Url chiteroman has deleted his repo, so I should maintain my own fork.
This commit is contained in:
parent
4c4a3f4fa1
commit
75e300532e
|
|
@ -1,9 +1,12 @@
|
||||||
[submodule "external/lsplant"]
|
[submodule "external/lsplant"]
|
||||||
path = external/lsplant
|
path = external/lsplant
|
||||||
url = https://github.com/JingMatrix/LSPlant.git
|
url = https://github.com/JingMatrix/LSPlant.git
|
||||||
|
[submodule "external/dobby"]
|
||||||
|
path = external/dobby
|
||||||
|
url = https://github.com/JingMatrix/Dobby.git
|
||||||
[submodule "external/lsplt"]
|
[submodule "external/lsplt"]
|
||||||
path = external/lsplt
|
path = external/lsplt
|
||||||
url = https://github.com/LSPosed/LSPlt
|
url = https://github.com/LSPosed/LSPlt.git
|
||||||
[submodule "external/fmt"]
|
[submodule "external/fmt"]
|
||||||
path = external/fmt
|
path = external/fmt
|
||||||
url = https://github.com/fmtlib/fmt.git
|
url = https://github.com/fmtlib/fmt.git
|
||||||
|
|
|
||||||
|
|
@ -58,10 +58,10 @@ You can contribute translation [here](https://crowdin.com/project/lsposed_jingma
|
||||||
- [Magisk](https://github.com/topjohnwu/Magisk/): makes all these possible
|
- [Magisk](https://github.com/topjohnwu/Magisk/): makes all these possible
|
||||||
- [Riru](https://github.com/RikkaApps/Riru): provides a way to inject code into zygote process
|
- [Riru](https://github.com/RikkaApps/Riru): provides a way to inject code into zygote process
|
||||||
- [XposedBridge](https://github.com/rovo89/XposedBridge): the OG Xposed framework APIs
|
- [XposedBridge](https://github.com/rovo89/XposedBridge): the OG Xposed framework APIs
|
||||||
- [LSPlt](https://github.com/LSPosed/LSPlt): used for inline hooking
|
- [LSPlt](https://github.com/LSPosed/LSPlt): used for (Android 15) `libart` inline hooking
|
||||||
|
- [Dobby](https://github.com/JingMatrix/Dobby): used for fallback and `native_api` inline hooking
|
||||||
- [LSPlant](https://github.com/JingMatrix/LSPlant): the core ART hooking framework
|
- [LSPlant](https://github.com/JingMatrix/LSPlant): the core ART hooking framework
|
||||||
- [EdXposed](https://github.com/ElderDrivers/EdXposed): fork source
|
- [EdXposed](https://github.com/ElderDrivers/EdXposed): fork source
|
||||||
- ~[Dobby](https://github.com/chiteroman/Dobby): used for inline hooking~
|
|
||||||
- ~[SandHook](https://github.com/ganyao114/SandHook/): ART hooking framework for SandHook variant~
|
- ~[SandHook](https://github.com/ganyao114/SandHook/): ART hooking framework for SandHook variant~
|
||||||
- ~[YAHFA](https://github.com/rk700/YAHFA): previous ART hooking framework~
|
- ~[YAHFA](https://github.com/rk700/YAHFA): previous ART hooking framework~
|
||||||
- ~[dexmaker](https://github.com/linkedin/dexmaker) and [dalvikdx](https://github.com/JakeWharton/dalvik-dx): to dynamically generate YAHFA hooker classes~
|
- ~[dexmaker](https://github.com/linkedin/dexmaker) and [dalvikdx](https://github.com/JakeWharton/dalvik-dx): to dynamically generate YAHFA hooker classes~
|
||||||
|
|
|
||||||
|
|
@ -12,5 +12,5 @@ add_library(${PROJECT_NAME} STATIC ${SRC_LIST})
|
||||||
target_include_directories(${PROJECT_NAME} PUBLIC include)
|
target_include_directories(${PROJECT_NAME} PUBLIC include)
|
||||||
target_include_directories(${PROJECT_NAME} PRIVATE src)
|
target_include_directories(${PROJECT_NAME} PRIVATE src)
|
||||||
|
|
||||||
target_link_libraries(${PROJECT_NAME} PUBLIC lsplt_static lsplant_static log fmt-header-only)
|
target_link_libraries(${PROJECT_NAME} PUBLIC dobby_static lsplt_static lsplant_static log fmt-header-only)
|
||||||
target_link_libraries(${PROJECT_NAME} PRIVATE dex_builder_static)
|
target_link_libraries(${PROJECT_NAME} PRIVATE dex_builder_static)
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,6 @@
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <dlfcn.h>
|
#include <dlfcn.h>
|
||||||
#include "native_util.h"
|
|
||||||
#include "elf_util.h"
|
#include "elf_util.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -59,8 +58,8 @@ namespace lspd {
|
||||||
const auto[entries] = []() {
|
const auto[entries] = []() {
|
||||||
auto *entries = new(protected_page.get()) NativeAPIEntries{
|
auto *entries = new(protected_page.get()) NativeAPIEntries{
|
||||||
.version = 2,
|
.version = 2,
|
||||||
.hookFunc = &HookFunction,
|
.hookFunc = &DobbyHookFunction,
|
||||||
.unhookFunc = &UnhookFunction,
|
.unhookFunc = &DobbyUnhookFunction,
|
||||||
};
|
};
|
||||||
|
|
||||||
mprotect(protected_page.get(), 4096, PROT_READ);
|
mprotect(protected_page.get(), 4096, PROT_READ);
|
||||||
|
|
@ -72,7 +71,7 @@ namespace lspd {
|
||||||
return InstallNativeAPI({
|
return InstallNativeAPI({
|
||||||
.inline_hooker = [](auto t, auto r) {
|
.inline_hooker = [](auto t, auto r) {
|
||||||
void* bk = nullptr;
|
void* bk = nullptr;
|
||||||
return HookFunction(t, r, &bk) == 0 ? bk : nullptr;
|
return DobbyHookFunction(t, r, &bk) == 0 ? bk : nullptr;
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}();
|
}();
|
||||||
|
|
|
||||||
|
|
@ -26,8 +26,11 @@
|
||||||
#define LSPOSED_NATIVE_API_H
|
#define LSPOSED_NATIVE_API_H
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
#include <dlfcn.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <dobby.h>
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
#include "utils/hook_helper.hpp"
|
#include "utils/hook_helper.hpp"
|
||||||
|
|
||||||
typedef int (*HookFunType)(void *func, void *replace, void **backup);
|
typedef int (*HookFunType)(void *func, void *replace, void **backup);
|
||||||
|
|
@ -48,6 +51,28 @@ namespace lspd {
|
||||||
bool InstallNativeAPI(const lsplant::HookHandler& handler);
|
bool InstallNativeAPI(const lsplant::HookHandler& handler);
|
||||||
|
|
||||||
void RegisterNativeLib(const std::string &library_name);
|
void RegisterNativeLib(const std::string &library_name);
|
||||||
|
|
||||||
|
inline int DobbyHookFunction(void *original, void *replace, void **backup) {
|
||||||
|
if constexpr (isDebug) {
|
||||||
|
Dl_info info;
|
||||||
|
if (dladdr(original, &info))
|
||||||
|
LOGD("Dobby hooking {} ({}) from {} ({})",
|
||||||
|
info.dli_sname ? info.dli_sname : "(unknown symbol)", info.dli_saddr,
|
||||||
|
info.dli_fname ? info.dli_fname : "(unknown file)", info.dli_fbase);
|
||||||
|
}
|
||||||
|
return DobbyHook(original, reinterpret_cast<dobby_dummy_func_t>(replace), reinterpret_cast<dobby_dummy_func_t *>(backup));
|
||||||
|
}
|
||||||
|
|
||||||
|
inline int DobbyUnhookFunction(void *original) {
|
||||||
|
if constexpr (isDebug) {
|
||||||
|
Dl_info info;
|
||||||
|
if (dladdr(original, &info))
|
||||||
|
LOGD("Dobby unhooking {} ({}) from {} ({})",
|
||||||
|
info.dli_sname ? info.dli_sname : "(unknown symbol)", info.dli_saddr,
|
||||||
|
info.dli_fname ? info.dli_fname : "(unknown file)", info.dli_fbase);
|
||||||
|
}
|
||||||
|
return DobbyDestroy(original);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif //LSPOSED_NATIVE_API_H
|
#endif //LSPOSED_NATIVE_API_H
|
||||||
|
|
|
||||||
|
|
@ -104,7 +104,8 @@ link_libraries(cxx)
|
||||||
|
|
||||||
OPTION(LSPLANT_BUILD_SHARED OFF)
|
OPTION(LSPLANT_BUILD_SHARED OFF)
|
||||||
OPTION(LSPLT_BUILD_SHARED OFF)
|
OPTION(LSPLT_BUILD_SHARED OFF)
|
||||||
|
add_subdirectory(dobby)
|
||||||
|
add_subdirectory(fmt)
|
||||||
add_subdirectory(lsplant/lsplant/src/main/jni)
|
add_subdirectory(lsplant/lsplant/src/main/jni)
|
||||||
add_subdirectory(lsplt/lsplt/src/main/jni)
|
add_subdirectory(lsplt/lsplt/src/main/jni)
|
||||||
add_subdirectory(fmt)
|
|
||||||
target_compile_definitions(fmt-header-only INTERFACE FMT_STATIC_THOUSANDS_SEPARATOR=1 FMT_USE_FLOAT=0 FMT_USE_DOUBLE=0 FMT_USE_LONG_DOUBLE=0)
|
target_compile_definitions(fmt-header-only INTERFACE FMT_STATIC_THOUSANDS_SEPARATOR=1 FMT_USE_FLOAT=0 FMT_USE_DOUBLE=0 FMT_USE_LONG_DOUBLE=0)
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit 389938ae5e7f2fbc45fc62f94a20192a29d37435
|
||||||
Loading…
Reference in New Issue