2

我尝试挂钩所有应用程序,我怎样才能获得应用程序的上下文。

我试过了

try {
    Class<?> ContextClass = XposedHelpers.findClass("android.content.ContextWrapper", lpp.classLoader);
    XposedHelpers.findAndHookMethod(ContextClass, "getApplicationContext", new XC_MethodHook() {
        @Override
        protected void afterHookedMethod(MethodHookParam param) throws Throwable {
            super.afterHookedMethod(param);

            if(applicationContext != null){
                return;
            }
            applicationContext = (Context) param.getResult();
            init();
        }
    });
} catch (Throwable t) {
    XposedBridge.log("error" + t);
}

对于某些应用程序,它可以工作,我怎样才能获得所有上下文?

4

1 回答 1

0

试试看:

findAndHookMethod(
                "android.content.ContextWrapper", loader, "attachBaseContext",
                Context::class.java, object : XC_MethodHook() {
            override fun afterHookedMethod(param: MethodHookParam) {
                callback(param.thisObject as? Application ?: return)
            }
        })
于 2019-01-25T10:48:38.587 回答