From f43aafc00d57d2e533ec945e6104fb1d98c92a75 Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Mon, 12 Jun 2023 13:31:49 -0400 Subject: [PATCH] Update Redumper PS1 output parsing --- CHANGELIST.md | 1 + MPF.Modules/Redumper/Parameters.cs | 145 ++++++++++++++++++++++++++++- 2 files changed, 145 insertions(+), 1 deletion(-) diff --git a/CHANGELIST.md b/CHANGELIST.md index e84e4c15..3bd84fde 100644 --- a/CHANGELIST.md +++ b/CHANGELIST.md @@ -66,6 +66,7 @@ - Fix 2-layer DVD support in Redumper - Fix VSCode build - Fix Redumper DAT/layer parsing +- Update Redumper PS1 output parsing ### 2.5 (2023-03-12) diff --git a/MPF.Modules/Redumper/Parameters.cs b/MPF.Modules/Redumper/Parameters.cs index fb254f44..75f7b73b 100644 --- a/MPF.Modules/Redumper/Parameters.cs +++ b/MPF.Modules/Redumper/Parameters.cs @@ -383,7 +383,30 @@ namespace MPF.Modules.Redumper info.CommonDiscInfo.EXEDateBuildDate = playstationDate; } - // TODO: Support EDC and Antimodchip information when generated + bool? psAntiModchipStatus = GetPlayStationAntiModchipDetected($"{basePath}.log"); + if (psAntiModchipStatus == true) + info.CopyProtection.AntiModchip = YesNo.Yes; + else if (psAntiModchipStatus == false) + info.CopyProtection.AntiModchip = YesNo.No; + else + info.CopyProtection.AntiModchip = YesNo.NULL; + + bool? psEdcStatus = GetPlayStationEDCStatus($"{basePath}.log"); + if (psEdcStatus == true) + info.EDC.EDC = YesNo.Yes; + else if (psEdcStatus == false) + info.EDC.EDC = YesNo.No; + else + info.EDC.EDC = YesNo.NULL; + + bool? psLibCryptStatus = GetPlayStationLibCryptStatus($"{basePath}.log"); + if (psLibCryptStatus == true) + info.CopyProtection.LibCrypt = YesNo.Yes; + else if (psLibCryptStatus == false) + info.CopyProtection.LibCrypt = YesNo.No; + else + info.CopyProtection.LibCrypt = YesNo.NULL; + break; case RedumpSystem.SonyPlayStation2: @@ -1293,6 +1316,126 @@ namespace MPF.Modules.Redumper } } + /// + /// Get the existence of an anti-modchip string from the input file, if possible + /// + /// Log file location + /// Anti-modchip existence if possible, false on error + private static bool? GetPlayStationAntiModchipDetected(string log) + { + // If the file doesn't exist, we can't get info from it + if (!File.Exists(log)) + return null; + + using (StreamReader sr = File.OpenText(log)) + { + try + { + // Check for the anti-modchip strings + string line = sr.ReadLine().Trim(); + while (!sr.EndOfStream) + { + if (line == null) + return false; + + if (line.StartsWith("anti-modchip: no")) + return false; + else if (line.StartsWith("anti-modchip: yes")) + return true; + + line = sr.ReadLine().Trim(); + } + + return false; + } + catch + { + // We don't care what the exception is right now + return null; + } + } + } + + /// + /// Get the detected missing EDC count from the input files, if possible + /// + /// Log file location + /// Status of PS1 EDC, if possible + private static bool? GetPlayStationEDCStatus(string log) + { + // If the file doesn't exist, we can't get info from it + if (!File.Exists(log)) + return null; + + using (StreamReader sr = File.OpenText(log)) + { + try + { + // Check for the EDC strings + string line = sr.ReadLine().Trim(); + while (!sr.EndOfStream) + { + if (line == null) + return false; + + if (line.StartsWith("EDC: no")) + return false; + else if (line.StartsWith("EDC: yes")) + return true; + + line = sr.ReadLine().Trim(); + } + + return false; + } + catch + { + // We don't care what the exception is right now + return null; + } + } + } + + /// + /// Get the existence of LibCrypt from the input file, if possible + /// + /// Log file location + /// Status of PS1 LibCrypt, if possible + private static bool? GetPlayStationLibCryptStatus(string log) + { + // If the file doesn't exist, we can't get info from it + if (!File.Exists(log)) + return null; + + using (StreamReader sr = File.OpenText(log)) + { + try + { + // Check for the libcrypt strings + string line = sr.ReadLine().Trim(); + while (!sr.EndOfStream) + { + if (line == null) + return false; + + if (line.StartsWith("libcrypt: no")) + return false; + else if (line.StartsWith("libcrypt: yes)) + return true; + + line = sr.ReadLine().Trim(); + } + + return false; + } + catch + { + // We don't care what the exception is right now + return null; + } + } + } + /// /// Get the PVD from the input file, if possible ///