日志提示: can not find libnative-lib.
#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.");
}
}
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 呢 ?有大佬指点下吗?