Last active
May 10, 2023 21:12
-
-
Save WitherOrNot/ac2431f0d9c418a4365720750c54b13a to your computer and use it in GitHub Desktop.
"special" minecraft bedrock launcher
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from subprocess import run, Popen, PIPE | |
from psutil import Process | |
from time import sleep | |
from tempfile import NamedTemporaryFile | |
import sys | |
import re | |
import ctypes | |
enable_reg = br"""Windows Registry Editor Version 5.00 | |
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\ClipSVC\Parameters] | |
"DisableSubscription"=dword:00000000 | |
"InactivityShutdownDelay"=dword:0000012c | |
"RefreshRequired"=dword:00000001 | |
"ServiceDll"=hex(2):25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f, 00,74,00,25,00,5c,00,53,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00, 43,00,6c,00,69,00,70,00,53,00,56,00,43,00,2e,00,64,00,6c,00,6c,00,61,00,00, 00 | |
"ServiceDllUnloadOnStop"=dword:00000001 | |
"ProcessBiosKey"=dword:00000001""" | |
disable_reg = br"""Windows Registry Editor Version 5.00 | |
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\ClipSVC\Parameters] | |
"DisableSubscription"=dword:00000000 | |
"InactivityShutdownDelay"=dword:0000012c | |
"RefreshRequired"=dword:00000001 | |
"ServiceDll"=hex(2):25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f, 00,74,00,25,00,5c,00,53,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00, 43,00,6c,00,69,00,70,00,53,00,56,00,43,00,2e,00,64,00,6c,00,6c,00,00,00 | |
"ServiceDllUnloadOnStop"=dword:00000001 | |
"ProcessBiosKey"=dword:00000001""" | |
def test_for_admin(): | |
if not ctypes.windll.shell32.IsUserAnAdmin(): | |
print("Administrator privileges are required for CreativeMode. Please re-launch this program with administrator privileges.") | |
print() | |
input("Press Enter to exit") | |
sys.exit() | |
def kill_rtbroker(): | |
tsl = run("tasklist.exe /apps", stdout=PIPE) | |
rtbrokers = list(filter(lambda p: "RuntimeBroker" in p and "MinecraftUWP" in p, map(lambda s: s.decode("utf-8"), tsl.stdout.split(b"\r\n")))) | |
for rtb in rtbrokers: | |
pid = int(re.search(r" (\d+) ", rtb)[1]) | |
print(f"Found RuntimeBroker process for MinecraftUWP with PID {pid}, killing...") | |
Process(pid).kill() | |
def is_mc_running(): | |
tsl = run("tasklist.exe /apps", stdout=PIPE) | |
mc_procs = list(filter(lambda p: "Minecraft.Windows.exe" in p, map(lambda s: s.decode("utf-8"), tsl.stdout.split(b"\r\n")))) | |
return len(mc_procs) > 0 | |
def enable_cmode(): | |
print("Disabling ClipSVC...") | |
with NamedTemporaryFile(suffix=".reg", delete=False) as f: | |
f.write(enable_reg) | |
f.flush() | |
run(["regedit", "/s", f.name], stdout=PIPE) | |
run("sc.exe stop ClipSVC", stdout=PIPE) | |
print("Launching Minecraft...") | |
proc = Popen(["explorer.exe", "shell:appsFolder\Microsoft.MinecraftUWP_8wekyb3d8bbwe!App"], stdout=PIPE) | |
proc.wait() | |
def disable_cmode(): | |
print("Re-enabling ClipSVC...") | |
with NamedTemporaryFile(suffix=".reg", delete=False) as f: | |
f.write(disable_reg) | |
f.flush() | |
run(["regedit", "/s", f.name], stdout=PIPE) | |
run("sc.exe start ClipSVC", stdout=PIPE) | |
if __name__ == "__main__": | |
print("CreativeMode Bedrock Launcher by witherornot") | |
test_for_admin() | |
enable_cmode() | |
while is_mc_running(): | |
kill_rtbroker() | |
print("Minecraft exit detected.") | |
disable_cmode() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment