

どのようにすればxposedをフックすることができますか？
私はいくつかのアプリのすべてのメソッドをフックするために`de.robv.android.XposedBridge.handleHookedMethod`をフックすることにしました。

[code]

    package com.kyunggi.logcalls;
    
    import android.util.*;
    import de.robv.android.xposed.*;
    import de.robv.android.xposed.callbacks.XC_LoadPackage.*;
    import java.lang.reflect.*;
    
    import static de.robv.android.xposed.XposedHelpers.findAndHookMethod;
    
    public class Main implements IXposedHookLoadPackage
    {
        private String TAG="LogCall";
        public void handleLoadPackage(final LoadPackageParam lpparam) throws Throwable {
            if (!lpparam.packageName.equals("com.android.bluetooth"))
            {
                Log.i(TAG,"Not: "+lpparam.packageName);
                return;
            }
            Log.i(TAG,"Yes "+lpparam.packageName);  
    
            findAndHookMethod("de.robv.android.xposed.XposedBridge", lpparam.classLoader, "handleHookedMethod", Member.class, int.class,Object.class,Object.class,Object[].class,new XC_MethodHook() {
                    @Override
                    protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
                        Method method=(Method)param.args[0];
                        Log.v(TAG, "className " + method.getClass().getName() + ",methodName " + method.getName());
                    }
    
                });
        }
    }
    
[/code]

ところが、`ClassNotFoundException`が発生します。クラスローダーの問題だとおもって、どうすれば解決できますか？

> de.robv.android.xposed.XposedHelpers$ClassNotFoundError:  
>  java.lang.ClassNotFoundException: de.robv.android.xposed.XposedBridge


CC BY-SA 4.0
2018-10-17T16:50:00.257
49395
2019-08-28T13:35:37.907
2019-08-28T13:35:37.907
30434
30434
question
android java
どのようにすればxposedをフックすることができますか？


私は、次のコードを使用して、システムクラスローダーを得フック自体は成功しました。

[code]

    ClassLoader rootcl=lpparam.classLoader.getSystemClassLoader();
            findAndHookMethod("de.robv.android.xposed.XposedBridge", rootcl, "handleHookedMethod", Member.class, int.class,Object.class,Object.class,Object[].class,new XC_MethodHook() {
                    @Override
                    protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
                        Method method=(Method)param.args[0];
                        Log.v(TAG, "className " + method.getClass().getName() + ",methodName " + method.getName());
                    }
    
                });
    
[/code]

ところが！

> 10-18 18:27:22.198 F/art (4490):  
>  art/runtime/indirect_reference_table.cc:132] JNI ERROR (app bug):  
>  local reference table overflow (max=512) 10-18 18:27:22.198 F/art  
>  (4490): art/runtime/indirect_reference_table.cc:132] local reference  
>  table dump: 10-18 18:27:22.198 F/art (4490):  
>  art/runtime/indirect_reference_table.cc:132] Last 10 entries (of  
>  512): 10-18 18:27:22.198 F/art (4490):  
>  art/runtime/indirect_reference_table.cc:132] 511: 0x12c58510  
>  java.lang.reflect.Method 10-18 18:27:22.198 F/art (4490):  
>  art/runtime/indirect_reference_table.cc:132] 510: 0x12c8b860  
>  java.lang.Object[] (5 elements) 10-18 18:27:22.198 F/art (4490):  
>  art/runtime/indirect_reference_table.cc:132] 509: 0x12c8b840  
>  java.lang.Object[] (5 elements) 10-18 18:27:22.198 F/art (4490):  
>  art/runtime/indirect_reference_table.cc:132] 508: 0x12c45958  
>  de.robv.android.xposed.XposedBridge$AdditionalHookInfo 10-18  
>  18:27:22.198 F/art (4490):  
>  art/runtime/indirect_reference_table.cc:132] 507: 0x12c58510  
>  java.lang.reflect.Method 10-18 18:27:22.198 F/art (4490):  
>  art/runtime/indirect_reference_table.cc:132] 506: 0x12c8b840  
>  java.lang.Object[] (5 elements) 10-18 18:27:22.198 F/art (4490):  
>  art/runtime/indirect_reference_table.cc:132] 505: 0x12c8b820  
>  java.lang.Object[] (5 elements) 10-18 18:27:22.198 F/art (4490):  
>  art/runtime/indirect_reference_table.cc:132] 504: 0x12c45958  
>  de.robv.android.xposed.XposedBridge$AdditionalHookInfo 10-18  
>  18:27:22.198 F/art (4490):  
>  art/runtime/indirect_reference_table.cc:132] 503: 0x12c58510  
>  java.lang.reflect.Method 10-18 18:27:22.198 F/art (4490):  
>  art/runtime/indirect_reference_table.cc:132] 502: 0x12c8b820  
>  java.lang.Object[] (5 elements) 10-18 18:27:22.198 F/art (4490):  
>  art/runtime/indirect_reference_table.cc:132] Summary: 10-18  
>  18:27:22.198 F/art (4490):  
>  art/runtime/indirect_reference_table.cc:132] 245 of  
>  java.lang.Object[] (5 elements) (123 unique instances) 10-18  
>  18:27:22.198 F/art (4490):  
>  art/runtime/indirect_reference_table.cc:132] 124 of  
>  java.lang.reflect.Method (2 unique instances) 10-18 18:27:22.198 F/art  
>  (4490): art/runtime/indirect_reference_table.cc:132] 123 of  
>  de.robv.android.xposed.XposedBridge$AdditionalHookInfo (2 unique  
>  instances) 10-18 18:27:22.198 F/art (4490):  
>  art/runtime/indirect_reference_table.cc:132] 5 of  
>  java.lang.Class (4 unique instances) 10-18 18:27:22.198 F/art  
>  (4490): art/runtime/indirect_reference_table.cc:132] 3 of  
>  android.app.ResourcesManager (1 unique instances) 10-18 18:27:22.199  
>  F/art (4490): art/runtime/indirect_reference_table.cc:132]  
>  3 of java.lang.String (3 unique instances)

したがって、XPOSEDフレームワークフックは良くないだと思います。


CC BY-SA 4.0
2018-10-18T11:41:07.053
49417
2018-10-18T11:41:07.053
30434
49395
answer