Skip to content

Commit

Permalink
Adjust for Nougat
Browse files Browse the repository at this point in the history
  • Loading branch information
rovo89 committed Sep 30, 2017
1 parent b3ba245 commit e665342
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
4 changes: 4 additions & 0 deletions ART.mk
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ LOCAL_C_INCLUDES += \
art/runtime \
external/gtest/include

ifeq (1,$(strip $(shell expr $(PLATFORM_SDK_VERSION) \>= 24)))
LOCAL_C_INCLUDES += bionic/libc/private
endif

LOCAL_SHARED_LIBRARIES += \
libart \
liblog \
Expand Down
4 changes: 4 additions & 0 deletions Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ ifeq (1,$(strip $(shell expr $(PLATFORM_SDK_VERSION) \>= 22)))
LOCAL_LDFLAGS := -Wl,--version-script,art/sigchainlib/version-script.txt -Wl,--export-dynamic
endif

ifeq (1,$(strip $(shell expr $(PLATFORM_SDK_VERSION) \>= 23)))
LOCAL_SHARED_LIBRARIES += libwilhelm
endif

LOCAL_MODULE := xposed
LOCAL_MODULE_TAGS := optional
LOCAL_STRIP_MODULE := keep_symbols
Expand Down
5 changes: 3 additions & 2 deletions libxposed_art.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ bool onVmCreated(JNIEnv*) {
////////////////////////////////////////////////////////////
void logExceptionStackTrace() {
Thread* self = Thread::Current();
ScopedObjectAccess soa(self);
#if PLATFORM_SDK_VERSION >= 23
XLOG(ERROR) << self->GetException()->Dump();
#else
Expand All @@ -80,6 +81,7 @@ void prepareSubclassReplacement(JNIEnv* env, jclass clazz) {
void XposedBridge_hookMethodNative(JNIEnv* env, jclass, jobject javaReflectedMethod,
jobject, jint, jobject javaAdditionalInfo) {
// Detect usage errors.
ScopedObjectAccess soa(env);
if (javaReflectedMethod == nullptr) {
#if PLATFORM_SDK_VERSION >= 23
ThrowIllegalArgumentException("method must not be null");
Expand All @@ -90,7 +92,6 @@ void XposedBridge_hookMethodNative(JNIEnv* env, jclass, jobject javaReflectedMet
}

// Get the ArtMethod of the method to be hooked.
ScopedObjectAccess soa(env);
ArtMethod* artMethod = ArtMethod::FromReflectedMethod(soa, javaReflectedMethod);

// Hook the method
Expand All @@ -103,7 +104,7 @@ jobject XposedBridge_invokeOriginalMethodNative(JNIEnv* env, jclass, jobject jav
if (UNLIKELY(!isResolved)) {
ArtMethod* artMethod = ArtMethod::FromReflectedMethod(soa, javaMethod);
if (LIKELY(artMethod->IsXposedHookedMethod())) {
javaMethod = artMethod->GetXposedHookInfo()->reflectedMethod;
javaMethod = artMethod->GetXposedHookInfo()->reflected_method;
}
}
#if PLATFORM_SDK_VERSION >= 23
Expand Down
3 changes: 2 additions & 1 deletion xposed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <dlfcn.h>
#include <errno.h>
#include <fcntl.h>
#include <inttypes.h>
#include <stdlib.h>

#if PLATFORM_SDK_VERSION >= 18
Expand Down Expand Up @@ -309,7 +310,7 @@ static bool addPathToEnv(const char* name, const char* path) {
char newPath[4096];
int neededLength = snprintf(newPath, sizeof(newPath), "%s:%s", path, oldPath);
if (neededLength >= (int)sizeof(newPath)) {
ALOGE("ERROR: %s would exceed %d characters", name, sizeof(newPath));
ALOGE("ERROR: %s would exceed %" PRIuPTR " characters", name, sizeof(newPath));
return false;
}
setenv(name, newPath, 1);
Expand Down

0 comments on commit e665342

Please sign in to comment.