Only set ILOnly if there are no native methods

This commit is contained in:
de4dot 2012-11-14 11:29:22 +01:00
parent 6d43a7d6ee
commit 226d18dff7
2 changed files with 21 additions and 2 deletions

View File

@ -307,9 +307,12 @@ namespace de4dot.code.deobfuscators.Agile_NET {
addResources("Obfuscator protection files");
}
module.IsILOnly = true;
base.deobfuscateEnd();
// Call hasNativeMethods() after all types/methods/etc have been removed since
// some of the removed methods could be native methods
if (!module.IsILOnly && !hasNativeMethods())
module.IsILOnly = true;
}
public override IEnumerable<int> getStringDecrypterMethods() {

View File

@ -763,6 +763,22 @@ namespace de4dot.code.deobfuscators {
return false;
}
protected bool hasNativeMethods() {
if (module.VTableFixups != null)
return true;
foreach (var type in module.GetTypes()) {
foreach (var method in type.Methods) {
var mb = method.MethodBody;
if (mb == null)
continue;
if (mb is CilBody)
continue;
return true;
}
}
return false;
}
protected static int toInt32(bool b) {
return b ? 1 : 0;
}