From 762c6ed2258ece20a42b70e0443dd89594db4157 Mon Sep 17 00:00:00 2001 From: Styris Date: Thu, 6 Apr 2023 22:50:11 -0700 Subject: [PATCH] Add icon, make folder detection more intelligent --- Program.cs | 77 +++++++++++++++++++++++++++++++++++++++------------ ameck.csproj | 4 +++ console.ico | Bin 0 -> 43006 bytes 3 files changed, 64 insertions(+), 17 deletions(-) create mode 100644 console.ico diff --git a/Program.cs b/Program.cs index 802ace6..a79c7c9 100644 --- a/Program.cs +++ b/Program.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Diagnostics; +using System.Globalization; using System.IO; using System.Linq; using System.Threading; @@ -83,11 +84,34 @@ namespace ame_integrity_check if (parentPath.Contains("*")) throw new ArgumentException("Parent directories to a given file filter cannot contain wildcards."); var filter = item.Substring(lastToken + 1); - foundItem = Directory.GetDirectories(parentPath, filter).Any(); - break; + var foundDirs = Directory.GetDirectories(parentPath, filter); + + foreach (var foundDir in foundDirs) + { + foreach (var file in Directory.GetFiles(foundDir, "*", SearchOption.AllDirectories)) + { + if (!file.ToLower().EndsWith(".mui") && !file.ToLower().EndsWith(".pri") && !file.ToLower().EndsWith(".res")) + { + foundItem = true; + } + } + } } - - foundItem = Directory.Exists(item); + else + { + + if (Directory.Exists(item)) + { + foreach (var file in Directory.GetFiles(item, "*", SearchOption.AllDirectories)) + { + if (!file.ToLower().EndsWith(".mui") && !file.ToLower().EndsWith(".pri") && !file.ToLower().EndsWith(".res")) + { + foundItem = true; + } + } + } + } + break; case Type.Process: foundItem = Process.GetProcessesByName(item).Any(); @@ -100,7 +124,14 @@ namespace ame_integrity_check break; } } catch (Exception e) { - errorOverride = true; + if (e.GetType().ToString() == "System.UnauthorizedAccessException" || e.GetType().ToString() == "System.Security.SecurityException") + { + foundItem = true; + } + else + { + errorOverride = true; + } } if (foundItem) found = true; @@ -152,7 +183,7 @@ namespace ame_integrity_check public static int PreviousSizeHeight; public static int PreviousSizeWidth; - public const double Ver = 0.9; + public const string Ver = "1.0"; public static void Main(string[] args) { @@ -161,9 +192,15 @@ namespace ame_integrity_check PreviousBufferHeight = Console.BufferHeight; PreviousBufferWidth = Console.BufferWidth; - Console.SetWindowSize(80, 26); - Console.SetBufferSize(80, 26); - Console.SetWindowSize(80, 26); + try + { + Console.SetWindowSize(80, 26); + Console.SetBufferSize(80, 26); + Console.SetWindowSize(80, 26); + } catch (Exception e) + { + + } Console.Clear(); @@ -243,7 +280,7 @@ namespace ame_integrity_check scanner.Query(Type.File, "%WINDIR%\\System32\\wuapi.dll", true); scanner.displayTask = scanner.DisplayQuery("Checking Microsoft Edge...", 200); - scanner.Query(Type.Directory, "%ProgramFiles(x86)%\\Microsoft\\EdgeCore"); + scanner.Query(Type.Directory, "%ProgramFiles(x86)%\\Microsoft\\Edge"); scanner.Query(Type.Directory, "%WINDIR%\\SystemApps\\*MicrosoftEdge*", true); scanner.displayTask = scanner.DisplayQuery("Checking for Microsoft Store activity...", 200); @@ -279,11 +316,11 @@ namespace ame_integrity_check var posCacheLeft = Console.CursorLeft; while (Console.KeyAvailable) { - Console.ReadKey(false); + Console.ReadKey(true); } - Console.SetCursorPosition(posCacheLeft, posCacheTop); - Console.Write("".PadLeft(Console.WindowHeight, ' ')); - Console.SetCursorPosition(posCacheLeft, posCacheTop); + //Console.SetCursorPosition(posCacheLeft, posCacheTop); + //Console.Write("".PadLeft(Console.WindowHeight, ' ')); + //Console.SetCursorPosition(posCacheLeft, posCacheTop); } private static void Exit(object sender, ConsoleCancelEventArgs args) { @@ -302,9 +339,15 @@ namespace ame_integrity_check Console.CursorVisible = true; Console.Clear(); Console.Title = PreviousTitle; - - Console.SetWindowSize(PreviousSizeWidth, PreviousSizeHeight); - Console.SetBufferSize(PreviousBufferWidth, PreviousBufferHeight); + + try + { + Console.SetWindowSize(PreviousSizeWidth, PreviousSizeHeight); + Console.SetBufferSize(PreviousBufferWidth, PreviousBufferHeight); + } catch (Exception e) + { + + } } } diff --git a/ameck.csproj b/ameck.csproj index 71c3a84..e28aa89 100644 --- a/ameck.csproj +++ b/ameck.csproj @@ -12,6 +12,7 @@ v4.7.2 512 true + console.ico x64 @@ -113,6 +114,9 @@ + + +