首页
论坛
课程
招聘
雪    币: 226
活跃值: 活跃值 (10)
能力值: ( LV9,RANK:210 )
在线值:
发帖
回帖
粉丝

[原创]Hook Java的的一个改进版本

2014-9-29 11:09 28920

[原创]Hook Java的的一个改进版本

2014-9-29 11:09
28920
<center> Hook Java的的一个改进版本
--------------------------

[《注入安卓进程,并Hook java世界的方法》](http://bbs.pediy.com/showthread.php?t=186054)这篇好文相信大家都看这,里面所提到的方法估计大家也都试过。不过里面的所用的方法,我发现有两个可以改进的地方。

##改进点一:更简单地修改java方法为本地方法##

```
        ...
        // hook method
        int argsSize = calcMethodArgsSize(method->shorty);
        if (!dvmIsStaticMethod(method))
                argsSize++;

        SET_METHOD_FLAG(method, ACC_NATIVE);
        method->registersSize = method->insSize = argsSize;
        method->outsSize = 0;
        method->jniArgInfo = dvmComputeJniArgInfo(method->shorty);

        // save info to insns
        method->insns = (u2*)info;

        // bind the bridge func,only one line
        method->nativeFunc = method_handler;
        LOGI("[+] %s->%s was hooked\n", classDesc, methodName);
        ...
```
直接把method->nativeFunc即可,无需重新调用JNIEnv的RegisterNatives方法,其中method_handler可以是下面两种形式之一:

```
typedef void (*DalvikBridgeFunc)(const u4* args, JValue* pResult, const Method* method, struct Thread* self);
typedef void (*DalvikNativeFunc)(const u4* args, JValue* pResult);
```

这样有一个好处,就是所有java方法都可以统一指向同一个native func,而不需要像为每一个java method方法指定一个native func。

##改进点二:方法回调避免线程安全问题##
原来的方法,是这样的

```
  //hook之前先拷贝
  uint mlen = sizeof(Method);
  Method *oldMeth = (Method*)malloc(mlen);
  memcpy(oldMeth,method,mlen);
  info->odlMethod = oldMeth;
  info->curMethod = method;
  
  //回调后再拷贝回来,再通过jni->callXXXXMethod调用,之后再重新hook
  memcpy(hi->curMethod,hi->odlMethod,mlen);
  jmethodID om = (jmethodID)hi->curMethod;
  jenv->CallVoidMethod(me,om,gDevice_Sensors);
  ClassMethodHook(jenv,&baiduhookInfos[0]);
```
这个方法,其实是有线程安全问题的,其中在dalvik中,有很多方法可以直接调用Method对象,比如dvmCallMethod, dvmCallMethodA, dvmCallMethodV,dvmInvokeMethod等等。针对DalvikBridgeFunc和DalvikNativeFunc的参数,我最后选择使用dvmInvokeMethod,这个函数的原型是这样的:

```
Object* dvmInvokeMethod(Object* obj, const Method* method, ArrayObject* argList, ArrayObject* params, ClassObject* returnType, bool noAccessCheck)

```

其中,obj是this或者null(如果是static方法),method可以直接使用hook之前copy的对象,比较麻烦是argList,params和returnType的获取。获取argList的方法,我在Proxy.cpp中到了现成的boxMethodArgs方法,而returnType通过Reflect.h中dvmGetBoxedReturnType的方法也可以获取,而剩下的params只能自己写代码了,下面是我的代码:

```
STATIC ArrayObject* dvmGetMethodParamTypes(const Method* method, const char* methodsig){
        /* count args */
        size_t argCount = dexProtoGetParameterCount(&method->prototype);
        STATIC ClassObject* java_lang_object_array = dvmFindSystemClass("[Ljava/lang/Object;");

        /* allocate storage */
        ArrayObject* argTypes = dvmAllocArrayByClass(java_lang_object_array, argCount, ALLOC_DEFAULT);
        if(argTypes == NULL){
                return NULL;
        }

        Object** argObjects = (Object**) argTypes->contents;
        const char *desc = (const char *)(strchr(methodsig, '(') + 1);

        /*
         * Fill in the array.
         */
        size_t desc_index = 0;
        size_t arg_index = 0;
        bool isArray = false;
        char descChar = desc[desc_index];

        while (descChar != ')') {

                switch (descChar) {
                case 'Z':
                case 'C':
                case 'F':
                case 'B':
                case 'S':
                case 'I':
                case 'D':
                case 'J':
                        if(!isArray){
                                argObjects[arg_index++] = dvmFindPrimitiveClass(descChar);
                                isArray = false;
                        }else{
                                char buf[3] = {0};
                                memcpy(buf, desc + desc_index - 1, 2);
                                argObjects[arg_index++] = dvmFindSystemClass(buf);
                        }

                        desc_index++;
                        break;

                case '[':
                        isArray = true;
                        desc_index++;
                        break;

                case 'L':
                        int s_pos = desc_index, e_pos = desc_index;
                        while(desc[++e_pos] != ';');
                        s_pos = isArray ? s_pos - 1 : s_pos;
                        isArray = false;

                        size_t len = e_pos - s_pos + 1;
                        char buf[128] = { 0 };
                        memcpy((void *)buf, (const void *)(desc + s_pos), len);
                        argObjects[arg_index++] = dvmFindClass(buf);
                        desc_index = e_pos + 1;
                        break;
                }

                descChar = desc[desc_index];
        }

        return argTypes;
}
```

通过上面几个类型的获取之后,最后再看一下整个method hook的实现,过程其实大同小异,不过直接把上述提及的向种类型信息预先获取并保存到method->insns里头了:

```
extern int __attribute__ ((visibility ("hidden"))) dalvik_java_method_hook(JNIEnv* env, HookInfo *info) {
        const char* classDesc = info->classDesc;
        const char* methodName = info->methodName;
        const char* methodSig = info->methodSig;
        const bool isStaticMethod = info->isStaticMethod;

        jclass classObj = dvmFindJNIClass(env, classDesc);
        if (classObj == NULL) {
                LOGE("[-] %s class not found", classDesc);
                return -1;
        }

        jmethodID methodId =
                        isStaticMethod ?
                                        env->GetStaticMethodID(classObj, methodName, methodSig) :
                                        env->GetMethodID(classObj, methodName, methodSig);

        if (methodId == NULL) {
                LOGE("[-] %s->%s method not found", classDesc, methodName);
                return -1;
        }

        // backup method
        Method* method = (Method*) methodId;
        if(method->nativeFunc == method_handler){
                LOGW("
  • %s->%s method had been hooked", classDesc, methodName);
  •                 return -1;
            }
            Method* bakMethod = (Method*) malloc(sizeof(Method));
            memcpy(bakMethod, method, sizeof(Method));

            // init info
            info->originalMethod = (void *)bakMethod;
            info->returnType = (void *)dvmGetBoxedReturnType(bakMethod);
            info->paramTypes = dvmGetMethodParamTypes(bakMethod, info->methodSig);

            // hook method
            int argsSize = calcMethodArgsSize(method->shorty);
            if (!dvmIsStaticMethod(method))
                    argsSize++;

            SET_METHOD_FLAG(method, ACC_NATIVE);
            method->registersSize = method->insSize = argsSize;
            method->outsSize = 0;
            method->jniArgInfo = dvmComputeJniArgInfo(method->shorty);

            // save info to insns
            method->insns = (u2*)info;

            // bind the bridge func,only one line
            method->nativeFunc = method_handler;
            LOGI("[+] %s->%s was hooked\n", classDesc, methodName);

            return 0;
    }

    ```

    然后是method_handler的实现,这个方法是所有java方法的跳转函数,所以在这里可以注册callback,不过这部分逻辑我没有做上,有兴趣的朋友可以加上。

    ```
    STATIC void method_handler(const u4* args, JValue* pResult, const Method* method, struct Thread* self){
            HookInfo* info = (HookInfo*)method->insns; //get hookinfo pointer from method-insns
            LOGI("entry %s->%s", info->classDesc, info->methodName);

            Method* originalMethod = reinterpret_cast<Method*>(info->originalMethod);
            Object* thisObject = (Object*)args[0];

            ArrayObject* argTypes = dvmBoxMethodArgs(originalMethod, args + 1);
            pResult->l = (void *)dvmInvokeMethod(thisObject, originalMethod, argTypes, (ArrayObject *)info->paramTypes, (ClassObject *)info->returnType, true);

            dvmReleaseTrackedAlloc((Object *)argTypes, self);
    }

    ```

    最后通过dvmInvokeMethod就可以直接调回原来的函数了。

    ##最后##
    写这个代码,主要是因为我在工作中要注入到某个系统进程,然后要hook java中的某些方法,但用cydia和xposed感觉太笨重了,特别是xposed,里面的很多参数的boxed/unboxed都是通过jni模块自动转换的,整个框架已经离不开dex文件了。

    所以才想自己实现一套纯本地的java hook代码,而《注入安卓进程,并Hook java世界的方法》所介绍的方法,我感觉用起来不太方便,跟cydia和xposed两个框架的主要区别就是缺少了一个“中转函数”,所以而有了本码。

    代码我上传到[github](https://github.com/boyliang/AllHookInOne.git),目前只有java hook,我打算把目前的hook技术都集成到这里,包括inline hook, elf hook等等。

    [公告]看雪论坛2020激励机制上线了!发帖不减雪币了!如何获得积分快速升级?

    上传的附件:
    最新回复 (33)
    雪    币: 76
    活跃值: 活跃值 (10)
    能力值: ( LV2,RANK:10 )
    在线值:
    发帖
    回帖
    粉丝
    mingxuan三千 活跃值 2014-9-29 11:18
    2
    0
    顶,期待inline hook, elf hook等。
    不知道是不是兼容性的问题,目前这几个hook java的例子我都没有编译成功运行过。。。
    用boyliang兄编译的可以运行。。。
    最好源代码里面也有Android.mk文件:)
    雪    币: 226
    活跃值: 活跃值 (10)
    能力值: ( LV9,RANK:210 )
    在线值:
    发帖
    回帖
    粉丝
    boyliang 活跃值 5 2014-9-29 11:20
    3
    0
    这次我把所有的东西上传了,编译应该没有问题了
    雪    币: 76
    活跃值: 活跃值 (10)
    能力值: ( LV2,RANK:10 )
    在线值:
    发帖
    回帖
    粉丝
    mingxuan三千 活跃值 2014-9-29 11:23
    4
    0
    thanks  
    有空我再测试下,有问题再麻烦boyliang兄
    雪    币: 317
    活跃值: 活跃值 (16)
    能力值: ( LV9,RANK:310 )
    在线值:
    发帖
    回帖
    粉丝
    ThomasKing 活跃值 6 2014-9-29 12:20
    5
    0
    学习了!感谢分享!
    雪    币: 101
    活跃值: 活跃值 (10)
    能力值: ( LV2,RANK:10 )
    在线值:
    发帖
    回帖
    粉丝
    suwey 活跃值 2014-9-29 12:37
    6
    0
    mark..
    雪    币: 9623
    活跃值: 活跃值 (297)
    能力值: ( LV12,RANK:830 )
    在线值:
    发帖
    回帖
    粉丝
    obaby 活跃值 19 2014-9-29 15:43
    7
    0
    mark
    雪    币: 261
    活跃值: 活跃值 (10)
    能力值: ( LV7,RANK:100 )
    在线值:
    发帖
    回帖
    粉丝
    wule 活跃值 2 2014-9-29 16:44
    8
    0
    不管是在博客,还是在看雪,感觉boyliang前辈总是这么nice,过程详细清晰,代码完整可用,真的对于我们初学者很大的帮助,非常的感谢前辈。
    雪    币: 226
    活跃值: 活跃值 (10)
    能力值: ( LV9,RANK:210 )
    在线值:
    发帖
    回帖
    粉丝
    boyliang 活跃值 5 2014-9-29 18:54
    9
    0
    谢谢夸奖啊,如有不足,还请多多指正
    雪    币: 304
    活跃值: 活跃值 (16)
    能力值: ( LV9,RANK:210 )
    在线值:
    发帖
    回帖
    粉丝
    我是土匪 活跃值 4 2014-9-29 21:58
    10
    0
    mark
    雪    币: 215
    活跃值: 活跃值 (10)
    能力值: ( LV2,RANK:10 )
    在线值:
    发帖
    回帖
    粉丝
    potop 活跃值 2014-9-30 10:31
    11
    0
    是在Eclipse——import...——Existing Projects into Workspace导入后编译吗?为什么我import后,看不到任何project,Finish按钮也无法选择?
    雪    币: 33
    活跃值: 活跃值 (27)
    能力值: ( LV8,RANK:120 )
    在线值:
    发帖
    回帖
    粉丝
    万抽抽 活跃值 2 2014-9-30 10:45
    12
    0
    终于有空了,马上学习学习!
    雪    币: 2936
    活跃值: 活跃值 (20)
    能力值: ( LV2,RANK:10 )
    在线值:
    发帖
    回帖
    粉丝
    Crakme 活跃值 2014-10-5 11:13
    13
    0
    非常期待inline hook, elf hook
    雪    币: 35
    活跃值: 活跃值 (10)
    能力值: ( LV2,RANK:10 )
    在线值:
    发帖
    回帖
    粉丝
    wujinfa 活跃值 2014-10-15 09:23
    14
    0
    请教一下,如果想要模拟gbd给某个代码地址加上断点,arm汇编应该怎么写比较好?
    雪    币: 226
    活跃值: 活跃值 (10)
    能力值: ( LV9,RANK:210 )
    在线值:
    发帖
    回帖
    粉丝
    boyliang 活跃值 5 2014-10-15 09:31
    15
    0
    你为什么不参考一下gdb的源码呢
    雪    币: 193
    活跃值: 活跃值 (10)
    能力值: ( LV4,RANK:50 )
    在线值:
    发帖
    回帖
    粉丝
    conyjune 活跃值 1 2014-10-22 15:32
    16
    0
    请问我编译SO的时候 include <android_runtime/AndroidRuntime.h> 这个库找不到是什么原因?
    雪    币: 230
    活跃值: 活跃值 (10)
    能力值: ( LV2,RANK:10 )
    在线值:
    发帖
    回帖
    粉丝
    jeffycf 活跃值 2014-10-23 09:52
    17
    0
    mark
    雪    币: 49
    活跃值: 活跃值 (10)
    能力值: ( LV2,RANK:10 )
    在线值:
    发帖
    回帖
    粉丝
    onegenius 活跃值 2014-10-23 16:46
    18
    0
    换一种思路,这样也可以。是吧,影帝:)
    void* handle = dlopen("/system/lib/libandroid_runtime.so", RTLD_NOW);
    void* jvmAddr = dlsym(handle, "_ZN7android14AndroidRuntime7mJavaVME");
    javaVM = *((JavaVM**) jvmAddr);
    雪    币: 33
    活跃值: 活跃值 (10)
    能力值: ( LV3,RANK:20 )
    在线值:
    发帖
    回帖
    粉丝
    步平凡 活跃值 2014-10-24 12:46
    19
    0
    好东西,群主,我关注了,加油!
    雪    币: 92
    活跃值: 活跃值 (10)
    能力值: ( LV5,RANK:60 )
    在线值:
    发帖
    回帖
    粉丝
    lcweik 活跃值 1 2014-11-12 16:09
    20
    0
    无法编译呀,boyliang大大什么时候可以把自己的NDK共享一下呀。
    我这里找不到一大把头文件
    雪    币: 226
    活跃值: 活跃值 (10)
    能力值: ( LV9,RANK:210 )
    在线值:
    发帖
    回帖
    粉丝
    boyliang 活跃值 5 2014-11-12 21:32
    21
    0
    https://github.com/boyliang/ndk-patch
    雪    币: 125
    活跃值: 活跃值 (12)
    能力值: ( LV4,RANK:40 )
    在线值:
    发帖
    回帖
    粉丝
    njxxdx 活跃值 2014-11-22 22:52
    22
    0
    hook 静态函数dvmInvokeMethod 貌似出错了
    雪    币: 226
    活跃值: 活跃值 (10)
    能力值: ( LV9,RANK:210 )
    在线值:
    发帖
    回帖
    粉丝
    boyliang 活跃值 5 2014-11-23 11:32
    23
    0
    可以把错误日志发一下不?另外,静态函数,你应该无法编译的吧?
    雪    币: 22
    活跃值: 活跃值 (10)
    能力值: ( LV2,RANK:10 )
    在线值:
    发帖
    回帖
    粉丝
    丶侠 活跃值 2014-12-7 10:54
    24
    0
    收藏了。感谢
    雪    币: 26
    活跃值: 活跃值 (10)
    能力值: ( LV2,RANK:10 )
    在线值:
    发帖
    回帖
    粉丝
    aazhiming 活跃值 2016-3-9 13:41
    25
    0
    Android NDK: WARNING: APP_PLATFORM android-21 is larger than android:minSdkVersion 14 in /cygdrive/f/android/workspace/AllHookInOne/AndroidManifest.xml
    Android NDK: WARNING:/cygdrive/f/android/workspace/AllHookInOne/jni/Android.mk:onehook: non-system libraries in linker flags: -landroid_runtime -lart -ldvm.2   
    Android NDK:     This is likely to result in incorrect builds. Try using LOCAL_STATIC_LIBRARIES
    Android NDK:     or LOCAL_SHARED_LIBRARIES instead to list the library dependencies of the
    Android NDK:     current module
    [armeabi] Compile++ thumb: onehook <= ArtMethodHook.cpp
    In file included from F:/android/workspace/AllHookInOne/jni/JavaHook/ArtMethodHook.cpp0:
    F:/android/workspace/AllHookInOne/jni/JavaHook/art_object_4_4.h:221:70: error: expected ')' before '::' token
         mirror::Object* GetThisObject() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
                                                                          ^
    F:/android/workspace/AllHookInOne/jni/JavaHook/art_object_4_4.h:42:74: note: in definition of macro 'SHARED_LOCKS_REQUIRED'
    #define SHARED_LOCKS_REQUIRED(...) __attribute__ ((shared_locks_required(__VA_ARGS__)))
                                                                              ^
    F:/android/workspace/AllHookInOne/jni/JavaHook/art_object_4_4.h:42:87: warning: 'shared_locks_required' attribute directive ignored [-Wattributes]
    #define SHARED_LOCKS_REQUIRED(...) __attribute__ ((shared_locks_required(__VA_ARGS__)))
                                                                                           ^
    F:/android/workspace/AllHookInOne/jni/JavaHook/art_object_4_4.h:221:43: note: in expansion of macro 'SHARED_LOCKS_REQUIRED'
         mirror::Object* GetThisObject() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
                                               ^
    F:/android/workspace/AllHookInOne/jni/JavaHook/art_object_4_4.h:223:86: error: expected ')' before '::' token
         mirror::Object* GetThisObject(uint16_t num_ins) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
                                                                                          ^
    F:/android/workspace/AllHookInOne/jni/JavaHook/art_object_4_4.h:42:74: note: in definition of macro 'SHARED_LOCKS_REQUIRED'
    #define SHARED_LOCKS_REQUIRED(...) __attribute__ ((shared_locks_required(__VA_ARGS__)))
                                                                              ^
    F:/android/workspace/AllHookInOne/jni/JavaHook/art_object_4_4.h:42:87: warning: 'shared_locks_required' attribute directive ignored [-Wattributes]
    #define SHARED_LOCKS_REQUIRED(...) __attribute__ ((shared_locks_required(__VA_ARGS__)))
                                                                                           ^
    F:/android/workspace/AllHookInOne/jni/JavaHook/art_object_4_4.h:223:59: note: in expansion of macro 'SHARED_LOCKS_REQUIRED'
         mirror::Object* GetThisObject(uint16_t num_ins) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
                                                               ^
    F:/android/workspace/AllHookInOne/jni/JavaHook/art_object_4_4.h:379:68: error: expected ')' before '::' token
      bool IsValidIndex(int32_t index) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
                                                                        ^
    F:/android/workspace/AllHookInOne/jni/JavaHook/art_object_4_4.h:42:74: note: in definition of macro 'SHARED_LOCKS_REQUIRED'
    #define SHARED_LOCKS_REQUIRED(...) __attribute__ ((shared_locks_required(__VA_ARGS__)))
                                                                              ^
    F:/android/workspace/AllHookInOne/jni/JavaHook/art_object_4_4.h:42:87: warning: 'shared_locks_required' attribute directive ignored [-Wattributes]
    #define SHARED_LOCKS_REQUIRED(...) __attribute__ ((shared_locks_required(__VA_ARGS__)))
                                                                                           ^
    F:/android/workspace/AllHookInOne/jni/JavaHook/art_object_4_4.h:379:41: note: in expansion of macro 'SHARED_LOCKS_REQUIRED'
      bool IsValidIndex(int32_t index) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
                                             ^
    F:/android/workspace/AllHookInOne/jni/JavaHook/art_object_4_4.h:395:53: error: expected ')' before '::' token
       T Get(int32_t i) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
                                                         ^
    F:/android/workspace/AllHookInOne/jni/JavaHook/art_object_4_4.h:42:74: note: in definition of macro 'SHARED_LOCKS_REQUIRED'
    #define SHARED_LOCKS_REQUIRED(...) __attribute__ ((shared_locks_required(__VA_ARGS__)))
                                                                              ^
    F:/android/workspace/AllHookInOne/jni/JavaHook/art_object_4_4.h:42:87: warning: 'shared_locks_required' attribute directive ignored [-Wattributes]
    #define SHARED_LOCKS_REQUIRED(...) __attribute__ ((shared_locks_required(__VA_ARGS__)))
                                                                                           ^
    F:/android/workspace/AllHookInOne/jni/JavaHook/art_object_4_4.h:395:26: note: in expansion of macro 'SHARED_LOCKS_REQUIRED'
       T Get(int32_t i) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
                              ^
    F:/android/workspace/AllHookInOne/jni/JavaHook/art_object_4_4.h:616:59: error: expected ')' before '::' token
      Class* GetSuperClass() const SHARED_LOCKS_REQUIRED (Locks::mutator_lock_){
                                                               ^
    F:/android/workspace/AllHookInOne/jni/JavaHook/art_object_4_4.h:42:74: note: in definition of macro 'SHARED_LOCKS_REQUIRED'
    #define SHARED_LOCKS_REQUIRED(...) __attribute__ ((shared_locks_required(__VA_ARGS__)))
                                                                              ^
    F:/android/workspace/AllHookInOne/jni/JavaHook/art_object_4_4.h:42:87: warning: 'shared_locks_required' attribute directive ignored [-Wattributes]
    #define SHARED_LOCKS_REQUIRED(...) __attribute__ ((shared_locks_required(__VA_ARGS__)))
                                                                                           ^
    F:/android/workspace/AllHookInOne/jni/JavaHook/art_object_4_4.h:616:31: note: in expansion of macro 'SHARED_LOCKS_REQUIRED'
      Class* GetSuperClass() const SHARED_LOCKS_REQUIRED (Locks::mutator_lock_){
                                   ^
    F:/android/workspace/AllHookInOne/jni/JavaHook/art_object_4_4.h:624:60: error: expected ')' before '::' token
      DexCache* GetDexCache() const SHARED_LOCKS_REQUIRED (Locks::mutator_lock_){
                                                                ^
    F:/android/workspace/AllHookInOne/jni/JavaHook/art_object_4_4.h:42:74: note: in definition of macro 'SHARED_LOCKS_REQUIRED'
    #define SHARED_LOCKS_REQUIRED(...) __attribute__ ((shared_locks_required(__VA_ARGS__)))
                                                                              ^
    F:/android/workspace/AllHookInOne/jni/JavaHook/art_object_4_4.h:42:87: warning: 'shared_locks_required' attribute directive ignored [-Wattributes]
    #define SHARED_LOCKS_REQUIRED(...) __attribute__ ((shared_locks_required(__VA_ARGS__)))
                                                                                           ^
    F:/android/workspace/AllHookInOne/jni/JavaHook/art_object_4_4.h:624:32: note: in expansion of macro 'SHARED_LOCKS_REQUIRED'
      DexCache* GetDexCache() const SHARED_LOCKS_REQUIRED (Locks::mutator_lock_){
                                    ^
    /cygdrive/d/Android/Sdk/ndk-bundle/build/core/build-binary.mk:466: recipe for target '/cygdrive/f/android/workspace/AllHookInOne/obj/local/armeabi/objs/onehook/JavaHook/ArtMethodHook.o' failed
    make: *** [/cygdrive/f/android/workspace/AllHookInOne/obj/local/armeabi/objs/onehook/JavaHook/ArtMethodHook.o] Error 1
    雪    币: 4
    活跃值: 活跃值 (10)
    能力值: ( LV2,RANK:10 )
    在线值:
    发帖
    回帖
    粉丝
    myeanngg 活跃值 2016-3-23 14:14
    26
    0
    期待楼主把更加完整的东西拿出来
    雪    币: 227
    活跃值: 活跃值 (16)
    能力值: ( LV8,RANK:130 )
    在线值:
    发帖
    回帖
    粉丝
    大王叫我挖坟 活跃值 3 2016-5-8 15:37
    27
    0
    好文章哦,看起来比以前老版本的精简了很多,多谢分享
    雪    币: 3
    活跃值: 活跃值 (10)
    能力值: ( LV2,RANK:10 )
    在线值:
    发帖
    回帖
    粉丝
    小鱼钓猫 活跃值 2016-5-24 15:14
    28
    0
    学习了,谢谢分享
    雪    币: 4
    活跃值: 活跃值 (10)
    能力值: ( LV2,RANK:10 )
    在线值:
    发帖
    回帖
    粉丝
    evanlin 活跃值 2016-8-18 17:05
    29
    0
    非常感谢大神,
    我做了下测试,最后卡在如何在method_handler 函数中,写callback?
    比如我已经hook到了:"android/net/wifi/WifiInfo","getMacAddress" 函数,现在想实现该函数,不知道如何才能实现?
    期待解答,谢谢
    雪    币: 0
    活跃值: 活跃值 (10)
    能力值: ( LV2,RANK:10 )
    在线值:
    发帖
    回帖
    粉丝
    o飞跃o 活跃值 2016-8-28 00:35
    30
    0
    不行啊,编译报错,已经把ndk-patch解压到NDK_DIR/platforms/android-xx/arch-arm/usr目录下了
    以下是报错信息,求大神指点!

    00:34:08 **** Incremental Build of configuration Default for project AllHookInOne ****
    "D:\\android\\ndk\\ndk-build.cmd" all
    Android NDK: WARNING: APP_PLATFORM android-16 is larger than android:minSdkVersion 14 in ./AndroidManifest.xml   
    Android NDK: WARNING:jni/Android.mk:onehook: non-system libraries in linker flags: -landroid_runtime -lart -ldvm   
    Android NDK:     This is likely to result in incorrect builds. Try using LOCAL_STATIC_LIBRARIES   
    Android NDK:     or LOCAL_SHARED_LIBRARIES instead to list the library dependencies of the   
    Android NDK:     current module   
    [armeabi] Compile++ thumb: onehook <= JavaMethodHook.cpp
    [armeabi] Compile++ thumb: onehook <= ArtMethodHook.cpp
    [armeabi] Compile++ thumb: onehook <= DalvikMethodHook.cpp
    In file included from D:/android/ndk/platforms/android-16/arch-arm/usr/include/utils/String16.h:22:0,
                     from D:/android/ndk/platforms/android-16/arch-arm/usr/include/binder/IBinder.h:22,
                     from D:/android/ndk/platforms/android-16/arch-arm/usr/include/android_runtime/AndroidRuntime.h:23,
                     from jni/JavaHook/DalvikMethodHook.cpp:1:
    D:/android/ndk/platforms/android-16/arch-arm/usr/include/utils/Unicode.h:25:18: warning: redeclaration of C++ built-in type 'char32_t' [-fpermissive]
    D:/android/ndk/platforms/android-16/arch-arm/usr/include/utils/Unicode.h:26:18: warning: redeclaration of C++ built-in type 'char16_t' [-fpermissive]
    [armeabi] Compile thumb  : onehook <= art_quick_proxy.S
    [armeabi] Compile++ thumb: onehook <= elfhook.cpp
    jni/ElfHook/elfhook.cpp: In function 'int replaceFunc(void*, void*, void**)':
    jni/ElfHook/elfhook.cpp:53:2: warning: format '%p' expects argument of type 'void*', but argument 6 has type 'uint32_t {aka unsigned int}' [-Wformat]
    [armeabi] Compile++ thumb: onehook <= elfio.cpp
    [armeabi] Compile++ thumb: onehook <= elfutils.cpp
    [armeabi] Compile++ thumb: onehook <= main.cpp
    [armeabi] SharedLibrary  : libonehook.so
    D:/android/ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: warning: hidden symbol '__aeabi_atexit' in D:/android/ndk/sources/cxx-stl/gnu-libstdc++/4.6/libs/armeabi/libgnustl_static.a(atexit_arm.o) is referenced by DSO D:/android/ndk/platforms/android-16/arch-arm/usr/lib/libandroid_runtime.so
    D:/android/ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: warning: hidden symbol '__aeabi_atexit' in D:/android/ndk/sources/cxx-stl/gnu-libstdc++/4.6/libs/armeabi/libgnustl_static.a(atexit_arm.o) is referenced by DSO D:/android/ndk/platforms/android-16/arch-arm/usr/lib/libutils.so
    D:/android/ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: warning: hidden symbol '__aeabi_atexit' in D:/android/ndk/sources/cxx-stl/gnu-libstdc++/4.6/libs/armeabi/libgnustl_static.a(atexit_arm.o) is referenced by DSO D:/android/ndk/platforms/android-16/arch-arm/usr/lib/libart.so
    D:/android/ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: error: cannot find -ldvm
    D:/android/ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi/objs/onehook/JavaHook/DalvikMethodHook.o: in function dvmFindClass(char const*):jni/JavaHook/DalvikMethodHook.cpp:190: error: undefined reference to 'dvmDescriptorToName(char const*)'
    D:/android/ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi/objs/onehook/JavaHook/DalvikMethodHook.o: in function dvmFindClass(char const*):jni/JavaHook/DalvikMethodHook.cpp:193: error: undefined reference to 'dvmThreadSelf()'
    D:/android/ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi/objs/onehook/JavaHook/DalvikMethodHook.o: in function dvmFindClass(char const*):jni/JavaHook/DalvikMethodHook.cpp:193: error: undefined reference to 'dvmDecodeIndirectRef(Thread*, _jobject*)'
    D:/android/ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi/objs/onehook/JavaHook/DalvikMethodHook.o: in function dvmBoxMethodArgs(Method const*, unsigned int const*):jni/JavaHook/DalvikMethodHook.cpp:203: error: undefined reference to 'dexProtoGetParameterCount(DexProto const*)'
    D:/android/ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi/objs/onehook/JavaHook/DalvikMethodHook.o: in function dvmBoxMethodArgs(Method const*, unsigned int const*):jni/JavaHook/DalvikMethodHook.cpp:205: error: undefined reference to 'dvmFindSystemClass(char const*)'
    D:/android/ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi/objs/onehook/JavaHook/DalvikMethodHook.o: in function dvmBoxMethodArgs(Method const*, unsigned int const*):jni/JavaHook/DalvikMethodHook.cpp:208: error: undefined reference to 'dvmAllocArrayByClass'
    D:/android/ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi/objs/onehook/JavaHook/DalvikMethodHook.o: in function dvmBoxMethodArgs(Method const*, unsigned int const*):jni/JavaHook/DalvikMethodHook.cpp:231: error: undefined reference to 'dvmFindPrimitiveClass(char)'
    D:/android/ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi/objs/onehook/JavaHook/DalvikMethodHook.o: in function dvmBoxMethodArgs(Method const*, unsigned int const*):jni/JavaHook/DalvikMethodHook.cpp:231: error: undefined reference to 'dvmBoxPrimitive(JValue, ClassObject*)'
    D:/android/ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi/objs/onehook/JavaHook/DalvikMethodHook.o: in function dvmBoxMethodArgs(Method const*, unsigned int const*):jni/JavaHook/DalvikMethodHook.cpp:233: error: undefined reference to 'dvmReleaseTrackedAlloc'
    D:/android/ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi/objs/onehook/JavaHook/DalvikMethodHook.o: in function dvmBoxMethodArgs(Method const*, unsigned int const*):jni/JavaHook/DalvikMethodHook.cpp:240: error: undefined reference to 'dvmFindPrimitiveClass(char)'
    D:/android/ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi/objs/onehook/JavaHook/DalvikMethodHook.o: in function dvmBoxMethodArgs(Method const*, unsigned int const*):jni/JavaHook/DalvikMethodHook.cpp:240: error: undefined reference to 'dvmBoxPrimitive(JValue, ClassObject*)'
    D:/android/ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi/objs/onehook/JavaHook/DalvikMethodHook.o: in function dvmBoxMethodArgs(Method const*, unsigned int const*):jni/JavaHook/DalvikMethodHook.cpp:241: error: undefined reference to 'dvmReleaseTrackedAlloc'
    D:/android/ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi/objs/onehook/JavaHook/DalvikMethodHook.o: in function dvmGetMethodParamTypes(Method const*, char const*):jni/JavaHook/DalvikMethodHook.cpp:256: error: undefined reference to 'dexProtoGetParameterCount(DexProto const*)'
    D:/android/ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi/objs/onehook/JavaHook/DalvikMethodHook.o: in function dvmGetMethodParamTypes(Method const*, char const*):jni/JavaHook/DalvikMethodHook.cpp:257: error: undefined reference to 'dvmFindSystemClass(char const*)'
    D:/android/ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi/objs/onehook/JavaHook/DalvikMethodHook.o: in function dvmGetMethodParamTypes(Method const*, char const*):jni/JavaHook/DalvikMethodHook.cpp:260: error: undefined reference to 'dvmAllocArrayByClass'
    D:/android/ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi/objs/onehook/JavaHook/DalvikMethodHook.o: in function dvmGetMethodParamTypes(Method const*, char const*):jni/JavaHook/DalvikMethodHook.cpp:288: error: undefined reference to 'dvmFindPrimitiveClass(char)'
    D:/android/ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi/objs/onehook/JavaHook/DalvikMethodHook.o: in function dvmGetMethodParamTypes(Method const*, char const*):jni/JavaHook/DalvikMethodHook.cpp:293: error: undefined reference to 'dvmFindSystemClass(char const*)'
    D:/android/ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi/objs/onehook/JavaHook/DalvikMethodHook.o: in function method_handler(unsigned int const*, JValue*, Method const*, Thread*):jni/JavaHook/DalvikMethodHook.cpp:332: error: undefined reference to 'dvmInvokeMethod(Object*, Method const*, ArrayObject*, ArrayObject*, ClassObject*, bool)'
    D:/android/ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi/objs/onehook/JavaHook/DalvikMethodHook.o: in function method_handler(unsigned int const*, JValue*, Method const*, Thread*):jni/JavaHook/DalvikMethodHook.cpp:334: error: undefined reference to 'dvmReleaseTrackedAlloc'
    D:/android/ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi/objs/onehook/JavaHook/DalvikMethodHook.o: in function dalvik_java_method_hook(_JNIEnv*, HookInfo*):jni/JavaHook/DalvikMethodHook.cpp:371: error: undefined reference to 'dvmGetBoxedReturnType(Method const*)'
    collect2: ld returned 1 exit status
    make.exe: *** [obj/local/armeabi/libonehook.so] Error 1

    00:34:17 Build Finished (took 8s.441ms)
    雪    币: 0
    活跃值: 活跃值 (10)
    能力值: ( LV2,RANK:10 )
    在线值:
    发帖
    回帖
    粉丝
    o飞跃o 活跃值 2016-8-28 00:37
    31
    0
    不行啊,编译报错,已经把ndk-patch解压到NDK_DIR/platforms/android-xx/arch-arm/usr目录下了
    以下是报错信息,求大神指点!

    00:34:08 **** Incremental Build of configuration Default for project AllHookInOne ****
    "D:\\android\\ndk\\ndk-build.cmd" all
    Android NDK: WARNING: APP_PLATFORM android-16 is larger than android:minSdkVersion 14 in ./AndroidManifest.xml   
    Android NDK: WARNING:jni/Android.mk:onehook: non-system libraries in linker flags: -landroid_runtime -lart -ldvm   
    Android NDK:     This is likely to result in incorrect builds. Try using LOCAL_STATIC_LIBRARIES   
    Android NDK:     or LOCAL_SHARED_LIBRARIES instead to list the library dependencies of the   
    Android NDK:     current module   
    [armeabi] Compile++ thumb: onehook <= JavaMethodHook.cpp
    [armeabi] Compile++ thumb: onehook <= ArtMethodHook.cpp
    [armeabi] Compile++ thumb: onehook <= DalvikMethodHook.cpp
    In file included from D:/android/ndk/platforms/android-16/arch-arm/usr/include/utils/String16.h:22:0,
                     from D:/android/ndk/platforms/android-16/arch-arm/usr/include/binder/IBinder.h:22,
                     from D:/android/ndk/platforms/android-16/arch-arm/usr/include/android_runtime/AndroidRuntime.h:23,
                     from jni/JavaHook/DalvikMethodHook.cpp:1:
    D:/android/ndk/platforms/android-16/arch-arm/usr/include/utils/Unicode.h:25:18: warning: redeclaration of C++ built-in type 'char32_t' [-fpermissive]
    D:/android/ndk/platforms/android-16/arch-arm/usr/include/utils/Unicode.h:26:18: warning: redeclaration of C++ built-in type 'char16_t' [-fpermissive]
    [armeabi] Compile thumb  : onehook <= art_quick_proxy.S
    [armeabi] Compile++ thumb: onehook <= elfhook.cpp
    jni/ElfHook/elfhook.cpp: In function 'int replaceFunc(void*, void*, void**)':
    jni/ElfHook/elfhook.cpp:53:2: warning: format '%p' expects argument of type 'void*', but argument 6 has type 'uint32_t {aka unsigned int}' [-Wformat]
    [armeabi] Compile++ thumb: onehook <= elfio.cpp
    [armeabi] Compile++ thumb: onehook <= elfutils.cpp
    [armeabi] Compile++ thumb: onehook <= main.cpp
    [armeabi] SharedLibrary  : libonehook.so
    D:/android/ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: warning: hidden symbol '__aeabi_atexit' in D:/android/ndk/sources/cxx-stl/gnu-libstdc++/4.6/libs/armeabi/libgnustl_static.a(atexit_arm.o) is referenced by DSO D:/android/ndk/platforms/android-16/arch-arm/usr/lib/libandroid_runtime.so
    D:/android/ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: warning: hidden symbol '__aeabi_atexit' in D:/android/ndk/sources/cxx-stl/gnu-libstdc++/4.6/libs/armeabi/libgnustl_static.a(atexit_arm.o) is referenced by DSO D:/android/ndk/platforms/android-16/arch-arm/usr/lib/libutils.so
    D:/android/ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: warning: hidden symbol '__aeabi_atexit' in D:/android/ndk/sources/cxx-stl/gnu-libstdc++/4.6/libs/armeabi/libgnustl_static.a(atexit_arm.o) is referenced by DSO D:/android/ndk/platforms/android-16/arch-arm/usr/lib/libart.so
    D:/android/ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: error: cannot find -ldvm
    D:/android/ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi/objs/onehook/JavaHook/DalvikMethodHook.o: in function dvmFindClass(char const*):jni/JavaHook/DalvikMethodHook.cpp:190: error: undefined reference to 'dvmDescriptorToName(char const*)'
    D:/android/ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi/objs/onehook/JavaHook/DalvikMethodHook.o: in function dvmFindClass(char const*):jni/JavaHook/DalvikMethodHook.cpp:193: error: undefined reference to 'dvmThreadSelf()'
    D:/android/ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi/objs/onehook/JavaHook/DalvikMethodHook.o: in function dvmFindClass(char const*):jni/JavaHook/DalvikMethodHook.cpp:193: error: undefined reference to 'dvmDecodeIndirectRef(Thread*, _jobject*)'
    D:/android/ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi/objs/onehook/JavaHook/DalvikMethodHook.o: in function dvmBoxMethodArgs(Method const*, unsigned int const*):jni/JavaHook/DalvikMethodHook.cpp:203: error: undefined reference to 'dexProtoGetParameterCount(DexProto const*)'
    D:/android/ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi/objs/onehook/JavaHook/DalvikMethodHook.o: in function dvmBoxMethodArgs(Method const*, unsigned int const*):jni/JavaHook/DalvikMethodHook.cpp:205: error: undefined reference to 'dvmFindSystemClass(char const*)'
    D:/android/ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi/objs/onehook/JavaHook/DalvikMethodHook.o: in function dvmBoxMethodArgs(Method const*, unsigned int const*):jni/JavaHook/DalvikMethodHook.cpp:208: error: undefined reference to 'dvmAllocArrayByClass'
    D:/android/ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi/objs/onehook/JavaHook/DalvikMethodHook.o: in function dvmBoxMethodArgs(Method const*, unsigned int const*):jni/JavaHook/DalvikMethodHook.cpp:231: error: undefined reference to 'dvmFindPrimitiveClass(char)'
    D:/android/ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi/objs/onehook/JavaHook/DalvikMethodHook.o: in function dvmBoxMethodArgs(Method const*, unsigned int const*):jni/JavaHook/DalvikMethodHook.cpp:231: error: undefined reference to 'dvmBoxPrimitive(JValue, ClassObject*)'
    D:/android/ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi/objs/onehook/JavaHook/DalvikMethodHook.o: in function dvmBoxMethodArgs(Method const*, unsigned int const*):jni/JavaHook/DalvikMethodHook.cpp:233: error: undefined reference to 'dvmReleaseTrackedAlloc'
    D:/android/ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi/objs/onehook/JavaHook/DalvikMethodHook.o: in function dvmBoxMethodArgs(Method const*, unsigned int const*):jni/JavaHook/DalvikMethodHook.cpp:240: error: undefined reference to 'dvmFindPrimitiveClass(char)'
    D:/android/ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi/objs/onehook/JavaHook/DalvikMethodHook.o: in function dvmBoxMethodArgs(Method const*, unsigned int const*):jni/JavaHook/DalvikMethodHook.cpp:240: error: undefined reference to 'dvmBoxPrimitive(JValue, ClassObject*)'
    D:/android/ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi/objs/onehook/JavaHook/DalvikMethodHook.o: in function dvmBoxMethodArgs(Method const*, unsigned int const*):jni/JavaHook/DalvikMethodHook.cpp:241: error: undefined reference to 'dvmReleaseTrackedAlloc'
    D:/android/ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi/objs/onehook/JavaHook/DalvikMethodHook.o: in function dvmGetMethodParamTypes(Method const*, char const*):jni/JavaHook/DalvikMethodHook.cpp:256: error: undefined reference to 'dexProtoGetParameterCount(DexProto const*)'
    D:/android/ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi/objs/onehook/JavaHook/DalvikMethodHook.o: in function dvmGetMethodParamTypes(Method const*, char const*):jni/JavaHook/DalvikMethodHook.cpp:257: error: undefined reference to 'dvmFindSystemClass(char const*)'
    D:/android/ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi/objs/onehook/JavaHook/DalvikMethodHook.o: in function dvmGetMethodParamTypes(Method const*, char const*):jni/JavaHook/DalvikMethodHook.cpp:260: error: undefined reference to 'dvmAllocArrayByClass'
    D:/android/ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi/objs/onehook/JavaHook/DalvikMethodHook.o: in function dvmGetMethodParamTypes(Method const*, char const*):jni/JavaHook/DalvikMethodHook.cpp:288: error: undefined reference to 'dvmFindPrimitiveClass(char)'
    D:/android/ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi/objs/onehook/JavaHook/DalvikMethodHook.o: in function dvmGetMethodParamTypes(Method const*, char const*):jni/JavaHook/DalvikMethodHook.cpp:293: error: undefined reference to 'dvmFindSystemClass(char const*)'
    D:/android/ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi/objs/onehook/JavaHook/DalvikMethodHook.o: in function method_handler(unsigned int const*, JValue*, Method const*, Thread*):jni/JavaHook/DalvikMethodHook.cpp:332: error: undefined reference to 'dvmInvokeMethod(Object*, Method const*, ArrayObject*, ArrayObject*, ClassObject*, bool)'
    D:/android/ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi/objs/onehook/JavaHook/DalvikMethodHook.o: in function method_handler(unsigned int const*, JValue*, Method const*, Thread*):jni/JavaHook/DalvikMethodHook.cpp:334: error: undefined reference to 'dvmReleaseTrackedAlloc'
    D:/android/ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi/objs/onehook/JavaHook/DalvikMethodHook.o: in function dalvik_java_method_hook(_JNIEnv*, HookInfo*):jni/JavaHook/DalvikMethodHook.cpp:371: error: undefined reference to 'dvmGetBoxedReturnType(Method const*)'
    collect2: ld returned 1 exit status
    make.exe: *** [obj/local/armeabi/libonehook.so] Error 1

    00:34:17 Build Finished (took 8s.441ms)
    雪    币: 11
    活跃值: 活跃值 (10)
    能力值: ( LV2,RANK:10 )
    在线值:
    发帖
    回帖
    粉丝
    aiseven 活跃值 2016-8-31 15:24
    32
    0
    学习mark一下!
    雪    币: 0
    活跃值: 活跃值 (10)
    能力值: ( LV2,RANK:10 )
    在线值:
    发帖
    回帖
    粉丝
    sunxuechao 活跃值 2017-1-1 18:19
    33
    0
    楼主这个需要添加什么库文件吗?还是Android版本不对?
    jni/JavaHook/DalvikMethodHook.cpp:190: error: undefined reference to 'dvmDescriptorToName(char const*)'
    jni/JavaHook/DalvikMethodHook.cpp:193: error: undefined reference to 'dvmThreadSelf()'
    jni/JavaHook/DalvikMethodHook.cpp:193: error: undefined reference to 'dvmDecodeIndirectRef(Thread*, _jobject*)'
    jni/JavaHook/DalvikMethodHook.cpp:203: error: undefined reference to 'dexProtoGetParameterCount(DexProto const*)'
    jni/JavaHook/DalvikMethodHook.cpp:205: error: undefined reference to 'dvmFindSystemClass(char const*)'
    jni/JavaHook/DalvikMethodHook.cpp:208: error: undefined reference to 'dvmAllocArrayByClass'
    jni/JavaHook/DalvikMethodHook.cpp:231: error: undefined reference to 'dvmFindPrimitiveClass(char)'
    jni/JavaHook/DalvikMethodHook.cpp:231: error: undefined reference to 'dvmBoxPrimitive(JValue, ClassObject*)'
    jni/JavaHook/DalvikMethodHook.cpp:233: error: undefined reference to 'dvmReleaseTrackedAlloc'
    jni/JavaHook/DalvikMethodHook.cpp:240: error: undefined reference to 'dvmFindPrimitiveClass(char)'
    jni/JavaHook/DalvikMethodHook.cpp:240: error: undefined reference to 'dvmBoxPrimitive(JValue, ClassObject*)'
    jni/JavaHook/DalvikMethodHook.cpp:241: error: undefined reference to 'dvmReleaseTrackedAlloc'
    jni/JavaHook/DalvikMethodHook.cpp:256: error: undefined reference to 'dexProtoGetParameterCount(DexProto const*)'
    jni/JavaHook/DalvikMethodHook.cpp:257: error: undefined reference to 'dvmFindSystemClass(char const*)'
    jni/JavaHook/DalvikMethodHook.cpp:260: error: undefined reference to 'dvmAllocArrayByClass'
    jni/JavaHook/DalvikMethodHook.cpp:288: error: undefined reference to 'dvmFindPrimitiveClass(char)'
    jni/JavaHook/DalvikMethodHook.cpp:293: error: undefined reference to 'dvmFindSystemClass(char const*)'
    jni/JavaHook/DalvikMethodHook.cpp:332: error: undefined reference to 'dvmInvokeMethod(Object*, Method const*, ArrayObject*, ArrayObject*, ClassObject*, bool)'
    jni/JavaHook/DalvikMethodHook.cpp:334: error: undefined reference to 'dvmReleaseTrackedAlloc'
    jni/JavaHook/DalvikMethodHook.cpp:371: error: undefined reference to 'dvmGetBoxedReturnType(Method const*)'
    雪    币: 156
    活跃值: 活跃值 (10)
    能力值: ( LV2,RANK:10 )
    在线值:
    发帖
    回帖
    粉丝
    houruiming 活跃值 2017-1-13 16:46
    34
    0
    @sunxuechao libdvm.so
    游客
    登录 | 注册 方可回帖
    返回