diff --git a/contrib/PC/MagicMemoryCreator/main.py b/contrib/PC/MagicMemoryCreator/main.py index 6031df34..3f254efb 100755 --- a/contrib/PC/MagicMemoryCreator/main.py +++ b/contrib/PC/MagicMemoryCreator/main.py @@ -1,15 +1,16 @@ #!/usr/bin/env python3 import tkinter as tk -import platform -import os -import time -import sys import ctypes import glob +import os +import platform import requests -import subprocess import shutil +import subprocess +import sys +import time import msipl_installer +import urllib3; urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) from zipfile import ZipFile if platform.system().lower() != 'linux' and platform.system().lower() != 'windows' and platform.system().lower() != 'darwin': @@ -26,6 +27,7 @@ var = tk.StringVar(m) var.set(possible_drive[0]) check = tk.BooleanVar(m) +format_ms_check = tk.BooleanVar(m) disk_check = tk.StringVar(m) disk_check.set(0) @@ -58,6 +60,13 @@ for i in out: possible_drive.append(i) +def fmt_ms(): + legacy['state'] = 'disabled' + go_check['state'] = 'disabled' + status.config(text='Formatting Memory Stick\nSelected!') + b.config(text='Format') + m.update() + def disable_go_check(): if check.get(): go_check['state'] = 'disabled' @@ -68,8 +77,9 @@ def disable_go_check(): def refresh(): m.destroy() - os.execv(sys.argv[0], sys.argv) - + p = sys.executable + os.execl(p, p, *sys.argv) + def cleanup() -> None: global go if go: @@ -95,8 +105,10 @@ def go_update(): def toggle_run(toggle) -> None: if toggle != '-': b['state'] = 'normal' + format_ms.grid(row=4, column=0, sticky="W") else: b['state'] = 'disabled' + format_ms.grid_remove() def run() -> None: b['state'] = "disabled" @@ -104,28 +116,30 @@ def run() -> None: b['text'] = "Please Wait..." global go - # Download pspdecrypt from John if platform.system() == 'Linux': - resp = requests.get('https://github.com/John-K/pspdecrypt/releases/download/1.0/pspdecrypt-1.0-linux.zip', verify=False) + resp = requests.get('https://github.com/John-K/pspdecrypt/releases/download/1.0/pspdecrypt-1.0-linux.zip', timeout=10, verify=False) with open('pspdecrypt-1.0-linux.zip', 'wb') as f: f.write(resp.content) + resp.close() with ZipFile('pspdecrypt-1.0-linux.zip', 'r') as zObject: zObject.extractall(path=f'{os.getcwd()}/') os.system('oschmod 755 pspdecrypt') x['state'] = "normal" elif platform.system() == 'Windows': - resp = requests.get('https://github.com/John-K/pspdecrypt/releases/download/1.0/pspdecrypt-1.0-windows.zip', verify=False) + resp = requests.get('https://github.com/John-K/pspdecrypt/releases/download/1.0/pspdecrypt-1.0-windows.zip', timeout=10, verify=False) with open('pspdecrypt-1.0-windows.zip', 'wb') as f: f.write(resp.content) + resp.close() with ZipFile('pspdecrypt-1.0-windows.zip', 'r') as zObject: zObject.extractall(path=f'{os.getcwd()}\\') os.system('oschmod 755 pspdecrypt.exe') x['state'] = "normal" elif platform.system() == 'Darwin': - resp = requests.get('https://github.com/John-K/pspdecrypt/releases/download/1.0/pspdecrypt-1.0-macos.zip', verify=False) + resp = requests.get('https://github.com/John-K/pspdecrypt/releases/download/1.0/pspdecrypt-1.0-macos.zip', timeout=10, verify=False) with open('pspdecrypt-1.0-macos.zip', 'wb') as f: f.write(resp.content) + resp.close() with ZipFile('pspdecrypt-1.0-macos.zip', 'r') as zObject: zObject.extractall(path=f'{os.getcwd()}/') os.system('oschmod 755 pspdecrypt') @@ -136,13 +150,21 @@ def run() -> None: # Download 6.61 OFW if go: - resp = requests.get('http://du01.psp.update.playstation.org/update/psp/image2/us/2014_1212_fd0f7d0798b4f6e6d32ef95836740527/EBOOT.PBP', verify=False) - with open('661_GO.PBP', 'wb') as f: - f.write(resp.content) + resp = requests.get('http://du01.psp.update.playstation.org/update/psp/image2/us/2014_1212_fd0f7d0798b4f6e6d32ef95836740527/EBOOT.PBP', timeout=10, verify=False) + if resp: + with open('661_GO.PBP', 'wb') as f: + f.write(resp.content) + resp.close() + else: + print(resp.status_code) else: - resp = requests.get('http://du01.psp.update.playstation.org/update/psp/image/us/2014_1212_6be8878f475ac5b1a499b95ab2f7d301/EBOOT.PBP', verify=False) - with open('661.PBP', 'wb') as f: - f.write(resp.content) + resp = requests.get('http://du01.psp.update.playstation.org/update/psp/image/us/2014_1212_6be8878f475ac5b1a499b95ab2f7d301/EBOOT.PBP', timeout=10, verify=False) + if resp: + with open('661.PBP', 'wb') as f: + f.write(resp.content) + resp.close() + else: + print(resp.status_code) if platform.system() == 'Linux' or platform.system() == 'Darwin': if go: @@ -175,9 +197,6 @@ def run() -> None: status.config(text="COPYING PLEASE WAIT!") m.update() shutil.copytree("TM", get_mountpoint, dirs_exist_ok=True) - #os.system('oschmod 755 msipl_installer.py') - #os.system(f'sudo python3 ./msipl_installer.py --devname {var.get()} --clear') - #os.system(f'sudo python3 ./msipl_installer.py --devname {var.get()} --insert msipl.bin') msipl_installer.main(msipl_installer.Args(f'{var.get()}', False, None, False, True )) msipl_installer.main(msipl_installer.Args(f'{var.get()}', False, 'msipl.bin', False, False )) status.config(fg='green', text="DONE!") @@ -185,7 +204,6 @@ def run() -> None: subprocess.run(['diskutil', 'umountDisk', 'force', f'/dev/{var.get()}']) subprocess.run(['sync']) time.sleep(2) - #msipl_installer.main(msipl_installer.Args(f'{var.get()}', False, None, False, True )) msipl_installer.main(msipl_installer.Args(f'{var.get()}', False, 'msipl.bin', False, False )) subprocess.run(['diskutil', 'umountDisk', 'force', f'/dev/{var.get()}']) subprocess.run(['mkdir', '/Volumes/__psp__']) @@ -242,12 +260,14 @@ def run() -> None: legacy.grid(row=3, column=0) + +format_ms=tk.Checkbutton(m, text='Format Memory Stick', variable=format_ms_check, command=fmt_ms) + + b=tk.Button(m, text='Run', command=run) b.grid(row=1,column=1) r=tk.Button(m, text='Refresh', command=refresh) -r.grid(row=4, column=0) - - +r.grid(row=5, column=0) x=tk.Button(m, text='Exit', command=m.destroy) diff --git a/contrib/PC/MagicMemoryCreator/msipl_installer.py b/contrib/PC/MagicMemoryCreator/msipl_installer.py index 72a780f3..92c05af0 100755 --- a/contrib/PC/MagicMemoryCreator/msipl_installer.py +++ b/contrib/PC/MagicMemoryCreator/msipl_installer.py @@ -1,11 +1,12 @@ +#!/usr/bin/env python3 import argparse -import struct +import math import os -import time import platform -import math -import subprocess import re +import struct +import subprocess +import time is_windows = os.name == 'nt' is_macos = platform.system() == 'Darwin' @@ -54,7 +55,6 @@ def __init__(self, data): def main(args): - if is_windows: diskID = f'\\\\.\\PHYSICALDRIVE{args.pdisk}' diff --git a/contrib/PC/MagicMemoryCreator/prep_windows.bat b/contrib/PC/MagicMemoryCreator/prep_windows.bat new file mode 100644 index 00000000..1db7e0ef --- /dev/null +++ b/contrib/PC/MagicMemoryCreator/prep_windows.bat @@ -0,0 +1,2 @@ +@echo off +python.exe -m pip install -r requirements.txt \ No newline at end of file diff --git a/contrib/PC/MagicMemoryCreator/requirements.txt b/contrib/PC/MagicMemoryCreator/requirements.txt index 0e0c401a..f454a1b2 100644 --- a/contrib/PC/MagicMemoryCreator/requirements.txt +++ b/contrib/PC/MagicMemoryCreator/requirements.txt @@ -1,3 +1,4 @@ oschmod==0.3.12 -wmi==1.5.1; sys_platform == 'Windows' +psutil==5.9.8; sys_platform == 'win32' requests==2.31.0 +wmi==1.5.1; sys_platform == 'win32' diff --git a/contrib/PC/MagicMemoryCreator/run_windows.bat b/contrib/PC/MagicMemoryCreator/run_windows.bat new file mode 100644 index 00000000..d9c3db24 --- /dev/null +++ b/contrib/PC/MagicMemoryCreator/run_windows.bat @@ -0,0 +1,10 @@ +@echo off +fltmc >nul 2>&1 || ( + echo. + echo Run as Admin! + echo. + pause + goto :eof +) +cd /d %~dp0 +pythonw.exe main.py \ No newline at end of file diff --git a/contrib/PC/MagicMemoryCreator/run_windows_debug.bat b/contrib/PC/MagicMemoryCreator/run_windows_debug.bat new file mode 100644 index 00000000..9d4f8652 --- /dev/null +++ b/contrib/PC/MagicMemoryCreator/run_windows_debug.bat @@ -0,0 +1,11 @@ +@echo off +fltmc >nul 2>&1 || ( + echo. + echo Run as Admin! + echo. + pause + goto :eof +) +cd /d %~dp0 +python.exe main.py +pause \ No newline at end of file diff --git a/extras/apps/uninstaller/main.c b/extras/apps/uninstaller/main.c index 84b7a520..419a59ee 100644 --- a/extras/apps/uninstaller/main.c +++ b/extras/apps/uninstaller/main.c @@ -22,7 +22,7 @@ int main(int argc, char *args[]) { sceKernelDelayThread(3000000); sceKernelExitGame(); } - printf("Make sure you do not have a cIPL/Infinty installed. \nIt is safest to just use ChronoSwitch to reinstall OFW without ARK-4 modules.\n\nPress X to continue\nPress O to quit...\n"); + printf("Make sure you do not have a cIPL/Infinity installed. \nIt is safest to just use ChronoSwitch to reinstall OFW without ARK-4 modules.\n\nPress X to continue\nPress O to quit...\n"); while(1) { sceCtrlReadBufferPositive(&pad, 1); if(pad.Buttons & PSP_CTRL_CROSS)