diff --git a/ChromeDevExtWarningPatcher/Program.cs b/ChromeDevExtWarningPatcher/Program.cs index 6d15f77..9b01a91 100644 --- a/ChromeDevExtWarningPatcher/Program.cs +++ b/ChromeDevExtWarningPatcher/Program.cs @@ -2,6 +2,8 @@ using System.Collections.Generic; using System.IO; using System.Linq; +using System.Text; +using System.Text.RegularExpressions; using System.Threading; // Ugly and uncommented code ahead @@ -9,7 +11,7 @@ namespace ChromeDevExtWarningPatcher { class Program { - private const string CHROME_INSTALLATION_FOLDER = @"C:\Program Files (x86)\Google\Chrome\Application"; + private static string CHROME_INSTALLATION_FOLDER = @"C:\Program Files (x86)\Google\Chrome\Application"; private static readonly byte[] SHOULDINCLUDEEXTENSION_FUNCTION_PATTERN = { 0x56, 0x48, 0x83, 0xEC, 0x20, 0x48, 0x89, 0xD6, 0x48, 0x89, 0xD1, 0xE8, 0xFF, 0xFF, 0xFF, 0xFF, 0x89, 0xC1 }; // 0xFF is ? private static readonly byte[] MAYBEADDINFOBAR_FUNCTION_PATTERN = { 0x41, 0x57, 0x41, 0x56, 0x56, 0x57, 0x53, 0x48, 0x81, 0xEC, 0xFF, 0xFF, 0xFF, 0xFF, 0x48, 0x89, 0xCE, 0x48, 0x8B, 0x05, 0xFF, 0xFF, 0xFF, 0xFF, 0x48, 0x31, 0xE0, 0x48, 0x89, 0x84, 0x24, 0xFF, 0xFF, 0xFF, 0xFF, 0x48, 0x8D, 0x4A, 0x08 }; // 0xFF is ?; debugPatch @@ -32,6 +34,7 @@ public static void Main(string[] args) RemovePatches(SHOULDPREVENTELISION_FUNCTION_PATTERN); if (ContainsArg(args, "noDebugPatch")) RemovePatches(MAYBEADDINFOBAR_FUNCTION_PATTERN); + SetNewFolder(args); DirectoryInfo chromeFolder = new DirectoryInfo(CHROME_INSTALLATION_FOLDER); @@ -153,5 +156,36 @@ private static void RemovePatches(byte[] pattern) i++; } } + + private const string PATH_REGEX = @"\\([a-zA-Z]{4,})"; + private static void SetNewFolder(string[] args) { + StringBuilder sb = new StringBuilder(); + + for (int i = 0; i < args.Length; i++) { + sb.Append(args[i] + " "); + } + if(sb.Length > 0) + sb.Remove(sb.Length - 1, 1); + string fullArgs = sb.ToString().ToLower(); + + string arg = "-custompath "; + int pathIndex = fullArgs.IndexOf(arg); + if(pathIndex != -1) { + pathIndex += arg.Length; + fullArgs = fullArgs.Substring(pathIndex).Replace("\"", ""); + + var regMatches = Regex.Matches(fullArgs, PATH_REGEX); + if (regMatches.Count == 0) { + Console.WriteLine("Invalid path given"); + Environment.Exit(1); + return; + } + Match regMatch = regMatches[regMatches.Count - 1]; + string regMatchGroup = regMatch.Groups[0].Value; + + CHROME_INSTALLATION_FOLDER = fullArgs.Substring(0, regMatch.Index + regMatchGroup.Length); + Console.WriteLine("New installation folder set: " + CHROME_INSTALLATION_FOLDER); + } + } } } \ No newline at end of file diff --git a/README.md b/README.md index cca41c7..22e27bf 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,22 @@ -# Disable Chrome's Developer Mode Extension Warning Popup -Download it in the [release section](https://github.com/Ceiridge/Chrome-Developer-Mode-Extension-Warning-Patcher/releases). +# Disable Chrome's and Chromium's Developer Mode Extension Warning Popup +**Download** it in the [release section](https://github.com/Ceiridge/Chrome-Developer-Mode-Extension-Warning-Patcher/releases). + +## Supported browsers +See below for the custom paths (commandline option). +```javascript +- All Chromium-based browsers, including: +- Chrome +- Chromium +- Brave +- New Edge +- Opera? +- Vivaldi +- Blisk +- Colibri +- Epic Browser +- Iron Browser +- Ungoogled Chromium? +``` ## Message to Chromium contributors This project is not meant for malicious use, especially because patching requires administrative rights. If an attacker wants to get rid of that notification, they will always be able to do it somehow, since it clientsided. Additionally, you can just install a crx-file and allow it with some group policies, which makes absolutely no sense, because it punishes developers with this annoying popup, but crx files that are already packed can be installed easily. @@ -7,11 +24,13 @@ This project is not meant for malicious use, especially because patching require The idea originates from that one stackoverflow patching method, which forces a command line option in the `chrome.dll`. ## How the program works -It discovers your `chrome.dll` file of the latest installed Chrome version. Then it performs a pattern scan for a function that gets patched, so the dialog does not appear anymore. +It discovers your `chrome.dll` file of the latest installed Chrome/Chromium version. Then it performs a pattern scan for a function that gets patched, so the dialog does not appear anymore. ## Commandline Options +All commandline options are **optional** and not required. + ```bash -ChromeDevExtWarningPatcher.exe [-noDebugPatch] [-noWWWPatch] [-noWarningPatch] [-noWait] +ChromeDevExtWarningPatcher.exe [-noDebugPatch] [-noWWWPatch] [-noWarningPatch] [-noWait] [-customPath "C:\Path"] Explanation: -noDebugPatch: Disables the patch for the warning of debugging extensions (chrome.debugger) @@ -19,6 +38,17 @@ Explanation: -noWarningPatch: Disables the patch for the warning of developer extensions -noWait: Disables the almost-pointless wait after finishing + +-customPath: Tell the patcher to use another patch to find the chrome.dll file, see below. +``` + +**Recommended `customPath`s:** +```java +Chrome (default): C:\Program Files (x86)\Google\Chrome\Application +Brave: C:\Program Files (x86)\BraveSoftware\Brave-Browser\Application + +Remember: The path always needs to include the version folders of the browser. +Please create a new issue with a path, if you want to contribute to this list. ``` ## What is the pattern and what does it patch @@ -109,4 +139,4 @@ bool ChromeLocationBarModelDelegate::ShouldPreventElision() const { ``` ## How and when to run it -Run it after every chrome update with administrator rights. \ No newline at end of file +Run it after every chrome/chromium update with administrator rights. \ No newline at end of file