From 6f9bcc21114e49109821f7171a984e02757a912f Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Sat, 18 Nov 2023 20:55:32 -0500 Subject: [PATCH] Fix multiple invocation bug This bug arose when all of the libraries were consoliated into the same library for better packaging. Each set of classes was being instantiated 3 times as a result. --- BinaryObjectScanner/FileType/Executable.cs | 10 ++-------- BinaryObjectScanner/GameEngine/_DUMMY.cs | 7 ------- BinaryObjectScanner/Handler.cs | 12 ++---------- BinaryObjectScanner/Packer/_DUMMY.cs | 7 ------- .../Protection/Macrovision.SafeDisc.cs | 1 - BinaryObjectScanner/Protection/_DUMMY.cs | 7 ------- 6 files changed, 4 insertions(+), 40 deletions(-) delete mode 100644 BinaryObjectScanner/GameEngine/_DUMMY.cs delete mode 100644 BinaryObjectScanner/Packer/_DUMMY.cs delete mode 100644 BinaryObjectScanner/Protection/_DUMMY.cs diff --git a/BinaryObjectScanner/FileType/Executable.cs b/BinaryObjectScanner/FileType/Executable.cs index 3a6c3739..cc857bed 100644 --- a/BinaryObjectScanner/FileType/Executable.cs +++ b/BinaryObjectScanner/FileType/Executable.cs @@ -399,10 +399,8 @@ namespace BinaryObjectScanner.FileType /// /// Initialize all implementations of a type /// - private static IEnumerable? InitCheckClasses() - => InitCheckClasses(typeof(GameEngine._DUMMY).Assembly) ?? Enumerable.Empty() - .Concat(InitCheckClasses(typeof(Packer._DUMMY).Assembly) ?? Enumerable.Empty()) - .Concat(InitCheckClasses(typeof(Protection._DUMMY).Assembly) ?? Enumerable.Empty()); + private static IEnumerable? InitCheckClasses() => + InitCheckClasses(typeof(Handler).Assembly) ?? Enumerable.Empty(); /// /// Initialize all implementations of a type @@ -412,11 +410,7 @@ namespace BinaryObjectScanner.FileType return assembly.GetTypes()? .Where(t => t.IsClass && t.GetInterface(typeof(T).Name) != null)? .Select(t => (T?)Activator.CreateInstance(t)) -#if NET40 || NET452 .Cast() ?? []; -#else - .Cast() ?? Array.Empty(); -#endif } #endregion diff --git a/BinaryObjectScanner/GameEngine/_DUMMY.cs b/BinaryObjectScanner/GameEngine/_DUMMY.cs deleted file mode 100644 index c3a6c514..00000000 --- a/BinaryObjectScanner/GameEngine/_DUMMY.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace BinaryObjectScanner.GameEngine -{ - /// - /// This class exists for reflection purposes and should not be used - /// - public sealed class _DUMMY { } -} diff --git a/BinaryObjectScanner/Handler.cs b/BinaryObjectScanner/Handler.cs index 2362136c..eb1c052d 100644 --- a/BinaryObjectScanner/Handler.cs +++ b/BinaryObjectScanner/Handler.cs @@ -171,12 +171,8 @@ namespace BinaryObjectScanner /// /// Initialize all implementations of a type /// - private static IEnumerable InitCheckClasses() - { - return InitCheckClasses(typeof(GameEngine._DUMMY).Assembly) - .Concat(InitCheckClasses(typeof(Packer._DUMMY).Assembly)) - .Concat(InitCheckClasses(typeof(Protection._DUMMY).Assembly)); - } + private static IEnumerable InitCheckClasses() => + InitCheckClasses(typeof(Handler).Assembly); /// /// Initialize all implementations of a type @@ -185,11 +181,7 @@ namespace BinaryObjectScanner { return assembly.GetTypes()? .Where(t => t.IsClass && t.GetInterface(typeof(T).Name) != null)? -#if NET40 || NET452 .Select(t => (T?)Activator.CreateInstance(t)) ?? []; -#else - .Select(t => (T?)Activator.CreateInstance(t)) ?? Array.Empty(); -#endif } #endregion diff --git a/BinaryObjectScanner/Packer/_DUMMY.cs b/BinaryObjectScanner/Packer/_DUMMY.cs deleted file mode 100644 index c8f5ab65..00000000 --- a/BinaryObjectScanner/Packer/_DUMMY.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace BinaryObjectScanner.Packer -{ - /// - /// This class exists for reflection purposes and should not be used - /// - public sealed class _DUMMY { } -} diff --git a/BinaryObjectScanner/Protection/Macrovision.SafeDisc.cs b/BinaryObjectScanner/Protection/Macrovision.SafeDisc.cs index 8c33280e..2487d522 100644 --- a/BinaryObjectScanner/Protection/Macrovision.SafeDisc.cs +++ b/BinaryObjectScanner/Protection/Macrovision.SafeDisc.cs @@ -146,7 +146,6 @@ namespace BinaryObjectScanner.Protection new PathMatch("drvmgt.dll", useEndsWith: true), new PathMatch("mcp.dll", useEndsWith: true), new PathMatch("secdrv.sys", useEndsWith: true), - }, "SafeDisc 1.45.011-1.50.020"), // TODO: Research "splash16.bmp" and "splash256.bmp". diff --git a/BinaryObjectScanner/Protection/_DUMMY.cs b/BinaryObjectScanner/Protection/_DUMMY.cs deleted file mode 100644 index 55785198..00000000 --- a/BinaryObjectScanner/Protection/_DUMMY.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace BinaryObjectScanner.Protection -{ - /// - /// This class exists for reflection purposes and should not be used - /// - public sealed class _DUMMY { } -}