From ead70df6241c671d27320716a3a111e92aa672db Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Mon, 18 Nov 2024 16:20:09 -0500 Subject: [PATCH] Support back to .NET Framework 2.0 --- NDecrypt.Core/DecryptArgs.cs | 2 +- NDecrypt.Core/NDecrypt.Core.csproj | 2 +- NDecrypt.Core/PartitionKeys.cs | 8 ++++++++ NDecrypt/NDecrypt.csproj | 2 +- NDecrypt/Program.cs | 6 +++--- publish-nix.sh | 2 +- publish-win.ps1 | 2 +- 7 files changed, 16 insertions(+), 8 deletions(-) diff --git a/NDecrypt.Core/DecryptArgs.cs b/NDecrypt.Core/DecryptArgs.cs index 29d61e1..d5ff991 100644 --- a/NDecrypt.Core/DecryptArgs.cs +++ b/NDecrypt.Core/DecryptArgs.cs @@ -107,7 +107,7 @@ namespace NDecrypt.Core // Ignore comments in the file if (reader.RowType == IniRowType.Comment) continue; - if (reader.KeyValuePair == null || string.IsNullOrWhiteSpace(reader.KeyValuePair?.Key)) + if (reader.KeyValuePair == null || string.IsNullOrEmpty(reader.KeyValuePair?.Key)) break; var kvp = reader.KeyValuePair!.Value; diff --git a/NDecrypt.Core/NDecrypt.Core.csproj b/NDecrypt.Core/NDecrypt.Core.csproj index ae3b96a..fb0f7c6 100644 --- a/NDecrypt.Core/NDecrypt.Core.csproj +++ b/NDecrypt.Core/NDecrypt.Core.csproj @@ -2,7 +2,7 @@ - net40;net452;net462;net472;net48;netcoreapp3.1;net5.0;net6.0;net7.0;net8.0;net9.0 + net20;net35;net40;net452;net462;net472;net48;netcoreapp3.1;net5.0;net6.0;net7.0;net8.0;net9.0 false false latest diff --git a/NDecrypt.Core/PartitionKeys.cs b/NDecrypt.Core/PartitionKeys.cs index 772b191..26abfd9 100644 --- a/NDecrypt.Core/PartitionKeys.cs +++ b/NDecrypt.Core/PartitionKeys.cs @@ -68,7 +68,11 @@ namespace NDecrypt.Core NormalKey2C = RotateLeft(NormalKey2C, 87); // Special case for zero-key +#if NET20 || NET35 + if ((masks & BitMasks.FixedCryptoKey) > 0) +#else if (masks.HasFlag(BitMasks.FixedCryptoKey)) +#endif { Console.WriteLine("Encryption Method: Zero Key"); NormalKey = new byte[16]; @@ -113,7 +117,11 @@ namespace NDecrypt.Core public void SetRomFSValues(BitMasks masks) { // NormalKey has a constant value for zero-key +#if NET20 || NET35 + if ((masks & BitMasks.FixedCryptoKey) > 0) +#else if (masks.HasFlag(BitMasks.FixedCryptoKey)) +#endif { NormalKey = new byte[16]; return; diff --git a/NDecrypt/NDecrypt.csproj b/NDecrypt/NDecrypt.csproj index d2f5082..16f2d84 100644 --- a/NDecrypt/NDecrypt.csproj +++ b/NDecrypt/NDecrypt.csproj @@ -2,7 +2,7 @@ - net40;net452;net462;net472;net48;netcoreapp3.1;net5.0;net6.0;net7.0;net8.0;net9.0 + net20;net35;net40;net452;net462;net472;net48;netcoreapp3.1;net5.0;net6.0;net7.0;net8.0;net9.0 Exe false false diff --git a/NDecrypt/Program.cs b/NDecrypt/Program.cs index 63660a7..83dca33 100644 --- a/NDecrypt/Program.cs +++ b/NDecrypt/Program.cs @@ -67,7 +67,7 @@ namespace NDecrypt start++; string tempPath = args[start]; - if (string.IsNullOrWhiteSpace(tempPath)) + if (string.IsNullOrEmpty(tempPath)) Console.WriteLine($"Invalid keyfile path: null or empty path found!"); tempPath = Path.GetFullPath(tempPath); @@ -107,7 +107,7 @@ namespace NDecrypt } else if (Directory.Exists(args[i])) { - foreach (string file in Directory.EnumerateFiles(args[i], "*", SearchOption.AllDirectories)) + foreach (string file in Directory.GetFiles(args[i], "*", SearchOption.AllDirectories)) { ProcessPath(file, encrypt, force, outputHashes); } @@ -158,7 +158,7 @@ namespace NDecrypt /// Additional error text to display, can be null to ignore private static void DisplayHelp(string? err = null) { - if (!string.IsNullOrWhiteSpace(err)) + if (!string.IsNullOrEmpty(err)) Console.WriteLine($"Error: {err}"); Console.WriteLine(@"Usage: NDecrypt [flags] ... diff --git a/publish-nix.sh b/publish-nix.sh index ff5ddcd..02b81a4 100644 --- a/publish-nix.sh +++ b/publish-nix.sh @@ -49,7 +49,7 @@ RUNTIMES=("win-x86" "win-x64" "win-arm64" "linux-x64" "linux-arm64" "osx-x64" "o # Use expanded lists, if requested if [ $USE_ALL = true ]; then - FRAMEWORKS=("net40" "net452" "net462" "net472" "net48" "netcoreapp3.1" "net5.0" "net6.0" "net7.0" "net8.0" "net9.0") + FRAMEWORKS=("net20" "net35" "net40" "net452" "net462" "net472" "net48" "netcoreapp3.1" "net5.0" "net6.0" "net7.0" "net8.0" "net9.0") fi # Create the filter arrays diff --git a/publish-win.ps1 b/publish-win.ps1 index b4cac29..166d194 100644 --- a/publish-win.ps1 +++ b/publish-win.ps1 @@ -40,7 +40,7 @@ $RUNTIMES = @('win-x86', 'win-x64', 'win-arm64', 'linux-x64', 'linux-arm64', 'os # Use expanded lists, if requested if ($USE_ALL.IsPresent) { - $FRAMEWORKS = @('net40', 'net452', 'net462', 'net472', 'net48', 'netcoreapp3.1', 'net5.0', 'net6.0', 'net7.0', 'net8.0', 'net9.0') + $FRAMEWORKS = @('net20', 'net35', 'net40', 'net452', 'net462', 'net472', 'net48', 'netcoreapp3.1', 'net5.0', 'net6.0', 'net7.0', 'net8.0', 'net9.0') } # Create the filter arrays