Welcome to XDA

Search to go directly to your device's forum

Register an account

Unlock full posting privileges

Ask a question

No registration required
Post Reply

[Q] Can Xposed hook native methods?

OP Vardion

16th July 2014, 02:42 PM   |  #1  
OP Junior Member
Thanks Meter: 0
 
16 posts
Join Date:Joined: Jul 2013
More
Letts assume there is a method

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

which gets called by regular Java code.

Can Xposed hook it?
16th July 2014, 08:19 PM   |  #2  
GermainZ's Avatar
Forum Moderator / Recognized Developer / XDA Portal Team
Thanks Meter: 7,333
 
5,910 posts
Join Date:Joined: Aug 2012
More
EDIT: I'm wrong, see rovo's answer.
Last edited by GermainZ; 17th July 2014 at 01:35 AM.
16th July 2014, 10:11 PM   |  #3  
rovo89's Avatar
Senior Recognized Developer
Thanks Meter: 15,323
 
2,386 posts
Join Date:Joined: Jan 2012
More
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.
The Following User Says Thank You to rovo89 For This Useful Post: [ View ]
17th July 2014, 01:43 AM   |  #4  
GermainZ's Avatar
Forum Moderator / Recognized Developer / XDA Portal Team
Thanks Meter: 7,333
 
5,910 posts
Join Date:Joined: Aug 2012
More
Quote:
Originally Posted by rovo89

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.
Last edited by GermainZ; 17th July 2014 at 02:49 AM.
17th July 2014, 07:22 AM   |  #5  
rovo89's Avatar
Senior Recognized Developer
Thanks Meter: 15,323
 
2,386 posts
Join Date:Joined: Jan 2012
More
Quote:
Originally Posted by GermainZ

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.
The Following User Says Thank You to rovo89 For This Useful Post: [ View ]
Post Reply Subscribe to Thread
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes