AndroidAdvanceWithGeektime / Chapter06-plus

Hook Thread Sample
105 stars 34 forks source link

native线程hook不到 #2

Open oboolean opened 5 years ago

oboolean commented 5 years ago

9.0Android下,Java线程hook到了,很好. 但是我在jni代码中创建的native线程hook不到,代码如下: ` pthread_t pthread;//线程对象

void threadDoThings(void data) { ALOG("jni thread do things"); pthread_exit(&pthread); }

extern "C" JNIEXPORT void JNICALL Java_com_dodola_thread_ThreadHook_createNativeThread(JNIEnv *env, jclass type) {

pthread_create(&pthread, NULL, threadDoThings, NULL);

} ` 请问有啥办法能hook到native线程的创建吗 并且能拿到bakctrace最好.

coolegos commented 5 years ago

因为只hook 了libart.so,你改成hook_plt_method("libthreadhook.so", "pthread_create", (hook_func) &pthread_create_hook);就可以了