Skip to content

Commit

Permalink
Added Linux Support
Browse files Browse the repository at this point in the history
  • Loading branch information
bamhm182 committed May 17, 2019
1 parent a387ac7 commit 9e0494b
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 92 deletions.
119 changes: 36 additions & 83 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 14 additions & 6 deletions FinTrinity.py
Expand Up @@ -20,14 +20,17 @@ def __init__(self):

def read_config(self):
try:
username = None
account = None

if platform.uname().system == "Windows":
self.apps_path = Path(Utils.read_hkcu(r"Software\codestation\qcma", 'appsPath')) / 'PGAME'
account = Utils.read_hkcu(r"Software\codestation\qcma", 'lastAccountId')
username = Utils.read_hkcu(r"Software\codestation\qcma", 'lastOnlineId')
elif platform.uname().system == "Linux":
self.apps_path = Path(Utils.read_conf('Linux', 'appsPath'))
account = Utils.read_conf('Linux', 'lastAccountId')
username = Utils.read_conf('Linux', 'lastOnlineId')
self.apps_path = Path(Utils.read_conf('appsPath')) / 'PGAME'
account = Utils.read_conf('lastAccountId')
username = Utils.read_conf('lastOnlineId')

if not os.path.exists(self.apps_path):
print(f"{self.apps_path} does not exist. Please ensure you have run QCMA and backed up your game.")
Expand Down Expand Up @@ -68,10 +71,15 @@ def backup_game(self):

def download_dependencies(self):
print(f"Downloading and Extracting Dependencies")
psvimgtools = None
if platform.uname().system == "Windows":
psvimgtools = "https://github.com/yifanlu/psvimgtools/releases/download/v0.1/psvimgtools-0.1-win64.zip"
elif platform.uname().system == "Linux":
psvimgtools = "https://github.com/yifanlu/psvimgtools/releases/download/v0.1/psvimgtools-0.1-linux64.zip"

Utils.download('https://github.com/TheOfficialFloW/Trinity/releases/download/v1.0/PBOOT.PBP', self.working_dir)
Utils.download('https://github.com/yifanlu/psvimgtools/releases/download/v0.1/psvimgtools-0.1-win64.zip',
self.working_dir)
Utils.extract(self.working_dir / 'psvimgtools-0.1-win64.zip', self.decrypt_dir)
Utils.download(psvimgtools, self.working_dir)
Utils.extract(self.working_dir / psvimgtools.split("/")[-1], self.decrypt_dir)

def hack(self):
print(f"Applying Trinity Hack:\n\n\n")
Expand Down
19 changes: 16 additions & 3 deletions classes/Utils.py
@@ -1,17 +1,20 @@
import os
import shutil
import winreg
from urllib import request
from zipfile import ZipFile
import datetime
from pathlib import Path
import sys
import platform
import stat


def decrypt_game(key, src, pboot, game_id):
print("Decrypting:\n")
os.chdir(src)
command = f'psvimg-extract -K {key} game/game.psvimg game_dec'
if platform.uname().system == "Linux":
os.chmod("./psvimg-extract", stat.S_IRWXU)
command = f'./psvimg-extract -K {key} game/game.psvimg game_dec'
print(command)
if os.system(command) != 0:
print("Decryption failed with the above information.")
Expand All @@ -22,7 +25,9 @@ def decrypt_game(key, src, pboot, game_id):
def encrypt_game(key, src, dst):
print("\nEncrypting:\n")
os.chdir(src)
command = f'psvimg-create -n game -K {key} game_dec "{dst}/game"'
if platform.uname().system == "Linux":
os.chmod("./psvimg-create", stat.S_IRWXU)
command = f'./psvimg-create -n game -K {key} game_dec "{dst}/game"'
print(command)
if os.system(command) != 0:
print("Game Creation failed with the above information.")
Expand All @@ -38,10 +43,18 @@ def make_dir(d):


def read_hkcu(key: str, val: str):
import winreg
with winreg.OpenKey(winreg.HKEY_CURRENT_USER, key, 0, winreg.KEY_READ) as key:
return winreg.QueryValueEx(key, val)[0]


def read_conf(val: str):
with open(os.path.expanduser('~/.config/codestation/qcma.conf')) as config:
for line in config.readlines():
if line.startswith(val):
return line.split("=")[1].replace("\n", "")


def download(url, dst):
request.urlretrieve(url, f'{dst}/{url.split("/")[-1]}')

Expand Down
Binary file modified classes/__pycache__/Game.cpython-37.pyc
Binary file not shown.
Binary file modified classes/__pycache__/User.cpython-37.pyc
Binary file not shown.
Binary file modified classes/__pycache__/Utils.cpython-37.pyc
Binary file not shown.

0 comments on commit 9e0494b

Please sign in to comment.