EdXposed icon indicating copy to clipboard operation
EdXposed copied to clipboard

[BUG] File hook doesn't work

Open Dr-TSNG opened this issue 4 years ago • 0 comments

什么情况/What happened? Hook method File.class doesn't work on YAHFA version

Xposed模块列表/Xposed Module List testmodule

Magisk模块列表/Magisk Module List Riru Riru - EdXposed Riru - Enhanced mode for Storage Isolation Riru - IsolatedMagiskHider Riru - IFW Enhance

版本信息/Versions

Android: 11

Magisk: 22004(alpha)

Riru: 25.3.3

EdXposed: 4683 YAHFA

相关日志/Related Logs

no useful logs

Here's the code

void fileHook(final LoadPackageParam lpp, final XSharedPreferences pref) {
    XposedHelpers.findAndHookConstructor(File.class, String.class, new XC_MethodHook() {
        @Override
        protected void beforeHookedMethod(MethodHookParam param) {
            if (pref.getBoolean("HideAllApps", false) &&
                    ((String) param.args[0]).contains("Android/data/") &&
                    !((String) param.args[0]).contains(lpp.packageName)) {
                param.args[0] = "fuck/there/is/no/file";
                return;
            }
            for (String pkg : pref.getStringSet("HideApps", null))
                if (((String) param.args[0]).contains(pkg)) {
                    param.args[0] = "fuck/there/is/no/file";
                    break;
                }
        }
    });
}

Everything works fine switching to SandHook version or LSPosed, but in YAHFA I just cannot hook into the file constructor

Dr-TSNG avatar Mar 27 '21 15:03 Dr-TSNG