Skip to content

Commit

Permalink
Change : for android5.1
Browse files Browse the repository at this point in the history
  • Loading branch information
baiyi.hwj committed Sep 27, 2015
1 parent 20e7f24 commit 4e79b09
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,9 @@ public synchronized static boolean canDexposed(Context context) {
private static boolean loadDexposedLib(Context context) {
// load dexposed lib for hook.
try {
if (android.os.Build.VERSION.SDK_INT > 19 && android.os.Build.VERSION.SDK_INT < 21){
if (android.os.Build.VERSION.SDK_INT == 22){
System.loadLibrary("dexposed_l51");
} else if (android.os.Build.VERSION.SDK_INT > 19 && android.os.Build.VERSION.SDK_INT <= 21){
System.loadLibrary("dexposed_l");
} else if (android.os.Build.VERSION.SDK_INT > 14){
System.loadLibrary("dexposed");
Expand Down
Binary file not shown.
16 changes: 14 additions & 2 deletions dexposed_so/dexposed_art/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ LOCAL_SRC_FILES := \
dexposed.cpp \
art_quick_dexposed_invoke_handler.S

LOCAL_CFLAGS += -std=c++0x -O0
LOCAL_CFLAGS += -std=c++0x -O0 -DPLATFORM_SDK_VERSION=$(PLATFORM_SDK_VERSION) -Wno-unused-parameter
LOCAL_C_INCLUDES := \
$(JNI_H_INCLUDE) \
art/runtime/ \
Expand All @@ -18,11 +18,23 @@ LOCAL_C_INCLUDES := \

include external/libcxx/libcxx.mk

ifeq (1,$(strip $(shell expr $(PLATFORM_SDK_VERSION) \>= 21)))
ifdef ART_IMT_SIZE
LOCAL_CFLAGS += -DIMT_SIZE=$(ART_IMT_SIZE)
else
# Default is 64
LOCAL_CFLAGS += -DIMT_SIZE=64
endif
endif

LOCAL_SHARED_LIBRARIES := libutils liblog libart libc++ libcutils

LOCAL_MODULE_TAGS := optional

LOCAL_MODULE := libdexposed_l
ifeq (1,$(strip $(shell expr $(PLATFORM_SDK_VERSION) \>= 21)))
LOCAL_MODULE := libdexposed_l51
else
LOCAL_MODULE := libdexposed_l
endif

include $(BUILD_SHARED_LIBRARY)
16 changes: 13 additions & 3 deletions dexposed_so/dexposed_art/dexposed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,13 @@ namespace art {
}
}

const DexposedHookInfo* hookInfo =
(DexposedHookInfo*) (soa.DecodeMethod(method)->GetNativeMethod());
#if PLATFORM_SDK_VERSION < 22
const DexposedHookInfo *hookInfo =
(DexposedHookInfo *) (soa.DecodeMethod(method)->GetNativeMethod());
#else
const DexposedHookInfo *hookInfo =
(DexposedHookInfo *) (soa.DecodeMethod(method)->GetEntryPointFromJni());
#endif

// Call XposedBridge.handleHookedMethod(Member method, int originalMethodId, Object additionalInfoObj,
// Object thisObject, Object[] args)
Expand Down Expand Up @@ -261,7 +266,12 @@ namespace art {
hookInfo->reflectedMethod = env->NewGlobalRef(reflect_method);
hookInfo->additionalInfo = env->NewGlobalRef(additional_info);
hookInfo->originalMethod = backup_method;
art_method->SetNativeMethod(reinterpret_cast<uint8_t*>(hookInfo));

#if PLATFORM_SDK_VERSION < 22
art_method->SetNativeMethod(reinterpret_cast<uint8_t *>(hookInfo));
#else
art_method->SetEntryPointFromJni(reinterpret_cast<void *>(hookInfo));
#endif

art_method->SetEntryPointFromQuickCompiledCode(GetQuickDexposedInvokeHandler());
// art_method->SetEntryPointFromInterpreter(art::artInterpreterToCompiledCodeBridge);
Expand Down
3 changes: 1 addition & 2 deletions dexposed_so/dexposed_art/dexposed.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#ifndef DEXPOSED_H
#define DEXPOSED_H

#define ANDROID_SMP 0
#include <jni.h>
#include <mirror/art_method.h>
#include <mirror/object.h>
Expand Down Expand Up @@ -67,7 +66,7 @@ using art::ThrowLocation;
#define DEXPOSED_CLASS "com/taobao/android/dexposed/DexposedBridge"
#define DEXPOSED_CLASS_DOTS "com.taobao.android.dexposed.DexposedBridge"

#define PLATFORM_SDK_VERSION 21
//#define PLATFORM_SDK_VERSION 21

#define SHARED_LOCKS_REQUIRED(...) THREAD_ANNOTATION_ATTRIBUTE__(shared_locks_required(__VA_ARGS__))

Expand Down
Binary file not shown.

0 comments on commit 4e79b09

Please sign in to comment.