Skip to content

Commit

Permalink
Add XposedBridge.removeFinalFlagNative()
Browse files Browse the repository at this point in the history
  • Loading branch information
rovo89 committed Oct 9, 2017
1 parent 0307d5c commit f2a7379
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 0 deletions.
9 changes: 9 additions & 0 deletions libxposed_art.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,15 @@ jobject XposedBridge_cloneToSubclassNative(JNIEnv* env, jclass, jobject javaObje
return soa.AddLocalReference<jobject>(dest);
}

void XposedBridge_removeFinalFlagNative(JNIEnv* env, jclass, jclass javaClazz) {
ScopedObjectAccess soa(env);
mirror::Class* clazz = soa.Decode<mirror::Class*>(javaClazz);
uint32_t flags = clazz->GetAccessFlags();
if ((flags & kAccFinal) != 0) {
clazz->SetAccessFlags(flags & ~kAccFinal);
}
}

jint XposedBridge_getRuntime(JNIEnv*, jclass) {
return 2; // RUNTIME_ART
}
Expand Down
1 change: 1 addition & 0 deletions libxposed_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,7 @@ int register_natives_XposedBridge(JNIEnv* env, jclass clazz) {
NATIVE_METHOD(XposedBridge, setObjectClassNative, "(Ljava/lang/Object;Ljava/lang/Class;)V"),
NATIVE_METHOD(XposedBridge, dumpObjectNative, "(Ljava/lang/Object;)V"),
NATIVE_METHOD(XposedBridge, cloneToSubclassNative, "(Ljava/lang/Object;Ljava/lang/Class;)Ljava/lang/Object;"),
NATIVE_METHOD(XposedBridge, removeFinalFlagNative, "(Ljava/lang/Class;)V"),
#if PLATFORM_SDK_VERSION >= 21
NATIVE_METHOD(XposedBridge, invokeOriginalMethodNative,
"!(Ljava/lang/reflect/Member;I[Ljava/lang/Class;Ljava/lang/Class;Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;"),
Expand Down
1 change: 1 addition & 0 deletions libxposed_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ extern void XposedBridge_hookMethodNative(JNIEnv* env, jclass clazz, jobject
extern void XposedBridge_setObjectClassNative(JNIEnv* env, jclass clazz, jobject objIndirect, jclass clzIndirect);
extern jobject XposedBridge_cloneToSubclassNative(JNIEnv* env, jclass clazz, jobject objIndirect, jclass clzIndirect);
extern void XposedBridge_dumpObjectNative(JNIEnv* env, jclass clazz, jobject objIndirect);
extern void XposedBridge_removeFinalFlagNative(JNIEnv* env, jclass clazz, jclass javaClazz);

#if PLATFORM_SDK_VERSION >= 21
extern jobject XposedBridge_invokeOriginalMethodNative(JNIEnv* env, jclass, jobject javaMethod, jint, jobjectArray,
Expand Down
7 changes: 7 additions & 0 deletions libxposed_dalvik.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,13 @@ jobject XposedBridge_cloneToSubclassNative(JNIEnv* env, jclass clazz, jobject ob
return copyIndirect;
}

void XposedBridge_removeFinalFlagNative(JNIEnv* env, jclass, jclass javaClazz) {
ClassObject* clazz = (ClassObject*) dvmDecodeIndirectRef(dvmThreadSelf(), javaClazz);
if (dvmIsFinalClass(clazz)) {
clazz->accessFlags &= ~ACC_FINAL;
}
}

jint XposedBridge_getRuntime(JNIEnv* env, jclass clazz) {
return 1; // RUNTIME_DALVIK
}
Expand Down

0 comments on commit f2a7379

Please sign in to comment.