private bool Map(ILInstruction instruction) { if (instruction.OpCode != OpCodes.Call && instruction.OpCode != OpCodes.Callvirt) { return(false); } var prevInstruction = instruction.GetPrevious() as ILInstruction; if (prevInstruction != null && prevInstruction.OpCode.Type == OpCodeType.Prefix) { return(false); } var calledMethodRef = instruction.Value as MethodReference; if (calledMethodRef == null) { return(false); } var calledResolveMethod = calledMethodRef.Resolve(_module); if (calledResolveMethod == null) { return(false); } var calledMethod = calledResolveMethod.DeclaringMethod as BuildMethod; if (calledMethod == null) { return(false); } if (!calledMethod.EncryptIL) { return(false); } if (calledMethod.IsVirtual) { return(false); } var targetModule = (BuildModule)calledMethod.Module; var cryptoMethod = calledMethod.ILCrypto; var invokeMethodSig = GetInvokeMethodSig(cryptoMethod, calledMethodRef, targetModule); instruction.AddPrevious(new ILInstruction(Instruction.GetLdc(cryptoMethod.MethodID))); instruction.OpCode = OpCodes.Call; instruction.Value = invokeMethodSig; return(true); }