From 70d30d370f2e08623085fcc60557f8d37c607dda Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Tue, 3 Nov 2020 21:49:59 -0800 Subject: [PATCH] Update to BurnOutSharp 1.5.0 --- CHANGELIST.md | 1 + DICUI.Avalonia/DICUI.Avalonia.csproj | 6 ++- DICUI.Check/DICUI.Check.csproj | 6 ++- DICUI.Library/DICUI.Library.csproj | 6 ++- DICUI.Library/Utilities/Tools.cs | 69 ++++++++++++++++++++++++++- DICUI.Library/Utilities/Validators.cs | 20 ++++---- DICUI/DICUI.csproj | 4 +- 7 files changed, 95 insertions(+), 17 deletions(-) diff --git a/CHANGELIST.md b/CHANGELIST.md index 9b2eb0ae5..e40632afc 100644 --- a/CHANGELIST.md +++ b/CHANGELIST.md @@ -19,6 +19,7 @@ - Add option to allow users to select dumping program - ~~Updated to DIC version 20201101~~ - Add support for `/ps` DIC flag +- Updated to BurnOutSharp 1.5.0 ### 1.17.1 (2020-09-14) - Shuffled some shared, internal UI variables diff --git a/DICUI.Avalonia/DICUI.Avalonia.csproj b/DICUI.Avalonia/DICUI.Avalonia.csproj index ae5a3dc2f..76a226d29 100644 --- a/DICUI.Avalonia/DICUI.Avalonia.csproj +++ b/DICUI.Avalonia/DICUI.Avalonia.csproj @@ -21,13 +21,15 @@ - + + runtime; compile; build; native; analyzers; buildtransitive + - + diff --git a/DICUI.Check/DICUI.Check.csproj b/DICUI.Check/DICUI.Check.csproj index 33eb48ab8..fb1282339 100644 --- a/DICUI.Check/DICUI.Check.csproj +++ b/DICUI.Check/DICUI.Check.csproj @@ -22,11 +22,13 @@ - + + runtime; compile; build; native; analyzers; buildtransitive + - + diff --git a/DICUI.Library/DICUI.Library.csproj b/DICUI.Library/DICUI.Library.csproj index ea45d66da..8cbc09dee 100644 --- a/DICUI.Library/DICUI.Library.csproj +++ b/DICUI.Library/DICUI.Library.csproj @@ -67,13 +67,15 @@ - + + runtime; compile; build; native; analyzers; buildtransitive + - + diff --git a/DICUI.Library/Utilities/Tools.cs b/DICUI.Library/Utilities/Tools.cs index 059d0e546..52e67eca1 100644 --- a/DICUI.Library/Utilities/Tools.cs +++ b/DICUI.Library/Utilities/Tools.cs @@ -4,8 +4,74 @@ namespace DICUI.Utilities { - public class Tools + public static class Tools { + #region Byte Arrays + + /// + /// Search for a byte array in another array + /// + public static bool Contains(this byte[] stack, byte[] needle, out int position, int start = 0, int end = -1) + { + // Initialize the found position to -1 + position = -1; + + // If either array is null or empty, we can't do anything + if (stack == null || stack.Length == 0 || needle == null || needle.Length == 0) + return false; + + // If the needle array is larger than the stack array, it can't be contained within + if (needle.Length > stack.Length) + return false; + + // If start or end are not set properly, set them to defaults + if (start < 0) + start = 0; + if (end < 0) + end = stack.Length - needle.Length; + + for (int i = start; i < end; i++) + { + if (stack.EqualAt(needle, i)) + { + position = i; + return true; + } + } + + return false; + } + + /// + /// See if a byte array starts with another + /// + public static bool StartsWith(this byte[] stack, byte[] needle) + { + return stack.Contains(needle, out int _, start: 0, end: 1); + } + + /// + /// Get if a stack at a certain index is equal to a needle + /// + private static bool EqualAt(this byte[] stack, byte[] needle, int index) + { + // If we're too close to the end of the stack, return false + if (needle.Length >= stack.Length - index) + return false; + + for (int i = 0; i < needle.Length; i++) + { + if (stack[i + index] != needle[i]) + return false; + } + + return true; + } + + #endregion + + #region Versioning + /// /// Check for a new DICUI version /// @@ -44,5 +110,6 @@ private static string GetCurrentVersion() return $"{assemblyVersion.Major}.{assemblyVersion.Minor}" + (assemblyVersion.Build != 0 ? $".{assemblyVersion.Build}" : string.Empty); } + #endregion } } diff --git a/DICUI.Library/Utilities/Validators.cs b/DICUI.Library/Utilities/Validators.cs index 7da3e661f..6884e37c9 100644 --- a/DICUI.Library/Utilities/Validators.cs +++ b/DICUI.Library/Utilities/Validators.cs @@ -1044,30 +1044,32 @@ public static Result GetSupportStatus(KnownSystem? system, MediaType? type) /// Copy protection detected in the envirionment, if any public static async Task RunProtectionScanOnPath(string path, IProgress progress = null) { -#if NET_FRAMEWORK try { var found = await Task.Run(() => { - return ProtectionFind.Scan(path, includePosition: false, progress: progress); + var scanner = new Scanner(progress) + { + IncludePosition = false, // Debug flag to include protection position in file + ScanAllFiles = false, // Forces all files to be scanned as executables + ScanArchives = true, // Allows archives to have internals extracted and scanned + ScanPackers = false, // Allows executable packers to be detected + }; + return scanner.GetProtections(path); }); if (found == null || found.Count == 0) return "None found"; - // Strip out "CD Check" instances due to false positives + // Join the output protections for writing return string.Join("\n", found - .Where(kvp => !kvp.Value.Equals("CD Check", StringComparison.OrdinalIgnoreCase)) - .Select(kvp => kvp.Key + ": " + kvp.Value.Replace("CD Check,", string.Empty).Replace("CD Check", string.Empty).Trim()) - .ToArray()); + .Where(kvp => kvp.Value != null && kvp.Value.Any()) + .Select(kvp => $"{kvp.Key}: {string.Join(", ", kvp.Value)}")); } catch (Exception ex) { return $"Path could not be scanned! {ex}"; } -#else - return "Copy protection scanning is not available on .NET Core builds"; -#endif } } } diff --git a/DICUI/DICUI.csproj b/DICUI/DICUI.csproj index b99765c26..4a06e00f4 100644 --- a/DICUI/DICUI.csproj +++ b/DICUI/DICUI.csproj @@ -21,7 +21,9 @@ - + + runtime; compile; build; native; analyzers; buildtransitive +