adbi 是一个android平台(arm 32 )的so注入+挂钩框架,源码开放在github上 : ADBI 项目 。从github上下载来目录如下:
执行主目录下build.sh编译后目录如下,前提是你有在环境变量下设置ndk-build路径,不知道ndk-build是啥的说明还没下载过NDK哦。
对比编译前的目录很容易看出多了obj目录、so库、静态库和可执行文件,具体为何如此请学习各自目录下的Android.mk
hijack下的Android.mk——生成可执行文件hijack
LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE := hijack LOCAL_SRC_FILES := ../hijack.c LOCAL_ARM_MODE := arm LOCAL_CFLAGS := -g include $(BUILD_EXECUTABLE)
base下的Android.mk——生成静态库libbase.a
LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE := base LOCAL_SRC_FILES := ../util.c ../hook.c ../base.c LOCAL_ARM_MODE := arm include $(BUILD_STATIC_LIBRARY)
example下的Android.mk——生成共享库libexample.so;注意这里是PREBUILD_STATIC_LIBRARY而不是BUILD_STATIC_LIBRARY,因为是包含所以是预编译
LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE := base LOCAL_SRC_FILES := ../../base/obj/local/armeabi/libbase.a LOCAL_EXPORT_C_INCLUDES := ../../base include $(PREBUILT_STATIC_LIBRARY) include $(CLEAR_VARS) LOCAL_MODULE := libexample LOCAL_SRC_FILES := ../epoll.c ../epoll_arm.c.arm LOCAL_CFLAGS := -g LOCAL_SHARED_LIBRARIES := dl LOCAL_STATIC_LIBRARIES := base include $(BUILD_SHARED_LIBRARY)
以上就是下载来的adbi项目中的Android.mk啦,如果你看不懂可以看我之前的一篇关于makefile的文章里面有简单的介绍。
ok,编译好了我们执行来看看效果吧
参考资料: