Remove module if we don't load it. Restore indent level.
This commit is contained in:
parent
75ff534ecd
commit
79eb228200
|
@ -72,19 +72,19 @@ namespace de4dot {
|
||||||
deobfuscateAll();
|
deobfuscateAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
void removeModule(ModuleDefinition module) {
|
static void removeModule(ModuleDefinition module) {
|
||||||
AssemblyResolver.Instance.removeModule(module);
|
AssemblyResolver.Instance.removeModule(module);
|
||||||
DotNetUtils.typeCaches.invalidate(module);
|
DotNetUtils.typeCaches.invalidate(module);
|
||||||
}
|
}
|
||||||
|
|
||||||
void detectObfuscators() {
|
void detectObfuscators() {
|
||||||
foreach (var file in loadAllFiles(true)) {
|
foreach (var file in loadAllFiles(true))
|
||||||
removeModule(file.ModuleDefinition);
|
removeModule(file.ModuleDefinition);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void deobfuscateOneAtATime() {
|
void deobfuscateOneAtATime() {
|
||||||
foreach (var file in loadAllFiles()) {
|
foreach (var file in loadAllFiles()) {
|
||||||
|
int oldIndentLevel = Log.indentLevel;
|
||||||
try {
|
try {
|
||||||
file.deobfuscateBegin();
|
file.deobfuscateBegin();
|
||||||
file.deobfuscate();
|
file.deobfuscate();
|
||||||
|
@ -96,6 +96,7 @@ namespace de4dot {
|
||||||
file.save();
|
file.save();
|
||||||
|
|
||||||
removeModule(file.ModuleDefinition);
|
removeModule(file.ModuleDefinition);
|
||||||
|
AssemblyResolver.Instance.clearAll();
|
||||||
}
|
}
|
||||||
catch (Exception ex) {
|
catch (Exception ex) {
|
||||||
Log.w("Could not deobfuscate {0}. Use -v to see stack trace", file.Filename);
|
Log.w("Could not deobfuscate {0}. Use -v to see stack trace", file.Filename);
|
||||||
|
@ -103,6 +104,7 @@ namespace de4dot {
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
file.deobfuscateCleanUp();
|
file.deobfuscateCleanUp();
|
||||||
|
Log.indentLevel = oldIndentLevel;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -200,13 +202,14 @@ namespace de4dot {
|
||||||
|
|
||||||
if ((file.ModuleDefinition.Attributes & ModuleAttributes.ILOnly) == 0) {
|
if ((file.ModuleDefinition.Attributes & ModuleAttributes.ILOnly) == 0) {
|
||||||
Log.w("Ignoring assembly with native code {0}", file.Filename);
|
Log.w("Ignoring assembly with native code {0}", file.Filename);
|
||||||
|
removeModule(file.ModuleDefinition);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
var deob = file.Deobfuscator;
|
var deob = file.Deobfuscator;
|
||||||
if (skipUnknownObfuscator && deob is deobfuscators.Unknown.Deobfuscator) {
|
if (skipUnknownObfuscator && deob is deobfuscators.Unknown.Deobfuscator) {
|
||||||
Log.v("Skipping unknown obfuscator: {0}", file.Filename);
|
Log.v("Skipping unknown obfuscator: {0}", file.Filename);
|
||||||
|
removeModule(file.ModuleDefinition);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -22,7 +22,7 @@ using System.Collections.Generic;
|
||||||
|
|
||||||
namespace de4dot {
|
namespace de4dot {
|
||||||
static class Log {
|
static class Log {
|
||||||
static int indentLevel = 0;
|
public static int indentLevel = 0;
|
||||||
const int indentSize = 2;
|
const int indentSize = 2;
|
||||||
|
|
||||||
public enum LogLevel {
|
public enum LogLevel {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user