Remove MC type and module refs

This commit is contained in:
de4dot 2012-02-21 11:57:47 +01:00
parent 7bc3930df9
commit e5145fcca9
2 changed files with 39 additions and 2 deletions

View File

@ -103,5 +103,14 @@ namespace de4dot.code.deobfuscators.MaxtoCode {
newOne.mainType = new MainType(module, mainType);
return newOne;
}
public override void deobfuscateBegin() {
base.deobfuscateBegin();
foreach (var method in mainType.InitMethods)
addCctorInitCallToBeRemoved(method);
addTypeToBeRemoved(mainType.Type, "Obfuscator type");
addModuleReferencesToBeRemoved(mainType.ModuleReferences, "MC runtime module reference");
}
}
}

View File

@ -28,6 +28,34 @@ namespace de4dot.code.deobfuscators.MaxtoCode {
TypeDefinition mcType;
ModuleReference mcModule1, mcModule2;
public TypeDefinition Type {
get { return mcType; }
}
public IEnumerable<ModuleReference> ModuleReferences {
get {
var list = new List<ModuleReference>();
if (mcModule1 != null)
list.Add(mcModule1);
if (mcModule2 != null)
list.Add(mcModule2);
return list;
}
}
public IEnumerable<MethodDefinition> InitMethods {
get {
var list = new List<MethodDefinition>();
if (mcType == null)
return list;
foreach (var method in mcType.Methods) {
if (method.IsStatic && DotNetUtils.isMethod(method, "System.Void", "()"))
list.Add(method);
}
return list;
}
}
public bool Detected {
get { return mcType != null; }
}
@ -39,8 +67,8 @@ namespace de4dot.code.deobfuscators.MaxtoCode {
public MainType(ModuleDefinition module, MainType oldOne) {
this.module = module;
this.mcType = lookup(oldOne.mcType, "Could not find main type");
this.mcModule1 = DeobUtils.lookup(module, mcModule1, "Could not find MC runtime module ref #1");
this.mcModule2 = DeobUtils.lookup(module, mcModule2, "Could not find MC runtime module ref #2");
this.mcModule1 = DeobUtils.lookup(module, oldOne.mcModule1, "Could not find MC runtime module ref #1");
this.mcModule2 = DeobUtils.lookup(module, oldOne.mcModule2, "Could not find MC runtime module ref #2");
}
T lookup<T>(T def, string errorMessage) where T : MemberReference {