Move code to DeobUtils
This commit is contained in:
parent
2b4fc0a836
commit
4e89d707dc
|
@ -18,6 +18,7 @@
|
|||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Security.Cryptography;
|
||||
using Mono.Cecil;
|
||||
|
@ -206,5 +207,29 @@ namespace de4dot.code.deobfuscators {
|
|||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static IEnumerable<MethodDefinition> getInitCctors(ModuleDefinition module, int maxCctors) {
|
||||
var cctor = DotNetUtils.getModuleTypeCctor(module);
|
||||
if (cctor != null)
|
||||
yield return cctor;
|
||||
|
||||
var entryPoint = module.EntryPoint;
|
||||
if (entryPoint != null) {
|
||||
cctor = DotNetUtils.getMethod(entryPoint.DeclaringType, ".cctor");
|
||||
if (cctor != null)
|
||||
yield return cctor;
|
||||
}
|
||||
|
||||
foreach (var type in module.GetTypes()) {
|
||||
if (type == DotNetUtils.getModuleType(module))
|
||||
continue;
|
||||
cctor = DotNetUtils.getMethod(type, ".cctor");
|
||||
if (cctor == null)
|
||||
continue;
|
||||
yield return cctor;
|
||||
if (!type.IsEnum && --maxCctors <= 0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -81,20 +81,8 @@ namespace de4dot.code.deobfuscators.MaxtoCode {
|
|||
}
|
||||
|
||||
public void find() {
|
||||
if (checkCctor(DotNetUtils.getModuleTypeCctor(module)))
|
||||
return;
|
||||
|
||||
var entryPoint = module.EntryPoint;
|
||||
if (entryPoint != null && checkCctor(DotNetUtils.getMethod(entryPoint.DeclaringType, ".cctor")))
|
||||
return;
|
||||
|
||||
int checksLeft = 3;
|
||||
foreach (var type in module.GetTypes()) {
|
||||
if (type == DotNetUtils.getModuleType(module))
|
||||
continue;
|
||||
if (checkCctor(DotNetUtils.getMethod(type, ".cctor")))
|
||||
return;
|
||||
if (!type.IsEnum && --checksLeft <= 0)
|
||||
foreach (var cctor in DeobUtils.getInitCctors(module, 3)) {
|
||||
if (checkCctor(cctor))
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user