Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

macOS 无法编译出相关 so 库 #54

Open
AlphaHans opened this issue Sep 30, 2019 · 5 comments
Open

macOS 无法编译出相关 so 库 #54

AlphaHans opened this issue Sep 30, 2019 · 5 comments

Comments

@AlphaHans
Copy link

[armeabi] Compile thumb  : xhook <= xhook.c
[armeabi] Compile thumb  : xhook <= xh_core.c
/Users/hans/GitSpace/xHook/libxhook/jni/xh_core.c: In function 'xh_core_refresh_impl':
/Users/hans/GitSpace/xHook/libxhook/jni/xh_core.c:329:9: error: use of assignment suppression and length modifier together in gnu_scanf format [-Werror=format=]
         if(sscanf(line, "%"PRIxPTR"-%*lx %4s %lx %*x:%*x %*d%n", &base_addr, perm, &offset, &pathname_pos) != 3) continue;
         ^
cc1: all warnings being treated as errors
make: *** [/Users/hans/GitSpace/xHook/libxhook/obj/local/armeabi/objs/xhook/xh_core.o] Error 1
Android NDK: ERROR:/Users/hans/GitSpace/xHook/libbiz/jni/Android.mk:xhook: LOCAL_SRC_FILES points to a missing file    
Android NDK: Check that /Users/hans/GitSpace/xHook/libbiz/jni/../../libxhook/libs/armeabi/libxhook.so exists  or that its path is correct   
/Users/Hans/Library/Android/ndk/android-ndk-r12b/build/core/prebuilt-library.mk:45: *** Android NDK: Aborting    .  Stop.
[armeabi] Compile thumb  : test <= test.c
[armeabi] SharedLibrary  : libtest.so
[armeabi] Install        : libtest.so => libs/armeabi/libtest.so
[armeabi-v7a] Compile thumb  : test <= test.c
[armeabi-v7a] SharedLibrary  : libtest.so
[armeabi-v7a] Install        : libtest.so => libs/armeabi-v7a/libtest.so
[arm64-v8a] Compile        : test <= test.c
[arm64-v8a] SharedLibrary  : libtest.so
[arm64-v8a] Install        : libtest.so => libs/arm64-v8a/libtest.so
[x86] Compile        : test <= test.c
[x86] SharedLibrary  : libtest.so
[x86] Install        : libtest.so => libs/x86/libtest.so
[x86_64] Compile        : test <= test.c
[x86_64] SharedLibrary  : libtest.so
[x86_64] Install        : libtest.so => libs/x86_64/libtest.so

@AlphaHans
Copy link
Author

此外问个问题,使用 xHook 之后,如何能够调用原本的函数返回呢?

如 hook malloc,myMalloc 仅记录内存分配信息,但是还是要调用系统真正的 malloc 方法返回。

@fr0zenrain
Copy link

我觉得可以通过函数指针直接调原来的malloc,不用担心死循环问题。

@caikelun
Copy link
Collaborator

caikelun commented Oct 9, 2019

@AlphaHans 编译警告的问题我有空改一下,暂时请先使用readme中的方法用 NDK r16b 编译吧。

可以用 xhook_register 函数的最后一次参数,保留原 malloc 函数的地址,myMalloc 中使用这个函数地址来调用原 malloc。

@fr0zenrain
Copy link

@caikelun 有个问题请教,一定要用r16b么,hook修改的是data,感觉不是一定需要flush cache吧,会不会有其他后果。主要是我的ndk太古老不想换。

@caikelun
Copy link
Collaborator

caikelun commented Oct 9, 2019

@fr0zenrain r16b是最后一个官方支持 armeabi 的版本,ndk版本太低的话bug比较多,建议升级哦。需要 flush cache,你可以把 flush 的逻辑临时去掉对比试一下。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants