Related
Hi there!
I am searching for an easy way to make a Magisk module that can do the following:
Look for file /system/<whatever>
Look inside this file for a string, e.g. value = 0
Replace this string with value = 1
Systemlessly replace the modified file.
I'm pretty sure this should be possible with post-fs scripts, but I'm too bad at shell-scripts to know how.
I am aware that I could just copy the file, edit it on the computer and create a simple replacement module, but this solution would always replace the whole file and would thus possibly be device specific. It would give trouble on devices which need other content around the line to be replaced.
The solution that I'm looking for would be much more universal and would work on any device which has that file, regardless of the content.
Can anybody help?
DISCLAIMER! The following is pure guesswork and airscripting:
In your modules post-fs-data.sh:
Code:
cp /system/<filenamehere> /magisk/<yourmodulename>/system/<filenamehere>
sed -i 's/<originalstring>/<newstring>/g' /magisk/<yourmodulename>/system/<filenamehere>
If my slightly tipsy and tired as f brain isn't completely misleading me, this would copy the file to your modules path, replace the string and then mount the new file systemlessly. I've been thinking of doing something similar, but never tried it. Let me know if it works... And if someone who knows anything about scripting can correct me, please do.
Edit: No... wait... That wouldn't work, would it? Or? Bugger... I'll just leave it here until someone who knows what they're talking about comes around.
Didgeridoohan said:
DISCLAIMER! The following is pure guesswork and airscripting:
In your modules post-fs-data.sh:
If my slightly tipsy and tired as f brain isn't completely misleading me, this would copy the file to your modules path, replace the string and then mount the new file systemlessly. I've been thinking of doing something similar, but never tried it. Let me know if it works... And if someone who knows anything about scripting can correct me, please do.
Edit: No... wait... That wouldn't work, would it? Or? Bugger... I'll just leave it here until someone who knows what they're talking about comes around.
Click to expand...
Click to collapse
The idea looks kinda interesting. Wouldn't the cp command be obsolete if I could make the sed command take /system/<file> as input and output to /magisk/<Modname>/system/<file> ?
I guess I'll try to study some documents about sed before continuing. But the idea is already pretty good I think.
Naudiz said:
The idea looks kinda interesting. Wouldn't the cp command be obsolete if I could make the sed command take /system/<file> as input and output to /magisk/<Modname>/system/<file> ?
I guess I'll try to study some documents about sed before continuing. But the idea is already pretty good I think.
Click to expand...
Click to collapse
You need to copy the file to the magisk module folder for it to work as a magisk mod properly. Essentially this is necessary.
Sed is what removes, finds, replaces, or injects lines or matches within a file.
How can I modify or replace /proc/sys/net/ip_default_ttl
Which is better option?
To modify I would change from 64 to 65 or put new file..
Thanks in advanced
RawSlugs said:
How can I modify or replace /proc/sys/net/ip_default_ttl
Which is better option?
To modify I would change from 64 to 65 or put new file..
Thanks in advanced
Click to expand...
Click to collapse
Magisk can't mount anything there (only to /system). If you don't want to do it manually, you can create a module with a boot script (post-fs-data.sh or service.sh, depending on the timing you want) that modifies the file (with sed), or simply use a boot script in post-fs-data.d or service.d.
You can find more details on the different boot stages and stuff in the official Magisk docs.
Didgeridoohan said:
DISCLAIMER! The following is pure guesswork and airscripting:
In your modules post-fs-data.sh:
Code:
cp /system/<filenamehere> /magisk/<yourmodulename>/system/<filenamehere>
sed -i 's/<originalstring>/<newstring>/g' /magisk/<yourmodulename>/system/<filenamehere>
If my slightly tipsy and tired as f brain isn't completely misleading me, this would copy the file to your modules path, replace the string and then mount the new file systemlessly. I've been thinking of doing something similar, but never tried it. Let me know if it works... And if someone who knows anything about scripting can correct me, please do.
Edit: No... wait... That wouldn't work, would it? Or? Bugger... I'll just leave it here until someone who knows what they're talking about comes around.
Click to expand...
Click to collapse
Code is good, and adding the --archive flag to the cp command will make it preserve the older properties, mode, contexts, etc
And also if the string contains any PATHs or just a slash in it, then sed will not recognize the pattern and give an error, so using pipes as sed delimeters will prevent this
This is all I could say
MCMotherEffin' said:
Code is good, and adding the --archive flag to the cp command will make it preserve the older properties, mode, contexts, etc
And also if the string contains any PATHs or just a slash in it, then sed will not recognize the pattern and give an error, so using pipes as sed delimeters will prevent this
This is all I could say
Click to expand...
Click to collapse
Thanks, but that's a year old post and I've since had plenty of opportunity to test. And yes, what you say is true. :good:
Didgeridoohan said:
Thanks, but that's a year old post and I've since had plenty of opportunity to test. And yes, what you say is true. :good:
Click to expand...
Click to collapse
Oops, forgive me, I forgot to see the date
Hello everyone.
This is a little mod to the Magisk Module Template that allows you to patch APK files on-the-fly and have them created as a Magisk Module.
For example, you could have a modified camera module for your ROM, where this patcher would replace the classes.dex file with mods, then pack that as a Magisk Module, using the original file found in the /system (ROM)
For some of the devs that have been around for a while, you would be aware of the old VRTheme modding system, which would allow you to patch files on-the-fly. EvilTheme is basically a newer version of that, so combined with Magisk can be very useful
Here's what this module CAN do:
Replace resources.arsc, classes.dex, AndroidManifest.xml, and META-INF folder
Replace compiled res folders / files
Here's what this module CAN'T do:
Replace files in res/values or smali folders
How to use EVilTheme
(Example using /system/priv-app/SecSettings2.apk)
In the eviltheme folder, go to system and make a folder called priv-app. Inside it, make another folder called SecSettings2.apk
Now make folders as necessary, according to the location of the files you want to theme. For example, battery_icon_50.png is located in res/drawable-hdpi, so make a folder named res inside SecSettings2.apk.
Inside it, create a folder named drawable-hdpi, then paste your new battery_icon_50.png inside.
Repeat step 2 until you've placed your theme files in their appropriate locations.
When you're done, go back to the root folder of the theme (the one that contains eviltheme, engine, etc.) and put all the objects in a ZIP file.
You should use Deflate compression with compression level on Normal, but if your theme is huge, you can safely try compressing using Deflate and the level set to Ultra or whatever high level is available.
Test your mod.
For information regarding the Magisk Module subbmision etc, please read the information HERE
Link to Github Repository: HERE
Enjoy
Nice! Sounds interesting!
I've been using vrtheme for years and even contacted spanna aabout adapting the script to achieve modding of live system files this eliminating the need for recovery zips and even Aroma!
So I have a question about the use and locations of the asset files.
Would it be possible to change, at least the location from which the files get pulled from and placed into the execute folders?
So basically could it be set to pull the image/resource, whatever file from either a data folder or my preference, sd storage?
I've used an asset folder built into my system for similar commands, but with enough options and large files the system partition can get extremely crowded.
Does my question make sense?
Basically i would like to eliminate a big section of my packed 2gb Aroma zip. About 700mb is all vrtheme injected compiled files.
Either way I will definitely be looking into this!
Thanks
stangdriver44 said:
Nice! Sounds interesting!
I've been using vrtheme for years and even contacted spanna aabout adapting the script to achieve modding of live system files this eliminating the need for recovery zips and even Aroma!
So I have a question about the use and locations of the asset files.
Would it be possible to change, at least the location from which the files get pulled from and placed into the execute folders?
So basically could it be set to pull the image/resource, whatever file from either a data folder or my preference, sd storage?
I've used an asset folder built into my system for similar commands, but with enough options and large files the system partition can get extremely crowded.
Does my question make sense?
Basically i would like to eliminate a big section of my packed 2gb Aroma zip. About 700mb is all vrtheme injected compiled files.
Either way I will definitely be looking into this!
Thanks
Click to expand...
Click to collapse
You could, but you would have to look at update-binary and installtheme.sh, then modify it for your needs. So instead of copying the modded files from the flashable zip, you would just have to remove the unzip function and change the path of where they are unzipped to to the location of where the files are on your data partition.
Give it a try
so with this I can technically change the rotation of an app without ever messing with the apk? I've tried editing the AndroidManifest.xml, but after editing I've never been successful putting it back into the apk
dimm0k said:
so with this I can technically change the rotation of an app without ever messing with the apk? I've tried editing the AndroidManifest.xml, but after editing I've never been successful putting it back into the apk
Click to expand...
Click to collapse
If you plan to change androidmanifest.xml you will have to include the newly created META-INF folder for it too.
Could this be used to convert substratum themes to work systemlessly with magisk?
Sent from my Pixel using XDA Labs
qwer777 said:
Could this be used to convert substratum themes to work systemlessly with magisk?
Sent from my Pixel using XDA Labs
Click to expand...
Click to collapse
If you're talking about pre-packaged APK theme files, no it probably won't work, as they still need to be installed.
This is more for files that are already installed that require patching.
Nice work
Got one question - is it possible to modify classes.dex if .apk file is not in system folder? I mean for example, if system app gets updated, it creates new folder in data/app/ with the name of the package and with either -1, -2 or whetever number at the end (ex. data/app/com.google.android.youtube-2).
Do I need to just integrate update into system and then modify it? Or just create new folder in eviltheme one with data/... instead of system/...?
Thanks
I tried to modify system/framework/framework-res.apk/res/drawable-xxhdpi-v4/default_wallpaper.jpg, but unfortunately it did not work. Neither on InFocus M808/mod stock 6.0(mt6753) nor on SamsungS5Neo/mod stock 6.0.1(exynos7580)
Both tried with official Magisk 12.0 and newest beta.
nevermind i didn't read all the way
drei.liter.milch said:
I tried to modify system/framework/framework-res.apk/res/drawable-xxhdpi-v4/default_wallpaper.jpg, but unfortunately it did not work. Neither on InFocus M808/mod stock 6.0(mt6753) nor on SamsungS5Neo/mod stock 6.0.1(exynos7580)
Both tried with official Magisk 12.0 and newest beta.
Click to expand...
Click to collapse
Started another try to replace some icons. did not work. am I missing something or is this template just faulty?
anybody who got this working?
drei.liter.milch said:
Started another try to replace some icons. did not work. am I missing something or is this template just crap?
anybody who got this working?
Click to expand...
Click to collapse
That was a bit rude.
Edit: better to give some details on what you've actually done, maybe even upload your files. Easier to find any faults on your side or possible bugs that way.
I want to add the clock onto my lockscreen statusbar. Would this help me achieve that?
Didgeridoohan said:
That was a bit rude.
Edit: better to give some details on what you've actually done, maybe even upload your files. Easier to find any faults on your side or possible bugs that way.
Click to expand...
Click to collapse
yes ok, the word "crap" maybe was a little bit over the top. i'm sorry for that. I just would like to know, if anybody can report this module/template as working. If so, I would go on looking for the error on my side.
I've actually followed exactly the guide given in OP. (It seems not that tricky to me)
-placed folder tree system/framework/framework-res.apk/res/drawable-xxhdpi-v4/ in the eviltheme-folder and put my default_wallpaper.jpg file in drawable-xxhdpi-v4 folder
-edited module.prop und config.sh
-zipped the whole template folder
-installed via magisk manager
-rebooted
tried with to different phones, beta and official magisk (see my first post)
I'll reproduce my logs and attach them later.
anyway thanks for the hint
drei.liter.milch said:
yes ok, the word "crap" maybe was a little bit over the top. i'm sorry for that. I just would like to know, if anybody can report this module/template as working. If so, I would go on looking for the error on my side.
I've actually followed exactly the guide given in OP. (It seems not that tricky to me)
-placed folder tree system/framework/framework-res.apk/res/drawable-xxhdpi-v4/ in the eviltheme-folder and put my default_wallpaper.jpg file in drawable-xxhdpi-v4 folder
-edited module.prop und config.sh
-zipped the whole template folder
-installed via magisk manager
-rebooted
tried with to different phones, beta and official magisk (see my first post)
I'll reproduce my logs and attach them later.
anyway thanks for the hint
Click to expand...
Click to collapse
Flash Via Recovery, it may work. didnt work for me when i installed from magisk manager.
btw i have a question, is there any way to remove a file from the apk?
shekhawat2 said:
Flash Via Recovery, it may work. didnt work for me when i installed from magisk manager.
btw i have a question, is there any way to remove a file from the apk?
Click to expand...
Click to collapse
thx, i'll try that. which magisk-version do you use? and i guess maybe you can remove a file by placing a dummy.
drei.liter.milch said:
thx, i'll try that. which magisk-version do you use? and i guess maybe you can remove a file by placing a dummy.
Click to expand...
Click to collapse
No brother, I want to delete the file, not to replace it with dummy file. Replacing with dummy file will give system ui FCs.
I saw something delete.list in the installtheme.sh, but I don't know how to use it. If anyone can help, pls help me.
BTW I am using Magisk v12.
shekhawat2 said:
No brother, I want to delete the file, not to replace it with dummy file. Replacing with dummy file will give system ui FCs.
I saw something delete.list in the installtheme.sh, but I don't know how to use it. If anyone can help, pls help me.
BTW I am using Magisk v12.
Click to expand...
Click to collapse
Ok, I see. Perhaps you find sth about it in the vrtheme-topic. Btw. flashing in recovery doesn't work either. I'm not messing around with this anymore and continue using flipster :good:
Where can we download? I want to change Viber's background to pure black so I will change the AndroidManifest. Will this theoretically work?
I was wondering what, if anything, I would need to change for this to work on a pixel. On Pixel's, the install path is system/system. I couldn't tell whether or not this could detect the correct path on its own.
Edit: Never mind. I got it to work.
Hi,
So I want to systemlessly replace a huge number of files (images)/or just an entire folder within an app.
For example: inside app.apk there is a folder "assets/images". I want to replace every single image that is in that folder with other ones.
Is this possible with a Magisk Module?
Grab a copy of the apk, edit it to your liking, and then make a Magisk module that replaces the stock apk with your edited one.
That would be the way to do it in Magisk.
If you want it done in a more automatic fashion, you would have to create a script or program that extracts the apk, edits it, and then creates and installs a Magisk module that replaces the stock apk with the edited one.
Yes, I would like an automated one... I think it should be done with post-fs-data.sh. But is it capable of decompiling and recompiling apk files?
No. And you don't want to do something like that during post-fs-data.
Your best bet (IMHO) is to do it during installation of the module, somehow. An automated process that pulls the apk from /system, decompiles, edits, and recompiles it, before installing it as a Magisk module.
Why do you need the automation? Just for fun, or do you specifically need it? I often find my reason for doing something to be: "to see if I can"... :laugh:
Didgeridoohan said:
No. And you don't want to do something like that during post-fs-data.
Your best bet (IMHO) is to do it during installation of the module, somehow. An automated process that pulls the apk from /system, decompiles, edits, and recompiles it, before installing it as a Magisk module.
Why do you need the automation? Just for fun, or do you specifically need it? I often find my reason for doing something to be: "to see if I can"... :laugh:
Click to expand...
Click to collapse
Yes, I want to learn and see if I can do it. And Ivdont want to make a new apk everytime the original app updates. If you have a script this happens automatically.
Also if I program config.sh (this is the install script right?) to automate this process would it still me systemless? I think even when I uninstall the module the mod would still be there...
ilivss said:
Also if I program config.sh (this is the install script right?) to automate this process would it still me systemless? I think even when I uninstall the module the mod would still be there...
Click to expand...
Click to collapse
If you copy the apk from /system before working on it, and then make it into a Magisk module that magic mounts the apk over the stock apk, it'll be a systemless modification. If you then proceed to uninstall the module, the modified apk will not be replacing the original apk anymore, returning everything to stock. Anything else would not be systemless...
Didgeridoohan said:
Why do you need the automation? Just for fun, or do you specifically need it? I often find my reason for doing something to be: "to see if I can"... :laugh:
Click to expand...
Click to collapse
I got one that I actually need. Rotation set to landscape and auto-rotation off in the head unit upgrade I recently put on. However, my unit orientation is portrait.
I have Magisk installed, and I need it to override this setting and change the default to portrait.
Is this even possible or sound like something fun to do ?
How do I tell a Magisk Module to set the permissions for files? I have three .QMG files that I want people to install VIA Magisk, but in order to do that, I need to tell the module to set the permissions for the files. The permissions are listed below. Any and all help is appreciated!
Thank you in advanced!
Red Prez
There is extensive documentation available on how to make modules (https://topjohnwu.github.io/Magisk/guides.html). You want to use customize.sh and either use the included set_perm function (see the linked docs) or put your own chmod command in there.
Didgeridoohan said:
There is extensive documentation available on how to make modules (https://topjohnwu.github.io/Magisk/guides.html). You want to use customize.sh and either use the included set_perm function (see the linked docs) or put your own chmod command in there.
Click to expand...
Click to collapse
Yeah, but the problem is I do not know what CHMOD command to use.
Actually, you don't need to do anything (I couldn't see your attachment before)... The default permission is 644, so you're set.
Didgeridoohan said:
Actually, you don't need to do anything (I couldn't see your attachment before)... The default permission is 644, so you're set.
Click to expand...
Click to collapse
Okay, so how do I put that into the Customize file?
You don't have to do anything, the installation script will do it for you...
You really should read through the instructions I linked you earlier. Most stuff is explained there.
I have an LG V60 phone and I would like to put the phone in "high impedance mode" all the the time for more power to the earphones even if they are less than 50 ohm impedance.
In LG V40/50, it was very simple by rooting the phone and making some modifications in the one of the files that was in the "vendor/etc" directory. The problem with LG V60 is it does not allow any write access to the vendor folder at all.
So the only feasible option that I can think of is to create a Magisk module that replaces the original file with the modified one. My biggest disadvantage is not knowing anything about writing codes including Magisk module ones. So I was wondering if anyone could create a Magisk module that would replace the original file through Magisk?
ADDTIONAL INOFRMATION:
I am running Magisk 25 on a fully rooted LG V60.
The file that needs to be changed is mixer_paths.xml and it resides in the "vendor/etc" folder. I have created the modified file.
So if someone is able to develop a module to accomplish this, I will place the modified file in the "system/vendor/etc" folder of the Magisk module, as I understand it.
Many thanks for your support!
You can use this template system in future as its super easy
The template itself is here
GitHub - Zackptg5/MMT-Extended: Magisk Module Template Extended
Magisk Module Template Extended. Contribute to Zackptg5/MMT-Extended development by creating an account on GitHub.
github.com
click the Code button, then download zip
then extract the zip into a folder and rename the folder "MMT-Extended-master" to the something more meaningful, like the name of your module
Read the wiki and docs here to go step by step to create your first module:
Home
Magisk Module Template Extended. Contribute to Zackptg5/MMT-Extended development by creating an account on GitHub.
github.com
Notably the heading:
How do I make a MMT Extended mod?
The steps for a simple file addition/replacement module, which are simple, should be steps 1-4, then 8. Then zip up the modules (as a zip) and test.
For you, if you read along (in Step 3) you will need to create a folder vendor, under the existing system one, and then a further etc folder under vendor, and put the necessary file (mixer_paths.xml in there.
If you try and fail, post back and someone will assist. But we prefer people to at least read the documentation and try first, ideally...this is the way the great didgeridoohan mentored myself and many others, he was not big on spoonfeeding
Imagine the satisfaction you might get finding out youre capable of such feats...i promise its not rocket surgery
Feel free to PM even, if you get stuck and think you have a silly question - of course knowing me, and i do, you'll probably get an even sillier, and off topic answer as well...
hint: you can knock out this basic module in far far less time than it took me to write all this
Thank you!
So my changes look like this:
1. Put the modified file in the system/vendor/etc folder of the Magisk module.
2. Made the needed changes to the customize.sh as attached.
Royaltiger said:
Thank you!
So my changes look like this:
1. Put the modified file in the system/vendor/etc folder of the Magisk module.
2. Made the needed changes to the customize.sh as attached.
Click to expand...
Click to collapse
Yes, though you'll need to uncomment (remove the leading #) from the set_perm lines to make them active, also you only really need the 2nd one
Royaltiger said:
Thank you
73sydney said:
Yes, though you'll need to uncomment (remove the leading #) from the set_perm lines to make them active, also you only really need the 2nd one
Click to expand...
Click to collapse
Click to expand...
Click to collapse
So I made the module with the suggested changes in customize.sh and put the modified mixer_path.xml file in the system/vendor/etc folder of the module. Module installs fine with Magisk but when it reboots, the device hangs on the initial LG screen and does not go anywhere from there.
I am attaching the customize.sh snapshot. Also, attached is the module file.
See here under "Disabling/uninstalling modules manually" if youre not able to boot
Module Issues:Magisk and MagiskHide Installation and Troubleshooting guide
www.didgeridoohan.com
I am assuming that it is not possible to accomplish what I wanted to achieve.
Royaltiger said:
I am assuming that it is not possible to accomplish what I wanted to achieve.
Click to expand...
Click to collapse
mixer_paths files have been replaced for years, long before magisk even...i did it back as far as the Galaxy S2 from memory, so im not sure why this didnt work for you, was the mxer_paths file specifically for your device? i have no clear idea why it hasnt worked for you
this thread has a guide to making /system RW, so you could manually copy the file and overwrite it, but id really consider how much you want to replace mixer_paths before i set out to do that
V60 Bootloader Unlock and Magisk Root
Earlier today I was alerted to https://www.cnblogs.com/yanhua-tj/p/15525593.html which has the actual firehose and steps to unlock! However it seems to be in Simplified Chinese so I'll translate it here for you. The firehose is attached below...
forum.xda-developers.com
73sydney said:
mixer_paths files have been replaced for years, long before magisk even...i did it back as far as the Galaxy S2 from memory, so im not sure why this didnt work for you, was the mxer_paths file specifically for your device? i have no clear idea why it hasnt worked for you
this thread has a guide to making /system RW, so you could manually copy the file and overwrite it, but id really consider how much you want to replace mixer_paths before i set out to do that
V60 Bootloader Unlock and Magisk Root
Earlier today I was alerted to https://www.cnblogs.com/yanhua-tj/p/15525593.html which has the actual firehose and steps to unlock! However it seems to be in Simplified Chinese so I'll translate it here for you. The firehose is attached below...
forum.xda-developers.com
Click to expand...
Click to collapse
Actually I had no problem in editing the mixer_tavil.xml file in LG V40/50. But when it comes to LG V60, the file is read-only. There is no way to edit it due to dynamic partition. Hence, I was seeking the only option available i.e., via Magisk module.
Royaltiger said:
Actually I had no problem in editing the mixer_tavil.xml file in LG V40/50. But when it comes to LG V60, the file is read-only. There is no way to edit it due to dynamic partition. Hence, I was seeking the only option available i.e., via Magisk module.
Click to expand...
Click to collapse
So, I encountered the same problem and found what you did wrong. I was able to write my own Magisk module and it works wonderfully. It took so much time to understand how to do it because there is no proper tutorial.
If you are still active and trying to know how to do it the right way, here comes the explanation:
The Replace = " /system/vendor/etc/ " must not be written as it completely wipes the actual folder from your phone. This is why you were not able to turn the phone on. It should be like this:
Replace = " " (That part must be blank)
The rest of the code is good. If you try it like this now, you will see it will work, just like mine did.
Cheers
Does not work. May I see your module? Please upload it here as attachment.
I even put my edited file under /data/adb/modules/<my directory>/system/vendor/etc. It shows up in Magisk as a module and the file loads (as it is not visible in file explorer) but there is no change in volume. So the thing is not working.