Skip to content

Commit 8bb8223

Browse files
committed
fixed an issue with other instances not being toggled to r/w, and ensured that the configuration goes back to Readonly correctly if you un toggle the rw
1 parent b5ab143 commit 8bb8223

3 files changed

Lines changed: 42 additions & 19 deletions

File tree

README.md

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# BlueStacks Root GUI
22

3-
This is an AIO application designed to simplify the configuration part of my original tutorial on how to [root BlueStacks](https://github.com/RobThePCGuy/Root-Bluestacks-with-Kitsune-Mask/) with Kitsune Mask. If you want to do things manually, then the original repo is where you go. This tool will allow you to toggle root access and read/write (R/W) modes for BlueStacks instances. It provides an intuitive interface for managing these settings without manually editing configuration files.
3+
>[!IMPORTANT]
4+
> This is an **unofficial modification**. It is not supported by the BlueStacks team, nor should you blame me or them if your dishwasher blows up. Work **IN** Progress only use if you are crazy!
5+
> As always, I am happy to accept help.
6+
7+
This is an AIO application designed to simplify the configuration part of my original tutorial on how to [root BlueStacks](https://github.com/RobThePCGuy/Root-Bluestacks-with-Kitsune-Mask/) with Kitsune Mask. If you want to do things manually, then the original repo is where you go. This tool will allow you to toggle root access and read/write (R/W) modes for BlueStacks instances. It provides an intuitive interface for managing these settings without manually editing configuration files. It will not automatically download BlueStacks or Magisk, nor install either.. yet.
48

59
## Features
610

@@ -33,7 +37,8 @@ This is an AIO application designed to simplify the configuration part of my ori
3337
- **Toggle Root**: Toggles root access (`On`/`Off`) for the selected instance.
3438
- **Toggle R/W**: Toggles read/write mode (`On`/`Off`) for the selected instance.
3539
5. Observe the status updates (`Root: On/Off` and `R/W: On/Off`) next to each instance.
36-
6. Close the app when finished.
40+
6. Once you have installed Kitsune Mask and completed the direct install to the system partition part of my other tutorial, you can untoggle Root and leave the R/W checked. 
41+
7. Close the app when finished.
3742

3843
---
3944

@@ -67,8 +72,8 @@ This is an AIO application designed to simplify the configuration part of my ori
6772

6873
1. Clone the repository:
6974
```bash
70-
git clone https://github.com/your-repo-name.git
71-
cd your-repo-name
75+
git clone https://github.com/RobThePCGuy/BlueStacks-Root-GUI.git
76+
cd BlueStacks-Root-GUI
7277
```
7378

7479
2. Install dependencies:
@@ -83,11 +88,11 @@ This is an AIO application designed to simplify the configuration part of my ori
8388

8489
4. Build the `.exe` file:
8590
```bash
86-
pyinstaller --onefile --windowed main.py
91+
pyinstaller --onefile --windowed --icon=main.ico main.py
8792
```
8893

8994
---
9095

9196
## Contributions
9297

93-
Contributions are welcome! Feel free to open an issue or submit a pull request.
98+
Contributions are welcome! Feel free to open an issue or submit a pull request.

instance_handler.py

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,27 @@
1-
from docx import Document
21
import os
2+
import glob # Import the glob module
33

44
def modify_instance_files(instance_path, file_names, new_type):
55
"""Modifies the type of specified files within an instance's .bstk files.
66
7+
Directly replaces "Readonly" and "Normal" strings to toggle R/W status.
8+
79
Args:
810
instance_path: The path to the instance directory (e.g., ...\Engine\Rvc64).
911
file_names: A list of file names to modify (e.g., ["fastboot.vdi", "Root.vhd"]).
1012
new_type: The new type to set (e.g., "Normal" or "Readonly").
1113
"""
12-
for bstk_file_name in ["Android.bstk.in", f"{os.path.basename(instance_path)}.bstk"]:
14+
bstk_files = ["Android.bstk.in"]
15+
16+
# Find the instance-specific .bstk file
17+
instance_bstk_files = glob.glob(os.path.join(instance_path, "*.bstk"))
18+
if instance_bstk_files:
19+
bstk_files.append(os.path.basename(instance_bstk_files[0]))
20+
else:
21+
print(f"Error: No instance-specific .bstk file found in {instance_path}")
22+
return
23+
24+
for bstk_file_name in bstk_files:
1325
bstk_file_path = os.path.join(instance_path, bstk_file_name)
1426

1527
try:
@@ -19,9 +31,14 @@ def modify_instance_files(instance_path, file_names, new_type):
1931
modified = False
2032
with open(bstk_file_path, "w") as file:
2133
for line in content:
22-
for file_name in file_names:
23-
if file_name in line:
24-
line = line.replace("Readonly", new_type).replace("Normal", new_type)
34+
# Check if any of the file_names are in the current line
35+
if any(file_name in line for file_name in file_names):
36+
# Replace "Readonly" or "Normal" with the new_type
37+
if "Readonly" in line:
38+
line = line.replace("Readonly", new_type)
39+
modified = True
40+
elif "Normal" in line:
41+
line = line.replace("Normal", new_type)
2542
modified = True
2643
file.write(line)
2744

@@ -34,15 +51,15 @@ def modify_instance_files(instance_path, file_names, new_type):
3451
print(f"Error: Instance file not found at {bstk_file_path}")
3552
except Exception as e:
3653
print(f"Error modifying instance file: {e}")
37-
54+
3855
def is_instance_readonly(instance_path):
3956
"""Checks if the instance files are set to Readonly.
4057
4158
Args:
4259
instance_path: The path to the instance directory.
4360
4461
Returns:
45-
True if the instance files are in Readonly mode, False otherwise.
62+
True if any line in the instance files contains "Readonly", False otherwise.
4663
"""
4764
for bstk_file_name in ["Android.bstk.in", f"{os.path.basename(instance_path)}.bstk"]:
4865
bstk_file_path = os.path.join(instance_path, bstk_file_name)
@@ -51,11 +68,11 @@ def is_instance_readonly(instance_path):
5168
with open(bstk_file_path, "r") as file:
5269
for line in file:
5370
if "Readonly" in line:
54-
return True
55-
return False
71+
return True # Found "Readonly" in a line
72+
return False # Did not find "Readonly" in any line
5673
except FileNotFoundError:
5774
print(f"Error: Instance file not found at {bstk_file_path}")
5875
return False
5976
except Exception as e:
6077
print(f"Error reading instance file: {e}")
61-
return False
78+
return False

main.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,10 @@ def update_instance_data(self):
102102
for line in f:
103103
if line.startswith(INSTANCE_PREFIX) and ENABLE_ROOT_KEY in line:
104104
instance_name = line.split(".")[2]
105+
instance_path = os.path.join(self.bluestacks_path, instance_name)
105106
new_instance_data[instance_name] = {
106107
"root_enabled": config_handler.is_root_enabled(self.config_path, instance_name),
107-
"rw_mode": "Normal" if not instance_handler.is_instance_readonly(
108-
os.path.join(self.bluestacks_path, instance_name)) else "Readonly"
108+
"rw_mode": "Normal" if not instance_handler.is_instance_readonly(instance_path) else "Readonly"
109109
}
110110
self.instance_data = new_instance_data
111111
except Exception as e:
@@ -200,7 +200,7 @@ def toggle_root(self):
200200
self.status_label.setText(f"Error toggling root for {instance_name}: {e}")
201201

202202
def toggle_rw(self):
203-
"""Toggles R/W mode for selected instances."""
203+
"""Toggles R/W mode for selected instances, modifying both .bstk.in and .bstk files."""
204204
if not self.bluestacks_path:
205205
self.status_label.setText("Error: BlueStacks path not found.")
206206
return
@@ -214,6 +214,7 @@ def toggle_rw(self):
214214
current_state = self.instance_data[instance_name]["rw_mode"]
215215
new_state = "Normal" if current_state == "Readonly" else "Readonly"
216216

217+
# Use the modify_instance_files from instance_handler
217218
instance_handler.modify_instance_files(instance_path, [FASTBOOT_VDI, ROOT_VHD], new_state)
218219

219220
# Update the instance data and UI

0 commit comments

Comments
 (0)