I want to prevent an app from knowing whether certain files or directories exist on a device. For instance, if the application have some code like:

if (/system/lib/libJohnDoe.so){

I want this to always evaluate to "no" even if the file does exist. I was thinking of completely changing the directory tree that the application sees but I do not know if this is even possible.

What I would like even more is to only allow applications to see specific directories and files rather than hiding existing ones from them.

  • Is your device rooted? For rooted devices, e.g. using a module similar to MagiskHide. If the device is not rooted by Magisk you can still try to modify the return value of a certain function by developing an XposedModule (requires [Ed]Xposed installed).
    – Robert
    Nov 5, 2021 at 13:10
  • Device is rooted. Unfortunately, I don't know much about exposed not to mention developing modules for it. I suppose it has to do with hooking certain functions in the target app's code. Thing is, I don't know which functions are being used also, I want to do this for a wide range of apps. So I was thinking it would be easier to restrict access or visibility to certain files and directories. Nov 5, 2021 at 13:23
  • Magisk modules use bind mounts to add and remove files to a filesystem by overlaying the file / directories, without modifying the actual contents of the filesystem. You can achieve the same by doing bind mounts manually too. Nov 5, 2021 at 14:36
  • I was thinking of that also. I even tried it once. However, it gets tricky when trying to perform bind mounts on system directories; /system/lib for example. Doing this sometimes crash the system. A more perfect solution is to somehow isolate a specific application and allow it to see only what you want it to. Nov 5, 2021 at 19:00
  • Achieving that at application level doesn't seem to be a viable option to me. Intercepting the filesystem APIs e.g. using Xposed hooks or by patching the app is highly unlikely to work, in particular when you are dealing with multiple different apps. Another option is to use mount namespaces. But that can get even more complicated than bind mounts. Nov 6, 2021 at 9:03


You must log in to answer this question.

Browse other questions tagged .