From 54b706a7f60c767faf7002b81bdc91749d32614f Mon Sep 17 00:00:00 2001 From: Melissa Eckardt Date: Thu, 5 Mar 2026 15:54:10 +0100 Subject: [PATCH 1/2] Don't dereference null pointer when arg is specified at wrong position --- de4dot.cui/CommandLineParser.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/de4dot.cui/CommandLineParser.cs b/de4dot.cui/CommandLineParser.cs index 2e4c9d6d..eb69e710 100644 --- a/de4dot.cui/CommandLineParser.cs +++ b/de4dot.cui/CommandLineParser.cs @@ -175,9 +175,13 @@ void AddAllOptions() { filesOptions.AssemblyClientFactory = new NewProcessAssemblyClientFactory(); })); miscOptions.Add(new NoArgOption(null, "keep-types", "Keep obfuscator types, fields, methods", () => { + if (newFileOptions == null) + ExitError("Please specify --keep-types after the input file name."); newFileOptions.KeepObfuscatorTypes = true; })); miscOptions.Add(new NoArgOption(null, "preserve-tokens", "Preserve important tokens, #US, #Blob, extra sig data", () => { + if (newFileOptions == null) + ExitError("Please specify --preserve-tokens after the input file name."); newFileOptions.MetadataFlags |= MetadataFlags.PreserveRids | MetadataFlags.PreserveUSOffsets | MetadataFlags.PreserveBlobOffsets | From 3d3dbad08d849bb192f4614cf5aa350ca9730e1d Mon Sep 17 00:00:00 2001 From: Melissa Eckardt Date: Thu, 5 Mar 2026 15:55:33 +0100 Subject: [PATCH 2/2] Always print stack trace for unhandled exceptions This removes the need to specify the STACKTRACE=1 env var. --- de4dot.cui/Program.cs | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/de4dot.cui/Program.cs b/de4dot.cui/Program.cs index 85a89308..8cf87c98 100644 --- a/de4dot.cui/Program.cs +++ b/de4dot.cui/Program.cs @@ -131,14 +131,7 @@ public static int Main(string[] args) { exitCode = 1; } catch (Exception ex) { - if (PrintFullStackTrace()) { - PrintStackTrace(ex); - Logger.Instance.LogErrorDontIgnore("\nTry the latest version!"); - } - else { - Logger.Instance.LogErrorDontIgnore("\n\n"); - Logger.Instance.LogErrorDontIgnore("Hmmmm... something didn't work. Try the latest version."); - } + PrintStackTrace(ex); exitCode = 1; } @@ -162,15 +155,6 @@ public static int Main(string[] args) { return exitCode; } - static bool PrintFullStackTrace() { - if (!Logger.Instance.IgnoresEvent(LoggerEvent.Verbose)) - return true; - if (HasEnv("STACKTRACE")) - return true; - - return false; - } - static bool HasEnv(string name) { foreach (var tmp in Environment.GetEnvironmentVariables().Keys) { var env = tmp as string;