V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
chenqh
V2EX  ›  Android

菜鸟关于 Cydia Substrate 的问题

  •  
  •   chenqh · 2018-10-12 01:02:32 +08:00 · 8122 次点击
    这是一个创建于 2239 天前的主题,其中的信息可能已经有所发展或是发生改变。

    现象

    日志提示: can not find libnative-lib.
    

    C++代码

    #include <jni.h>
    #include "substrate.h"
    #include <android/log.h>
    #include <unistd.h>
    #include <stdio.h>
    #include <fcntl.h>
    #include <sys/types.h>
    #include <string.h>
    #include <sys/stat.h>
    
    #define TAG "HOOKTEST"
    #define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG, TAG, __VA_ARGS__)
    #define LOGI(...) __android_log_print(ANDROID_LOG_INFO, TAG, __VA_ARGS__)
    
    //MSConfig(MSFilterLibrary, "libnative-lib.so");
    MSConfig(MSFilterExecutable, "/system/bin/app_process");
    
    bool (*_dvmLoadNativeCode)(char* pathName, void* classLoader, char** detail);
    
    bool fake_dvmLoadNativeCode(char* soPath, void* classLoader, char** detail)
    {
    	LOGD("fake_dvmLoadNativeCode soPath:%s", soPath);
    	return _dvmLoadNativeCode(soPath,classLoader,detail);
    }
    char* (*getFromNativeString) (void);
    
    char* newhello(void)
    {	static char str[] = "hello better tomorrow";
    //    return "hello better tomorrow from cqh";
    	return str;
    }
    
    //Substrate entry point
    MSInitialize{
        LOGD("Substrate initialized.");
    //    LOGD();
        MSImageRef image;
        image = MSGetImageByName("/data/app-lib/zcgames.com.cynativeexample-1/libnative-lib.so"); // ¾ø¶Ô·¾¶
        if (image != NULL)
        {
        	LOGD("dvm image: 0x%08X", (void*)image);
    
            void * dvmload = MSFindSymbol(image, "createHello");
            LOGD("Search createHello");
            if(dvmload == NULL)
            {
                LOGD("error find createHello.");
            }
            else
            {	MSHookFunction(dvmload, (void*)&fake_dvmLoadNativeCode, (void **)&_dvmLoadNativeCode);
            //	MSHookFunction(dvmload,(void*)&newhello,(void **)&getFromNativeString);
    			LOGD("hook createHello sucess.");
            }
        }
        else{
            LOGD("can not find libnative-lib.");
        }
    }
    
    

    app so 的路径为data/data/zcgames.com.cynativeexample/libnative-lib.so, 而在内存中的名字为

    root@hammerhead:/ # cat /proc/1855/maps | grep "libnative"
    402af000-402b3000 r-xp 00000000 b3:19 970        /system/lib/libnativehelper.so
    402b3000-402b4000 r--p 00003000 b3:19 970        /system/lib/libnativehelper.so
    402b4000-402b5000 rw-p 00004000 b3:19 970        /system/lib/libnativehelper.so
    75615000-75618000 r-xp 00000000 b3:1c 1638427    /data/app-lib/zcgames.com.cynativeexample-1/libnative-lib.so
    75618000-75619000 r--p 00002000 b3:1c 1638427    /data/app-lib/zcgames.com.cynativeexample-1/libnative-lib.so
    75619000-7561a000 rw-p 00003000 b3:1c 1638427    /data/app-lib/zcgames.com.cynativeexample-1/libnative-lib.so
    root@hammerhead:/ #
    

    现在问题为什么问题提示找不到 library 呢 ?有大佬指点下吗?

    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   2914 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 20ms · UTC 00:29 · PVG 08:29 · LAX 16:29 · JFK 19:29
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.