From 603fa74cebaec5fb1f9650081ac627362986369f Mon Sep 17 00:00:00 2001 From: de4dot Date: Fri, 21 Oct 2011 21:47:06 +0200 Subject: [PATCH] Only use DNR hack if methods have same declaring type --- blocks/cflow/BlockCflowDeobfuscator.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/blocks/cflow/BlockCflowDeobfuscator.cs b/blocks/cflow/BlockCflowDeobfuscator.cs index 99cee022..799b14ce 100644 --- a/blocks/cflow/BlockCflowDeobfuscator.cs +++ b/blocks/cflow/BlockCflowDeobfuscator.cs @@ -23,10 +23,12 @@ using Mono.Cecil.Cil; namespace de4dot.blocks.cflow { class BlockCflowDeobfuscator { + Blocks blocks; Block block; InstructionEmulator instructionEmulator = new InstructionEmulator(); public void init(Blocks blocks, Block block) { + this.blocks = blocks; this.block = block; instructionEmulator.init(blocks.Method.HasThis, false, blocks.Method.Parameters, blocks.Locals); } @@ -100,6 +102,10 @@ namespace de4dot.blocks.cflow { ldci4 = (Instruction)ldci4.Operand; if (ldci4 == null || !DotNetUtils.isLdcI4(ldci4) || ldci4.Next == null || ldci4.Next.OpCode.Code != Code.Ret) return false; + + if (!MemberReferenceHelper.compareTypes(method.DeclaringType, blocks.Method.DeclaringType)) + return false; + int val = DotNetUtils.getLdcI4Value(ldci4); block.Instructions[instrIndex] = new Instr(Instruction.Create(OpCodes.Ldc_I4, val)); return true;