Change method to take a ref to a type

This commit is contained in:
de4dot 2012-07-07 00:58:18 +02:00
parent d5c8f6842a
commit 0a5764a093
5 changed files with 9 additions and 8 deletions

View File

@ -49,7 +49,7 @@ namespace de4dot.code.deobfuscators.CliSecure {
}
}
protected override object checkCctor(TypeDefinition type, MethodDefinition cctor) {
protected override object checkCctor(ref TypeDefinition type, MethodDefinition cctor) {
var instrs = cctor.Body.Instructions;
if (instrs.Count != 3)
return null;

View File

@ -80,7 +80,7 @@ namespace de4dot.code.deobfuscators.CodeFort {
return creatorMethod;
}
protected override object checkCctor(TypeDefinition type, MethodDefinition cctor) {
protected override object checkCctor(ref TypeDefinition type, MethodDefinition cctor) {
var instrs = cctor.Body.Instructions;
if (instrs.Count != 3)
return null;

View File

@ -89,7 +89,7 @@ namespace de4dot.code.deobfuscators.CodeVeil {
info.methodInfoType = lookup(oldOne.info.methodInfoType, "Could not find methodInfoType");
}
protected override object checkCctor(TypeDefinition type, MethodDefinition cctor) {
protected override object checkCctor(ref TypeDefinition type, MethodDefinition cctor) {
var instrs = cctor.Body.Instructions;
for (int i = 0; i < instrs.Count - 1; i++) {
var ldci4 = instrs[i];

View File

@ -203,14 +203,15 @@ namespace de4dot.code.deobfuscators {
return;
Log.v("Finding all proxy delegates");
foreach (var type in getDelegateTypes()) {
foreach (var tmp in getDelegateTypes()) {
var type = tmp;
var cctor = DotNetUtils.getMethod(type, ".cctor");
if (cctor == null || !cctor.HasBody)
continue;
if (!type.HasFields)
continue;
object context = checkCctor(type, cctor);
object context = checkCctor(ref type, cctor);
if (context == null)
continue;
@ -240,7 +241,7 @@ namespace de4dot.code.deobfuscators {
}
}
protected abstract object checkCctor(TypeDefinition type, MethodDefinition cctor);
protected abstract object checkCctor(ref TypeDefinition type, MethodDefinition cctor);
protected abstract void getCallInfo(object context, FieldDefinition field, out MethodReference calledMethod, out OpCode callOpcode);
protected override bool deobfuscate(Blocks blocks, IList<Block> allBlocks) {
@ -458,7 +459,7 @@ namespace de4dot.code.deobfuscators {
}
// Fixes proxy calls that call a static method with the instance of
// of a delegate as the last arg, which then calls the Invoke method.
// a delegate as the last arg, which then calls the Invoke method.
// ...push args...
// ldsfld delegate instance
// call static method

View File

@ -51,7 +51,7 @@ namespace de4dot.code.deobfuscators.SmartAssembly {
this.simpleDeobfuscator = simpleDeobfuscator;
}
protected override object checkCctor(TypeDefinition type, MethodDefinition cctor) {
protected override object checkCctor(ref TypeDefinition type, MethodDefinition cctor) {
var instrs = cctor.Body.Instructions;
if (instrs.Count > 10)
return null;