-
Notifications
You must be signed in to change notification settings - Fork 77
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
1 parent
e43e6a6
commit f0c4c06
Showing
16 changed files
with
487 additions
and
134 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
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
LOCAL_PATH := $(call my-dir) | ||
include $(CLEAR_VARS) | ||
|
||
LOCAL_MODULE := test | ||
|
||
LOCAL_CFLAGS := -Wno-error=format-security -fpermissive | ||
LOCAL_CFLAGS += -fno-rtti -fno-exceptions | ||
LOCAL_CFLAGS += -fvisibility=hidden -O3 | ||
LOCAL_CFLAGS := -std=gnu++11 -DDEBUG -O0 | ||
|
||
LOCAL_SRC_FILES := test.cpp \ | ||
|
||
LOCAL_LDLIBS := -llog | ||
|
||
include $(BUILD_SHARED_LIBRARY) |
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# The ARMv7 is significanly faster due to the use of the hardware FPU | ||
|
||
APP_STL := | ||
|
||
APP_CPPFLAGS += -fpermissive #此项有效时表示宽松的编译形式,比如没有用到的代码中有错误也可以通过编译; | ||
|
||
ifeq ($(NDK_DEBUG), 1) | ||
APP_CPPFLAGS += -DNDK_DEBUG | ||
else | ||
APP_CPPFLAGS += -fvisibility=hidden -O3 | ||
endif | ||
|
||
APP_ABI := armeabi armeabi-v7a | ||
APP_PLATFORM := android-14 | ||
APP_STL := gnustl_static |
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 |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#include <jni.h> | ||
#include <stdio.h> | ||
#include <cassert> | ||
#include "test.h" | ||
#include <malloc.h> | ||
#include <string.h> | ||
|
||
static void repair(JNIEnv* env,jclass clazz,jobject thiz) { | ||
LOGD("panda"); | ||
jclass cls=env->FindClass(JAVA_CLASS); | ||
jmethodID m=env->GetMethodID(cls,"test2","()I"); | ||
env->CallIntMethod(thiz,m); | ||
return; | ||
} | ||
/* | ||
* JNI registration. | ||
*/ | ||
static JNINativeMethod gMethods[] = { | ||
{ "tt", "(Lcom/panda/hook/andhook/MainActivity;)V", (void*) repair }, | ||
}; | ||
/* | ||
* Register several native methods for one class. | ||
*/ | ||
static int registerNativeMethods(JNIEnv* env, const char* className, | ||
JNINativeMethod* gMethods, int numMethods) { | ||
jclass clazz; | ||
clazz = env->FindClass(className); | ||
if (clazz == NULL) { | ||
return JNI_FALSE; | ||
} | ||
if (env->RegisterNatives(clazz, gMethods, numMethods) < 0) { | ||
return JNI_FALSE; | ||
} | ||
|
||
return JNI_TRUE; | ||
} | ||
|
||
static int registerNatives(JNIEnv* env) { | ||
if (!registerNativeMethods(env, JAVA_CLASS, gMethods, | ||
sizeof(gMethods) / sizeof(gMethods[0]))) | ||
return JNI_FALSE; | ||
return JNI_TRUE; | ||
} | ||
|
||
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void* reserved) { | ||
JNIEnv* env = NULL; | ||
jint result = -1; | ||
if (vm->GetEnv((void**) &env, JNI_VERSION_1_4) != JNI_OK) { | ||
return -1; | ||
} | ||
assert(env != NULL); | ||
if (!registerNatives(env)) { //注册 | ||
return -1; | ||
} | ||
// LOGD("size offset=%d level=%d",size,level); | ||
return JNI_VERSION_1_4; | ||
} |
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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* | ||
* Copyright (c) 2015, alipay.com | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
/* | ||
* common.h | ||
* | ||
* @author : [email protected] | ||
* | ||
*/ | ||
|
||
#ifndef NativeHelper_H_ | ||
#define NativeHelper_H_ | ||
|
||
#include <jni.h> | ||
#include "dlfcn.h" | ||
#include "stdio.h" | ||
#include <elf.h> | ||
#include <android/log.h> | ||
#define TAG "panda" | ||
#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG, TAG, __VA_ARGS__) | ||
#define LOGI(...) __android_log_print(ANDROID_LOG_INFO, TAG, __VA_ARGS__) | ||
#define LOGW(...) __android_log_print(ANDROID_LOG_WARN, TAG, __VA_ARGS__) | ||
#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR, TAG, __VA_ARGS__) | ||
#define JAVA_CLASS "com/panda/hook/andhook/MainActivity" | ||
|
||
#endif |
Binary file not shown.
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.