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


C# ModuleDefMD.GetTypes方法代码示例

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


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

示例1: FindAll

		public static List<MethodDef> FindAll(ModuleDefMD module) {
			var list = new List<MethodDef>();
			foreach (var type in module.GetTypes()) {
				foreach (var method in type.Methods) {
					if (IsInvalidMethod(method))
						list.Add(method);
				}
			}
			return list;
		}
开发者ID:GreenDamTan,项目名称:de4dot,代码行数:10,代码来源:InvalidMethodsFinder.cs

示例2: Find

		public static List<MethodDef> Find(ModuleDefMD module, IEnumerable<MethodDef> notInlinedMethods) {
			var notInlinedMethodsDict = new Dictionary<MethodDef, bool>();
			foreach (var method in notInlinedMethods)
				notInlinedMethodsDict[method] = true;

			var inlinedMethods = new List<MethodDef>();

			foreach (var type in module.GetTypes()) {
				foreach (var method in type.Methods) {
					if (!notInlinedMethodsDict.ContainsKey(method) && CanInline(method))
						inlinedMethods.Add(method);
				}
			}

			return inlinedMethods;
		}
开发者ID:RafaelRMachado,项目名称:de4dot,代码行数:16,代码来源:BabelMethodCallInliner.cs

示例3: Execute

        public static void Execute(ModuleDefMD module)
        {
            cctor = module.GlobalType.FindStaticConstructor();
            Dictionary<FieldDef, Tuple<byte[], int>> fields = new Dictionary<FieldDef,Tuple<byte[], int>>();
            List<byte> data = new List<byte>();
            int count = 0;
            foreach (var method in  module.GetTypes().SelectMany(type => type.Methods))
            {
                if (method.HasBody)
                {
                    List<Instruction> stringInstr = method.Body.Instructions.Where(instr => instr.OpCode == OpCodes.Ldstr).ToList();
                    for (int i = 0; i < stringInstr.Count; i++)
                    {
                        byte[] stringByte = Encoding.UTF8.GetBytes(stringInstr[i].Operand as string);
                        data.AddRange(stringByte);
                        FieldDef field = CreateField(module);
                        fields.Add(field, Tuple.Create(stringByte, count));
                        method.DeclaringType.Fields.Add(field);
                        stringInstr[i].OpCode = OpCodes.Ldsfld;
                        stringInstr[i].Operand = field;
                        count++;
                    }
                }
            }
            staticFields = fields;
            data = Encrypt(data.ToArray()).ToList();
            var dataType = new TypeDefUser("", "", module.CorLibTypes.GetTypeRef("System", "ValueType"));
            RenameTask.Rename(dataType);
            dataType.Layout = TypeAttributes.ExplicitLayout;
            dataType.Visibility = TypeAttributes.NestedPrivate;
            dataType.IsSealed = true;
            dataType.ClassLayout = new ClassLayoutUser(1, (uint)data.Count);
            module.GlobalType.NestedTypes.Add(dataType);

            var dataField = new FieldDefUser("", new FieldSig(dataType.ToTypeSig()))
            {
                IsStatic = true,
                HasFieldRVA = true,
                InitialValue = data.ToArray(),
                Access = FieldAttributes.CompilerControlled
            };
            module.GlobalType.Fields.Add(dataField);
            GlobalDataField = dataField;
            RenameTask.Rename(dataField);
            NETUtils.listener.OnWriterEvent += OnWriterEvent;
        }
开发者ID:M3rcurio,项目名称:denvlib,代码行数:46,代码来源:StringEncodingTaskTest.cs

示例4: Execute

        public static void Execute(ModuleDefMD module)
        {
            int key = rand.Next(97, 122);
               /* rand.GetBytes(byteKey);

            var dataType = new TypeDefUser(module.GlobalType.Namespace, "", module.CorLibTypes.GetTypeRef("System", "ValueType"));
            RenameTask.Rename(dataType);
            dataType.Layout = TypeAttributes.ExplicitLayout;
            dataType.Visibility = TypeAttributes.NestedPrivate;
            dataType.IsSealed = true;
            dataType.ClassLayout = new ClassLayoutUser(1, (uint)byteKey.Length);
            module.GlobalType.NestedTypes.Add(dataType);

            var dataField = new FieldDefUser("", new FieldSig(dataType.ToTypeSig()))
            {
                IsStatic = true,
                HasFieldRVA = true,
                InitialValue = byteKey,
                Access = FieldAttributes.CompilerControlled
            };
            module.GlobalType.Fields.Add(dataField);
            RenameTask.Rename(dataField);*/

            TypeDef stringInjType = NETUtils.ImportType(typeof(StringEncInj));
            MethodDef stringDecMeth = NETUtils.GetMethodByName(stringInjType, "StringDec");
            stringDecMeth.DeclaringType = null;
               stringDecMeth.Body.Instructions[13].OpCode = OpCodes.Ldc_I4;
            stringDecMeth.Body.Instructions[13].Operand = key;
            RenameTask.Rename(stringDecMeth, true);
            TypeDef cctor = module.GlobalType;
            cctor.Methods.Add(stringDecMeth);
            foreach (var method in module.GetTypes().SelectMany(type => type.Methods))
            {
                if (method != stringDecMeth && method.HasBody)
                {
                    List<Instruction> stringInstr = method.Body.Instructions.Where(instr => instr.OpCode == OpCodes.Ldstr).ToList();
                    for (int i = 0; i < stringInstr.Count; i++)
                    {
                        int index = method.Body.Instructions.IndexOf(stringInstr[i]);
                        stringInstr[i].Operand = Ecrypt((string)stringInstr[i].Operand,key);
                        method.Body.Instructions.Insert(index + 1, Instruction.Create(OpCodes.Call, stringDecMeth));
                    }
                }
            }
        }
开发者ID:M3rcurio,项目名称:denvlib,代码行数:45,代码来源:StringEncodingTask.cs


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