From 3d8be2c29b65f5d0e18ed62d0098cc9ee8d3e1e2 Mon Sep 17 00:00:00 2001 From: ScrubN <72096833+ScrubN@users.noreply.github.com> Date: Thu, 8 May 2025 23:47:07 -0400 Subject: [PATCH 1/3] Significantly speed up BIOS exports --- PS5 NOR Modifier/Form1.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/PS5 NOR Modifier/Form1.cs b/PS5 NOR Modifier/Form1.cs index 8f6dec8..56cc7d8 100644 --- a/PS5 NOR Modifier/Form1.cs +++ b/PS5 NOR Modifier/Form1.cs @@ -680,8 +680,8 @@ private void convertToDigitalEditionButton_Click(object sender, EventArgs e) { bytes[i] = replace[replaceIndex]; } - File.WriteAllBytes(newFile, bytes); } + File.WriteAllBytes(newFile, bytes); } } @@ -716,8 +716,8 @@ private void convertToDigitalEditionButton_Click(object sender, EventArgs e) { bytes[i] = replace[replaceIndex]; } - File.WriteAllBytes(newFile, bytes); } + File.WriteAllBytes(newFile, bytes); } } @@ -750,8 +750,8 @@ private void convertToDigitalEditionButton_Click(object sender, EventArgs e) { bytes[i] = replace[replaceIndex]; } - File.WriteAllBytes(newFile, bytes); } + File.WriteAllBytes(newFile, bytes); } catch(System.ArgumentException ex) @@ -783,8 +783,8 @@ private void convertToDigitalEditionButton_Click(object sender, EventArgs e) { bytes[i] = replace[replaceIndex]; } - File.WriteAllBytes(newFile, bytes); } + File.WriteAllBytes(newFile, bytes); } catch (System.ArgumentException ex) From c8602c07e840c2b51e6294945fcdad22d520845b Mon Sep 17 00:00:00 2001 From: Scrub <72096833+ScrubN@users.noreply.github.com> Date: Thu, 8 May 2025 23:53:50 -0400 Subject: [PATCH 2/3] Significantly speed up UART-CL BIOS exports --- .../UART-CL By TheCod3r/Program.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/UART-CL By TheCod3r/UART-CL By TheCod3r/Program.cs b/UART-CL By TheCod3r/UART-CL By TheCod3r/Program.cs index aa87133..df708c2 100644 --- a/UART-CL By TheCod3r/UART-CL By TheCod3r/Program.cs +++ b/UART-CL By TheCod3r/UART-CL By TheCod3r/Program.cs @@ -726,8 +726,8 @@ static void RunSubMenu(string appTitle, Dictionary regionMap) { bytes[i] = replace[replaceIndex]; } - File.WriteAllBytes(pathToDump, bytes); } + File.WriteAllBytes(pathToDump, bytes); byte[] find2 = ConvertHexStringToByteArray(Regex.Replace("22020101", "0x|[ ,]", string.Empty).Normalize().Trim()); byte[] replace2 = ConvertHexStringToByteArray(Regex.Replace("22030101", "0x|[ ,]", string.Empty).Normalize().Trim()); @@ -738,8 +738,8 @@ static void RunSubMenu(string appTitle, Dictionary regionMap) { bytes[i] = replace2[replaceIndex]; } - File.WriteAllBytes(pathToDump, bytes); } + File.WriteAllBytes(pathToDump, bytes); System.Console.WriteLine("Your BIOS file has been updated successfully. The new .bin file will now report to"); System.Console.WriteLine("the PlayStation 5 as a 'digital edition' console."); @@ -859,8 +859,8 @@ static void RunSubMenu(string appTitle, Dictionary regionMap) { bytes[i] = replace[replaceIndex]; } - File.WriteAllBytes(pathToDump, bytes); } + File.WriteAllBytes(pathToDump, bytes); byte[] find2 = ConvertHexStringToByteArray(Regex.Replace("22030101", "0x|[ ,]", string.Empty).Normalize().Trim()); byte[] replace2 = ConvertHexStringToByteArray(Regex.Replace("22020101", "0x|[ ,]", string.Empty).Normalize().Trim()); @@ -871,8 +871,8 @@ static void RunSubMenu(string appTitle, Dictionary regionMap) { bytes[i] = replace2[replaceIndex]; } - File.WriteAllBytes(pathToDump, bytes); } + File.WriteAllBytes(pathToDump, bytes); System.Console.WriteLine("Your BIOS file has been updated successfully. The new .bin file will now report to"); System.Console.WriteLine("the PlayStation 5 as a 'disc edition' console."); @@ -991,8 +991,8 @@ static void RunSubMenu(string appTitle, Dictionary regionMap) { bytes[i] = replace[replaceIndex]; } - File.WriteAllBytes(pathToDump, bytes); } + File.WriteAllBytes(pathToDump, bytes); byte[] find2 = ConvertHexStringToByteArray(Regex.Replace("22030101", "0x|[ ,]", string.Empty).Normalize().Trim()); byte[] replace2 = ConvertHexStringToByteArray(Regex.Replace("22010101", "0x|[ ,]", string.Empty).Normalize().Trim()); @@ -1003,8 +1003,8 @@ static void RunSubMenu(string appTitle, Dictionary regionMap) { bytes[i] = replace2[replaceIndex]; } - File.WriteAllBytes(pathToDump, bytes); } + File.WriteAllBytes(pathToDump, bytes); System.Console.WriteLine("Your BIOS file has been updated successfully. The new .bin file will now report to"); System.Console.WriteLine("the PlayStation 5 as a 'slim edition' console."); @@ -1247,8 +1247,8 @@ static void RunSubMenu(string appTitle, Dictionary regionMap) { bytes[i] = replace[replaceIndex]; } - File.WriteAllBytes(pathToDump, bytes); } + File.WriteAllBytes(pathToDump, bytes); System.Console.WriteLine("The new motherboard serial number you entered been saved successfully."); System.Console.WriteLine("Press Enter to continue..."); @@ -1373,8 +1373,8 @@ static void RunSubMenu(string appTitle, Dictionary regionMap) { bytes[i] = replace[replaceIndex]; } - File.WriteAllBytes(pathToDump, bytes); } + File.WriteAllBytes(pathToDump, bytes); System.Console.WriteLine("The new console model you chose has been saved successfully."); System.Console.WriteLine("Press Enter to continue..."); From 907dbaee92a7401d0d3873473c07dddb36f61402 Mon Sep 17 00:00:00 2001 From: ScrubN <72096833+ScrubN@users.noreply.github.com> Date: Fri, 9 May 2025 00:53:28 -0400 Subject: [PATCH 3/3] Make PatternAt() free --- PS5 NOR Modifier/Form1.cs | 4 ++-- UART-CL By TheCod3r/UART-CL By TheCod3r/Program.cs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/PS5 NOR Modifier/Form1.cs b/PS5 NOR Modifier/Form1.cs index 56cc7d8..dc8d0b0 100644 --- a/PS5 NOR Modifier/Form1.cs +++ b/PS5 NOR Modifier/Form1.cs @@ -46,7 +46,7 @@ private void throwError(string errmsg) static SerialPort UARTSerial = new SerialPort(); /// - /// With thanks to @jjxtra on Github. The code has already been created and there's no need to reinvent the wheel is there? + /// 2-pointer search algorithm based on code by @jjxtra on GitHub. /// #region Hex Code @@ -54,7 +54,7 @@ private static IEnumerable PatternAt(byte[] source, byte[] pattern) { for (int i = 0; i < source.Length; i++) { - if (source.Skip(i).Take(pattern.Length).SequenceEqual(pattern)) + if (source.AsSpan(i).StartsWith(pattern)) { yield return i; } diff --git a/UART-CL By TheCod3r/UART-CL By TheCod3r/Program.cs b/UART-CL By TheCod3r/UART-CL By TheCod3r/Program.cs index df708c2..71d8b6e 100644 --- a/UART-CL By TheCod3r/UART-CL By TheCod3r/Program.cs +++ b/UART-CL By TheCod3r/UART-CL By TheCod3r/Program.cs @@ -57,7 +57,7 @@ static IEnumerable PatternAt(byte[] source, byte[] pattern) { for (int i = 0; i < source.Length; i++) { - if (source.Skip(i).Take(pattern.Length).SequenceEqual(pattern)) + if (source.AsSpan(i).StartsWith(pattern)) { yield return i; }