当前位置: 首页>>代码示例>>C#>>正文


C# MethodDefinition.GetElementMethod方法代码示例

本文整理汇总了C#中Mono.Cecil.MethodDefinition.GetElementMethod方法的典型用法代码示例。如果您正苦于以下问题:C# MethodDefinition.GetElementMethod方法的具体用法?C# MethodDefinition.GetElementMethod怎么用?C# MethodDefinition.GetElementMethod使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Mono.Cecil.MethodDefinition的用法示例。


在下文中一共展示了MethodDefinition.GetElementMethod方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: IsMethodContainsAttribute

 private bool IsMethodContainsAttribute(MethodDefinition method)
 {
     var methodInfo = method.GetElementMethod();
     return method.HasCustomAttributes ||
         methodInfo.MethodReturnType.HasCustomAttributes ||
         methodInfo.MethodReturnType.HasFieldMarshal ||
         methodInfo.MethodReturnType.HasMarshalInfo;
 }
开发者ID:MishaUliutin,项目名称:RemoveUnusedRef,代码行数:8,代码来源:TypesAttributesEntry.cs

示例2: EncryptStringsInAssembly

        /// <summary>
        /// Encrypts the strings within the given assembly.
        /// </summary>
        /// <param name="definition">The assembly definition.</param>
        private void EncryptStringsInAssembly(AssemblyDefinition definition)
        {
            //Add an encryption function
            MethodReference decryptionMethod = null;

            //Generate a new type for decryption
            OutputHelper.WriteLine("Generating global decrypt method");
            foreach (TypeDefinition td in definition.MainModule.GetAllTypes())
                if (td.Name == "<Module>")
                {
                    MethodDefinition md = new MethodDefinition("Decrypt", MethodAttributes.HideBySig | MethodAttributes.Static | MethodAttributes.CompilerControlled, definition.Import(typeof(string)));

                    //Generate the parameters
                    md.Parameters.Add(new ParameterDefinition("v", ParameterAttributes.None, definition.Import(typeof(string))));
                    md.Parameters.Add(new ParameterDefinition("s", ParameterAttributes.None, definition.Import(typeof(int))));

                    //Add it
                    td.Methods.Add(md);
                    //We now need to create a method body
                    md.Body = new MethodBody(md);

                    //Output the encryption method body
                    switch (method)
                    {
                        case StringEncryptionMethod.Xor:
                            GenerateXorDecryptionMethod(definition, md.Body);
                            break;
                        default:
                            throw new ArgumentOutOfRangeException();
                    }

                    //Finally get the reference
                    decryptionMethod = md.GetElementMethod();
                }

            //Loop through the modules
            OutputHelper.WriteLine("Processing modules");
            foreach (ModuleDefinition moduleDefinition in definition.Modules)
            {
                //Go through each type
                foreach (TypeDefinition typeDefinition in moduleDefinition.GetAllTypes())
                {
                    //Go through each method
                    foreach (MethodDefinition methodDefinition in typeDefinition.Methods)
                    {
                        if (methodDefinition.HasBody)
                        {
                            OutputHelper.WriteMethod(typeDefinition, methodDefinition);
                            ProcessInstructions(definition, methodDefinition.Body, decryptionMethod);
                        }
                    }
                }
            }
        }
开发者ID:modulexcite,项目名称:ncloak,代码行数:58,代码来源:StringEncryptionTask.cs


注:本文中的Mono.Cecil.MethodDefinition.GetElementMethod方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。