From a4430f58f34b26ab7aa8a1b7e4b3ba0226552430 Mon Sep 17 00:00:00 2001 From: divya0795 <12871391+divya0795@users.noreply.github.com> Date: Sun, 26 Jul 2026 14:00:03 +0000 Subject: [PATCH] =?UTF-8?q?=EF=BB=BFfix:=20skip=20patch=20types=20that=20h?= =?UTF-8?q?ave=20no=20definition=20instead=20of=20throwing?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit EnhancerConfig.GetInstance() returns entries for ActivatePro, DisableUpdates, DevToolsOnF12 and RemoteWebPanelPreview. EPatchType also declares DisableTelemetry = 4, which has no entry, and both lookups of that dictionary indexed it directly: var entries = enhancerConfig[entry]; // PatchAsar foreach (var patchEntry in enhancerConfig[patchType]) // CouldFileContainRemainingPatch A PatchConfig carrying DisableTelemetry would therefore abort the entire patch run with an unhandled KeyNotFoundException, taking the other requested patches with it. This is not reachable today: PatchVectorsPopup exposes no control for DisableTelemetry, and PatchConfig is only ever constructed there -- nothing deserialises it -- so no supported path can put that value into PatchTypes. It becomes reachable the moment a checkbox is added for it. Look both lookups up with TryGetValue and skip a type that has no definition. The type is deliberately left in remainingPatches, so instead of crashing the run it now surfaces through the existing summary: [ENHANCER] Failed to apply patches: DisableTelemetry. The version may not be supported. which is the same channel used when a real patch fails to match. PatchAsar also logs a warning naming the skipped type. Behaviour for every implemented patch type is unchanged. --- WandEnhancer/Core/Enhancer.cs | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/WandEnhancer/Core/Enhancer.cs b/WandEnhancer/Core/Enhancer.cs index de59311..87b1a51 100644 --- a/WandEnhancer/Core/Enhancer.cs +++ b/WandEnhancer/Core/Enhancer.cs @@ -150,7 +150,16 @@ private void PatchAsar() foreach (var entry in remainingPatches.ToList()) { - var entries = enhancerConfig[entry]; + // Not every EPatchType has an implementation in EnhancerConfig. Such a + // type stays in remainingPatches so it is reported by the summary below, + // rather than taking down the whole run with a KeyNotFoundException. + EnhancerConfig.PatchEntry[] entries; + if (!enhancerConfig.TryGetValue(entry, out entries)) + { + _logger($"[ENHANCER] No patch definition for {entry}, skipping", ELogType.Warn); + continue; + } + foreach (var patchEntry in entries) { bool patchApplied; @@ -189,7 +198,13 @@ private static bool CouldFileContainRemainingPatch(string filePath, IEnumerable< { foreach (var patchType in remainingPatches) { - foreach (var patchEntry in enhancerConfig[patchType]) + EnhancerConfig.PatchEntry[] entries; + if (!enhancerConfig.TryGetValue(patchType, out entries)) + { + continue; + } + + foreach (var patchEntry in entries) { if (patchEntry.Applied) {