[Miscellaneous Android Development] Peter1212:
EDIT: Deleting my previous comments for a proper post.

This is how I managed to get magisk 21.4 over Bluestacks 5 (tested on v5.0.100.2106 - should work on subsequent or previous versions using the same)

The script file is the same as LDPlayer's instructions with a little modification.

1) Need to make /system partition writable first.

For that, you need to go to this directory "%ProgramData%\Bluestacks_nxt\Engine"

If you're changing this for one of the master instance go to respective folder, Nougat32 for x86 and Nougat64 for the x64 bit android.

Edit the file Nougatxx.bstk and change type="ReadOnly" to type="Normal" for Root.vdi

2) Need superuser.

For this go to "%ProgramData%\Bluestacks_nxt" and edit the file bluestacks.conf present within. Again, remember which instance you're enabling root for. Search for root and look for an entry similar to - bst.instance.Nougat32.enable_root_access="0"

That entry is for the master instance of Nougat32. Change it's value to 1 and save this file.

Note: Make sure you made these changes while there were no instances running and no services related to bluestacks were running, if there are please close or kill them via task manager. HD-Player.exe BstkSVC.exe needs to be not running essentially. If not, these changes might revert back.

Now fire up the emulator and let the instance run. Optional apps you can install - Mixplorer, Terminal

3) Need to make a file called bootstat.rc for the script to work.

Head over to /system/etc/init and make a new file within it called bootstat.rc (make sure extension is rc and not txt).

This directory might not be mounted as rewritable, which you can by either running

mount -o rw,remount / from terminal or via mixplorer settings, Auto remount

This file is crucial for magisk to be there when bluestack boots.

4) You'll also require these files:

Magisk 21.4 from here - Place it over at /sdcard/init.d/bin/magisk.zip

Magisk Manager 8.0.7 from here - Install the app

Script File - Place the run.sh over at any directory like /sdcard/Download

Bluestacks doesn't work with enforcing selinux and hence needs it to be permissive. The script file changes selinux status once it finishes, by the command setenforce 1 search for it within the script file and change it's value to 0

Another thing to note is that shell script files only work in UNIX eof. I have already edited the file and provided it here just in case.

5) Fire up a terminal window and run this code

su
sh /sdcard/Download/run.sh

6) Close emulator.

Edit the bluestacks.conf file once again, disable root access to the instance. Make sure again no bluestacks related services were running.

That is all. Run Bluestacks once again and fire up magisk app.

7) Can optionally update busybox after that using the stericson's app.

Note: If you're making changes to an cloned/non-master instance instead, you'll have to use BStweaker latest version instead. Run BStweaker and choose the instance you want, check it's box and then go to Root tab, click Unlock. This might take a couple seconds to a minute, be patient. Also, this is only necessary for cloned/non-master instance. Bluestacks only creates a cloned/fresh Data.vdi and it's hdd ID hence, any changes to the system partition will all be saved in the master instance instead, defeats the purpose of instances not that they ever thought it'd be getting messed up with.

BStweaker only works for cloned/non-master instances only, hence it is needed. Using BStweaker, it automatically puts the type to "Normal" so no need to edit manually. Once done, this should make your system partition writable.

View attachment 5318363