Don't print the full stack trace. Too confusing for most people.

This commit is contained in:
de4dot 2012-05-09 19:32:52 +02:00
parent 9b9e692947
commit f6db11ac09

View File

@ -79,9 +79,18 @@ namespace de4dot.cui {
exitCode = 1;
}
catch (Exception ex) {
printStackTrace(ex);
Log.e("\nTry the latest version before reporting this problem!");
Log.e("Send bug reports to de4dot@gmail.com or go to https://github.com/0xd4d/de4dot/issues");
if (printFullStackTrace()) {
printStackTrace(ex);
Log.e("\nTry the latest version before reporting this problem!");
Log.e("Send bug reports to de4dot@gmail.com or go to https://github.com/0xd4d/de4dot/issues");
}
else {
Log.e("\n\n");
Log.e("Hmmmm... something didn't work. Try the latest version. ({0})", ex.GetType());
Log.e("If it's a supported obfuscator, it could be a bug or a new obfuscator version.");
Log.e("If it's an unsupported obfuscator, make sure the methods are decrypted!");
Log.e("Send bug reports to de4dot@gmail.com or go to https://github.com/0xd4d/de4dot/issues");
}
exitCode = 1;
}
@ -97,11 +106,30 @@ namespace de4dot.cui {
return exitCode;
}
static bool printFullStackTrace() {
if (Log.isAtLeast(Log.LogLevel.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;
if (env == null)
continue;
if (string.Equals(env, name, StringComparison.OrdinalIgnoreCase))
return true;
}
return false;
}
static bool isN00bUser() {
var env = Environment.GetEnvironmentVariables();
if (env["VisualStudioDir"] != null)
if (hasEnv("VisualStudioDir"))
return false;
return env["windir"] != null && env["PROMPT"] == null;
return hasEnv("windir") && !hasEnv("PROMPT");
}
public static void printStackTrace(Exception ex, Log.LogLevel logLevel = Log.LogLevel.error) {