From d6f3ff64b94c1d53ac392ce6213bdbb96cfd8cb0 Mon Sep 17 00:00:00 2001 From: de4dot Date: Thu, 5 Jan 2012 17:16:38 +0100 Subject: [PATCH] Remove "castclass System.String" if present --- de4dot.code/StringDecrypter.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/de4dot.code/StringDecrypter.cs b/de4dot.code/StringDecrypter.cs index 95f1a92f..56a875c7 100644 --- a/de4dot.code/StringDecrypter.cs +++ b/de4dot.code/StringDecrypter.cs @@ -34,6 +34,13 @@ namespace de4dot.code { int ldstrIndex = callResult.callStartIndex; block.replace(ldstrIndex, num, Instruction.Create(OpCodes.Ldstr, (string)callResult.returnValue)); + // If it's followed by castclass string, remove it + if (ldstrIndex + 1 < block.Instructions.Count) { + var instr = block.Instructions[ldstrIndex + 1]; + if (instr.OpCode.Code == Code.Castclass && instr.Operand.ToString() == "System.String") + block.remove(ldstrIndex + 1, 1); + } + // If it's followed by String.Intern(), then nop out that call if (ldstrIndex + 1 < block.Instructions.Count) { var instr = block.Instructions[ldstrIndex + 1];