Fix registering hooked native methods.#11
Fix registering hooked native methods.#11mh0rst wants to merge 1 commit intorovo89:xposed-lollipopfrom
Conversation
…sterNativeMethods
|
@mh0rst thanks for mentioning this to me. Maybe the test version can be of use, but I would rather like to see an official release with all these problems solved. |
|
@rovo89 I'm also curious why the Xposed hooked methods are always marked as non-native (see https://github.com/rovo89/android_art/blob/xposed-lollipop/runtime/mirror/art_method.cc#L438). Is this to circumvent ART optimizations? |
|
Thanks for the detailed pull request! The fix looks good, but I'm wondering if it's better or worse to handle it like in 1895202 instead (i.e. simulate that the method is non-native in most situations, but explicitely allow some very specific places to see the actual flags. The reason for removing the flag from the hooked (but not the original) method is that there are many places that check this property and handle those methods differently than other methods. Most importantly, the native implementation would be called instead of the proxy entrypoint, and Xposed already re-uses the field with the function pointer for its internal structure. I think I'll go for your implementation first, in order to finally release a version which is native-capable at all. Then I think it would be good to check all the places where IsNative() is called and decide which ones need special handling. |
|
Merged in 5f4bc91, but I keep this open to think about the different approach mentioned above. |
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