Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,737,452 Members 42,423 Now Online
XDA Developers Android and Mobile Development Forum

[Q] Can Xposed hook native methods?

Tip us?
 
Vardion
Old
#1  
Junior Member - OP
Thanks Meter 0
Posts: 15
Join Date: Jul 2013
Default [Q] Can Xposed hook native methods?

Letts assume there is a method

public static native boolean doSomething(params...);

which gets called by regular Java code.

Can Xposed hook it?
 
rovo89
Old
#3  
rovo89's Avatar
Senior Recognized Developer
Thanks Meter 13696
Posts: 2,367
Join Date: Jan 2012
Yes, native methods can be hooked. However, in case this is for an app's code, it has to be done after System.loadLibrary(), otherwise the latter overwrites the hook. Ideally, the framework should take care of this itself, but it's not straight-forward and the has been vey little need for this.
Tired of updating your mod for every new ROM release?
You want give users the possibility to combine different mods without creating tons of different files for all possible combinations?
Then have a look at my Xposed framework - modifications without APK changes!
The Following User Says Thank You to rovo89 For This Useful Post: [ Click to Expand ]
 
GermainZ
Old
(Last edited by GermainZ; 17th July 2014 at 01:49 AM.)
#4  
GermainZ's Avatar
Forum Moderator / Recognized Developer
Thanks Meter 5684
Posts: 4,993
Join Date: Aug 2012
Quote:
Originally Posted by rovo89 View Post
Yes, native methods can be hooked. However, in case this is for an app's code, it has to be done after System.loadLibrary(), otherwise the latter overwrites the hook. Ideally, the framework should take care of this itself, but it's not straight-forward and the has been vey little need for this.
I've always assumed this wasn't the case. Just to clarify, Xposed is able to hook native functions, but not (native) C/C++ code/libraries? I've read more than once it can't so I'm a bit confused. Thanks for the correction.
 
rovo89
Old
#5  
rovo89's Avatar
Senior Recognized Developer
Thanks Meter 13696
Posts: 2,367
Join Date: Jan 2012
Quote:
Originally Posted by GermainZ View Post
Just to clarify, Xposed is able to hook native functions, but not (native) C/C++ code/libraries?
Correct. Only JNI functions can be hooked, i.e. those which are declared in and called by Java code.
Tired of updating your mod for every new ROM release?
You want give users the possibility to combine different mods without creating tons of different files for all possible combinations?
Then have a look at my Xposed framework - modifications without APK changes!
The Following User Says Thank You to rovo89 For This Useful Post: [ Click to Expand ]
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes