From 5ee158918f083fbbc9ea04683714b963da93fbd7 Mon Sep 17 00:00:00 2001 From: patchzyy <64382339+patchzyy@users.noreply.github.com> Date: Sun, 18 Oct 2026 15:05:19 +0200 Subject: [PATCH] Show sha (#301) --- .../InstallerEngine.cs | 32 +++++++++++++------ Launcher/macos/extract-disc.command | 6 ++-- 2 files changed, 27 insertions(+), 11 deletions(-) diff --git a/Launcher/WiiCompiled.Setup.Windows/InstallerEngine.cs b/Launcher/WiiCompiled.Setup.Windows/InstallerEngine.cs index fb96d3c..f69e4f9 100644 --- a/Launcher/WiiCompiled.Setup.Windows/InstallerEngine.cs +++ b/Launcher/WiiCompiled.Setup.Windows/InstallerEngine.cs @@ -501,17 +501,31 @@ internal sealed class InstallerEngine var dol = Path.Combine(dataRoot, "sys", "main.dol"); var rel = Path.Combine(dataRoot, "files", "rel", "StaticR.rel"); var fst = Path.Combine(dataRoot, "sys", "fst.bin"); - if (!File.Exists(dol) || !File.Exists(rel) || !File.Exists(fst)) - throw new InvalidDataException("The disc extraction is missing required Mario Kart Wii files."); - var dolHash = InputValidation.Sha256File(dol); - var relHash = InputValidation.Sha256File(rel); - if (!dolHash.Equals(manifest.ExpectedDolSha256, StringComparison.OrdinalIgnoreCase) || - !relHash.Equals(manifest.ExpectedRelSha256, StringComparison.OrdinalIgnoreCase)) - { + var missing = new[] { dol, rel, fst }.Where(path => !File.Exists(path)) + .Select(path => Path.GetRelativePath(dataRoot, path)).ToList(); + if (missing.Count > 0) throw new InvalidDataException( - "The disc is RMCP01 but does not match the supported clean PAL revision. " + - "Patched or otherwise modified game code cannot be installed safely."); + "The disc extraction is missing required Mario Kart Wii files: " + + string.Join(", ", missing) + "."); + + var mismatches = new List(); + foreach (var (name, path, expected) in new[] + { + ("main.dol", dol, manifest.ExpectedDolSha256), + ("StaticR.rel", rel, manifest.ExpectedRelSha256) + }) + { + var actual = InputValidation.Sha256File(path); + if (!actual.Equals(expected, StringComparison.OrdinalIgnoreCase)) + mismatches.Add($"{name} is {new FileInfo(path).Length:N0} bytes with SHA-256 {actual} " + + $"(expected {expected})"); } + + if (mismatches.Count > 0) + throw new InvalidDataException( + "The disc is RMCP01 but its game code does not match the supported clean PAL revision: " + + string.Join("; ", mismatches) + ". " + + "Patched or otherwise modified game code cannot be installed safely."); } private static void ValidateInstallDirectory(string path) => diff --git a/Launcher/macos/extract-disc.command b/Launcher/macos/extract-disc.command index 663b542..baf4b22 100755 --- a/Launcher/macos/extract-disc.command +++ b/Launcher/macos/extract-disc.command @@ -51,8 +51,10 @@ dol=$(find "$scratch/extracted" -type f -path '*/sys/main.dol' -print -quit) rel=$(find "$scratch/extracted" -type f -path '*/files/rel/StaticR.rel' -print -quit) [[ -n "$dol" ]] || fail 'nodtool extraction did not contain sys/main.dol' [[ -n "$rel" ]] || fail 'nodtool extraction did not contain files/rel/StaticR.rel' -[[ $(sha256 "$dol") == "$EXPECTED_DOL_SHA256" ]] || fail 'disc is not the supported clean PAL RMCP01 Mario Kart Wii image' -[[ $(sha256 "$rel") == "$EXPECTED_REL_SHA256" ]] || fail 'disc has an unexpected StaticR.rel; use a clean PAL RMCP01 image' +dol_sha=$(sha256 "$dol") +rel_sha=$(sha256 "$rel") +[[ $dol_sha == "$EXPECTED_DOL_SHA256" ]] || fail "main.dol does not match the clean PAL RMCP01 image (expected $EXPECTED_DOL_SHA256, got $dol_sha)" +[[ $rel_sha == "$EXPECTED_REL_SHA256" ]] || fail "StaticR.rel does not match the clean PAL RMCP01 image (expected $EXPECTED_REL_SHA256, got $rel_sha)" data_root=$(dirname "$(dirname "$dol")") [[ -d "$data_root/files" ]] || fail 'nodtool extraction did not contain the Wii files directory'