[Help] Modifying and replacing existing files - Magisk

Hi! I need to modify build.prop in /vendor partition. As i understood system.prop can't affect it. So i decided to edit it with "sed" cmd. But i got stuck on boot script. It is executed in magisk logs, but there is no code executed (i added one copy+paste cmd to test).
How should i properly modify /vendor files?
Should i modify it in post-fs-data.sh or service.sh?
I'm noob in magisk module making
Bash:
# This script will be executed in post-fs-data mode
# More info in the main Magisk thread
MODDIR=${0%/*}
#testing and no result
cp /system/build.prop /storage/emulated/0/build.propes
cp /system/build.prop /sdcard/build.propes
#i want to do this
sed -i 's/ro.product.system.brand=Xiaomi/ro.product.system.brand=Google/g' ${$MODDIR}/system/build.prop
sed -i 's/ro.product.system.brand=Xiaomi/ro.product.system.brand=Google/g' ${$MODDIR}/vendor/build.prop

Why do you need to edit the actual build.prop file? Isn't it enough to use the resetprop tool (system.prop in the module).

Didgeridoohan said:
Why do you need to edit the actual build.prop file? Isn't it enough to use the resetprop tool (system.prop in the module).
Click to expand...
Click to collapse
I've tried to do this via system.prop, but got negative result. When i do replace modified files through recovery, i get positive result. Idk whats the problem, cuz i even tried to mount files in moddir/system/ folder. Seems android somehow detects any changes
So i have to copy files to module folder, modify, and replace them in original directory. Now the problem is in editing file, i successfully copied file but "sed" doesnt seem to work lol

What do you mean with "negative results"? Does the prop value not change? Have you tested with the getprop command (because you can't look in the prop file, it won't change when using the resetprop tool)?
Using a Magisk module to magic mount the prop files is likely not going to work since that will happen way too late for the files to be read by the system.

Didgeridoohan said:
What do you mean with "negative results"? Does the prop value not change? Have you tested with the getprop command (because you can't look in the prop file, it won't change when using the resetprop tool)?
Using a Magisk module to magic mount the prop files is likely not going to work since that will happen way too late for the files to be read by the system.
Click to expand...
Click to collapse
Negative result for me - app does not recognize me as another device. There is some protection in it that doesnt simply read system props. It read the build props in root directory. (last android security patch)
I just need to modify files in module directory and thats all. I have only this problem now.

No apps can read the build.prop files directly (unless they're root apps, of course)... Apps will be reading the values, not the file, which is why the resetprop tool works without changing the prop file.
If you really want to go for it though your sed command looks fine, except that I would use ${MODDIR}/system/vendor/build.prop since I don't think the ${MODDIR}/vendor symlink will be available when post-fs-data.sh is executed.
Not sure why you're copying the files to the internal storage and why you're naming them .propes, so can't say much about that.

Related

Working with su.d

Hi @Chainfire,
So, a while ago, I posted in the Liveboot thread inquiring as to how I'd go about incorporating liveboot into a ROM so that it could just run on first boot.
Your instructions were to chmod 0770 both the files and folders in su.d, and it should work:
If /system/su.d/0000liveboot.script exists (chmod 0644, not 0700 like other files in /system/su.d/ !), this script will be run instead of logcat and dmesg, and its output will be shown in white (stdout) and red (stderr).
Click to expand...
Click to collapse
However, I tried this, and never got it to work, and essentially moved on to other stuff for a while.
Today, I tried to revisit it, and while I was at it, replace my current init.d stuff with su.d.
So, I created the folder in /system which gets copied with t he rest of the ROM on install. I'm setting folder and file permissions to 0700, owner and group to root, SE context to ubject_r:system_file:s0, which, is exactly the same as what I'm seeing on 0000liveboot when I look at it's info.
This leaves two questions.
One, the above quote you say to set it to 0644, but liveboot itself sets it to 0700 when it installs it.
Two, what is the trick to getting other scripts to work? In your "How to SU" guide, you mention this:
From versions 2.22 onwards, after the policies have been patched and the daemon is ready to go, all executables in the /system/su.d/ directory are executed (chmod 0700 both the directoy and the scripts), followed by setprop supolicy.loaded 1. This is akin to /system/(etc/)init.d/, though execution of those scripts is both kernel-dependent and they may run before the SELinux are patches and/or su is available.
Click to expand...
Click to collapse
Setprop supolicy.loaded. Where am I supposed to do that? You say execution of those scripts is kernel-dependent - you're referring to init.d, yes? So, again, what am I missing?
This is 5.0.1 GPE for M8VZW. I have selinux set to permissive via boot image in init.rc, and verify that "getenforce" returns "permissive" from shell.
Any help you could lend would be greatly appreciated - which is also why I'm posting this as a thread...because su.d sounds like an awesome idea, and I bet more devs would like to start using this method over init.d.
Thank!
digitalhigh said:
One, the above quote you say to set it to 0644, but liveboot itself sets it to 0700 when it installs it.
Click to expand...
Click to collapse
liveboot sets the script that gets run by SuperSU to 0700. The script which I said to be set 0644 is a different script, and is not executed by SuperSU, but by liveboot.
Setprop supolicy.loaded. Where am I supposed to do that?
Click to expand...
Click to collapse
You don't. SuperSU sets this. Kernel developers can hook this event to run their own code.
You say execution of those scripts is kernel-dependent - you're referring to init.d, yes?
Click to expand...
Click to collapse
Yes, not all kernels support init.d, and init.d stuff generally runs before SuperSU patches policies, so there's no guarantees about any SELinux state.
So, again, what am I missing?
Click to expand...
Click to collapse
I don't know. Make sure you are running the latest version of SuperSU (2.46 at the time of writing). Make sure /system/su.d is chmod 0700. Make sure the scripts you want to run are also chmod 0700 and #!'d to a working shell executable. Keep in mind that the scripts are called one-by-one, in a blocking way. So if a script never exits, the next script isn't run.
Deleted
Say I have SU v2.62. I have 2 files in my /system/su.d folder. The first file doesn't have an exit, neither does the second. The second file DOES get executed as it sets selinux to permissive at boot as directed. First file is 0700 (text file), second is 0755 (a .sh file).
Now, I want to take an init.d setprop script and try it via su.d.
1) Do the other files need exit commands?
2) What should the third file (setprop file) be set to, 0755? A .sh or text file?
3) Are the other two set to the correct chmod?
Thank you for any input!
EDIT: Left it as text, and 0755. No exits, and it worked?
Using su.d to disable doze
Is it possible to use su.d in order to load a script that disables Android doze mode?
I'm trying to run this script:
Code:
#!/system/bin/sh
dumpsys deviceidle disable
Script file is located in root\su\su.d
Permissions are set to 0700.
However, script is not loaded automatically during the boot, because if I run the script manually in SManager I get a response Idle mode disabled, which means su.d script wasn't loaded.
Currenlty I use SManager to execute this doze disabling script automatically on every boot, but I wonder why wouldn't the same script work using su.d?
I use another su.d script that disables LED back-lights of hardware navigation buttons and the script works just fine.
I'm using SuperSU v2.82
Thanks for your input.

[Q] How to change a build.prop value using resetprop

Hello guys. I'm trying to make some modifications in my build.prop using magisk's systemless interface. In a module, I saw that resetprop can add lines in build.prop, but, I need to change a specific line in build.prop and resetprop in a module intercafe can't do that (or can, I don't know ). I was thinking in creating a script using su + resetprop to delete and include again, and I'll put in a .sh file inside /magisk/.core/service.d/ to run in every boot.
Code:
su
resetprop --delete [my build.prop line]
But I don't know to to include a line using this interface (script in terminal).
So, I need you, guys haha
Just put whatever resetprop commands you want inside a file, put that file in service.d and give it execution permissions (755). You don't need "su" in there... It's Magisk executing those scripts and it already has escalated privileges.
If it doesn't work, try putting the file in post-fs-data.d instead.
To do this with a module, simply put your commands inside the service.sh file (or post_fs_data.sh) in the common folder.
https://github.com/garethwza/TheFla...mmit/25fb6a451a4d5280c26dbd67f4c5dfad7a3f20fc how to do this with resetprop? resetprop is binary here. how to make it?
Didgeridoohan said:
Just put whatever resetprop commands you want inside a file, put that file in service.d and give it execution permissions (755). You don't need "su" in there... It's Magisk executing those scripts and it already has escalated privileges.
If it doesn't work, try putting the file in post-fs-data.d instead.
To do this with a module, simply put your commands inside the service.sh file (or post_fs_data.sh) in the common folder.
Click to expand...
Click to collapse

[MODULE HELP] How to execute a script only once when module is installed/uninstalled?

The question title can't be much longer but I basically need to execute a script only once when each of the following events happen:
Module is installed.
Module is uninstalled.
Module is enabled.
Module is disabled.
In other words:
When the user first installs my module, I need to execute a script just once.
If the user eventually disables the module, I need to execute the same script again just once.
If the user eventually re-enables the module, I need to execute the same script again just once.
When the user decides to uninstall my module, I need to execute a script just once.
That script is basically removing a particular app's dalvik cache (rm -rf /data/dalvik-cache/<(arm|arm64)>/<app_specific_folder>), and user data (rm -rf /data/data/<package_name>).
I need some pointers on how to do this properly for those 4 events mentioned above and in a way compatible with most devices (for the record, I'm only supporting Nougat and above, if that's relevant).
Installation is easy. Make a function with your script in config.sh and call that from update-binary. Also make sure to let the module install a boot script (post-fs-data.d or service.d, depends on what you want to do) that takes care of the rest for you.
Whenever a module is disabled, there'll be a file named disable in the module folder, so you can let the boot script check for that and then run whatever code you need for the "module disabled" scenario. If you also let that code add a check file to the module folder you can let the code only run once. If both the disable and check files are present, don't run the code...
If the module then is enabled again, the disable file will be deleted. In that case you'll only have the check file, which will mean you should then run the "module enabled" code (which should also delete the check file, of course).
Also let the boot script check for the module folder. If it isn't found it means the module has been uninstalled and you can safely run your "module uninstalled" scenario, do some cleanup, and then let the boot script uninstall itself.
That should work...
There are several modules that do something similar, my MagiskHide Props Config is one of them. Look around for more examples.
I see what you mean but I need to test my code with logging to make sure I'm doing things correctly. What's the best way for me to print to logcat from my Magisk module?
Use exec with xtrace.
Code:
exec 2>/path/to/log/file;
set -x;
It will redirect the command (execution) tree and their errors to the log_file.
Regards.
@JayminSuthar Sorry, I don't understand. Where should I place that code? And are you saying that all the commands (outputs and errors) on my module will be redirected to that file, no exceptions?
You should place this code in your script from where you want logging to start (mostly the beginning). This will print the command (execution) tree in the log file, and all errors (if any), It will not print the output, but the command executed itself.
The format of the logs should be like
Code:
+ >&2
+ echo 'Here logging starts, I'm stderr'
Here logging starts, I'm stderr
+ rm -f /some/non/existent/file
rm: Can't remove file: No such file or directory

Need someone to convert TWRP zip into Magisk Module

Dear Members iam not a developer so i am looking for someone who can convert attached file into Magisk Module.. This TWRP zip contain vendor files for Sharp Aquos S3 (HH6) and iam using it to run Android One which is for device HH1..
If it is possible for anyone please.
I downloaded this file from 4PDA so i can not request them to convert as i don't know russian to communicate
You don't need to be a developer to create a Magisk module. You've got the module template right here: https://github.com/topjohnwu/magisk-module-installer
Simply take the vendor directory from the original zip and place it in the system directory of the module template. Then you can update the info in module.prop to something descriptive (so you know which module it is in the modules list later), zip up the template and flash it.
Great Thanks alot i will do it right away
Didgeridoohan said:
You don't need to be a developer to create a Magisk module. You've got the module template right here: https://github.com/topjohnwu/magisk-module-installer
Simply take the vendor directory from the original zip and place it in the system directory of the module template. Then you can update the info in module.prop to something descriptive (so you know which module it is in the modules list later), zip up the template and flash it.
Click to expand...
Click to collapse
Iam getting an error as below
Copying zip to temp_directory
Installing module.zip
Installation failed
Where I can see what is wrong, i simply copied vendor folder from original TWRP zip folder and pasted into system folder of module template as instructed
There are no logs in Magisk Manager > Logs
Didgeridoohan said:
You don't need to be a developer to create a Magisk module. You've got the module template right here: https://github.com/topjohnwu/magisk-module-installer
Simply take the vendor directory from the original zip and place it in the system directory of the module template. Then you can update the info in module.prop to something descriptive (so you know which module it is in the modules list later), zip up the template and flash it.
Click to expand...
Click to collapse
jameelmemon said:
Iam getting an error as below
Copying zip to temp_directory
Installing module.zip
Installation failed
Where I can see what is wrong, i simply copied vendor folder from original TWRP zip folder and pasted into system folder of module template as instructed
There are no logs in Magisk Manager > Logs
Click to expand...
Click to collapse
I'm gonna guess you didn't replace the dummy update-binary with the proper installation script. It's detailed in the documentation but I could probably have mentioned it... Here's the relevant part of the docs: https://topjohnwu.github.io/Magisk/guides.html#magisk-module-installer
Didgeridoohan said:
I'm gonna guess you didn't replace the dummy update-binary with the proper installation script. It's detailed in the documentation but I could probably have mentioned it... Here's the relevant part of the docs: https://topjohnwu.github.io/Magisk/guides.html#magisk-module-installer
Click to expand...
Click to collapse
After Following all instructions, module gets installed but it is not effective
After analyzing files that this module loads I think they doesn't work as they do not execute as they should, I maybe wrong here, but i think these scripts need to be split and placed / executed in different way.
here is code from vendor/etc/init/hw/init.sku.rc
on fs
setprop persist.radio.skt_iot 1
setprop persist.vendor.ims.no_stapa 1
setprop ro.product.first_api_level 27
setprop ro.product.vendor.brand SHARP
setprop ro.product.vendor.model FS8032
setprop ro.product.vendor.name FS8032_00A0
setprop ro.product.vendor.device HH6_sprout
setprop ro.product.vendor.manufacturer SHARP
on post-fs
setprop persist.sys.security_enable false
setprop persist.radio.multisim.config dsds
on fs
setprop ro.vendor.build.fingerprint SHARP/FS8032_00A0/HH6_sprout:9/PPR1.180610.011/FS8032S0314P:user/release-keys
there are 2 files init.fingerprint.gxfp5288_sd1.rc and init.fingerprint.gxfp3258_sd1.rc containing on post-fs-data which should be placed in common/post-fs-data.sh file, but i don't know about on fs or other parts.
whereas vendor/etc/init/hw/init.HH1.target.rc imports some existing scripts from vendor folder and executes code on boot, on pre-boot and on init
from prename of each file i guess they can be executed as init.d script if so how i can use a module to convert them as init.d scripts and load effectively
All the props (the setprop commands) can be placed in the module system.prop file (don't forget to also activate it in install.sh). The rest of the commands would have to be converted to the post-fs-data.sh and service.sh module scripts, depending on when they're needed (again, don't forget to activate them in install.sh). The service.sh script runs later in the boot process.
I can unfortunately not help you there though. Time is a way too valuable commodity...
Setprop i can do but can you please have a look into the files and explain to me how i would rewrite the script or point me to a tutorial would be great help
Didgeridoohan said:
All the props (the setprop commands) can be placed in the module system.prop file (don't forget to also activate it in install.sh). The rest of the commands would have to be converted to the post-fs-data.sh and service.sh module scripts, depending on when they're needed (again, don't forget to activate them in install.sh). The service.sh script runs later in the boot process.
I can unfortunately not help you there though. Time is a way too valuable commodity...
Click to expand...
Click to collapse

How To Guide How to change files in the directory /system with Magisk

How to change files in the directory /system with Magisk
Note:
I tested the instructions below with Magisk 24. 25.0, and 25.2 on an ASUS Zenfone 8 running OmniROM (Android 12 ) .
The filesystem for /system is normally mounted read-only In Android 12 and it's difficult to change files in that filesystem.
One possible solution to change files in /system is to create a Magisk module for this task.
For testing if a Magisk Module would work like expected you can create a Dummy Magisk module . The steps to implement the Dummy Magisk Module are:
Install Magisk, enable root access for the shell in Magisk and enable access via adb (this can be done in the "Developer Options" in the system settings)
Next connect to the phone using the command
Code:
adb shell
and become root user
Code:
su -
Now create a sub directory in the directory
/data/adb/modules
e.g.
Code:
ASUS_I006D:/ # ls -ld /data/adb/modules/*
drwxrws--- 3 u0_a118 media_rw 3452 2022-05-30 12:12 /data/adb/modules/playstore
ASUS_I006D:/ #
Then copy the new files for the directory in /system to that directory (/data/adb/modules/<modulename>/ is equal here to the root dir, /, on the phone)
Example:
Code:
ASUS_I006D:/ # find /data/adb/modules/playstore
/data/adb/modules/playstore
/data/adb/modules/playstore/system
/data/adb/modules/playstore/system/etc
/data/adb/modules/playstore/system/etc/permissions
/data/adb/modules/playstore/system/etc/permissions/com.android.vending.xml
/data/adb/modules/playstore/system/priv-app
/data/adb/modules/playstore/system/priv-app/Phonesky
/data/adb/modules/playstore/system/priv-app/Phonesky/lib
/data/adb/modules/playstore/system/priv-app/Phonesky/lib/arm
/data/adb/modules/playstore/system/priv-app/Phonesky/lib/arm/libbrotli.so
/data/adb/modules/playstore/system/priv-app/Phonesky/lib/arm/libconscrypt_jni.so
/data/adb/modules/playstore/system/priv-app/Phonesky/lib/arm/libcronet.85.0.4181.5.so
/data/adb/modules/playstore/system/priv-app/Phonesky/lib/arm/libgame_sdk_device_info_jni.so
/data/adb/modules/playstore/system/priv-app/Phonesky/lib/arm/libphonesky_data_loader.so
/data/adb/modules/playstore/system/priv-app/Phonesky/lib/arm/libtensorflowlite_jni.so
/data/adb/modules/playstore/system/priv-app/Phonesky/Phonesky.apk
/data/adb/modules/playstore/system/priv-app/FakeStore
/data/adb/modules/playstore/system/priv-app/FakeStore/oat
/data/adb/modules/playstore/system/priv-app/FakeStore/oat/arm64
/data/adb/modules/playstore/system/priv-app/FakeStore/oat/arm64/FakeStore.odex
/data/adb/modules/playstore/system/priv-app/FakeStore/oat/arm64/FakeStore.vdex
/data/adb/modules/playstore/system/priv-app/FakeStore/FakeStore.apk
ASUS_I006D:/ #
Now reboot the phone.
After the reboot all files in /data/adb/modules/<modulename> will be mapped to /system by Magisk, e.g:
Code:
ASUS_I006D:/ # find /system/priv-app/Phonesky/
/system/priv-app/Phonesky/
/system/priv-app/Phonesky/lib
/system/priv-app/Phonesky/lib/arm
/system/priv-app/Phonesky/lib/arm/libbrotli.so
/system/priv-app/Phonesky/lib/arm/libconscrypt_jni.so
/system/priv-app/Phonesky/lib/arm/libcronet.85.0.4181.5.so
/system/priv-app/Phonesky/lib/arm/libgame_sdk_device_info_jni.so
/system/priv-app/Phonesky/lib/arm/libphonesky_data_loader.so
/system/priv-app/Phonesky/lib/arm/libtensorflowlite_jni.so
/system/priv-app/Phonesky/Phonesky.apk
ASUS_I006D:/ #
ASUS_I006D:/ # find /system/priv-app/FakeStore/
/system/priv-app/FakeStore/
/system/priv-app/FakeStore/oat
/system/priv-app/FakeStore/oat/arm64
/system/priv-app/FakeStore/oat/arm64/FakeStore.vdex
/system/priv-app/FakeStore/oat/arm64/FakeStore.odex
/system/priv-app/FakeStore/FakeStore.apk
ASUS_I006D:/ #
Because the mapping will be done while booting the phone it will also survive updating the OS on the phone to a new version as long as the user data is not deleted and Magisk is installed in the boot partition.
Notes:
Magisk "replaces" existing directories and files in /system with the files in that directory by using bind mounts.
You can not add additional files or directories to /system using this method -- it's only possible to add additional files and directories to the existing sub directories in /system.
This Magisk feature can also be used to make files in sub directories in /system writable -- see How to make files in system writable for detailed instructions.
This method can also be used to replace files in the directories /vendor, /product, or /system_ext:
from https://topjohnwu.github.io/Magisk/guides.html:
The system folder​
All files you want to replace/inject should be placed in this folder. This folder will be recursively merged into the real /system; that is: existing files in the real /system will be replaced by the one in the module’s system, and new files in the module’s system will be added to the real /system.
If you place a file named .replace in any of the folders, instead of merging its contents, that folder will directly replace the one in the real system. This can be very handy for swapping out an entire folder.
If you want to replace files in /vendor, /product, or /system_ext, please place them under system/vendor, system/product, and system/system_ext respectively. Magisk will transparently handle whether these partitions are in a separate partition or not.
Click to expand...
Click to collapse
But this seems to work only to replace existing files in these directories.
This method to replace files in /system simulates a module in Magisk so if everything is okay I strongly recommend to create a "real" Magisk Module with the new files for /system.
Trouble Shooting
If something does not work check the Magisk log file in /cache :
/cache/magisk.log
History
Update 10.06.2022
added the infos about how to update files /vendor, /product, /system-ext
Update 12.06.2022
The Magisk Module to install the patched Playstore used in this example can be downloaded here
http://bnsmb.de/files/public/Android/PlayStore_for_MicroG.zip
see also this Message
https://forum.xda-developers.com/t/...h-a-patched-playstore-from-nanodroid.4456421/
Update 03.10.2022
The sentence about how to update files in /vendor, /product, /system-ext was missing here --fixed
Added a note about what can not be done using this method
Update 04.11.2022
Added the hint for the post to make files in /system writable
Doing some cleanup to make the instructions more clear
Update 18.01.2023
See How to change any file or directory using Magisk for another approach to change files on read-only mounted filesystems.
Can this way be used with the Product and other folders?, framework?
To remove apps?, make fake apk's?
NisseGurra said:
Can this way be used with the Product and other folders?, framework?
Click to expand...
Click to collapse
I just did a quick test and it seems that replacing files in other folders seems not to work
(but this was only a quick test without checking the documentation for Magisk ...)
To remove apps?, make fake apk's?
Click to expand...
Click to collapse
I don't think that you can remove files because Magisk uses bind mounts for replacing the files. But you can disable apps by creating empty files.
E.g. in my example in the previous post
/data/adb/modules/playstore/system/priv-app/FakeStore/FakeStore.apk
is an empty file to overwrite (and therfor disable) the file
/system/priv-app/FakeStore/FakeStore.apk.
That's neccessary because FakeStore.apk and Phonesky.apk use the same signature and that is not allowed in Android.
regards
Bernd
Tested to change a app: SamsungCalendar
Copied the files to /data/adb/modules/
Want to exchange the samsung calendar to an other calendar app that cant be installed due to name conflict.
Replace app?, seems no go
NisseGurra said:
Tested to change a app: SamsungCalendar
Copied the files to /data/adb/modules/
Want to exchange the samsung calendar to an other calendar app that cant be installed due to name conflict.
Replace app?, seems no go
Click to expand...
Click to collapse
Post an "ls -l" for the directory with the app you want to replace and the output of
ls -lr /data/adb/
The file structure in /data/adb/module must match the file structure in / , e.g. to replace the file
/system/priv-app/<appname>/<app.apk>
the file to replace that app must be
/data/adb/modules/<modulename>/system/priv-app/<appname>/<app.apk>
Module Name can be any name .
regards
Bernd
I have try this again, seems magisk creates an file connected to the replaced file.
How do i make these files?
I have some 200 apps in system that i like to disable. Would an "fake" apk disable these apps?
Tested calendar app again, it replaces apk but as its in system/app it can not start the "calendar"
Hi,
Do you think that in this module I can switch mbm system file from
vendor/rfs/msm/mpss/readonly/vendor/mbm/mcfg_sw/mbn_sw.txt
kubans2301 said:
Hi,
Do you think that in this module I can switch mbm system file from
vendor/rfs/msm/mpss/readonly/vendor/mbm/mcfg_sw/mbn_sw.txt
Click to expand...
Click to collapse
Hi
The file does not exist on my phone:
Code:
ASUS_I006D:/ # ls /vendor/rfs/msm/mpss/readonly/vendor/
firmware
ASUS_I006D:/ #
So I will create it now:
Code:
ASUS_I006D:/data/adb/modules/fmradio # mkdir -p system/vendor/rfs/msm/mpss/readonly/vendor/mbm/mcfg_sw
ASUS_I006D:/data/adb/modules/fmradio #
ASUS_I006D:/data/adb/modules/fmradio # echo "# Test file" > system/vendor/rfs/msm/mpss/readonly/vendor/mbm/mcfg_sw/mbn_sw.txt
ASUS_I006D:/data/adb/modules/fmradio #
ASUS_I006D:/data/adb/modules/fmradio # cat system/vendor/rfs/msm/mpss/readonly/vendor/mbm/mcfg_sw/mbn_sw.txt
# Test file
ASUS_I006D:/data/adb/modules/fmradio #
and reboot
Code:
ASUS_I006D:/data/adb/modules/fmradio # reboot
after the reboot the file is thre:
Code:
ASUS_I006D:/data/adb/modules/fmradio # cat /vendor/rfs/msm/mpss/readonly/vendor/mbm/mcfg_sw/mbn_sw.txt
# Test file
ASUS_I006D:/data/adb/modules/fmradio #
ASUS_I006D:/data/adb/modules/fmradio # echo "Test 1234" >>./system/vendor/rfs/msm/mpss/readonly/vendor/mbm/mcfg_sw/mbn_sw.txt
ASUS_I006D:/data/adb/modules/fmradio #
ASUS_I006D:/data/adb/modules/fmradio #
ASUS_I006D:/data/adb/modules/fmradio # cat /vendor/rfs/msm/mpss/readonly/vendor/mbm/mcfg_sw/mbn_sw.txt
# Test file
Test 1234
ASUS_I006D:/data/adb/modules/fmradio #
So it should also work to "overwrite" an existing file in that directory.
regards
Bernd
regards
Bernd
NisseGurra said:
I have try this again, seems magisk creates an file connected to the replaced file.
How do i make these files?
I have some 200 apps in system that i like to disable. Would an "fake" apk disable these apps?
Tested calendar app again, it replaces apk but as its in system/app it can not start the "calendar"
Click to expand...
Click to collapse
HI
I missed that post -- what did you do exactly and what did not work?
regards
Bernd
just make a Replace list in customize.sh in magisk zip is fine
Thank you so much. It works perfectly on my Xiaomi mi 11 on miui 14 (android 13). It is easy and very fast way to change files in subfolders in system when it mounted read-only.
This is great and the best thing is that if something doesnt work and I get a bootloop I can always just boot into safe mode and remove the module
So this replaces files or just creates some links?
For instance if I make a module to replace Samsung My Files with a custom app, will this be reversible, meaning that if I delete my module I get original My Files app back?
veso266 said:
This is great and the best thing is that if something doesnt work and I get a bootloop I can always just boot into safe mode and remove the module
So this replaces files or just creates some links?
For instance if I make a module to replace Samsung My Files with a custom app, will this be reversible, meaning that if I delete my module I get original My Files app back?
Click to expand...
Click to collapse
This is great and the best thing is that if something doesnt work and I get a bootloop I can always just boot into safe mode and remove the module
Click to expand...
Click to collapse
correct (and if booting to save mode does not work anymore you can boot from the recovery image and fix the problem)
So this replaces files or just creates some links
Click to expand...
Click to collapse
/system is mounted read-only and neither you nor Magisk can replace files on a read-only mounted filesystem . Magisk creates bind mounts for the files and directories to replace.
Bind mounts only exist in memory and will be removed by a reboot.
For instance if I make a module to replace Samsung My Files with a custom app, will this be reversible, meaning that if I delete my module I get original My Files app back?
Click to expand...
Click to collapse
yes, just deactivate or deinstall the Magisk Module. This can be done either in the Magisk App, in an adb shell, or, if the phone does not boot anymore, from within a booted recovery image
regards
Bernd
bnsmb said:
correct (and if booting to save mode does not work anymore you can boot from the recovery image and fix the problem)
/system is mounted read-only and neither you nor Magisk can replace files on a read-only mounted filesystem . Magisk creates bind mounts for the files and directories to replace.
Bind mounts only exist in memory and will be removed by a reboot.
yes, just deactivate or deinstall the Magisk Module. This can be done either in the Magisk App, in an adb shell, or, if the phone does not boot anymore, from within a booted recovery image
regards
Bernd
Click to expand...
Click to collapse
Thanks, let me first tell you I am using Android 10 (no need to upgrade, and I don't want some obscure api to be removed, which I found out about when I need it)
I was able to make a small module that adds a priv-app, a permissions and a library, and it works great
No the onlything I need to add is a system service
So I need to replace framework.jar (I also have EdXposed installed through Riru and I dont want to break it)
Now I have Samsung Galaxy S10+ (SM-G975F) which doesnt have this service, but korean version of it (SM-G975N) has
So for the first test, I just wanted to transplant framework.jar (using the same android version of course) from SM-G975N to my SM-G975F
this seams easier to do then patch my framework.jar, because I read that system service also needs to be signed, and I don't know how to do that yet
I hope replacing framework.jar file will be enought (since I also read system services are located elsewhere)
The service I need to add is called: FMRadioService.java (and is located under com\android\server\ (if you decompile framework.jar)
Now I need to figure out how to recover, if something goes wrong (because something alawys goes wrong, I would like to be prepared)
So how to enter safe mode and disable my module?
And you said that if this doesnt work I can boot from recovery image (what image? is stock recovery allright? (I don't have TWRP yet (I will install it, once I figure out how), and I explained the reasons in this thread: https://forum.xda-developers.com/t/...-app-after-you-have-root-with-magisk.4564363/ )
Thanks
veso266 said:
Thanks, let me first tell you I am using Android 10 (no need to upgrade, and I don't want some obscure api to be removed, which I found out about when I need it)
I was able to make a small module that adds a priv-app, a permissions and a library, and it works great
No the onlything I need to add is a system service
So I need to replace framework.jar
Now I have Samsung Galaxy S10+ (SM-G975F) which doesnt have this service, but korean version of it (SM-G975N) has
So for the first test, I just wanted to transplant framework.jar (using the same android version of course) from SM-G975N to my SM-G975F
this seams easier to do then patch my framework.jar, because I read that system service also needs to be signed, and I don't know how to do that yet
I hope replacing framework.jar file will be enought (since I also read system services are located elsewhere)
The service I need to add is called: FMRadioService.java (and is located under com\android\server\ (if you decompile framework.jar)
Now I need to figure out how to recover, if something goes wrong (because something alawys goes wrong, I would like to be prepared)
So how to enter safe mode and disable my module?
And you said that if this doesnt work I can boot from recovery image (what image? is stock recovery allright? (I don't have TWRP yet (I will install it, once I figure out how), and I explained the reasons in this thread: https://forum.xda-developers.com/t/...-app-after-you-have-root-with-magisk.4564363/ )
Thanks
Click to expand...
Click to collapse
Hi
I don't have a Samsung phone and as far as I know Samsung uses other tools then other vendors for accessing the phone ...
Anyway, these are the instructions to do this on an ASUS Zenfone 8 (using fastboot and adb):
To enter the safe mode just press the power button; wait until the dialog with restart, power-off, etc occurs. Klick on the restart button in that dialog without releasing the power button of the phone. A new dialog to confirm the Save mode should appear.
To boot the ASUS Zenfone 8 from the recovery image boot the phone into the bootloader
adb reboot bootloader
and then issue on the PC
sudo fastboot boot <recovery_image>
<recovery_image> can either be the TWRP image for the phone or the recovery image for the LineageOS (or any other recovery with enabled access via adb).
adb is enabled by default in the TWRP image; in the LineageOS access via adb must be enabled via a menu entry after booting from the image.
AFAIK the stock recovery from Android does not support access via adb.
The phone can also be booted from the recovery installed on the phone via
adb reboot recovery
if the installed recovery supports access via adb.
And, for the records:
In most cases where the OS is loaded after booting the phone but seems to hang, access via adb will already work.
The Magisk Modules are stored in sub directories the directory /data/adb/modules/ , e.g.:
Bash:
ASUS_I006D:/ # ls -l /data/adb/modules/
total 21
drwxr-xr-x 3 root root 3452 1970-01-29 22:32 MiXplorer
drwxr-xr-x 4 root root 3452 1970-01-29 22:32 PlayStore_for_MicroG
drwxr-xr-x 5 root root 3452 1970-01-29 22:32 addbin
drwxr-xr-x 3 root root 3452 1970-01-29 22:32 bootctl-binary
drwxr-xr-x 5 root root 3452 1970-02-01 14:10 btop++
drwxrwxrwx 3 root root 3452 1970-01-29 22:32 nano-ndk
drwxr-xr-x 3 root root 3452 1970-01-29 22:32 ssh
ASUS_I006D:/ #
To disable a Magisk module after the next reboot create the file
/data/adb/modules/<modulename>/disable
To force Magisk to remove a Magisk module after the next reboot create the file
/data/adb/modules/<modulename>/remove
(see also here: https://forum.xda-developers.com/t/some-hints-for-using-magisk-on-android-phones.4471857/)
Note that Magisk will disable all Magisk modules automatically if the phone is booted into Safe mode.
regards
Bernd

Categories

Resources