diff --git a/PS5 NOR Modifier/Form1.cs b/PS5 NOR Modifier/Form1.cs index 8f6dec8..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; } @@ -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) 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..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; } @@ -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...");