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] Hook android.util.Log methods

OP xxk89xx

26th July 2014, 01:28 PM   |  #1  
OP Junior Member
Thanks Meter: 5
 
4 posts
Join Date:Joined: Jun 2013
Hi, I followed the tutorial on github and tried to hook android.util.Log.i(String tag, String msg) method, but I always get a ClassNotFoundError.
I don't know what I did wrong, my code seems so simple.

Edit: I found the solution. The code below works correctly, the problem was in another part of my code.

Here is the code:
Code:
public void handleLoadPackage(final LoadPackageParam lpparam) throws Throwable
    {
        XposedBridge.log("Package name: " + lpparam.packageName);

                try
                {
                        findAndHookMethod("android.util.Log", lpparam.classLoader, "i", String.class, String.class, new XC_MethodHook()
                        {
                            @Override
                            protected void beforeHookedMethod(MethodHookParam param) throws Throwable
                            {
                                //do something before
                            }

                            @Override
                            protected void afterHookedMethod(MethodHookParam param) throws Throwable
                            {
                                //do something after
                            }
                        });
                }
                catch (XposedHelpers.ClassNotFoundError e)
                {
                    XposedBridge.log("ClassNotFoundError");
                }
                catch (NoSuchMethodError e)
                {
                    XposedBridge.log("NoSuchMethodError");
                }
            }
        }
    }
Last edited by xxk89xx; 26th July 2014 at 03:24 PM.
Post Reply Subscribe to Thread
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes