-
Notifications
You must be signed in to change notification settings - Fork 76
Description
Hi guys, I've used the default setting with Dobby but since that can only work with an emulator (not real device) or just my bad.
This is my native-lib.cpp
#include "BNM/Loading.hpp"
#include "BNM/Class.hpp"
#include "BNMResolve.hpp"
void OnLoaded_Example() {
BNM_LOG_INFO("OnLoaded_Example Called");
}
JNIEXPORT jint JNI_OnLoad(JavaVM *vm, void *reserved) {
JNIEnv *env;
vm->GetEnv((void **) &env, JNI_VERSION_1_6);
BNM::Loading::AllowLateInitHook();
BNM::Loading::AddOnLoadedEvent(OnLoaded_Example);
BNM::Loading::TryLoadByJNI(env);
BNM_LOG_INFO("JNI_OnLoad");
return JNI_VERSION_1_6;
}
I started to try shadowhook by first following https://github.com/bytedance/android-inline-hook/blob/main/doc/manual.md#integration and add shadowhook_init before the BNM::Loading. Also, uncomment the section in GlobalSettings.hpp and add #include <shadowhook.h>
// Shadowhook
template<typename PTR_T, typename NEW_T, typename T_OLD>
inline void *BasicHook(PTR_T ptr, NEW_T newMethod, T_OLD &oldBytes) {
if ((void *) ptr != nullptr) return shadowhook_hook_func_addr((void *)ptr, (void *) newMethod, (void **) &oldBytes);
return nullptr;
}
template<typename PTR_T, typename NEW_T, typename T_OLD>
inline void *BasicHook(PTR_T ptr, NEW_T newMethod, T_OLD &&oldBytes) {
if ((void *) ptr != nullptr) return shadowhook_hook_func_addr((void *)ptr, (void *) newMethod, (void **) &oldBytes);
return nullptr;
}
template<typename PTR_T>
inline void Unhook(PTR_T ptr) {
if ((void *) ptr != nullptr) shadowhook_unhook((void *)ptr);
}
I also remove dobby related stuffs in CMakeLists.txt and replace with shadowhook.
I'm using AndKittyInjector to inject the final lib.so but constantly get
I: inject_lib: Stopped target process threads.
I: inject_lib: Attaching to target process...
I: inject_lib: Attached successfully.
I: injectLibrary: [native=arm64 | lib=arm64].
I: injectLibrary: lib handle = 0x0.
I: injectLibrary: lib Base = 0x0.
E: injectLibrary: failed )':
E: injectLibrary: calling dlerror...
E: injectLibrary: dlopen failed: library "libshadowhook.so" not found
I: inject_lib: Killing target process...
E: Injection failed.
even though I pushed that libshadowhook.so into the device and even add LD_LIBRARY_PATH point to /data/local/tmp..
What did I do wrong? If possible, can you show your full configs to make shadowhook work? Thanks