-
Notifications
You must be signed in to change notification settings - Fork 0
/
patch.py
56 lines (45 loc) · 1.5 KB
/
patch.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import os
import sys
from pathlib import Path
from shutil import copy, move
from subprocess import run
import urllib.request
HERE = Path(os.getcwd())
VANILLA = HERE / "Vanilla"
PATCHED = HERE / "Patched"
TYPES = {".exe", ".dll", ".bak"}
NEEDTAO = {"Transistor"}
TAOURL = "https://files.catbox.moe/6yhtsb.dll"
TAOFILE = VANILLA / "Tao.sdl.dll"
GAME = None
def gamestr(game):
if game.name[0] == 'x':
return f"{game.parent.name}'s {game.name}"
return f"{game.name}'s"
if len(sys.argv) > 1:
s = sys.argv[1]
GAME = Path(s)
if not Game.exists():
raise FileNotFoundError(s)
else:
GAME = Path(input("Enter path to game's binaries folder (x64, x86 etc):"))
while not GAME.exists():
s = input("Invalid Path! Press ENTER to exit progam or try another path:")
if not s:
exit()
GAME = Path(s)
print(f"Patching {gamestr(GAME)} binaries...")
if not VANILLA.exists():
os.mkdir(VANILLA)
for path in os.scandir(GAME):
if path.is_file() and (t == path.name[-len(t):] for t in TYPES):
copy(path, VANILLA / path.name)
if GAME.parent.name in NEEDTAO and not TAOFILE.exists():
with open(TAOFILE, "wb") as file:
file.write(urllib.request.urlopen(TAOURL).read())
from build import *
for path in os.scandir(PATCHED):
if path.is_file():
copy(path, GAME / path.name)
if len(sys.argv) == 1:
input(f"Patched {gamestr(GAME)} binaries! Press ENTER to exit program...")