diff --git a/.gitignore b/.gitignore index 6a51c542f8c..95be12e84a4 100644 --- a/.gitignore +++ b/.gitignore @@ -25,6 +25,7 @@ docs/doxygen/ # IDE .vscode/ +.idea/ # Python __pycache__/ diff --git a/tools/extract_game_assets.py b/tools/extract_game_assets.py index 1cfdf6ee30a..9ae1777c959 100644 --- a/tools/extract_game_assets.py +++ b/tools/extract_game_assets.py @@ -9,6 +9,7 @@ Extracts the game assets and stores them in the game folder Usage: `python tools/extract_game_assets.py` """ +fileMagicNumber = b"GZ2E01" fstInfoPosition = 0x424 bootPosition = 0x0 bootSize = 0x440 @@ -243,6 +244,13 @@ def extract(isoPath: Path, gamePath: Path, yaz0Encoder): cwd = os.getcwd() os.chdir(gamePath) with open(isoPath, "rb") as f: + magic = f.read(len(fileMagicNumber)) + if magic != fileMagicNumber: + if magic.startswith(b"CISO"): + raise RuntimeError("Compressed ISO files are not supported.") + else: + raise RuntimeError(f"Invalid ISO magic number: expected {fileMagicNumber}, got {magic}") + # Seek to fst offset information and retrieve it f.seek(fstInfoPosition) fstOffset, fstSize = getFstInfo(f, fstInfoPosition) diff --git a/tools/requirements.txt b/tools/requirements.txt index d2717753943..fc6011a52a4 100644 --- a/tools/requirements.txt +++ b/tools/requirements.txt @@ -10,4 +10,5 @@ cxxfilt pyelftools requests GitPython -clang \ No newline at end of file +clang +pyyaml