Remove module if we don't load it. Restore indent level.

This commit is contained in:
de4dot 2011-11-16 22:59:04 +01:00
parent 75ff534ecd
commit 79eb228200
2 changed files with 8 additions and 5 deletions

View File

@ -72,19 +72,19 @@ namespace de4dot {
deobfuscateAll();
}
void removeModule(ModuleDefinition module) {
static void removeModule(ModuleDefinition module) {
AssemblyResolver.Instance.removeModule(module);
DotNetUtils.typeCaches.invalidate(module);
}
void detectObfuscators() {
foreach (var file in loadAllFiles(true)) {
foreach (var file in loadAllFiles(true))
removeModule(file.ModuleDefinition);
}
}
void deobfuscateOneAtATime() {
foreach (var file in loadAllFiles()) {
int oldIndentLevel = Log.indentLevel;
try {
file.deobfuscateBegin();
file.deobfuscate();
@ -96,6 +96,7 @@ namespace de4dot {
file.save();
removeModule(file.ModuleDefinition);
AssemblyResolver.Instance.clearAll();
}
catch (Exception ex) {
Log.w("Could not deobfuscate {0}. Use -v to see stack trace", file.Filename);
@ -103,6 +104,7 @@ namespace de4dot {
}
finally {
file.deobfuscateCleanUp();
Log.indentLevel = oldIndentLevel;
}
}
}
@ -200,13 +202,14 @@ namespace de4dot {
if ((file.ModuleDefinition.Attributes & ModuleAttributes.ILOnly) == 0) {
Log.w("Ignoring assembly with native code {0}", file.Filename);
removeModule(file.ModuleDefinition);
return false;
}
var deob = file.Deobfuscator;
if (skipUnknownObfuscator && deob is deobfuscators.Unknown.Deobfuscator) {
Log.v("Skipping unknown obfuscator: {0}", file.Filename);
removeModule(file.ModuleDefinition);
return false;
}
else {

View File

@ -22,7 +22,7 @@ using System.Collections.Generic;
namespace de4dot {
static class Log {
static int indentLevel = 0;
public static int indentLevel = 0;
const int indentSize = 2;
public enum LogLevel {