This repository was archived by the owner on Jun 1, 2023. It is now read-only.
Fix registering hooked native methods. #11
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This patch fixes a problem with native methods which are hooked by a module and registered through AndroidRuntime::registerNativeMethods.
The problem occurred when I was testing XPrivacy with a custom build of Xposed with the change to enable hooking of native methods. When I enabled XPrivacy, I got stuck in a bootloop (shortened logcat):
The problem is that after XPrivacy hooked the method MediaRecorder.start(), the initialization of the MediaRouter JNI code calls AndroidRuntime::registerNativeMethods (see https://android.googlesource.com/platform/frameworks/base/+/android-5.1.0_r1/media/jni/android_media_MediaRecorder.cpp line 517), which will ultimately call RegisterNativeMethods inside jni_internal.cc.
Because the hooked native Xposed method does not have the native flag, the call fails. Adding a check whether the original method is native (see changeset) makes the problem disappear and the hooking successful (I am able to prevent the camera app from receiving an image through XPrivacy).
May be of interest for @M66B, as this fixes bootloops with XPrivacy.
A test version for Lollipop 5.1 on ARM including this patch is available at http://www.mediafire.com/download/ni4p461civf6csz/xposed-sdk22-arm-20150628.zip