IDeobfuscator now implements IDisposable
This commit is contained in:
parent
5b43e33a35
commit
8858205344
|
@ -40,7 +40,7 @@ namespace de4dot.code {
|
||||||
void deobfuscateEnd();
|
void deobfuscateEnd();
|
||||||
void deobfuscateCleanUp();
|
void deobfuscateCleanUp();
|
||||||
|
|
||||||
void load(IEnumerable<IDeobfuscator> deobfuscators);
|
void load(IList<IDeobfuscator> deobfuscators);
|
||||||
void save();
|
void save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -160,14 +160,22 @@ namespace de4dot.code {
|
||||||
return noExt + "-cleaned" + ext;
|
return noExt + "-cleaned" + ext;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void load(IEnumerable<IDeobfuscator> deobfuscators) {
|
public void load(IList<IDeobfuscator> deobfuscators) {
|
||||||
loadModule(deobfuscators);
|
try {
|
||||||
TheAssemblyResolver.Instance.addSearchDirectory(Utils.getDirName(Filename));
|
loadModule(deobfuscators);
|
||||||
TheAssemblyResolver.Instance.addSearchDirectory(Utils.getDirName(NewFilename));
|
TheAssemblyResolver.Instance.addSearchDirectory(Utils.getDirName(Filename));
|
||||||
detectObfuscator(deobfuscators);
|
TheAssemblyResolver.Instance.addSearchDirectory(Utils.getDirName(NewFilename));
|
||||||
if (deob == null)
|
detectObfuscator(deobfuscators);
|
||||||
throw new ApplicationException("Could not detect obfuscator!");
|
if (deob == null)
|
||||||
initializeDeobfuscator();
|
throw new ApplicationException("Could not detect obfuscator!");
|
||||||
|
initializeDeobfuscator();
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
foreach (var d in deobfuscators) {
|
||||||
|
if (d != deob && d != null)
|
||||||
|
d.Dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void loadModule(IEnumerable<IDeobfuscator> deobfuscators) {
|
void loadModule(IEnumerable<IDeobfuscator> deobfuscators) {
|
||||||
|
@ -793,6 +801,8 @@ namespace de4dot.code {
|
||||||
deobfuscateCleanUp();
|
deobfuscateCleanUp();
|
||||||
if (module != null)
|
if (module != null)
|
||||||
module.Dispose();
|
module.Dispose();
|
||||||
|
if (deob != null)
|
||||||
|
deob.Dispose();
|
||||||
module = null;
|
module = null;
|
||||||
deob = null;
|
deob = null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -782,5 +782,13 @@ namespace de4dot.code.deobfuscators {
|
||||||
protected static int toInt32(bool b) {
|
protected static int toInt32(bool b) {
|
||||||
return b ? 1 : 0;
|
return b ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Dispose() {
|
||||||
|
Dispose(true);
|
||||||
|
GC.SuppressFinalize(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual void Dispose(bool disposing) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,7 +52,7 @@ namespace de4dot.code.deobfuscators {
|
||||||
RenameResourceKeys = 2,
|
RenameResourceKeys = 2,
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface IDeobfuscator : INameChecker {
|
public interface IDeobfuscator : INameChecker, IDisposable {
|
||||||
string Type { get; }
|
string Type { get; }
|
||||||
string TypeLong { get; }
|
string TypeLong { get; }
|
||||||
string Name { get; }
|
string Name { get; }
|
||||||
|
|
|
@ -250,5 +250,11 @@ namespace de4dot.code.deobfuscators.MaxtoCode {
|
||||||
list.Add(stringDecrypter.Method.MDToken.ToInt32());
|
list.Add(stringDecrypter.Method.MDToken.ToInt32());
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void Dispose(bool disposing) {
|
||||||
|
if (disposing)
|
||||||
|
freePEImage();
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -614,5 +614,11 @@ namespace de4dot.code.deobfuscators.dotNET_Reactor.v4 {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void Dispose(bool disposing) {
|
||||||
|
if (disposing)
|
||||||
|
freePEImage();
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -162,7 +162,7 @@ namespace de4dot.cui {
|
||||||
public ModuleContext ModuleContext { get; set; }
|
public ModuleContext ModuleContext { get; set; }
|
||||||
public IEnumerable<IObfuscatedFile> PossibleFiles { get; set; }
|
public IEnumerable<IObfuscatedFile> PossibleFiles { get; set; }
|
||||||
public IEnumerable<SearchDir> SearchDirs { get; set; }
|
public IEnumerable<SearchDir> SearchDirs { get; set; }
|
||||||
public Func<IEnumerable<IDeobfuscator>> CreateDeobfuscators { get; set; }
|
public Func<IList<IDeobfuscator>> CreateDeobfuscators { get; set; }
|
||||||
public DecrypterType? DefaultStringDecrypterType { get; set; }
|
public DecrypterType? DefaultStringDecrypterType { get; set; }
|
||||||
public List<string> DefaultStringDecrypterMethods { get; set; }
|
public List<string> DefaultStringDecrypterMethods { get; set; }
|
||||||
public IAssemblyClientFactory AssemblyClientFactory { get; set; }
|
public IAssemblyClientFactory AssemblyClientFactory { get; set; }
|
||||||
|
@ -358,7 +358,7 @@ namespace de4dot.cui {
|
||||||
file.save();
|
file.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
IEnumerable<IDeobfuscator> createDeobfuscators() {
|
IList<IDeobfuscator> createDeobfuscators() {
|
||||||
var list = new List<IDeobfuscator>(options.DeobfuscatorInfos.Count);
|
var list = new List<IDeobfuscator>(options.DeobfuscatorInfos.Count);
|
||||||
foreach (var info in options.DeobfuscatorInfos)
|
foreach (var info in options.DeobfuscatorInfos)
|
||||||
list.Add(info.createDeobfuscator());
|
list.Add(info.createDeobfuscator());
|
||||||
|
|
Loading…
Reference in New Issue
Block a user