From 296145ba2d3a46f9745cc4560a2bf788e2481e2d Mon Sep 17 00:00:00 2001 From: YoshiRulz Date: Sun, 20 Feb 2022 23:34:16 +1000 Subject: [PATCH] Clean up dummy/zero checksums see #3159 --- src/BizHawk.Client.Common/XmlGame.cs | 2 +- src/BizHawk.Common/checksums/MD5Checksum.cs | 2 ++ src/BizHawk.Common/checksums/SHA1Checksum.cs | 6 ++++++ src/BizHawk.Emulation.Common/Database/Database.cs | 2 +- .../Database/FirmwareDatabase.cs | 10 ++++++---- 5 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/BizHawk.Client.Common/XmlGame.cs b/src/BizHawk.Client.Common/XmlGame.cs index 28cbd18c55..ac109183a7 100644 --- a/src/BizHawk.Client.Common/XmlGame.cs +++ b/src/BizHawk.Client.Common/XmlGame.cs @@ -112,7 +112,7 @@ namespace BizHawk.Client.Common } else { - ret.GI.Hash = "0000000000000000000000000000000000000000"; + ret.GI.Hash = SHA1Checksum.Zero; } return ret; diff --git a/src/BizHawk.Common/checksums/MD5Checksum.cs b/src/BizHawk.Common/checksums/MD5Checksum.cs index 5ccfcf817e..9a867733ce 100644 --- a/src/BizHawk.Common/checksums/MD5Checksum.cs +++ b/src/BizHawk.Common/checksums/MD5Checksum.cs @@ -17,6 +17,8 @@ namespace BizHawk.Common internal const string PREFIX = "MD5"; + public /*static readonly*/const string EmptyFile = "D41D8CD98F00B204E9800998ECF8427E"; + #if NET6_0 public static byte[] Compute(ReadOnlySpan data) => MD5.HashData(data); diff --git a/src/BizHawk.Common/checksums/SHA1Checksum.cs b/src/BizHawk.Common/checksums/SHA1Checksum.cs index 671dbf00c4..f67a3f34e7 100644 --- a/src/BizHawk.Common/checksums/SHA1Checksum.cs +++ b/src/BizHawk.Common/checksums/SHA1Checksum.cs @@ -17,6 +17,12 @@ namespace BizHawk.Common internal const string PREFIX = "SHA1"; + public /*static readonly*/const string Dummy = "EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE"; + + public /*static readonly*/const string EmptyFile = "DA39A3EE5E6B4B0D3255BFEF95601890AFD80709"; + + public /*static readonly*/const string Zero = "0000000000000000000000000000000000000000"; + #if NET6_0 public static byte[] Compute(ReadOnlySpan data) => SHA1.HashData(data); diff --git a/src/BizHawk.Emulation.Common/Database/Database.cs b/src/BizHawk.Emulation.Common/Database/Database.cs index 6007d5d81a..32a459d861 100644 --- a/src/BizHawk.Emulation.Common/Database/Database.cs +++ b/src/BizHawk.Emulation.Common/Database/Database.cs @@ -152,7 +152,7 @@ namespace BizHawk.Emulation.Common Region = items.Length >= 7 ? items[6] : "", ForcedCore = items.Length >= 8 ? items[7].ToLowerInvariant() : "" }; - if (game.Hash is "DA39A3EE5E6B4B0D3255BFEF95601890AFD80709" or "D41D8CD98F00B204E9800998ECF8427E") + if (game.Hash is SHA1Checksum.EmptyFile or MD5Checksum.EmptyFile) { Console.WriteLine($"WARNING: gamedb {path} contains entry for empty rom as \"{game.Name}\"!"); } diff --git a/src/BizHawk.Emulation.Common/Database/FirmwareDatabase.cs b/src/BizHawk.Emulation.Common/Database/FirmwareDatabase.cs index ad5b6919c2..f892d557ea 100644 --- a/src/BizHawk.Emulation.Common/Database/FirmwareDatabase.cs +++ b/src/BizHawk.Emulation.Common/Database/FirmwareDatabase.cs @@ -3,6 +3,8 @@ using System.Collections.Generic; using System.Linq; +using BizHawk.Common; + // ReSharper disable IdentifierTypo // ReSharper disable InconsistentNaming // ReSharper disable StringLiteralTypo @@ -114,8 +116,8 @@ namespace BizHawk.Emulation.Common FirmwareAndOption("24F67BDEA115A2C847C8813A262502EE1607B7DF", 16384, "NDS", "bios7", "NDS_Bios7.bin", "ARM7 BIOS"); FirmwareAndOption("BFAAC75F101C135E32E2AAF541DE6B1BE4C8C62D", 4096, "NDS", "bios9", "NDS_Bios9.bin", "ARM9 BIOS"); - FirmwareAndOption("0000000000000000000000000000000000000000", 65536, "NDS", "bios7i", "NDS_Bios7i.bin", "ARM7i BIOS"); - FirmwareAndOption("0000000000000000000000000000000000000000", 65536, "NDS", "bios9i", "NDS_Bios9i.bin", "ARM9i BIOS"); + FirmwareAndOption(SHA1Checksum.Dummy, 65536, "NDS", "bios7i", "NDS_Bios7i.bin", "ARM7i BIOS"); + FirmwareAndOption(SHA1Checksum.Dummy, 65536, "NDS", "bios9i", "NDS_Bios9i.bin", "ARM9i BIOS"); Firmware("NDS", "firmware", "NDS Firmware"); // throwing a ton of hashes from the interwebs var knownhack1 = File("22A7547DBC302BCBFB4005CFB5A2D426D3F85AC6", 262144, "NDS_Firmware [b1].bin", "NDS Firmware", "known hack", true); @@ -131,8 +133,8 @@ namespace BizHawk.Emulation.Common Option("NDS", "firmware", in likelygood2); Option("NDS", "firmware", in likelygood3); - FirmwareAndOption("0000000000000000000000000000000000000000", 131072, "NDS", "firmwarei", "DSi_Firmware.bin", "DSi Firmware"); - FirmwareAndOption("0000000000000000000000000000000000000000", 251658304, "NDS", "nand", "DSi_Nand.bin", "DSi NAND"); + FirmwareAndOption(SHA1Checksum.Dummy, 131072, "NDS", "firmwarei", "DSi_Firmware.bin", "DSi Firmware"); + FirmwareAndOption(SHA1Checksum.Dummy, 251658304, "NDS", "nand", "DSi_Nand.bin", "DSi NAND"); FirmwareAndOption("E4ED47FAE31693E016B081C6BDA48DA5B70D7CCB", 512, "Lynx", "Boot", "LYNX_boot.img", "Boot Rom");