[Xposed Framework Modules] Fif_:
Hi [MENTION=2799345]M66B[/MENTION],

I've attached a new version of BlockGuardOs.open and two new hooks for File.mkdir and File.mkdirs.

They're in the "Fif" category, but feel free to rename them to the Privacy category.

I've spent significant time on them, so credit would be nice, but I'm OK with having them incorporated into XPrivacyLua.

Some comments about this code dump:

BlockGuardOs.open has been updated with new paths:

/data/misc (see below for discussion)

The app's device-protected data directory

The app's removable storage data directory

The app's removable storage media directory

The app's removable storage obb directory.

New File.mkdir and File.mkdirs hooks:

Note that we cannot hook BlockGuardOs.mkdir() as this function is not called anywhere in the AOSP code (checked Marshmallow).

We have to be extra carefull as File.mkdirs() can call File.mkdir().

Also File.mkdir() can be called on existing directories and is always allowed to execute.

Further notes:

We have to use Environment.buildExternalStorage*Dirs rather than Context.get*Dirs because the latter will create the directories referenced rather than just return a list.

Now to your questions:

On my system (OnePlus 5), some system libraries are always preloaded in every java process.

For example: /system/lib64/libqti_performance.so

On my system again /system/lib64/libqti_performance.so is a link to /vendor/lib64/libqti_performance.so, that's why /vendor/ is whitelisted as well.

I figured that this could happen to more files (eg. framework files), hence the whitelisting of both /system/ and /vendor/.

If you think this is too broad, maybe /system/lib/, /system/lib64/, /vendor/lib/, /vendor/lib64/ and /system/framework/ can be whitelisted instead (although I have no proof that /system/framework/ is actually needed).

I'm also concerned that /system/etc and /vendor/etc may be needed... :)

Again, shared libraries. Loading webview causes this library to be loaded on my system:

/data/app/com.google.android.webview-2/lib/arm64/libwebviewchromium.so

Hence the whiltelisting of /data/app/com.google.android.webview- (trailing dash intentional) to catch all possible installation paths for the webview components.

I remember also seeing apps loading libraries from the gms app directory back from the XPrivacy days, so we may need that.

Before you ask, /data/misc is also whitelisted in the new version as these (SSL configuration?) files are sometimes needed by apps:

/data/misc/keychain/pubkey_blacklist.txt

/data/misc/keychain/serial_blacklist.txt

/data/misc/keychain/pins

Again, maybe only /data/misc/keychain/ is needed.

I'm a lua noob, but I was under the impression that ipairs is only needed if you care about the "array" elements coming out in order. In that code snippet we don't, so I choose pairs().

I've tried, and I've seen the provision for code sharing (ie. "luaScript": "@something"), but how I can use the UI to create scripts that are shared between two hooks?

For example the File.mkdir and File.mkdirs hooks have the same lua code. For duplicating them in UI, I:

Edit File.mkdirs and change the lua code (for example)

Delete File.mkdir

EditFile.mkdirs, change the method and hook names to mkdir, save, and now I have a clone.

Yet saving both hooks show that they each have their own copy of the script since luaScript says "@Fif.File.mkdirs" in the mkdirs json export and "@Fif.File.mkdir" in the mkdir json export.

Oh it has the potential. Some of my most basic Xposed modules could be reimplemented in XLua, vastly simplified as well.

On that topic, I was thinking it could be nice to have "dynamic" preferences (Values/Contacts/Location), where the list of global and per-app preferences shown in XPrivacyLua Pro could be generated automatically by looking at the preferences table. This way hooks could make use of preferences and they would show up in the UI.

The attachment below is obsolete, see this new post for an updated version.