-
Notifications
You must be signed in to change notification settings - Fork 307
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
50 changed files
with
1,320 additions
and
469 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
cmake_minimum_required(VERSION 3.22.1) | ||
cmake_minimum_required(VERSION 3.30.5) | ||
project(app) | ||
enable_language(ASM) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,7 @@ | |
|
||
// Created by Kelun Cai ([email protected]) on 2021-04-11. | ||
|
||
#include <dlfcn.h> | ||
#include <fcntl.h> | ||
#include <jni.h> | ||
#include <stdarg.h> | ||
|
@@ -34,6 +35,8 @@ | |
#define HACKER_JNI_VERSION JNI_VERSION_1_6 | ||
#define HACKER_JNI_CLASS_NAME "com/bytedance/shadowhook/sample/NativeHandler" | ||
|
||
static void *hookee2_handle = NULL; | ||
|
||
static int unittest_jni_hook_sym_addr(JNIEnv *env, jobject thiz, jint api_level) { | ||
(void)env; | ||
(void)thiz; | ||
|
@@ -55,11 +58,28 @@ static int unittest_jni_unhook(JNIEnv *env, jobject thiz) { | |
return unittest_unhook(); | ||
} | ||
|
||
static int unittest_jni_run(JNIEnv *env, jobject thiz, jboolean hookee2_loaded) { | ||
static int unittest_jni_run(JNIEnv *env, jobject thiz) { | ||
(void)env; | ||
(void)thiz; | ||
|
||
return unittest_run(NULL != hookee2_handle); | ||
} | ||
|
||
static void unittest_jni_dlopen(JNIEnv *env, jobject thiz) { | ||
(void)env; | ||
(void)thiz; | ||
|
||
return unittest_run(hookee2_loaded); | ||
if (NULL == hookee2_handle) hookee2_handle = dlopen("libhookee2.so", RTLD_NOW); | ||
} | ||
|
||
static void unittest_jni_dlclose(JNIEnv *env, jobject thiz) { | ||
(void)env; | ||
(void)thiz; | ||
|
||
if (NULL != hookee2_handle) { | ||
dlclose(hookee2_handle); | ||
hookee2_handle = NULL; | ||
} | ||
} | ||
|
||
static void unittest_jni_dump_records(JNIEnv *env, jobject thiz, jstring pathname) { | ||
|
@@ -95,7 +115,9 @@ JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) { | |
JNINativeMethod m[] = {{"nativeHookSymAddr", "(I)I", (void *)unittest_jni_hook_sym_addr}, | ||
{"nativeHookSymName", "(I)I", (void *)unittest_jni_hook_sym_name}, | ||
{"nativeUnhook", "()I", (void *)unittest_jni_unhook}, | ||
{"nativeRun", "(Z)I", (void *)unittest_jni_run}, | ||
{"nativeDlopen", "()V", (void *)unittest_jni_dlopen}, | ||
{"nativeDlclose", "()V", (void *)unittest_jni_dlclose}, | ||
{"nativeRun", "()I", (void *)unittest_jni_run}, | ||
{"nativeDumpRecords", "(Ljava/lang/String;)V", (void *)unittest_jni_dump_records}}; | ||
if (0 != (*env)->RegisterNatives(env, cls, m, sizeof(m) / sizeof(m[0]))) return JNI_ERR; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.